cancel
Showing results for 
Search instead for 
Did you mean: 

Passing value for multiple perners in smartform - VERY URGENT

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (1)

Answers (1)

Former Member
0 Kudos

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.