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: 

Multiple values for a record

Former Member
0 Kudos

Hi friends,

I have following code ......like

loop at it_pa0001.

-


-


-


loop at it_pa0022 where pernr eq it_pa0001-pernr.

?

endloop.

-


-


-


append it_final.

clear it_final.

endloop.

pa0022 have mulitple records for single pernr from pa0001.

?-How to send mutiple values for a single pernr record.

eg:for single pernr,i need to have all educt.qualifications from pa0022 to my it_final.

thanks in advance.

12 REPLIES 12

Former Member
0 Kudos

well do the append in you nested loop.

Former Member
0 Kudos

hi

try this

loop at it_pa0001.

-


-


-


loop at it_pa0022 into it_final where pernr eq it_pa0001-pernr.

append it_final.

clear it_final.

endloop.

-


-


-


endloop.

and if it_final and it_pa0022 are not same in structure then use

loop at it_pa0022 where pernr eq it_pa0001-pernr.

move-corrosponding from it_pa0022 to it_final.

append it_final.

clear it_final.

endloop.

check the syntex*

Edited by: mayank jain on May 4, 2009 11:31 AM

viquar_iqbal
Active Contributor
0 Kudos

Hi

put this code

append it_final.

clear it_final.

inside the second loop.

ie. loop at it_pa0022 where pernr eq it_pa0001-pernr.

append it_final.

clear it_final.

endloop.

Former Member
0 Kudos

hi,

loop at it_pa0001.

loop at it_pa0022 where pernr eq it_pa0001-pernr.
append it_final.  " >> Append entriles to it_final here
endloop.

clear it_final.          " >> Ue the Clear statement after the inner loop.

endloop.

Former Member
0 Kudos

Hi,

Use APPEND statement for your LOOP statements.

Regards,

Jyothi CH.

Former Member
0 Kudos

Hi Hosmath,

Instead of loop inside loop. Use READ.

Like this,

LOOP AT t_tadir INTO fs_tadir.
    MOVE:
      fs_tadir-object   TO ztab-objct,
    MODIFY Ztab.
      READ TABLE t_objt INTO fs_objt WITH KEY objectname = fs_tadir-object
                                     BINARY SEARCH.
appeend logic.

Much Regards,

Amuktha.

0 Kudos

Hi,

For the following code(for single pernr) i need to display as follows..

pernr - - - - ausbi zzyear ausbi1 zzyear1 ausbi2 zzyear2

122 7 1992 4 1994 6 1998

so how can i fetch those three qualifications and display it in single row on the output.

LOOP AT it_pa0001 INTO wa_pa0001.

-


-


---

loop at it_pa0022 INTO wa_pa0022 where pernr eq wa_pa0001-pernr.

(wat shld be wrtitn)

wa_final-ausbi = wa_pa0022-ausbi.

wa_final-zzyear = wa_pa0022-zzyear.

(wat shld be wrtitn)

wa_final-ausbi1 = wa_pa0022-ausbi.

wa_final-zzyear1 = wa_pa0022-zzyear.

(wat shld be wrtitn)

wa_final-ausbi2 = wa_pa0022-ausbi.

wa_final-zzyear2 = wa_pa0022-zzyear.

endloop.

-


-


-


append wa_final to it_final

clear wa_final.

endloop.

Hope I'm clear this time around.

Edited by: Hosmath C C on May 4, 2009 12:12 PM

0 Kudos

Hi hosmat,

if i am not wrong, your it_pa0022 is having three records for each pernr in it_pa0001.

So before the loop sort both tables by pernr and sort it_pa0022 by the other field which you want to be in the order in your display.

LOOP AT it_pa0001 INTO wa_pa0001.

-


-


---

loop at it_pa0022 INTO wa_pa0022 where pernr eq wa_pa0001-pernr.

if sy-tabix = 1.

wa_final-ausbi = wa_pa0022-ausbi.

wa_final-zzyear = wa_pa0022-zzyear.

elseif sy-tabix = 2.

wa_final-ausbi1 = wa_pa0022-ausbi.

wa_final-zzyear1 = wa_pa0022-zzyear.

elseif sy-tabix = 3.

wa_final-ausbi2 = wa_pa0022-ausbi.

wa_final-zzyear2 = wa_pa0022-zzyear.

endif.

endloop.

assuming you have only three records in the table it_pa0022 .

Let me know if you have any problems with this.

Thanks,

Vamshi

0 Kudos

Hi Vamshi,

Thanks for ur reply.

it_pa0022 is populated from all entries in it_pa0001.

It will have several entries based on it_pa0001-pernr.

but for one pernr,i need to display max three qualifications if it exists,otherwise one if there is single record for single pernr and so on...

.

0 Kudos

data it_pa0022_1 type table of pa0022.

loop at it_pa0022 INTO wa_pa0022 where pernr eq wa_pa0001-pernr.

append wa_pa0022 to it_pa0022_1. " this will pick all the data with records = wa_pa001-pernr

endloop.

read table it_pa0022_1 into wa_pa0022 index 1.

if sy-subrc = 0.

wa_final-ausbi = wa_pa0022-ausbi.

wa_final-zzyear = wa_pa0022-zzyear.

read table it_pa0022 into wa_pa0022 index 2.

if sy-subrc = 0.

wa_final-ausbi1 = wa_pa0022-ausbi.

wa_final-zzyear1 = wa_pa0022-zzyear.

read table it_pa0022 into wa_pa0022 index 3.

if sy-subrc = 0.

wa_final-ausbi2= wa_pa0022-ausbi.

wa_final-zzyear2 = wa_pa0022-zzyear.

Now u can append ur final table with wa_final.

assuming you have only three records in the table it_pa0022 .

Let me know if you have any problems with this.

Thanks,

Vijeta

Former Member
0 Kudos

U can use PROVIDE....... END PROVIDE instead of LOOP....ENDLOOP.

Former Member
0 Kudos

hi

as i understand your it_final table has fields- pernr - - - - ausbi zzyear ausbi1 zzyear1 ausbi2 zzyear2

so for this

data: int type i.

loop at it_1.

loop at it_2.

if it_2-pernr eq it_1-pernr.

add 1 to int.

if int eq 1.

assign value to ausbi and zzyear.

elseif int eq 2.

assign value to ausbi1 and zzyear1.

elseif int eq 3.

assign value to ausbi2 and zzyear2.

else.

clear int.

exit.

endif.

append it_final.

endif.

Edited by: mayank jain on May 4, 2009 12:51 PM

Edited by: mayank jain on May 4, 2009 12:52 PM