Application Development 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: 

Assigning Values to Structure on Loop Iteration

Former Member
0 Kudos

Hi Experts,

My structure is having the fiedls

Employee Number|Employee Name | Email ID | Client 1 | Client 2| Client 3 | Clinet 4 | Client 5|

Since Employee Numebr, Employee Name and Email Id are the master data,it is easy to popuplate on the structure.

But while populating the data into the structures fields

client 1 ,....Client5, these are field which are derived from different records in the internal table, based on the query from the database.

Every employee will not be having all the time all the 5 clients . Employee may have record from 1 to 5.

But I want to fix with respect to the loop iteration that if the iteration is one , then clinet 1 filed has to be populated.

Could you please advice me.

Thanks in Advance,

Regards,

Irfan Hussain

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Loop at itab.

at new employee.

loop at itab where employee = itab-employee.

l_recno = itab-recno.

case l_recno.

when '1'.

populate corresponding employee record.

when '2'.

populate corresponding employee record.

....

when '5'.

populate corresponding employee record.

endcase.

endloop.

endat.

endloop.

Hope this will works for your logic....

Cheers,

Bujji.

5 REPLIES 5

nishanthbhandar
Contributor
0 Kudos

data : l_counter type i.

Loop at itab.

l_counter = l_counter + 1.

Case l_counter.

when '1'.

populate client 1.

when '2'.

populate client 2.

.

.

( so on )

when '5'.

populate client 5.

clear l_counter.

endcase.

endloop.

Hope this is what you are looking for.

<i>Reward helpful answers</i>

Cheers

Nishanth

Former Member
0 Kudos

Hi,

Loop at itab.

at new employee.

loop at itab where employee = itab-employee.

l_recno = itab-recno.

case l_recno.

when '1'.

populate corresponding employee record.

when '2'.

populate corresponding employee record.

....

when '5'.

populate corresponding employee record.

endcase.

endloop.

endat.

endloop.

Hope this will works for your logic....

Cheers,

Bujji.

former_member480923
Active Contributor
0 Kudos

try using the following code

loop at t_itab.

case sy-index.

when '1'.

s_itab-client1 = '1'.

..........

endcase.

endloop.

hope its helps

Anirban

Former Member
0 Kudos

Dear Irfan,

loop at it_emp.

*-Check if employee has only 1 client.

on change of it_emp-empno.

move it_client1 to client1.

modify target_emp tansporting it-client1

where empno = it_empno.

continue.

endon.

*- If employee has more than 1 client.

on change of it_emp-client.

l_count = l_count + 1.

case l_count.

when '1'.

move it_client2 to client2.

modify target_emp tansporting it-client2

where empno = it_empno.

when '2'.

move it_client3 to client3.

modify target_emp tansporting it-client3

where empno = it_empno.

endcase.

endon.

regards,

Kalyan

former_member186741
Active Contributor
0 Kudos

field-symbol <client> type any.

DATA: NUM_IT(1) TYPE N,VNAME(30).

loop at itab.

num_it = sy-tabix.

concatenate 'CLIENT' NUM_IT INTO VNAME.

ASSIGN COMPONENT VNAME OF STRUCTURE ITAB TO <CLIENT>.

IF SY-SUBRC = 0.

*POPULATE CLIENT FIELD HERE....

ENDIF.

ENDLOOP.