Skip to Content
0
Former Member
Nov 15, 2012 at 07:14 AM

Z report is coming dumped

74 Views

I have created a zreport for customer ledger balance .This report is running correctly at testing client but coming dumped on production server.

*&---------------------------------------------------------------------*

*& Include ZCUSTOMER

*&---------------------------------------------------------------------*

SELECT SINGLE * FROM KNA1 WHERE KUNNR = S_KUNNR.

KUNNR = KNA1-KUNNR.

NAME1 = KNA1-NAME1.

ORT01 = KNA1-ORT01.

SELECT * FROM BKPF INTO CORRESPONDING FIELDS OF TABLE T_BKPF

WHERE

BUKRS = S_BUKRS AND

BUDAT IN S_DATE." AND

*BLART IN ('RV', 'ZP', 'DZ').

* DELETE REVERSAL

LOOP AT T_BKPF.

IF T_BKPF-XREVERSAL = 2.

DELETE T_BKPF WHERE BELNR = T_BKPF-STBLG.

DELETE T_BKPF.

ENDIF.

ENDLOOP.

*END OF DELETE

SELECT * FROM BKPF INTO CORRESPONDING FIELDS OF TABLE T_BKPF1

WHERE

BUKRS = S_BUKRS AND

BUDAT < S_DATE-LOW." AND

*BLART IN ('RV', 'ZP', 'DZ').

*************FOR OPENING

* DELETE REVERSAL

LOOP AT T_BKPF1.

IF T_BKPF1-XREVERSAL = 2.

DELETE T_BKPF1 WHERE BELNR = T_BKPF1-STBLG.

DELETE T_BKPF1.

ENDIF.

ENDLOOP.

*END OF DELETE

LOOP AT T_BKPF1.

SELECT * FROM BSEG WHERE

BUKRS = T_BKPF1-BUKRS AND

BELNR = T_BKPF1-BELNR AND

GJAHR = T_BKPF1-GJAHR AND

KUNNR = S_KUNNR.

IF SY-SUBRC = 0.

IF BSEG-SHKZG = 'H'. " TOTAL CREDIT AMOUNT.

CREDIT = CREDIT + BSEG-DMBTR.

ELSEIF BSEG-SHKZG = 'S'. "TOTAL DEBIT AMOUNT

DEBIT = DEBIT + BSEG-DMBTR.

ENDIF. " END IF FOR SHKZG

ENDIF.

ENDSELECT.

ENDLOOP.

*CREDIT = CREDIT * -1.

OPENING = DEBIT - CREDIT.

T_BSEG-SGTXT = 'OPENING BALANCE'.

T_BSEG-DEBIT = DEBIT.

T_BSEG-CREDIT = CREDIT.

T_BSEG-BALENCE = DEBIT - CREDIT.

T_BSEG-BUDAT = S_DATE-LOW.

APPEND T_BSEG.

**********END OF OPENING

T_BSEG-CREDIT = 0.

T_BSEG-DEBIT = 0.

*T_BSEG-BALENCE = 0.

T_BSEG-XBLNR = ''.

******** END OF OPENING BALENCES

********LINE ITEMS

SORT T_BKPF BY BUDAT.

LOOP AT T_BKPF.

SELECT * FROM BSEG WHERE

BUKRS = S_BUKRS AND

BELNR = T_BKPF-BELNR AND

GJAHR = T_BKPF-GJAHR AND

KUNNR = S_KUNNR.

IF SY-SUBRC = 0.

IF BSEG-SHKZG = 'H'. " TOTAL CREDIT AMOUNT.

T_BSEG-CREDIT = BSEG-DMBTR.

* T_BSEG-BALENCE = T_BSEG-BALENCE - T_BSEG-CREDIT + OPENING.

ELSEIF BSEG-SHKZG = 'S'. "TOTAL DEBIT AMOUNT

T_BSEG-DEBIT = BSEG-DMBTR.

* T_BSEG-BALENCE = T_BSEG-BALENCE + T_BSEG-DEBIT + OPENING.

ENDIF. " END IF FOR SHKZG

ENDIF.

T_BSEG-BALENCE = T_BSEG-BALENCE + T_BSEG-DEBIT - T_BSEG-CREDIT.

OPENING = T_BSEG-BALENCE.

T_BSEG-KUNNR = BSEG-KUNNR. " CUSTOMER CODE

T_BSEG-SAKNR = BSEG-SAKNR. " G/L/ AC

T_BSEG-BELNR = BSEG-BELNR. " DOCUMENT NUMBER

T_BSEG-USNAM = T_BKPF-USNAM. " POSTING DATE

T_BSEG-BUDAT = T_BKPF-BUDAT. " POSTING DATE

T_BSEG-XBLNR = T_BKPF-XBLNR. " REFERENCE NUMBER

T_BSEG-BLART = T_BKPF-BLART. " DOCUMENT TYPE

T_BSEG-BSCHL = BSEG-BSCHL. " POSTING KEY

T_BSEG-SHKZG = BSEG-SHKZG. " Dr/Cr INDICATOR

T_BSEG-GSBER = BSEG-GSBER. " BUSINESS AREA

T_BSEG-DMBTR = BSEG-DMBTR. " AMOUNT

T_BSEG-VBELN = BSEG-VBELN. " BILLING DOCUMENT

T_BSEG-BKTXT = T_BKPF-BKTXT. " HEADER TEXT

T_BSEG-SGTXT = BSEG-SGTXT. " HEADER TEXT

APPEND T_BSEG.

T_BSEG-CREDIT = 0.

T_BSEG-DEBIT = 0.

ENDSELECT.

ENDLOOP.

CLEAR T_BSEG.

T_BSEG-SGTXT = 'CLOSING BALANCE'.

T_BSEG-BALENCE = OPENING.

T_BSEG-BUDAT = S_DATE-HIGH.

APPEND T_BSEG.

***END OF LINE ITEMS