Tuesday, October 17, 2023

ABAP Supports - Transactions/ Table handling

 Debug a table entry (single entry, one at a time)

Go to SE11 --> provide table name  --> go to content --> get the entry in detail view --> in the address bar type /HA and hit ENTER button twice --> it will take you to debug screen of a SWITCH CASE, provide the value as INST (Inserting a new entry), DELE (for delete the entry), MODY (to modify the existing one). Next it will take you to screen with respective button in edit mode and you are good to modify as per need. SAVE it and come back, else debugger screen will continue.

 Debug multiple table entry (delete a set of entries in table)

Go to SE38 --> Provide the Include program LSE16NF10  --> Go to function Module SE16_INTERFACE at line 619 --> Set debugger.

Then go to SE16N --> open the table content with table name provided --> get the detail view by executing --> this will take to debugger session that will be appearing next, when the debugger stops at Function Module SE16_INTERFACE at line 619 --> Edit the entry of the field/parameter GD_SAPEDIT and GD-EDIT  and set X as value for both  --> then next screen will appear with delete button --> next you choose, the entries (multiple) and keep delete and SAVE.

SM12 -> to unlock the table if it is locked by others

SM59 -> to check if any session debugger is stuck or awaiting 

SE36 -> Logical Database (LDB) 

SE21 - > Package

SE09/SE10 -> Transports

SE01/ SE01D --> SAP user profile

SE24 --> Class

SE11 --> DDIC

SE37 --> function modules

ST22 --> Dumps/ Runtime Errors

STMS --> change requests transferring


Wednesday, August 16, 2023

ABAP 7.5 Coding Standards in OOPS

ABAP 7.4/7.5 in OOPS:

--------------------------------------------------------------------------------------

1 Upcasting/Downcasting with CAST

Before:

DATA lo_structure TYPE REF TO CL_ABAP_STRUCTDESCR. "Structure_description

DATA lo_components TYPE ABAP_COMPDESCR_TAB.

lo_structure ?= cl_abap_typedescr=>describe_by_name( 'ZSC_MONSTER_HEADER' ).

lo_components = structure_description->components.

After:

DATA(lo_components) = CAST cl_abap_structdescr(

cl_abap_typedescr=>describe_by_name( 'ZSC_MONSTER_HEADER' ) )->components.

--------------------------------------------------------------------------------------

2 Finding the Subclass of an Object Instance

DATA: full_screen_adapter TYPE REF TO cl_salv_fullscreen_adapter,

container_adapter TYPE REF TO cl_salv_grid_adapter.

TRY.

"Presume full screen mode (No Container)

"Fullscreen Adapter (Down Casting)

"Target FULL_SCREEN_ADAPTER = CL_SALV_FULLSCREEN_ADAPTER

"CL_SALV_FULLSCREEN is a subclass of CL_SALV_ADAPTER 

full_screen_adapter ?= io_salv_adapter.

"Get the Grid

ro_alv_grid = full_screen_adapter->get_grid( ).

CATCH cx_sy_move_cast_error.

"We must be in container mode

"CL_SALV_GRID_ADAPTER is a subclass of CL_SALV_ADAPTER

container_adapter ?= io_salv_adapter.

ro_alv_grid = container_adapter->get_grid( ).

ENDTRY.

After:

IF io_salv_adapter IS INSTANCE OF cl_salv_fullscreen_adapter.

    full_screen_adapter ?= io_salv_adapter.

    ro_alv_grid = full_screen_adapter->get_grid( ).

ELSEIF io_salv_adapter IS INSTANCE OF cl_salv_grid_adapter.

    container_adapter ?= io_salv_adapter.

    ro_alv_grid = container_adapter->get_grid( ).

ENDIF.

-------------------------------------------------------------

CASE TYPE OF io_salv_adapter.

WHEN TYPE cl_salv_fullscreen_adapter INTO DATA(full_screen_adapter2).

ro_alv_grid = full_screen_adapter2->get_grid( ).

WHEN TYPE cl_salv_grid_adapter INTO DATA(container_adapter2).

ro_alv_grid = container_adapter2->get_grid( ).

WHEN OTHERS.

RETURN.

ENDCASE.

--------------------------------------------------------------------------------------

3 CHANGING and EXPORTING Parameters

DATA: monster_number TYPE zde_monster_number VALUE '0000000001',

something_spurious TYPE string,

something_unrelated TYPE string.

DATA(monster_header_record) = lcl_monster=>get_details(

EXPORTING id_monster_number = monster_number

IMPORTING ed_something_spurious = something_spurious

CHANGING cd_something_unrelated = something_unrelated ).

--------------------------------------------------------------------------------------

4 Changes to Interfaces

INTERFACE scary_behavior.

METHODS: scare_small_children,

sells_mortgages DEFAULT FAIL,

hide_under_bed DEFAULT IGNORE,

is_fire_breather

DEFAULT IGNORE

RETURNING rf_yes_it_is TYPE abap_bool.

ENDINTERFACE. "Scary Behavior

--------------------------------------------------------------------------------------



Thursday, June 08, 2023

OOPS ABAP HR Classes

 List of Classes:

CL_HRPY_MASTER_INFOTYPE_READER

Replace with HR_READ_INFOTYPE, HR_INTOYPE_OPERATIONS

Wednesday, May 24, 2023

OOPS ABAP HR Decouple Framework

 How to Read Infotype (in oops)

DATA: lo_infotype TYPE REF TO cl_hrpa_read_infotype,

       li_infotype TYPE REF TO if_hrpa_read_infotype,

       lt_pri_infty TYPE pnnnn, "primary infotype

       lt_sec_infty TYPE pnnnn, "secoundary infotype

       lv_has_data TYPE boole_d,

       lv_has_auth TYPE boole_d.

 

// Initialization of the object

 TRY.

 CALL METHOD cl_hrpa_read_infotype=>get_instance

 *  EXPORTING

 *    masterdata_buffer =

   IMPORTING

     infotype_reader   = li_infotype.

  CATCH cx_hrpa_violated_assertion.

 ENDTRY.

 // Read method to get infotype data - METHOD: READ_SINGLE

 TRY.

 CALL METHOD li_infotype->read_single

   EXPORTING

     tclas         = 'A' "employee

     pernr         = '00012345'

     infty         = '0001'

     subty         = space

     objps         = space

     sprps         = ''

     begda         = '19000101'

     endda         = sy-datum

     mode          = '3'

     no_auth_check = space

   IMPORTING

     pnnnn         = lt_pri_infty

     pnnnn2        = lt_sec_infty

 *    pref          =

     data_exists   = lv_has_data

     missing_auth  = lv_has_auth.

  CATCH cx_hrpa_violated_assertion .

 ENDTRY.

 // Read method to get infotype data - METHOD: READ

 // Manipulate Data as needed

   CLEAR lt_infotype.

   CALL METHOD lr_infotype_reader->read

     EXPORTING

       tclas         = 'A'

       pernr         = lv_pernr

       infty         =  '0001'

       begda         = iv_begda

       endda         = iv_endda

       no_auth_check = abap_true

     IMPORTING

       infotype_tab  = lt_infotype

       data_exists   = lv_data_exists

       missing_auth  = lv_missing_auth.

 // Manipulate data

   LOOP AT lt_infotype INTO ls_infotype.

     CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn

       EXPORTING

         prelp = ls_infotype

       IMPORTING

         pnnnn = ls_p0001.

        APPEND ls_p0001 TO lt_p0001.

   ENDLOOP.