‎2011 Oct 14 5:47 PM
Hi,
I have Dynamic Internal Table : <LT_TX>
<LT_TX>
Col A Time Number
A1 01.2011 10
A2 02.2011 10
A1 03. 2011 10
How do I do LOOP AT on <LT_TX> with KEY COLA = A1 and hence ONLY LOOP AT 'A1' in THIS DYNAMIC INTERNAL TABLE.
if I do like this, below i get an error, how to only LOOP AT A1 ones ?
data: firstcol type string value 'ColA'.
LOOP AT <LT_TX> ASSIGNING <LS_TX> WHERE (firstcol) = 'A1'.
ERROR: in LOOP ... WHERE the line type of the table must be statically defined.
Advice please
‎2011 Oct 14 5:56 PM
You can't have a dynamic where in this case.
FIELD-SYMBOS: <FIELD_1> TYPE ANY.
LOOP AT <LT_TX> ASSIGNING <LS_TX>. "WHERE (firstcol) = 'A1'.
ASSIGN COMPONENT 1 OF STRUCTURE <LS_TX> TO <FIELD_1>.
IF <FIELD_1> EQ 'A1'.
ENDIF.
....
ENDLOOP.
‎2011 Oct 14 5:55 PM
Hi
You can't do a dynamic where condition in the LOOP, yo can use something like that with READ statament, but that means it can read one record only
If you need to use the LOOP, you can only use the CHECK statament:
LOOP AT <LT_TX> ASSIGNING <LS_TX>.
ASSIGN COMPONENT (FIRSTCOL) OF STRUCTURE <LS_TX> TO <FS_TX>.
CHECK <FS_TX> = 'A1'.Max
‎2011 Oct 14 5:56 PM
You can't have a dynamic where in this case.
FIELD-SYMBOS: <FIELD_1> TYPE ANY.
LOOP AT <LT_TX> ASSIGNING <LS_TX>. "WHERE (firstcol) = 'A1'.
ASSIGN COMPONENT 1 OF STRUCTURE <LS_TX> TO <FIELD_1>.
IF <FIELD_1> EQ 'A1'.
ENDIF.
....
ENDLOOP.