Professional Documents
Culture Documents
COM
The FOR ALL ENTRIES statement in SAP ABAP is used for efficient database queries when selecting
data from a database table based on a list of specified keys. It allows you to avoid multiple database
accesses by selecting all relevant data in one go. Here's a basic overview of how to use FOR ALL
ENTRIES.
2. MOVE CORRESPONDING:
It can transfer data between structures and work areas based on the corresponding field names.
data(wa_data1) = corresponding #( wa_data ).
3. CONVERSIONS ROUTINE:
This conversion routine is used to convert the data from SAP format to output format and output
format to SAP Format.
Conversion Input:
data(lv_matnr) = |{ wa_file_data-matnr alpha = in }|.
Conversion Outout:
data(lv_vbeln) = |{ wa_file_data-vbeln alpha = out }| .
4. CONCATENATION:
In SAP ABAP, the CONCATENATE statement is used to concatenate strings or fields into a single
string. The basic syntax of the CONCATENATE statement is as follows:
lv_descript = |{ text-001 } { gjahr } { space } { text-002 } { space } { monat }|.
In SAP ABAP, the READ TABLE statement can be used to check the existence of values in an internal
table without transferring any fields to the work area. When using TRANSPORTING NO FIELDS with
READ TABLE, it allows you to perform a simple existence check without copying any data to a target
structure.
Note:
Isn’t this pretty simple and useful? Try to use the above for checking
error or success for BAPI return messages, you will like it.
6. FILTERING data to an internal table:
This statement is to filter data in an internal table based on a specified condition.
In ABAP, the NEW constructor operator is used to dynamically create instances of objects. This is
commonly used with object-oriented programming in ABAP.
Before:
DATA lo_human TYPE REF TO class_human.
CREATE OBJECT lo_human EXPORTING NAME = 'TONY'.
After:
lo_human = NEW class_human( name = ‘TONY’ ).
30 to itab.
After:
DATA(itab) = VALUE t_itab( ( 10 ) ( 20 ) ( 30 ) ).
Before:
APPEND LINES OF lt_itab1 TO lt_itab2.
lt_itab2[] = lt_itab1[].
After:
FOR wa| IN itab [INDEX INTO idx] [cond]
Before :
TYPES: BEGIN OF ty_ship,
tknum TYPE tknum,
name TYPE ernam,
city TYPE ort01,
route TYPE route,
END OF ty_ship.
TYPES: ty_ships TYPE SORTED TABLE OF ty_ship WITH UNIQUE KEY tknum.
TYPES: ty_citys TYPE STANDARD TABLE OF ort01 WITH EMPTY KEY.
After:
DATA(gt_citys) = VALUE ty_citys( FOR ls_ship IN gt_ships ( ls_ship-city ) ).
After:
DATA(lv_text) = COND text30(
WHEN lv_vehicle ='01' AND lv_type = 'C' THEN 'Toyota'
WHEN lv_vehicle ='02' AND lv_type = 'C' THEN 'Chevy'
WHEN lv_vehicle ='03' AND lv_type = 'C' THEN 'Range Rover').
date = p_date
importing
day = l_indicator.
case l_indicator.
when 1.
l_day = 'Monday'.
when 2.
l_day = 'Tuesday'.
when 3.
l_day = 'Wednesday'.
when 4.
l_day = 'Thursday'.
when 5.
l_day = 'Friday'.
when 6.
l_day = 'Saturday'.
when 7.
l_day = 'Sunday'.
else.
Raise exception type zcx_day_problem.
endcase.
After:
DATA(L_DAY) = SWITCH char10( l_indicator
when 1 THEN 'Monday'
when 2 THEN 'Tuesday'
when 3 THEN 'Wednesday'
when 4 THEN 'Thursday'
when 5 THEN 'Friday'
when 6 THEN 'Saturday'
when 7 THEN 'Sunday'
ELSE THROW zcx_day_problem( ) ).