Skip to content

Instantly share code, notes, and snippets.

Avatar
🤷‍♂️
ABAP and more ABAP 拉尔斯

Lars Hvam larshp

🤷‍♂️
ABAP and more ABAP 拉尔斯
View GitHub Profile
View unit_test.abap
CLASS ltcl_test DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO zcl_unit_test.
METHODS setup.
METHODS calc FOR TESTING RAISING cx_static_check.
ENDCLASS.
CLASS ltcl_test IMPLEMENTATION.
METHOD setup.
View key_fields.abap
CONSTANTS lc_tabname TYPE c LENGTH 16 VALUE 'ZHVAM_CUST'.
DATA obj TYPE REF TO object.
DATA lr_ddfields TYPE REF TO data.
FIELD-SYMBOLS <any> TYPE any.
FIELD-SYMBOLS <fieldname> TYPE simple.
FIELD-SYMBOLS <ddfields> TYPE ANY TABLE.
DATA names TYPE STANDARD TABLE OF abap_compname WITH DEFAULT KEY.
TRY.
CALL METHOD ('XCO_CP_ABAP_DICTIONARY')=>('DATABASE_TABLE')
EXPORTING
@larshp
larshp / guidv4.abap
Last active Dec 14, 2021
GUID v4 implementation in ABAP
View guidv4.abap
* GUID v4 implementation in ABAP
* Also see SAP note 2619546 !
* https://answers.sap.com/questions/11928657/generating-uuid-in-abap.html
* http://www.cryptosys.net/pki/uuid-rfc4122.html
* https://tools.ietf.org/html/rfc4122#page-14
DATA guid TYPE c LENGTH 36.
DATA hex TYPE x LENGTH 16.
View aff.abap
REPORT zfoobar5.
CLASS lcl_mapping DEFINITION.
PUBLIC SECTION.
INTERFACES zif_abapgit_ajson_mapping.
ENDCLASS.
CLASS lcl_mapping IMPLEMENTATION.
METHOD zif_abapgit_ajson_mapping~to_abap.
ENDMETHOD.
View ecatt.abap
CLASS zcl_bcat_api_ecatt DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
CLASS-METHODS create_script .
CLASS-METHODS delete_container .
CLASS-METHODS delete_script .
View move_corresponding_analysis.abap
DATA(lo_stru1) = CAST cl_abap_structdescr( cl_abap_typedescr=>describe_by_name( 'VEKPVB' ) ).
DATA(lo_stru2) = CAST cl_abap_structdescr( cl_abap_typedescr=>describe_by_name( 'E1EDL37' ) ).
DATA(lt_components1) = lo_stru1->get_components( ).
DATA(lt_components2) = lo_stru2->get_components( ).
DATA(lt_list1) = lo_stru1->get_ddic_field_list( p_including_substructres = abap_true ).
DATA(lt_list2) = lo_stru2->get_ddic_field_list( p_including_substructres = abap_true ).
DATA(lv_count) = 0.
LOOP AT lt_list1 INTO DATA(ls_list1).
@larshp
larshp / zupdate_credit.abap
Created Apr 28, 2021
Update credit limit
View zupdate_credit.abap
REPORT zupdate_credit.
* quick and dirty
PARAMETERS p_part TYPE ukmbp_cms_sgm-partner OBLIGATORY.
PARAMETERS p_segm TYPE ukmbp_cms_sgm-credit_sgmnt OBLIGATORY.
PARAMETERS p_limit TYPE ukmbp_cms_sgm-credit_limit OBLIGATORY.
START-OF-SELECTION.
PERFORM run.
View change_tadir.abap
METHOD zif_abapgit_exit~change_tadir.
* this cherry picks objects from different packages into a dummy package
* make sure to enable write protection for the repository
* and dont do this setup :)
TYPES: BEGIN OF ty_object_and_name,
type TYPE tadir-object,
name TYPE tadir-obj_name,
END OF ty_object_and_name.
View oracle_upsert.sql
MERGE INTO schema.table t
USING
(SELECT ? field1, ? field2 FROM dual) s
ON
(t.field1 = s.field1)
WHEN MATCHED THEN
UPDATE SET t.field2 = s.field2
WHEN NOT MATCHED THEN
INSERT (field1, field2) values (s.field1, s.field2)
View mssql_upsert.sql
MERGE INTO Target_Table AS t
USING
(SELECT Field1=?, Field2=?, Field3=?, Field4=?) AS s
ON t.Field1 = s.Field1
WHEN MATCHED THEN
UPDATE SET
Field1=s.Field1,
Field2=s.Field2,
Field3=s.Field3,
Field4=s.Field4