Dynamic Data Acquisition Method
Implementation of ABAP dynamic query: it can fully implement dynamic query, and each field can be dynamic.
(1) Use macros
(2) Use the ABAP pointer
(3) Use Field-Symbol
Specific implementation:
1. structure dynamic query
Define select_data_to_wa.
Select & 1
From & 2
Into corresponding fields of & 3
Where (& 4 ).
Exit.
Endselect.
End-of-definition.
2. dynamic query of Variables
Define select_data_to_variant.
Select & 1
From & 2
Into & 3
Where (& 4 ).
Exit.
Endselect.
End-of-definition.
3. dynamic query of internal tables
Define select_data_to_variant.
Select & 1
From & 2
Into corresponding fields of Table & 3
Where (& 4 ).
Exit.
Endselect.
End-of-definition.
Specific program implementation:
Code
|
Data: Maid (100) type C,
Rochelle table (10) type C,
Rochelle cond (100) type C.
Data: I _cond type talbe of l_cond.
Field-Symbols <FS> Type any.
Start-of-selection.
Concatenate 'carrid' 'connid' 'cityfrom'
Into l_s
Separate by space.
Concatenate 'connid = '''' 0123'''' Into l_cond.
Append cond to I _cond.
Rochelle table = 'spfli '.
If <FS> Is assigned.
Unassign <FS> .
Assign spfli to <FS>.
Else.
Assign spfli to <FS>.
Endif.
Select_data_to_wa (l_s) (l_table) <FS> I _cond. |