TIP 1: Avoid a SQL dump with the following pattern:
try. update zship_table set sto_no = wa_table-sto_no dlv = wa_table-dlv_no where vbeln = wa_table-vbeln. catch cx_sy_dynamic_osql_error. endtry.
TIP 2: Format a message for printing
call function 'FORMAT_MESSAGE' exporting id = msg-msgid "Message ID lang = sy-langu no = msg-msgnr "Message number v1 = msg-msgv1 "Message variable 1 v2 = msg-msgv2 "Message variable 2 v3 = msg-msgv3 "Message variable 3 v4 = msg-msgv4 "Message variable 4 importing msg = outmsg . "String variable containing the "message in printable format exceptions not_found = 1 others = 2.
TIP 3: Avoid short dumps due to data conversion errors - Strings not being able to be converted to a number
catch system-exceptions conversion_errors = 1. lv_n5 = lv_string endcatch. if sy-subrc ne 0. " Value cannot be converted to a number. else. " Good value endif.
TIP 4: Debugging a popup
In the system you wish to debug
Click the “Customize Local Layout Icon” and select “Create Shortcut”
Give a Good title “Development Debugging”
Select “System Command” as the Type
Type /H as the Command
Click Finish
Now when you want to debug those popup messages just drag the shortcut on to the popup window and click to continue which will open the debug session.
TIP 5: Dynamic Tables with field symbols
This code will show you how to make use of field-symbols for dynamic tables and fields. Sometimes we are not aware of the table structure before hand and therefore we do not know how to handle such tables in code.
This example makes use of field-symbols to achieve the desired outcome.
REPORT Z_DYNAMIC_TABLE. types : begin of itab, vbeln type vbrk-vbeln, end of itab. data : itab type standard table of itab. data : wa type itab. data : obj1 type ref to data, obj2 type ref to data. field-symbols : <fs_table> type any table, <fs_line> type any, <fs_field> type any. * Internal table is ITAB. wa-vbeln = '33'. append wa to itab. *Create a DATA object which will be like ITAB. create data obj1 like itab. * This assigns the structure of ITAB to the field-symbols <FS_TABLE>. <FS_TABLE> has a structure and it is a table. assign obj1->* to <fs_table>. if <fs_table> is assigned. * Assigns the values if ITAB to the field symbol <FS_TABLE> <fs_table> = itab[]. * In order to read the contents of the table, we need a work area. Create a data object which has the same structure as line of ITAB and then assign it to <FS_LINE>. <FS_LINE> has a work area with a structure like ITAB create data obj2 like line of <fs_table>. assign obj2->* to <fs_line>. loop at <fs_table> assigning <fs_line>. * In order to access the individual fields of the work area we will have to use the Assign Component statement. This component can be either named if we know the fieldname or we can give the column position if we do not know the name assign component 'VBELN' of structure <fs_line> to <fs_field>. * or ASSIGN COMPONENT 1 OF STRUCTURE <fs_line> TO <fs_field>. if <fs_field> is assigned. write <fs_field>. endif. endloop. endif.
TIP 6: Evaluate Customizing Changes
It's easy to see changes to ABAP but customizing changes are a little harder to track down. Use transaction SCU3 to check up on customizing change logs. In addition you could use transaction OY19 to evaluate / compare cross-system customizing objects (i.e. Check if the config in your current systems differs from that in a remote system)
Comments