‎2007 Apr 12 7:13 AM
Hi every one.,
let me anybody know,
1. in table zx1 i am having fields VBELN , POSNR, VTWEG, SPART
( ex 900001 11 de 50 , 900001 ,12 ,de 50)
2. in table zx2 i am having fields KNUMA VTWEG SPART
( 122 de 50 , 234 de 50, 345 de 50).
But i want to pass into final table with six records.
i.e
VBELN POSNR KNUMA
900001 11 122
900001 11 234
900001 11 345
900001 12 122
900001 12 234
900001 12 345
But iam not able to fetch the data , please anybody let me know
how to select the data .
‎2007 Apr 12 7:27 AM
Hi,
I think you code should look like this:
loop at zX1.
loop at zx2 where vtweg = zx1-vtweg and
spart = zx1-spart.
final-vbeln = zx1-vbeln.
final-posnr = zx1-posnr.
final-knuma = zx2-knuma.
append final.
endloop.
endloop.
Thanks and regards,
S. Chandra Mouli.
‎2007 Apr 12 7:19 AM
hi,
use inner join on two tables.
select zx1vbeln zx1posnr zx2~knuma
from zx1 as zx1
inner join zx2 as zx2
on zx1vtweg eq zx2vtweg
and zx1spart eq zx2spart
into table itab.
reward points if helpful
‎2007 Apr 12 7:22 AM
Hi..
<b>select zx1VBELN zx1POSNR zx2~KNUMA
from zx1 inner join zx2
on zx1SPART = zx2SPART and
zx1vtweg = zx2vtweg
into itab
<b>up to 6 rows</b>
where zx1~posnr eq '000011' or
zx1~posnr eq '000012'.</b>
‎2007 Apr 12 7:23 AM
select vbeln posnr vtweg spart from zx1 into table itab1 where....
if not itab1[] is initial.
itab2[] = itab1[].
sort itab2 by vtweg spart.
delete adjacent duplicates from itab2 comparing vtweg spart.
select knuma
vtweg spart from zx2 into table itab3
for all entries in itab2
where vtweg = itab2-vtweg
and spart = itab2-spart.
endif.
sort itab3 by vtweg spart.
loop at itab1.
move-corresponding itab1 to itabfinal.
read table itab3 with key vtweg = itab1-vtweg spart = itab1-spart.
if sy-subrc = 0.
move itab3-knuma to itabfinal-knuma.
endif.
append itabfinal.
clear itabfinal.
endloop.
now the itabfinal contains the required data.
‎2007 Apr 12 7:23 AM
For this application, the tables zx1 and zx2 should have atleast one field in common (apert from MANDT).
Once the above requirement is fuilfilled, you can use JOIN to get the data.
If you wish to select data into two tables and build final internal table (without join), then both the internal tables should have the common field defined. After the selection:
LOOP AT itab1.
LOOP or READ itab2 with the condition
APPEND Final Table
endloop.
‎2007 Apr 12 7:24 AM
Hi..,
u can use Inner join for this..
SELECT VBELN POSNR KNUMA
INTO TABLE ITAB
FROM ZX1 AS ZX1 INNER JOIN ZX2 AS ZX2
ON ZX1VTWEG EQ ZX2VTWEG AND
ZX1SPART EQ ZX2SPART.
regards,
sai ramesh
‎2007 Apr 12 7:27 AM
Hi,
I hope you are talking about the Billing Tables VBRK and VBRP:
Based on the data it is clear because the fields
VBELN , POSNR, VTWEG, SPART are in VBRP .
and the fields KNUMA VTWEG SPART are in VBRK .
You can join the header and Item tables VBRK and VBRP
<b>select avbeln bposnr avtweg aspart a~knuma into table ITAB
from VBRK as a join VBRP as b on
avbeln = bvbeln
where a~vbeln in S_vbeln (or = p_vbeln).</b>this is the right method. use it.
reward points if useful
regards,
ANJI
‎2007 Apr 12 7:27 AM
Hi,
I think you code should look like this:
loop at zX1.
loop at zx2 where vtweg = zx1-vtweg and
spart = zx1-spart.
final-vbeln = zx1-vbeln.
final-posnr = zx1-posnr.
final-knuma = zx2-knuma.
append final.
endloop.
endloop.
Thanks and regards,
S. Chandra Mouli.