Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Report

Hi all,

In my report records comes respectively more .......

I mean in respect of Document Condition, CD Amount Value come perfectly but same CD Amount value come for 5-6 Document Condition also......and other records are right against other Document Conditions.....

for example-------

Doc. Condition Bill Value Tax Amount CD Amount

0000066403 37759.62 1510.38 1570.00

0000064986 9832.69 393.31 1570.00

0000064995 22890.37 915.63 1570.00

this is the structure that result come......

in this result......u can see all the CD Amount r same.....<b>THIS IS MY PROBLEM....</b>

Wat can i do.....plz tell me ......

My Code Is:----


TABLES : VBAK , VBRP, VBRK, KNA1, T001, LIKP, VBPA, TVKBT, TVGRT, KONV, VBKD, VBFA, T052.

TYPE-POOLS: SLIS.

DATA: BEGIN OF ITAB OCCURS 0,

VKBUR LIKE VBAK-VKBUR , "Sales Office

KUNNR LIKE VBAK-KUNNR , "Sold to party

NAME1 LIKE KNA1-NAME1 , "CUSTOMER NAME

VBELN LIKE VBAK-VBELN , "Sale Order Number

AUDAT LIKE VBAK-AUDAT , "SALES DOC. DATE

NETWR LIKE VBAK-NETWR , "SALES DOC VALUE

VBELN1 LIKE VBRP-VBELN , "BILLING DOCUMENT NO.

FKDAT LIKE VBRK-FKDAT , "BILLING DATE

NETWR1 LIKE VBRK-NETWR , "BILLING DOCUMENT VALUE

MWSBK LIKE VBRK-MWSBK , "TAX AMOUNT

CD_AMT TYPE P DECIMALS 2, "CD AMOUNT

AMT_DUE TYPE P DECIMALS 2 , "AMOUNT DUE

FKART LIKE VBRK-FKART , "BILLING TYPE

BLART LIKE BSID-BLART , "DOC TYPE

DUE_DT LIKE SY-DATUM , "Due Date

BSTNK LIKE VBAK-BSTNK , "Customer PO No.

ZTERM LIKE VBKD-ZTERM , "PAYMENT TERM

KNUMV LIKE VBRK-KNUMV , "VBRK DOCUMENT CONDITION

  • KNUMV1 LIKE KONV-KNUMV , "KONV DOCUMENT CONDITION

  • KSCHL LIKE KONV-KSCHL ,

  • KAWRT LIKE KONV-KAWRT ,

  • KBETR LIKE KONV-KBETR ,

  • KWERT LIKE KONV-KWERT , "Condition Value

END OF ITAB .

DATA: BEGIN OF ITAB1 OCCURS 0,

KNUMV LIKE KONV-KNUMV , "DOCUMENT CONDITION

KSCHL LIKE KONV-KSCHL ,

KAWRT LIKE KONV-KAWRT ,

KBETR LIKE KONV-KBETR ,

KWERT LIKE KONV-KWERT , "Condition Value

END OF ITAB1 .

DATA : WA1 LIKE ITAB1.

DATA: BEGIN OF ITAB2 OCCURS 0,

KNUMV LIKE KONV-KNUMV , "DOCUMENT CONDITION

KSCHL LIKE KONV-KSCHL ,

KAWRT LIKE KONV-KAWRT ,

KBETR LIKE KONV-KBETR ,

KWERT LIKE KONV-KWERT , "Condition Value

END OF ITAB2 .

*DATA : WA2 LIKE ITAB2.

DATA : X TYPE I.

**************************************************************************

DATA : W_CONTAINER TYPE SCRFNAME VALUE 'CL_GRID',

W_CPROG TYPE LVC_S_LAYO,

G_REPID LIKE SY-REPID,

W_SAVE TYPE C,

W_EXIT TYPE C,

CL_GRID TYPE REF TO CL_GUI_ALV_GRID,

CL_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

IT_FLD_CATALOG TYPE SLIS_T_FIELDCAT_ALV,

WA_FLD_CATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE ,

LAYOUT TYPE SLIS_LAYOUT_ALV,

COL_POS LIKE SY-CUCOL ,

ALVFC TYPE SLIS_T_FIELDCAT_ALV.

***----


SELECTION SCREEN -


SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME.

SELECT-OPTIONS: VKBUR FOR VBAK-VKBUR, " Sales Office

KUNNR FOR VBAK-KUNNR, " Sold to party

FKDAT FOR VBRK-FKDAT, " OBLIGATORY . " Created on

FKART FOR VBRK-FKART, " Billing Type

AUDAT FOR VBAK-AUDAT.

SELECTION-SCREEN END OF BLOCK A.

***************************************************************************

PERFORM FILL_CATALOG1 USING:

'VKBUR' 'ITAB' 'SALES OFFICE',

'KUNNR' 'ITAB' 'CUST CODE',

'NAME1' 'ITAB' 'NAME' ,

'VBELN' 'ITAB' 'SALES DOC NO.',

'AUDAT' 'ITAB' 'SALES DOC DATE',

'NETWR' 'ITAB' 'NET VALUE' ,

'KNUMV' 'ITAB' 'DOC. CONDITION NO.',

