‎2008 Jul 09 10:37 AM
Hi,
Can anybody please tell me how to solve this issue.
My requirement is for example in the internal table like below
data: begin of itab1 occurs 0,
field1 value 'namfld',
field2 value ' Test',
end of itab1.
data: x type string.
loop at itab1.
x = itab1-field1
endloop
In the initial i want the values of X to be field1 and after next iteration i want the value of X to be field2 dynamically i.e for each iteration the value of X to be changed to next field in the internal table.Can anybody please solve this its an urgent requirement.
‎2008 Jul 09 10:52 AM
Try like this :
loop at itab1.
if sy-tabix = 1.
x = itab1-field1.
else.
x = itab1-field2.
endif.
endloop
‎2008 Jul 09 10:40 AM
loop at itab1.
if sy-tabix = 1.
x = itab1-field1.
elseif sy-tabix = 2.
x = itab1-field2.
endif.
endloop
‎2008 Jul 09 10:52 AM
Try like this :
loop at itab1.
if sy-tabix = 1.
x = itab1-field1.
else.
x = itab1-field2.
endif.
endloop
‎2008 Jul 09 10:54 AM
data:
l_flag type c.
loop at itab.
if l_flag = ' '.
x = First field.
l_flag = 'X'.
else.
x = second field.
l_flag = ' '.
endif.
endloop.