Skip to Content
0
Former Member
Aug 04, 2008 at 03:01 PM

Moving data into final internal table

652 Views

Hi all,

I am having problem moving data into the final internal table.

The requirement is simple.

I am fetching data from PA0002 table.

And then I am fetching data from PA0006 table by using for all entries.

Now, I need to populate the final internal table with data from these 2 two internal table.

Have a look at my code.------

report YEMP_DATA no standard page heading line-size 355.

*********************************

  • TABLES USED *

*********************************

tables: PA0002,

PA0006.

*******************************************

  • DATA DECLARATION *

*******************************************

types: begin of TY_PA0002,

PERNR type PERSNO, "EMPLOYEE NUMBER

NACHN type NACHN, "LAST NAME

VORNA type VORNA, "FIRST NAME

MIDNM type PAD_MIDNM, "MIDDLE NAME

GBDAT type GBDAT , "DATE OF BIRTH

BEGDA type BEGDA, "DATE OF JOINING

PERID type PRDNI, "PERSONNEL ID

GESCH type GESCH, "GENDER KEY

end of TY_PA0002.

types: begin of TY_PA0006,

PERNR type PERSNO, "EMPLOYEE NUMBER

STRAS type STRAS, "STREET AND HOUSE NO.

PSTLZ type PSTLZ, "POSTAL CODE

end of TY_PA0006.

types: begin of TY_FINAL,

PERNR type PERSNO, "EMPLOYEE NUMBER

NACHN type NACHN, "LAST NAME

VORNA type VORNA, "FIRST NAME

MIDNM type PAD_MIDNM, "MIDDLE NAME

GBDAT type GBDAT , "DATE OF BIRTH

BEGDA type BEGDA, "DATE OF JOINING

PERID type PRDNI, "PERSONNEL ID

GESCH type GESCH, "GENDER KEY

STRAS type STRAS, "STREET AND HOUSE NO.

PSTLZ type PSTLZ, "POSTAL CODE

end of TY_FINAL.

******************************************

  • INTERNAL TABLE DECLARATION *

******************************************

data:IT_PA0002 type standard table of TY_PA0002 with header line,

IT_PA0006 type standard table of TY_PA0006 with header line,

IT_FINAL type standard table of TY_FINAL with header line.

**wa declaration**

*data:IT_PA0002 like line of IT_PA0002,

  • IT_PA0006 like line of IT_PA0006,

  • IT_FINAL like line of IT_FINAL.

******************************************

  • SELECTION SCREEN FOR INPUTS *

******************************************

*select-options : S_UNAME for p0002-UNAME.

******************************************

  • START-OF-SELECTION *

******************************************

select PERNR

NACHN

VORNA

MIDNM

GBDAT

BEGDA

PERID

GESCH

from PA0002

into table IT_PA0002

where UNAME = 'REDDYT'.

if not IT_PA0002[] is initial.

sort IT_PA0002 by PERNR.

endif.

loop at IT_PA0002.

IT_FINAL-PERNR = IT_PA0002-PERNR.

IT_FINAL-NACHN = IT_PA0002-NACHN.

IT_FINAL-VORNA = IT_PA0002-VORNA.

IT_FINAL-MIDNM = IT_PA0002-MIDNM.

IT_FINAL-GBDAT = IT_PA0002-GBDAT.

IT_FINAL-BEGDA = IT_PA0002-BEGDA.

IT_FINAL-PERID = IT_PA0002-PERID.

IT_FINAL-GESCH = IT_PA0002-GESCH.

append IT_FINAL.

endloop.

select PERNR

STRAS

PSTLZ

from PA0006

into table IT_PA0006

for all entries in IT_PA0002

where PERNR eq IT_PA0002-PERNR

and SUBTY = '1'.

sort IT_PA0006 by PERNR.

loop at IT_PA0006.

read table IT_PA0006 with key PERNR = IT_PA0002-PERNR binary search.

if SY-SUBRC ne 0.

clear IT_PA0006.

endif.

move IT_PA0006-STRAS to IT_FINAL-STRAS.

move IT_PA0006-PSTLZ to IT_FINAL-PSTLZ.

modify IT_FINAL.

endloop.

if not IT_FINAL[] is initial.

loop at IT_FINAL into IT_FINAL.

write:/10 IT_FINAL-PERNR,

20 IT_FINAL-NACHN,

30 IT_FINAL-VORNA,

40 IT_FINAL-MIDNM,

55 IT_FINAL-GBDAT,

70 IT_FINAL-BEGDA,

85 IT_FINAL-PERID,

100 IT_FINAL-GESCH,

115 IT_FINAL-STRAS,

130 IT_FINAL-PSTLZ.

endloop.

endif.

*************************************************************

Warm regards,

hari