Skip to Content
author's profile photo Former Member
Former Member

GETTING LAST SIX MONTH DATA IN DEBTORS AGING

Hi Experts,

we have gotten a requirement in debtors aging report.In that,we have to show last six months data.we have a custom report for getting the data.We have converted that custom report into function module.

We have created one more function module.In that, we called the function module six times to get the last six months data.

But it is taking so long to give the output.Suggest me any other way to get the last six month data.

FUNCTION YJK_DEBTORS_TEST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(PR_BLDAT1) TYPE BLDAT DEFAULT '20020731'
*" REFERENCE(PR_GJAHR1) TYPE GJAHR DEFAULT 2002
*" TABLES
*" IT_AGING_T1 STRUCTURE YJK_ITAGING
*" IT_AGING_T2 STRUCTURE YJK_ITAGINGSEG
*"----------------------------------------------------------------------
DATA SO_VKORG TYPE RSELOPTION WITH HEADER LINE.
SO_VKORG-SIGN = 'I'.
SO_VKORG-OPTION = 'EQ'.
SO_VKORG-LOW = 1100.
APPEND SO_VKORG.
DATA: YEAR(4) TYPE N,
 MONTH(2) TYPE N,
 DAY(2) TYPE N.
DATA:YR_L(4) TYPE N,
 MTH_L(2) TYPE N,
 LOW_DT TYPE D,
 HIGH_DT TYPE D.
YEAR = PR_BLDAT1+0(4).
MONTH = PR_BLDAT1+4(2).
DAY = PR_BLDAT1+6(2).
IF MONTH = '01'.
 YR_L = YEAR - 1.
 MTH_L = '08'.
ELSEIF MONTH = '02'.
 YR_L = YEAR - 1.
 MTH_L = '09'.
ELSEIF MONTH = '03'.
 YR_L = YEAR - 1.
 MTH_L = '10'.
ELSEIF MONTH = '04'.
 YR_L = YEAR - 1.
 MTH_L = '11'.
ELSEIF MONTH = '05'.
 YR_L = YEAR - 1.
 MTH_L = '12'.
ELSEIF MONTH = '06'.
 YR_L = YEAR.
 MTH_L = '01'.
ELSEIF MONTH = '07'.
 YR_L = YEAR.
 MTH_L = '02'.
ELSEIF MONTH = '08'.
 YR_L = YEAR.
 MTH_L = '03'.
ELSEIF MONTH = '09'.
 YR_L = YEAR.
 MTH_L = '04'.
ELSEIF MONTH = '10'.
 YR_L = YEAR.
 MTH_L = '05'.
ELSEIF MONTH = '11'.
 YR_L = YEAR.
 MTH_L = '06'.
ELSEIF MONTH = '12'.
 YR_L = YEAR.
 MTH_L = '07'.
ENDIF.
DO 6 TIMES.
 LOW_DT+0(4) = YR_L.
 LOW_DT+4(2) = MTH_L.
 LOW_DT+6(2) = DAY.
 CALL FUNCTION 'YJK_DEBTORS'
 EXPORTING
 PR_BUKRS = '1000'
 SO_VKORG = SO_VKORG[]
 PR_BLDAT = LOW_DT
 PR_GJAHR = PR_GJAHR1
 TABLES
 IT_AGING = IT_AGING_T1[].
 SORT IT_AGING_T1 BY FDGRV BLDAT.
 LOOP AT IT_AGING_T1.
 MOVE-CORRESPONDING IT_AGING_T1 TO IT_AGING_T2.
 IT_AGING_T2-ZYEAR = YR_L.
 IT_AGING_T2-ZMONTH = MTH_L.
 COLLECT IT_AGING_T2.
 ENDLOOP.
 REFRESH IT_AGING_T1.
 MTH_L = MTH_L + 1.
 IF MTH_L > 12.
 MTH_L = 1.
 YR_L = YR_L + 1.
 ENDIF.
ENDDO.
ENDFUNCTION.


Thanks,
Santhana
Add a comment
10|10000 characters needed characters exceeded

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.