ABAP/4

How to Generate Value Request by ABAP/4

We can use function module "F4IF_INT_TABLE_VALUE_REQUEST" for generate value request by ABAP report.

Example


              

*** Screen Flow ***

PROCESS ON VALUE-REQUEST.

  FIELD scn_kokrs MODULE create_value_request.

*** ABAP Editor ***

MODULE create_value_request INPUT.

DATA: BEGIN OF itab_request OCCURS 0,

kokrs LIKE TKA01-KOKRS,

bezei LIKE TKA01-BEZEI,

END OF itab_request.


SELECT KOKRS BEZEI
       FROM TK


            

How to Read Table Dynamically in ABAP/4

About statement "READ TABLE", we can generate code for read key dynamic as below:


DATA: BEGIN OF itab OCCURS 0,
fld1(2),
fld2(2),
fld3(10),
fld4 TYPE i,
END OF itab,
wa_tab LIKE itab,
gv_key1(4) TYPE C VALUE ’FLD1’,
gv_key2(4) TYPE C VALUE ’FLD2’.
...
...
...

READ TABLE itab INTO wa_tab
WITH KEY (gv_key1) = ’AA’
(gv_key2) = ’BB’.

Operator for comparing strings in ABAP/4


Operator     Description
CO Contains Only
CN Contains Not Only
CA Contains Any
NA Contains Not Any
CS Contains String
NS Contains No String
CP Matches Pattern
NP Not Match Pattern

How to Find the Number of Entries of Internal Table in ABAP/4

We can find out how many entries of internal table by apply statement "DESCRIBE".

Example


DATA: it_tab TYPE TABLE OF BKPF WITH HEADER LINE,
      tot_lines TYPE i.
...
...
DESCRIBE TABLE it_tab LINES tot_lines.

Or you can apply statement ’LOOP AT’ and count it.

Example


LOOP AT it_tab.
tot_lines = tot_lines + 1.
ENDLOOP.

Move & Move-Corresponding in ABAP/4


DATA: BEGIN OF wa_tab1,
fld1(4) VALUE ’FLD1’,
fld2(4) VALUE ’FLD2’,
fld3(4) VALUE ’FLD3’,
fld4(4) VALUE ’FLD4’,
fld5(4) VALUE ’FLD5’,
END OF wa_tab1,
BEGIN OF wa_tab2,
fld1(4),
fld2(4),
fld3(4),
fld4(4),
END OF wa_tab2.
************* Move Corresponding *************
MOVE-CORRESPONDING wa_tab1 to wa_tab2.
************ End Move Corresponding **********
******************** Move ********************
MOVE: wa_tab1-fld1 to wa_tab2-fld1,
wa_tab1-fld2 to wa_tab2-fld2,
wa_tab1-fld3 to wa_tab2-fld3,
wa_tab1-fld4 to wa_tab2-fld4.
****************** End Move ******************
In above example, the result of MOVE and MOVE-CORRESPONDING is same.

System Field When Generate ABAP/4 Report (Often to use)

Field     Description
COLNO the current column
LINNO the current line