Skip to Content
0
V K
Jun 23, 2020 at 01:11 AM

select join query in AMDP

1592 Views

Hi All,

Can anyone help me to fix below query.

I am working on AMDP and I need to write a select query in AMDP using select join condition so I can get filtered values in internal table. Below is the code which I have written in old abap program. Please let me know how we can convert same code in AMDP.

select vbeln, posnr, parvw, kunnr from vbrp into table @data(lt_vbrp1) 
for all entries in lt_itab 
where vbeln = lt_itab-aubel and posnr = lt_itab-aupos and parvw = 'WE'.


*-- get values from Header (here header values are stored on 000000 line item)
select vbeln, posnr, parvw, kunnr from vbrp into table @data(lt_vbrp2) for all entries in lt_itab
where vbeln = lt_itab-aubel and posnr = '000000' and parvw = 'WE'.

sort lt_vbrp1 by vbeln posnr.
sort lt_vbrp2 by vbeln posnr.

loop at lt_itab into data(ls_itab).
read table lt_vbrp1 into data(ls_vbrp) with key vbeln = ls_itab-aubel posnr = ls_itab-aupos binary search.
if sy-subrc eq 0.
* append data to itab_final.
else.
read table lt_vbrp2 into ls_vbrp with key vbeln = ls_itab-aubel posnr = '000000' binary search.
* append data to itab_final.
endif.

clear ls_vbrp.
endloop.


Thanks in Advance.

-- Vijendra