on 07-09-2007 1:15 PM
Hi All,
I have to pass a value "name1" in my smartform for multiple perners.
My table name is itab1. But i am not getting tha values.
please advice.
DATA: BEGIN OF ITAB_EMPNO OCCURS 0,
PERNR LIKE PA0001-PERNR,
END OF ITAB_EMPNO.
SELECT PERNR FROM PA0001 INTO TABLE ITAB_EMPNO WHERE PERNR IN P_PERNR.
SORT ITAB_EMPNO BY PERNR.
DELETE ADJACENT DUPLICATES FROM ITAB_EMPNO.
LOOP AT ITAB_EMPNO.
ITAB1-PERNR = ITAB_EMPNO-PERNR. " passing pernrs in itab1
AT END OF PERNR.
APPEND itab1.
CLEAR ITAB1.
ENDAT.
ENDLOOP.
LOOP AT ITAB1 .
read table it_0002 with key pernr = itab1-pernr.
if sy-subrc = 0.
ITAB1-NAME1 = IT_0002-NAME1.
APPEND ITAB1 .
endif.
ENDLOOP.
thanks & regards,
Preeti
Hello Preeti modify your code as below
LOOP AT ITAB1 .
read table it_0002 with key pernr = itab1-pernr.
if sy-subrc = 0.
ITAB1-NAME1 = IT_0002-NAME1.
<b>MODIFY ITAB1</b>. "APPEND ITAB1 .
endif.
ENDLOOP.
this should solve your problem.
inseatd of occurs in declaration use work area & loop your table into workarea.
reward points if helpful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Preeti,
Firstly, you dont need two seperate loops. Club the logic in the same loop. Read Infotype 0002 data in the same loop and assign the same to ITAB1.
<b>You will have to pass employee name (name1) to itab1.</b>
LOOP AT ITAB_EMPNO.
ITAB1-PERNR = ITAB_EMPNO-PERNR. " passing pernrs in itab1
AT END OF PERNR.
<u><b>read table it_0002 with key pernr = itab_empno-pernr.
if sy-subrc = 0.</b></u>
<u><b>itab1-name1 = it002-name1.</b></u>
<u><b>endif.</b></u>
APPEND itab1.
CLEAR ITAB1.
ENDAT.
ENDLOOP.
Regards,
Naveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.