'VBELN1' 'ITAB' 'BILLING DOC NO.' ,

'FKDAT' 'ITAB' 'BILLING DATE',

'NETWR1' 'ITAB' 'NET VALUE' ,

'MWSBK' 'ITAB' 'TAX AMOUNT' ,

'CD_AMT' 'ITAB' 'CD AMOUNT' ,

'AMT_DUE' 'ITAB' 'AMOUNT DUE' ,

'KNUMV1' 'ITAB' 'DOC. CONDITION NO.',

'KSCHL' 'ITAB' 'Condition type',

'FKART' 'ITAB' 'BILL TYPE' ,

'BLART' 'ITAB' 'DOC TYPE' ,

'DUE_DT' 'ITAB' 'DUE DATE',

'BSTNK' 'ITAB' 'CUST PO NO.' ,

'ZTERM' 'ITAB' 'PAYMENT TERMS'.

********************************************************************************

SELECT DISTINCT A~VKBUR A~KUNNR A~VBELN A~AUDAT A~NETWR A~BSTNK B~VBELN

INTO (ITAB-VKBUR, ITAB-KUNNR, ITAB-VBELN, ITAB-AUDAT, ITAB-NETWR, ITAB-BSTNK, ITAB-VBELN1)

FROM VBAK AS A INNER JOIN VBRP AS B ON A~VBELN = B~AUBEL

WHERE A~VKBUR IN VKBUR

AND A~KUNNR IN KUNNR

AND A~AUDAT IN AUDAT.

APPEND ITAB .

ENDSELECT.

SORT ITAB BY VBELN.

LOOP AT ITAB .

SELECT FKDAT NETWR MWSBK KNUMV FKART FROM VBRK INTO (ITAB-FKDAT, ITAB-NETWR1, ITAB-MWSBK, ITAB-KNUMV, ITAB-FKART) WHERE VBELN = ITAB-VBELN1 .

MODIFY ITAB INDEX SY-TABIX TRANSPORTING FKDAT NETWR1 MWSBK KNUMV FKART.

ENDSELECT .

SELECT NAME1 FROM KNA1 INTO ITAB-NAME1 WHERE KUNNR = ITAB-KUNNR .

MODIFY ITAB INDEX SY-TABIX TRANSPORTING NAME1 .

ENDSELECT .

SELECT BLART FROM BSID INTO ITAB-BLART WHERE VBELN = ITAB-VBELN1 .

MODIFY ITAB INDEX SY-TABIX TRANSPORTING BLART .

ENDSELECT .

SELECT ZTERM FROM VBKD INTO ITAB-ZTERM WHERE VBELN = ITAB-VBELN .

MODIFY ITAB INDEX SY-TABIX TRANSPORTING ZTERM .

ENDSELECT.

SELECT KNUMV KAWRT KBETR KSCHL INTO CORRESPONDING FIELDS OF TABLE ITAB1 FROM KONV

FOR ALL ENTRIES IN ITAB

WHERE KNUMV = ITAB-KNUMV AND KSCHL IN ('SKTO') .

LOOP AT ITAB1 INTO WA1.

ON CHANGE OF WA1-KNUMV.

ITAB2[] = ITAB1[].

DELETE ITAB2 WHERE KNUMV NE WA1-KNUMV.

ENDON.

ENDLOOP.

X = 0.

LOOP AT ITAB2.

X = X + ITAB2-KAWRT * ITAB2-KBETR / 1000 .

ENDLOOP .

ITAB-CD_AMT = X.

MODIFY ITAB INDEX SY-TABIX TRANSPORTING CD_AMT. "KNUMV.

  • MODIFY ITAB1 INDEX SY-TABIX TRANSPORTING KNUMV KAWRT KBETR KSCHL .

ENDLOOP .

********************************************************************************************

LOOP AT ITAB .

ITAB-AMT_DUE = ITAB-NETWR + ITAB-MWSBK - ITAB-CD_AMT .

MODIFY ITAB INDEX SY-TABIX TRANSPORTING AMT_DUE .

ENDLOOP .

*******************************************************************************

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = 'ZSDREPORT_NEW'

IS_LAYOUT = LAYOUT

IT_FIELDCAT = IT_FLD_CATALOG

I_DEFAULT = 'X'

I_SAVE = 'A'

TABLES

T_OUTTAB = ITAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*ENDFORM.

FORM FILL_CATALOG1 USING P_FIELDNAME TYPE ANY

P_REF_TABLE TYPE ANY

P_SCRTEXT TYPE ANY.

CLEAR : WA_FLD_CATALOG.

WA_FLD_CATALOG-FIELDNAME = P_FIELDNAME.

WA_FLD_CATALOG-TABNAME = P_REF_TABLE.

WA_FLD_CATALOG-SELTEXT_S = P_SCRTEXT.

WA_FLD_CATALOG-SELTEXT_M = P_SCRTEXT.

WA_FLD_CATALOG-SELTEXT_L = P_SCRTEXT.

APPEND WA_FLD_CATALOG TO IT_FLD_CATALOG.

ENDFORM. " fill_catalog1

**************************************************************************************

Regards,

<b>Anil Kumar</b>

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question