0% found this document useful (0 votes)
61 views3 pages

GR Cancel

This document contains ABAP code for updating a database table (ztmm_gr_upgard) with information from various other tables. It selects data from tables like ekbe, acdoca, bseg, and populates fields in the target table like belnr, buzei, ktonr, azbet, pswsl by looping through the result sets. It also checks for existing records in ztmm_gr_upgard and either modifies or clears the fields based on certain conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views3 pages

GR Cancel

This document contains ABAP code for updating a database table (ztmm_gr_upgard) with information from various other tables. It selects data from tables like ekbe, acdoca, bseg, and populates fields in the target table like belnr, buzei, ktonr, azbet, pswsl by looping through the result sets. It also checks for existing records in ztmm_gr_upgard and either modifies or clears the fields based on certain conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

ls_ztmm_gr_upgard-mblnr = ps_gohead-mblnr.

ls_ztmm_gr_upgard-mjahr = ps_gohead-mjahr.
ls_ztmm_gr_upgard-blart = ls_blart_cc-blart.
ls_ztmm_gr_upgard-gr_cancel = ps_gohead-gr_cancel.
** Boc by DREDDY on 20/01/2023
** To avoid the GR cancelization,which is already vendor payment have been
cleared.
CLEAR lwa_mseg.
SELECT SINGLE ebeln,
ebelp,
gjahr,
belnr,
bewtp,
lfbnr FROM ekbe INTO @lwa_mseg
where belnr = @ps_gohead-mblnr and gjahr = @ps_gohead-mjahr and
BEWTP = 'E'.
IF sy-subrc = 0 and lwa_mseg is NOT INITIAL.
CLEAR lt_ekbe.
SELECT ebeln,
ebelp,
gjahr,
belnr,
bewtp,
lfbnr FROM ekbe INTO TABLE @lt_ekbe
WHERE ebeln = @lwa_mseg-ebeln
AND ebelp = @lwa_mseg-ebelp
AND BEWTP = 'Q'
AND LFBNR = @lwa_mseg-lfbnr.
IF sy-subrc = 0.
CLEAR lt_acdoca_n.
SELECT rbukrs,
gjahr,
belnr,
docln,
awref,
augbl FROM acdoca INTO TABLE @lt_acdoca_n
FOR ALL ENTRIES IN @lt_ekbe
WHERE AWREF = @lt_ekbe-belnr
AND gjahr = @ps_gohead-mjahr
AND rldnr = '0L'
AND rbukrs = @ls_blart_cc-bukrs
AND ebeln = @lt_ekbe-ebeln.
IF sy-subrc = 0.
CLEAR lt_bseg.
SELECT bukrs,
belnr,
gjahr,
augbl FROM bseg INTO TABLE @lt_bseg
FOR ALL ENTRIES IN @lt_acdoca_n
WHERE belnr = @lt_acdoca_n-belnr and gjahr = @lt_acdoca_n-gjahr and
bukrs = @lt_acdoca_n-rbukrs
AND bschl = '31' and KOART = 'K'.
IF sy-subrc = 0.
CLEAR LT_BKPF.
SELECT bukrs, belnr, gjahr, blart FROM BKPF INTO TABLE @LT_BKPF
FOR ALL ENTRIES IN @lt_bseg
WHERE belnr = @lt_bseg-augbl AND gjahr = @lt_bseg-gjahr AND
bukrs = @lt_bseg-bukrs and blart in @r_doctype.
IF sy-subrc = 0.
CLEAR lv_paymentdone.
lv_paymentdone = abap_true.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
**Eoc by DREDDY on 20/01/2023
SELECT rbukrs,
gjahr,
belnr,
docln,
ktopl,
rwcur,
racct,
awref,
xtruerev,
DRCRK
FROM acdoca INTO TABLE @lt_acdoca
WHERE AWREF = @ps_gohead-mblnr
AND gjahr = @ps_gohead-mjahr
AND rldnr = '0L'
AND rbukrs = @ls_blart_cc-bukrs.
IF sy-subrc = 0 AND lt_acdoca IS NOT INITIAL.
SELECT bukrs,
gjahr,
belnr,
buzei,
shkzg,
hkont,
wrbtr,
pswsl
FROM bseg
INTO TABLE @lt_account_info
FOR ALL ENTRIES IN @lt_acdoca
WHERE bukrs = @lt_acdoca-rbukrs
AND gjahr = @lt_acdoca-gjahr
AND belnr = @lt_acdoca-belnr.

SELECT saknr,
txt20 FROM skat INTO TABLE @lt_skat
FOR ALL ENTRIES IN @lt_acdoca
WHERE ktopl = @lt_acdoca-ktopl
AND spras = @sy-langu
AND saknr = @lt_acdoca-racct.
IF lt_account_info[] IS NOT INITIAL.
LOOP AT lt_account_info ASSIGNING <FLS_ACCOUNT_INFO>.
ls_ztmm_gr_upgard-belnr = <fls_account_info>-belnr.
ls_ztmm_gr_upgard-buzei = <fls_account_info>-buzei.
** G/L account
*** BOC by DREDDY 16/01/2023 Update clearing documetn in our Ztable
ls_ztmm_gr_upgard-MIROACC = VALUE #( lt_ekbe[ LFBNR = lwa_mseg-lfbnr ]-belnr
OPTIONAL ).
ls_ztmm_gr_upgard-miroclr = VALUE #( lt_acdoca_n[ AWREF = ls_ztmm_gr_upgard-
MIROACC ]-belnr OPTIONAL ).
*** EOC by DREDDY 16/01/2023 Update clearing documetn in our Ztable
ls_ztmm_gr_upgard-ktonr = <fls_account_info>-hkont.
ls_ztmm_gr_upgard-shkzg = <fls_account_info>-shkzg.
ls_ztmm_gr_upgard-kobez = VALUE #( lt_skat[ saknr = ls_ztmm_gr_upgard-ktonr ]-
txt20 OPTIONAL ).

ls_ztmm_gr_upgard-azbet = <fls_account_info>-wrbtr.

ls_ztmm_gr_upgard-azbet = <fls_account_info>-wrbtr.
ls_ztmm_gr_upgard-pswsl = VALUE #( lt_acdoca[ rbukrs = <fls_account_info>-bukrs
belnr = <fls_account_info>-belnr
gjahr = <fls_account_info>-gjahr
]-RWCUR OPTIONAL ).

MODIFY ztmm_gr_upgard FROM ls_ztmm_gr_upgard.


CLEAR ls_ztmm_gr_upgard.
ENDLOOP.
ENDIF.
ELSE.
MODIFY ztmm_gr_upgard FROM ls_ztmm_gr_upgard.
ENDIF.
* ENDIF.
ENDIF.
**

You might also like