05-22-2006 5:16 AM
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
05-22-2006 6:35 AM
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.
05-22-2006 6:19 AM
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
05-22-2006 6:35 AM
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.
05-22-2006 6:40 AM
try using the following code
loop at t_itab.
case sy-index.
when '1'.
s_itab-client1 = '1'.
..........
endcase.
endloop.
hope its helps
Anirban
05-22-2006 7:09 AM
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
05-22-2006 7:28 AM
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.