‎2007 May 22 11:57 PM
Hi,
I need to extract data from two tables REGUH and PAYR common key is vblnr.
fields are zbukr hbkid hktid vblnr from REGUH and CHECT from PAYR,
could anyone help me to write the sql statement
Jeff
‎2007 May 23 12:02 AM
tables : REGUH,
PAYR .
data : begin of itab occurs 0,
zbukr like reguh-zbukr,
hbkid like reguh-hbkid,
hktid like reguh-hktid,
vblnr like reguh-vblnr,
CHECT like payr-CHECT,
end of itab.
start-of-selection.
select azbukr ahbkid ahktid avblnr
b~chect into table itab
from reguh as a inner join payr as b on bvblnr = avblnr.
‎2007 May 23 12:02 AM
tables : REGUH,
PAYR .
data : begin of itab occurs 0,
zbukr like reguh-zbukr,
hbkid like reguh-hbkid,
hktid like reguh-hktid,
vblnr like reguh-vblnr,
CHECT like payr-CHECT,
end of itab.
start-of-selection.
select azbukr ahbkid ahktid avblnr
b~chect into table itab
from reguh as a inner join payr as b on bvblnr = avblnr.
‎2007 May 23 12:23 AM
‎2007 May 23 2:19 PM
Jeff, you are getting duplicates because the field chect is not key in table reguh.
You can: DELETE ADJACENT DUPLICATES FROM i_reguh comparing chect.
But verify if functionally is ok that yoy delete whose records and you are not losing information. Otherwise you should use and inner join comparing both tables by vblnr or ZBUKR or put more conditions in the where clause like ZBUKR = i_reguh-zbukr.
Regards,
Roxana
‎2007 May 23 12:15 AM
Hi Jeff,
Maybe you can do:
select zbukr
hbkid
vblnr
from reguh
into i_reguh.
select chect
from payr
for all entries in i_reguh
where chect = i_reguh-chect.
It will be more performant if you put some condition in the where clause of reguh selection.
Regards,
Roxana