Skip to Content
avatar image
Former Member

Credit Ceiling Analysis Report for calculation of sales and balances month wise .

Hi experts ,

My query is that how can i display the sale value and balances value monthly wise.
Right now my report is calculating the amount of sale according to the date given in select option low and high value and showing it in one column only . i want to separate it monthly wise . similarly for the credit control area , right now it merge all the sales of all credit control area in one line . i want it in separate lines .

please refer to the attachments for you understandings .
my select query and loop is :

SELECT
VBRK~VBELN "Sale Document No
VBRK~KUNAG "Sold to Party
VBRK~KKBER "Creadit Control Area
VBRK~FKART "billing type
VBRK~FKDAT "billing DATE
VBRK~NETWR " net value
VBRK~MWSBK " tax
VBRP~VKBUR "sales office
VBRP~VKGRP "sales group
VBRP~MVGR1 "Brand
KNKK~KLIMK "credit Ceiling
KNA1~NAME1 "Customer Name
TVKBT~BEZEI " sale office description


FROM VBRK INNER JOIN VBRP ON VBRK~VBELN = VBRP~VBELN
INNER JOIN TVKBT ON VBRP~VKBUR = TVKBT~VKBUR
INNER JOIN KNKK ON VBRK~KUNAG = KNKK~KUNNR AND VBRK~KKBER = KNKK~KKBER
INNER JOIN KNA1 ON VBRK~KUNAG = KNA1~KUNNR
INTO CORRESPONDING FIELDS OF TABLE T_OUTPUTDATA
WHERE VBRK~KUNAG IN CUSTOMER AND
VBRK~KKBER IN CCA AND
VBRK~FKART IN BILLTYPE AND
VBRK~FKDAT IN FKDAT AND
VBRP~VKBUR IN SALEOFF AND
VBRP~VKGRP IN SALEGRP AND
VBRP~MVGR1 IN BRAND .


BREAK-POINT.

* LOOP for sales

LOOP AT T_OUTPUTDATA.


T_OUTPUTDATA-SALE = T_OUTPUTDATA-NETWR + T_OUTPUTDATA-MWSBK.


* GROUPING LINE ITEMs
ITAB-VBELN = T_OUTPUTDATA-VBELN.

IF T_OUTPUTDATA-KUNAG EQ ITAB-KUNAG AND T_OUTPUTDATA-VBELN EQ ITAB-VBELN .
"Add all numerical fields. See below for reference.

ITAB-SALE = T_OUTPUTDATA-SALE + ITAB-SALE.IF ITAB-DMBTR = '0.00'.

SELECT DMBTRFROM BSIDINTO T_OUTPUTDATA-DMBTRWHERE BSID~KUNNR IN CUSTOMER and bsid~budat in fkdat.
ITAB-DMBTR = T_OUTPUTDATA-DMBTR + ITAB-DMBTR.ENDSELECT.

ENDIF.


MODIFY ITAB INDEX INDEX. "index is a must else short dump occurs
ELSE.

MOVE-CORRESPONDING T_OUTPUTDATA TO ITAB.

APPEND ITAB.INDEX = SY-TABIX. "Get index of current row

ENDIF.
ENDLOOP.

output.png (8.1 kB)
report-format.png (17.0 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • May 23, 2017 at 08:20 AM

    Perform first some search in the forum on dynamic internal table (creation of 2 fields for each month in the row, either with good old CL_ALV_TABLE_CREATE from built field catalog class or with RTTS classes like CL_ABAP_STRUCTDESCR, CL_ABAP_TABLEDESCR, and CL_ABAP_REFDESCR, you should look in wiki section, FAQ/many samples and guides) then with some ASSIGN in a loop convert the table generated by the SELECT statements to the new final table.

    Add comment
    10|10000 characters needed characters exceeded