Friday, August 29, 2014

ABAP TIP Debugging-Load Current source code


ABAP Debugging-Load Current source code


When debugging is activated, even though the program is changed, we can call the program changed directly.

After creating test program, activate debugging.





And, open new session and change the program in t-code:se38



If you want to move to new program in current debgging session, you can choose Menu : Miscellaneous -> Load Current source code.
 



ABAP TIP Customizing IMG Menu

ABAP Customizing IMG Menu


Lets learn how to customizing the IMG menu.

First, you need to execute T-CODE: S_IMG_EXTENSION, click the Possible Entry in IMG structure.






ABAP TIP Field Symlbo Tip

ABAP Field Symlbo Tip


The one of lots of field symbol advantage of is efficiency because field symbol doesn’t occupy memory space and only have a reference to other variable.
When there is a need to improve filed symbol performance with BINARY SEARCH, we can sort field symbol.
In this case, the inter table defined with field symbol should declared as a standard type.

SORT <fs1> BY ('CARRID').

REPORT  zfieldsymbol01.

DATA : gt_scarr TYPE TABLE OF scarr.

FIELD-SYMBOLS : <fs1> TYPE STANDARD TABLE,
                <fs2> TYPE ANY.

SELECT * INTO TABLE gt_scarr FROM scarr.

ASSIGN gt_scarr TO <fs1>.

SORT <fs1> BY ('CARRID').

READ TABLE <fs1> WITH KEY ('CARRID') = 'AA' ASSIGNING <fs2>
                 BINARY SEARCH.

WRITE <fs2>.



Like this case, when field symbol is defined with TYPE ANY, you can sort the internal table like below program.


SORT <itab> BY (otab).


REPORT  zsort.


PARAMETERS p_dbtab TYPE c LENGTH 30.
DATA : GV_COLUMN TYPE C LENGTH 30.

SELECT-OPTIONS columns FOR GV_COLUMN NO INTERVALS.
PARAMETERS : p_ASC RADIOBUTTON GROUP OPT1,
             p_DSC RADIOBUTTON GROUP OPT1.

PARAMETERS p_where type c LENGTH 255.

DATA: otab  TYPE abap_sortorder_tab,
      oline TYPE abap_sortorder,
      dref  TYPE REF TO data.

FIELD-SYMBOLS: <column> LIKE LINE OF columns,
               <itab> TYPE STANDARD TABLE.

TRY.
    CREATE DATA dref TYPE STANDARD TABLE OF (p_dbtab).
    ASSIGN dref->* TO <itab>.
  CATCH cx_sy_create_data_error.
    MESSAGE 'Wrong data type!' TYPE 'I' DISPLAY LIKE 'E'.
    LEAVE PROGRAM.
ENDTRY.

TRY.
    SELECT *
           FROM (p_dbtab)
           INTO TABLE <itab>
           where (p_where).
  CATCH cx_sy_dynamic_osql_semantics.
    MESSAGE 'Wrong database table!' TYPE 'I' DISPLAY LIKE 'E'.
    LEAVE PROGRAM.
ENDTRY.

LOOP AT columns ASSIGNING <column>.
  oline-name = <column>-low.
  IF P_DSC = 'X'.
     oline-descending = P_DSC.
  ENDIF.
  APPEND oline TO otab.
ENDLOOP.

TRY.
    SORT <itab> BY (otab).
  CATCH cx_sy_dyn_table_ill_comp_val.
    MESSAGE 'Wrong column name!' TYPE 'I' DISPLAY LIKE 'E'.
    LEAVE PROGRAM.
ENDTRY.





Thursday, August 28, 2014

ABAP TIP F4(possible Entry) setting


ABAP F4(possible Entry) setting


We can change the F4 setting at SAP gui level in menu : Help -> settings ->  F4 Help tab,
For example, in case of increasing the number of hit list, we can adjust the option 'Max. number of hits to be displayed' .






With F4 dispaly, there are 2 kind of list type which are Control and Dialog.
There is difference between two display mode like below screen.

- Control Mode
 



- Dialog Mode



ABAP Extension Index

ABAP Extension Index
We already know that Index is very crucial for the performance. SAP offers two way to create index in t-code;s11.

- Create Index : this is classical and usual way
- Create Extension Index : it
s same function with Create index, but this kind of index will not be overwritten in SAP upgrade.



When doing SAP upgrade, there is a possibility to delete or overwrite the current secondary index customer created for performance issue. This issue might make a critical performance issue. Even though we found the root cause, it would take very long time to create index in production server because index is small copy of table.
When creating index, Extension Index protect this risk in advance.




ABAP TIP Check case sensitive

ABAP Check case sensitive

Let’s learn how to check upper/lower case in data variable.
After creating program, create 2 variables. First variable has only one lowercase character, Second variable has all lowercase alphabet. And if you compare with ‘CA’, the program check if the variable has a lowercase or not.
Starting the position of lowercase is saved to SY-FDPOS.


REPORT  zcase_test.

DATA : gv_v1 TYPE string VALUE 'AbCD',
       gv_v2 TYPE string VALUE 'abcdefghijklmnopqrstuvwxyz'.

IF gv_v1 CA gv_v2.
  MESSAGE 'There is lower case in variable.' TYPE 'I'.
ELSE.
  MESSAGE ' There is lower case in variable..' TYPE 'I'.
ENDIF.



In contrast, you can also check upper case with the string consisted of upper case.

