on 05-05-2006 3:24 PM
Hi,
I am new to ABAP and i was developiong a program . i have a requirement where i loop vbap table and get all the enrtries for a range of vbeln in a internal table say itab. i want to loop at this internatl table ( itab) and populate another internal table say itab_1 which has data for only one vbeln i.e values for one vebln no. ( as many line items may be present...)
can any body send me a sample code for this.
Thanks in advance
Priya
Hi,
i think this is what you are looking..
select *
from vbak
into table it_vbak
where vbeln in s_vbeln.
if sy-subrc = 0.
select *
from vbap
into table it_vbap
for all entries in it_vbak
where vbeln = it_vbak-vbeln.
if sy-subrc = 0.
sort it_vbap by vbeln posnr.
endif.
endif.
Regards
vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
in that case you will end up with so many internal tables.
see i have 10 vbelns(assume), then then i will have (10+1) intenal tables.
but from my code you have all vbeln in one, and items in other.
loop at it_vbak.
loop at it_vbap where vbeln = it_vbak-vbeln.
"here collect the data and append it.
move-corresponding it_vbap to it_vbap_sec.
append it_vbap_sec.
clear it_vbap_sec.
endloop.
then here do some thing and refresh the table.
then next run you will have second set.
endloop.
Regards
vijay
Hi Priya,
As far as I understood your requirement, this can be achieved by using nested loops.
Select * from Vbak into it_vbak where <conditions>.
Select * from Vbap into it_vbap for all entries in it_vbak where <conditions>.
Loop at it_vbak.
loop at it_vbap where vblen = it_vbak-vbeln.
*populate itab2 with the records of one single vbeln.
itab2 = it_vbap.
append itab2.
endloop.
endloop.
This would give you all the VBAP records for a particular VBELN. Hope this was what u required.
Thanks,
Rashmi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Re: ABAP Program
Posted: May 5, 2006 10:32 AM Reply E-mail this post
Hi,
select *
from vbap
into table itab
where vbeln in s_vbeln.
if sy-subrc = 0.
sort itab by vbeln
itab1[] = itab[].
delete itab where vbeln <> the vbeln which you requier.
endif.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well... I am not sure what exactly you want !!
But as per my understanding I am putting you a code snippet.
1. Select query from DB table to fill ITAB1
2. You have 2 choices :
LOOP AT ITAB1 1 TIMES.
Select query to fill second ITAB2 based on
first table value.
SELECT * FROM DBTAB INTO TABLE ITAB2
WHERE KEYFIELD = ITAB1-FIELD.
ENDLOOP.
Second Choice:
READ TABLE ITAB1 WITH KEY FIELD = <SOME VALUE>
Select query to fill second ITAB2 based on
first table value.
SELECT * FROM DBTAB INTO TABLE ITAB2
WHERE KEYFIELD = ITAB1-FIELD.
Let me know if this is not what you want.
If helpful then reward points !!
Jignesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.