My goal is to achieve the following using FOR
loop.
DATA(lt_wherecondn) = VALUE string_table( ).
DATA(lt_fields) = VALUE rsds_frange_t(
( fieldname = 'A~FLD1' ) ( fieldname = 'A~FLD2' ) ).
DATA(lv_lines) = lines( lt_fields ).
LOOP AT lt_fields ASSIGNING FIELD-SYMBOL(<fields>).
DATA(lv_length) = strlen( <fields>-fieldname ) - 2.
DATA(lv_line) = COND string(
WHEN lv_lines <> sy-tabix
THEN <fields>-fieldname+2(lv_length) && | IN | && |@| && <fields>-fieldname && | AND |
ELSE <fields>-fieldname+2(lv_length) && | IN | && |@| && <fields>-fieldname ).
APPEND lv_line TO lt_wherecondn.
ENDLOOP.
Also:
- There are field names in
LT_FIELDS
. - Concatenate
LT_FIELDS-FIELDNAME
data into a specific format. - Append it to
LT_WHERE
.
Result in LT_WHERECONDN
:
FLD1 IN @A~FLD1 AND
FLD2 IN @A~FLD2
Below is my code (not sure where to add my lv_length
logic in the loop):
TYPES: BEGIN OF ty_whr,
fieldname TYPE string,
END OF ty_whr.
DATA(lt_where) = REDUCE ty_whr(
INIT whereclause = VALUE ty_whr( )
FOR <fields> IN lt_fields
NEXT whereclause-fieldname =
COND #( WHEN whereclause IS NOT INITIAL
THEN <fields>-fieldname && | IN | && |@| && <fields>-fieldname && | AND |
ELSE <fields>-fieldname && | IN | && |@| && <fields>-fieldname ) ).
The above snippet is creating a deep structure lt_where
with fieldname
and holds only one line of data. Seems to be a syntax issue. What needs to be corrected here?