DATA : gv_v2 TYPE string VALUE 'ABCDEFGHIZKLMNOPQRSTUVWXYZ'.

Or system variable SY-ABCDE is replaced with 'ABCDEFGHIZKLMNOPQRSTUVWXYZ'.
.
IF gv_v1 CA SY-ABCDE.


ABAP TIP Analyze Dump Error with user variant (ST22)

ABAP Analyze Dump Error with user variant (ST22)

When dump error occurs, its very important to check which variant and value is used.

Go to T-CODE:ST22, double click dump error line. lets move to detailed screen.

                   




If you click BASIS developer view -> Directory of application Table  in left tree menu, you can see the program name and variant name user executed. Additionally, if you move down to next page, you can check the data value of table which is used by program.

ABAP TIP Editor screen splitter

ABAP Editor screen splitter

While developing program, copying and pasting is one of the most frequent activity we should. Usually, ABAP developers open new window and change program moving across the windows to refer to other program. There is helpful way to see the source in divided screen.

1.  In ABAP Editor, select the splitter button and drag to the place you want




2.  You will see the screen is split

       

Like this function, there is T-CODE:SE39(ABAP Splitscreen Editor). But splitter is more efficient for user who usually use abap editor.

ABAP TIP time dependency table


ABAP time dependency table

If there is a master data that should be maintained on time-based, its very efficient to use Time Dependency function.

For test, you need to create table and add extra columns ENDDA and BEGDA and set the ENDDA column as a key.




In order to create Table Maintenance, move to Menu Utilities -> Table Maintenance Generator.
And you need to choose Menu : Menu : Environment -> Generate Time-Dep.




For test, execute T-CODE:SM30 and enter table name and click the button Maintain.



Lets create a data that has a value from 2014/01/20 to 2014/01/31 .



And, if you try to create another data that has a overlapping period, the system displays an error message and data is not created.
“Overlapping records are deleted or delimited”



In case you want to change the date period, select the line and click the Delimit icon on the toolbar.






On the base of default Key value, 2 data is created automatically. These are split after and before2014/01/25/ .




If you go to T-CODE:SM30, there is only one available data



To display all time dependency history data, you need to click the Expand <-> Collapse button.





Wednesday, August 27, 2014

ABAP TIP System Command

ABAP System Command

There is need to execute the system command at OS level. You can apply this by using below statement.

CALL 'SYSTEM' ID 'COMMAND' field lv_cmd
             
ID 'TAB' field lt_result.

There is another more efficient way to use system command by calling function SXPG_CALL_SYSTEM.
First you need to create system command with t-code:sm69 to use this at a abap program.
For example, lets exercise with the command of LS which can list the all command list in UNIX system.

T-CODE:SM69, click the create button.





ABAP TIP Skip Breakpoint

ABAP Skip Breakpoint

Lets figure out how to skip the count number of breakpoint and activate breakpoint after designated loop.
With the following code, you can activate the breakpoint at the last loop with the help of debugging.





First set the breakpoint, and debugger screen will be displayed. Move to Break/Watchpoints tab, input the number you want to skip.

 


Then you press F8, the program will be stopped at the point skipping 98.

ABAP SE93 : CALL GRAPH

ABAP SE93 : CALL GRAPH


With T-CODE:SE93 Menu : Utilities -> Call Graph, you can easily see the overall flow of transaction code.




Initial screen for VA03 is displayed. Open all hierarch structure by clicking + icon.


You can become aware of all flow like PBO and PAI.


If you chose individual module, it takes you to the abap source program.

 



ABAP TIP SE80:Display worklist

ABAP SE80:Display worklist

SE80 has useful functions that we are not accustomed to. Especially, if you know the function of ‘diplay worklist’ and ‘Navigation stack’ in ABAP editor, you can easily move to the previous source line. It will improve development productivity.


Display Worklist - Menu : Utilities -> Worklist -> Display


Navigation Stack  - Menu : Utilities -> Display Navigation Window


ABAP TIP Radio button, List Box & User command

ABAP Radio button, List Box  &  User command

When user click radio button, there is need like setting some field disable on the screen.
In order to implement this, you need to trigger some event as like user input enter command. This effects is possible to add USER-COMMAND option in radio button.

<ex 1>
REPORT  zradio_01.


PARAMETERS PARAMETERS p_r1 TYPE c RADIOBUTTON GROUP 
rad1
USER-COMMAND test DEFAULT 'X',
             p_r2 TYPE c RADIOBUTTON GROUP rad1.

PARAMETERS p_date TYPE d.

AT SELECTION-SCREEN OUTPUT.
  IF p_r2 EQ 'X'.
    LOOP AT SCREEN.
      IF screen-name 'P_DATE'.
        screen-input '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.
















Seen as radio button, this is applicable to the LIST BOX.

PARAMETERS P_L1 TYPE SCARR-CARRID 
AS LISTBOX VISIBLE LENGTH 10 USER-COMMAND TEST2.

<EX 2> set the p_data field disable when user select 'AA'.

<ex 2>
REPORT  zradio_02.


PARAMETERS P_L1 TYPE SCARR-CARRID AS LISTBOX VISIBLE LENGTH 10 USER-COMMAND TEST2.

PARAMETERS p_date TYPE d.

AT SELECTION-SCREEN OUTPUT.
  IF P_L1 EQ 'AA'.
    LOOP AT SCREEN.
      IF screen-name 'P_DATE'.
        screen-input '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.