2019 May 31 7:47 AM
Is it possible to achieve this ?
field-symbols : <i_itab> TYPE table ,
<wa_tab> type any.
Loop at <i_itab> assigning <wa_tab> where (dynamic condition).
I am trying to replace value, if the condition satisfies it will change but i am unable to satisfy the condition here.
- thank you !
Is it possible to achieve this ?
field-symbols : <i_itab> TYPE table ,
<wa_tab> type any.
Loop at <i_itab> assigning <wa_tab> where (dynamic condition).
I am trying to replace value, if the condition satisfies it will change but i am unable to satisfy the condition here.
- thank you !
2019 May 31 7:53 AM
Hello vinayad,
Could you put in some more information about how your dynamic condition will be formed?
2019 May 31 8:08 AM
2019 May 31 10:44 AM
Hi Sandra Rossi
When I tried this below way,
DATA dref TYPE REF TO i.
DATA :BEGIN OF line,
col1 TYPE i,
col2 TYPE i,
END OF line.
dref = REF #( num ).
LOOP at <i_itab> INTO line FROM 10 TO 25 WHERE col2 > dref->*.
I am getting error, The field REF is unknown.
2019 May 31 10:57 AM
It's a completely different question. "dref = REF #( num )" works only from ABAP 7.40 SP 2.
2019 May 31 9:13 AM
Kindly try with range. Declare data type as range and then loop that dyanmic query into work area.
2019 May 31 10:13 AM
2019 May 31 10:39 AM
data cond type string.
Loop at <i_itab> assigning <wa_tab> where (cond).
-Thanks.
2019 May 31 2:33 PM
Hi,
CASE gv_cdvue.
WHEN 'L'.
lv_condi = 'dcmdr GE gv_daybf OR dcmdr LE gv_daybf '.
WHEN 'C'.
lv_condi = 'dcldr GE gv_daybf OR dcldr LE gv_daybf '.
WHEN 'E'.
WHEN OTHERS.
ENDCASE.
LOOP AT gt_plcad INTO ls_plcad WHERE (lv_condi).
....
ENDLOOP.https://answers.sap.com/questions/5712863/dynamic-where-clause-for-loop-at-internal-table.html
DATA: lt_spfli TYPE STANDARD TABLE OF spfli,
lv_where TYPE string,
lv_fld1 TYPE string value 'CARRID',
lv_fld2 TYPE string VALUE 'AIRPTO',
lv_carrid TYPE s_carr_id VALUE 'AA',
lv_airpt TYPE s_toairp VALUE 'JFK',
lv_sing_quote TYPE string VALUE '''',
lv_stub TYPE string,
lv_stub2 TYPE string.
FIELD-SYMBOLS: <fs_spfli> TYPE spfli.
SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_spfli FROM spfli.
"To add the single quote around value. E.g. AA => 'AA', JFK => 'JFK'
CONCATENATE lv_sing_quote lv_carrid lv_sing_quote INTO lv_stub.
CONCATENATE lv_sing_quote lv_airpt lv_sing_quote INTO lv_stub2.
"Where clause without AND
CONCATENATE lv_fld1 '=' lv_stub INTO lv_where SEPARATED BY space.
ULINE.
LOOP AT lt_spfli ASSIGNING <fs_spfli> WHERE (lv_where).
WRITE: / <fs_spfli>-carrid, <fs_spfli>-airpto.
ENDLOOP.
ULINE.
NEW-LINE.
NEW-LINE.
CLEAR lv_where.
"Where clause with AND
CONCATENATE lv_fld1 '=' lv_stub 'AND' lv_fld2 '=' lv_stub2 INTO lv_where SEPARATED BY SPACE.
ULINE.
LOOP AT lt_spfli ASSIGNING <fs_spfli> WHERE (lv_where).
WRITE: / <fs_spfli>-carrid, <fs_spfli>-airpto.
ENDLOOP.
ULINE.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |