Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Reg:Dynamic value change

former_member197425
Active Participant
0 Likes
478

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
460

Try like this :

loop at itab1.

if sy-tabix = 1.

x = itab1-field1.

else.

x = itab1-field2.

endif.

endloop

3 REPLIES 3
Read only

Former Member
0 Likes
460

loop at itab1.

if sy-tabix = 1.

x = itab1-field1.

elseif sy-tabix = 2.

x = itab1-field2.

endif.

endloop

Read only

Former Member
0 Likes
461

Try like this :

loop at itab1.

if sy-tabix = 1.

x = itab1-field1.

else.

x = itab1-field2.

endif.

endloop

Read only

Former Member
0 Likes
460

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.