ABAP/4

How to Insert or Delete Comment Block in ABAP Editor

Insert Comment

Select the statement line as block by hi-light and select menu Utilities -> Block/buffer -> Insert comment * in table control mode) or use hot key Ctrl + < in textedit control mode.

Delete Comment

Select the statement line as block by hi-light and select menu Utilities -> Block/buffer -> Delete comment * in table control mode) or use hot key Ctrl + > in textedit control mode.

How to Upload and Download Source Code of ABAP/4

Upload Source Code from PC File to ABAP Editor

You can do it by select Utilities -> More utilities -> Upload/download -> Upload and then enter your pc file that want to upload in your ABAP editor. Finally, select action ’Copy’.

Download Source Code from ABAP Editor to PC File

You can do it by select Utilities -> More utilities -> Upload/download -> Download and then enter your pc file that want to download from your ABAP editor. Finally, select action ’Copy’.

How to Find First Date and End Date of Period in ABAP/4

If you know year, month and fiscal year variant and you want to know the first date and end date of that period, you can apply function module "PERIOD_DAY_DETERMINE" in ABAP/4 to get them.

Example


CALL FUNCTION ’PERIOD_DAY_DETERMINE’
EXPORTING
I_GJAHR = ’2006’ "Year
I_MONAT = ’01’ "Month
I_PERIV = ’F2’ "Fiscal Year Variant

IMPORTING
E_FDAY = FIRST_DATE
E_LDAY = END_DATE
EXCEPTIONS

Example to apply DO statement in ABAP/4

You will apply this statement when you want to loop data with non-condition loops.

Example 1: Simple Loop

DO.
WRITE:/ sy-index.
IF sy-index = 4.
    EXIT.
ENDIF.
ENDDO.

The output is


1
2
3
4

Example 2: Loops with n times

DO 4 TIMES.
WRITE:/ sy-index.
ENDDO.

The output is same as example 1.

Example 3: Nested Loops

Difference between CONTINUE, CHECK and EXIT statement in ABAP/4

  • CONTINUE
    When you apply this statement, system will pass a current loop. System  ignores any statements after CONTINUE statement and start to the next loop.

Example

DO 4 TIMES.
WRITE:/ sy-index.
IF sy-index <= 2.
CONTINUE.

ENDIF.
WRITE: ’After’.
ENDDO.

The output is

1  
2
3  After
4  After
  • CHECK
    This statement will apply if you want to check condition before go to next statement. If the result of checking is ’TRUE’, system will go to next step as normally. If the result of checking is ’FALSE’, system will operate look like CONTINUE statement.

Example

Example to apply WHILE statement in ABAP/4

You will apply this statement when you want to loop data with condition loops.

Example 1: Simple Loop

DATA: lv_int TYPE I VALUE 1.
WHILE lv_int <= 4.
WRITE:/ lv_int.
lv_int = lv_int + 1.




ENDWHILE.

The output is 

1
2
3
4

Example 3: Nested Loops

DATA: lv_int TYPE I VALUE 1,
lv_int2 TYPE I.

WHILE lv_int <= 4.
WRITE:/ lv_int.
lv_int2 = 1.
WHILE lv_int2 <= 2.
WRITE: lv_int2.
lv_int2 = lv_int2 + 1.
ENDWHILE.
lv_int = lv_int + 1.




ENDWHILE.

The output is