Skip to Content
0
Former Member
May 10, 2008 at 03:00 PM

Please tell me the functionality of this piece of code

36 Views

vl_faedn = sy-datum - 15.

All amount fields are 0.00 initially.

Please tell me the functionality of this code.What is the purpose of each query?

YD = Commission Advance

AB = Automatic Clearing Doc

Y4 = Commission Invoice

X4 = Commission Credit Memo

K1 = Commission Adj. Invoice

K2 = Commission Adj.Credit Memo

  • Retrieve the YD document type total for a Customer

SELECT WRBTR SHKZG

INTO (VL_WRBTR, VL_SHKZG)

FROM BSID

WHERE BUKRS = VL_BUKRS AND

KUNNR = VL_KUNNR AND

UMSKS = 'C' AND

UMSKZ = 'C' AND

BLART = 'YD' AND

ZFBDT <= VL_FAEDN.

IF VL_SHKZG = 'H'.

VL_WRBTR = VL_WRBTR * -1.

ENDIF.

VL_YD_AMNT = VL_YD_AMNT + VL_WRBTR.

ENDSELECT.

  • Retrieve the AB document type total for a Customer

SELECT WRBTR SHKZG

INTO (VL_WRBTR, VL_SHKZG)

FROM BSID

WHERE BUKRS = VL_BUKRS AND

KUNNR = VL_KUNNR AND

UMSKS = 'G' AND

UMSKZ = 'G' AND

BLART = 'AB' AND

ZFBDT <= VL_FAEDN.

IF VL_SHKZG = 'H'.

VL_WRBTR = VL_WRBTR * -1.

ENDIF.

VL_AB_AMNT = VL_AB_AMNT + VL_WRBTR.

ENDSELECT.

  • Retrieve the Y4 document type total for a Vendor

SELECT WRBTR SHKZG

INTO (VL_WRBTR, VL_SHKZG)

FROM BSIK

WHERE BUKRS = VL_BUKRS AND

LIFNR = VL_LIFNR AND

( blart = 'Y4' OR blart = 'X4' OR blart = 'K1' OR blart = 'K2' ).

IF VL_SHKZG = 'H'.

VL_WRBTR = VL_WRBTR * -1.

ENDIF.

VL_Y4_AMNT = VL_Y4_AMNT + VL_WRBTR .

ENDSELECT.

VL_Y4_AMNT = -1 * VL_Y4_AMNT.

  • Retrieve the YD document type total for a Vendor

SELECT WRBTR SHKZG

INTO (VL_WRBTR, VL_SHKZG)

FROM BSIK

WHERE BUKRS = VL_BUKRS AND

LIFNR = VL_LIFNR AND

  • blart = 'YD'.

( BLART = 'YD' OR BLART = 'K1' OR

BLART = 'K2' ). " Insert

IF VL_SHKZG = 'H'.

VL_WRBTR = VL_WRBTR * -1.

ENDIF.

VL_YD_AMNT1 = VL_YD_AMNT1 + VL_WRBTR.

ENDSELECT.

VL_YD_AMNT1 = -1 * VL_YD_AMNT1 .

IF VL_Y4_AMNT = 0.

VL_TOT_AMOUNT = VL_YD_AMNT1 - VL_AB_AMNT.

ELSE.

VL_TOT_AMOUNT = VL_Y4_AMNT - ( VL_YD_AMNT + VL_AB_AMNT ).

ENDIF.