‎2007 Jun 08 2:54 AM
hi i have to write a statement in abap.
where i need to extract data from REGUH and PAYR table comparing company code, housebank and few more conditions.
even if there are no records in PAYR we have to extract the records from REGUH.
PAYR entries will be empty then.
that means if there are 10 records in REGUH and 5 records in PAYR.
all 5 records in payr have key field in REGUH.
10 entries should be extracted. 5 wiht combination of REGUh and PAYR other 5 wihtout cmbination.
this is the query i wrote pls check it.
SELECT azbukr ahbkid ahktid avblnr
azaldt aznme1 arwbtr aubhkt
awaers azbnkl a~rzawe
bchect bchecf b~gjahr
INTO CORRESPONDING FIELDS OF TABLE itreguh
FROM reguh AS a
LEFT OUTER JOIN payr AS b
ON avblnr = bvblnr
AND azbukr = bzbukr
AND ahbkid = bhbkid
AND ahktid = bhktid
WHERE a~zbukr = cmp_code
AND a~hbkid = hse_bank
AND a~hktid = acc_id
AND a~vblnr <> space.
DELETE ADJACENT DUPLICATES FROM itreguh COMPARING chect.
‎2007 Jun 08 6:36 AM
hi jeff,
instead of <b>inner join</b> u can use <b>for all enries</b> here,
ex:
select * from REGUH into <itab> where bukrs in s_bukrs.
if not <itab> is initial.
select * from PAYR into <itab1> for all entries in <itab> where bukrs = <itab>-bukrs and other coditions.
endif.
then in loop u can move all these field into global <itab> and disply.
reward points if helpful,
regards,
seshu.
‎2007 Jun 08 6:36 AM
hi jeff,
instead of <b>inner join</b> u can use <b>for all enries</b> here,
ex:
select * from REGUH into <itab> where bukrs in s_bukrs.
if not <itab> is initial.
select * from PAYR into <itab1> for all entries in <itab> where bukrs = <itab>-bukrs and other coditions.
endif.
then in loop u can move all these field into global <itab> and disply.
reward points if helpful,
regards,
seshu.