on 2010 Jul 15 9:29 AM
Hi Gurus,
I've implemented the code below for my report to display Required Start Date (MM/DD/YYYY) by searching and processing either a single Fiscal Year/Period (PPP/YYYY to PPP/YYYY) input or a range/interval Fiscal Year/Period (PPP/YYY) input. The details are,
1) Created 1 User Entry Interval Mandatory Variable under Fiscal Year/Period InfoObject (Display) - ZFYP_IN
2) Created 1 Customer Exit Interval Mandatory Variable under Required Start Date InfoObject (Output) - ZRSD_CX
&----
*& Include ZXRSRU01
&----
DATA: L_S_RANGE1 TYPE RSR_S_RANGESID,
L_S_RANGE TYPE RSR_S_RANGESID,
LOC_VAR_RANGE TYPE RRS0_S_VAR_RANGE,
ZYEAR TYPE T009B-BDATJ,
ZMM TYPE T009B-POPER,
ZMM1 TYPE T009B-POPER,
ZYEAR1 TYPE T009B-BDATJ,
ZSTARTDATE TYPE SY-DATUM,
ZENDDATE TYPE SY-DATUM.
IF I_STEP = 2.
CASE I_VNAM.
**To populate ZCURDAY with current system date**
WHEN 'ZCURDAY'.
CLEAR: L_S_RANGE1.
L_S_RANGE1-LOW = SY-DATUM.
L_S_RANGE1-SIGN = 'I'.
L_S_RANGE1-OPT = 'EQ'.
APPEND L_S_RANGE1 TO E_T_RANGE.
**To Lookup ZREQSTDAT with 0FISCPER*************
**This loop will capture the Fiscal Year/Period range input by the user**
WHEN 'ZRSD_CX'.
READ TABLE i_t_var_range WITH KEY VNAM = 'ZFYP_IN'
INTO LOC_VAR_RANGE.
IF SY-SUBRC = 0.
CLEAR L_S_RANGE.
**This 2 call functions are used to convert the Fiscal Year/Period range into**
**Calendar Day range for use on further lookup in Required Start Date**
ZYEAR = LOC_VAR_RANGE-LOW(4).
ZMM = LOC_VAR_RANGE-LOW+4(3).
CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
EXPORTING
I_GJAHR = ZYEAR
I_MONMIT = 00
I_PERIV = 'SC'
I_POPER = ZMM
IMPORTING
E_DATE = ZSTARTDATE.
IF ZMM EQ 012.
ZMM1 = '001'.
ZYEAR1 = ZYEAR + 1.
ELSE.
ZMM1 = ZMM + 1.
ZYEAR1 = ZYEAR.
ENDIF.
CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
EXPORTING
I_GJAHR = ZYEAR1
I_MONMIT = 00
I_PERIV = 'SC'
I_POPER = ZMM1
IMPORTING
E_DATE = ZENDDATE.
ZENDDATE = ZENDDATE - 1.
**A third and final function to use the calendar day range provided to lookup on matching**
**dates in Required Start Date (ZREQSTDAT)*************************************************
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
L_S_RANGE-LOW = ZSTARTDATE.
L_S_RANGE-HIGH = ZENDDATE.
APPEND L_S_RANGE TO E_T_RANGE.
ENDIF.
ENDCASE.
ENDIF.
However, after doing extensive testing I discovered that the code is only able to process 1 period at a time versus an interval of periods as required.
For example,
Input Fiscal Year/Period Interval - 001/2011 to 004/2011
Expected returned dates - 02/27/2010 to 07/02/2010 (4 periods)
Actual returned dates - 02/27/2010 to 04/02/2010 (only 1 period, the 1st period and not the balance 3 periods)
Only the first period is returned versus the periods entered. I'm not sure what is missing from the code to process the entered interval.
Appreciate any help provided.
Warm regards,
Eric
Hi,
After looking your code, I think the problem is at the below mentioend part.
WHEN 'ZRSD_CX'.
READ TABLE i_t_var_range WITH KEY VNAM = 'ZFYP_IN'
INTO LOC_VAR_RANGE.
IF SY-SUBRC = 0.
CLEAR L_S_RANGE.
**This 2 call functions are used to convert the Fiscal Year/Period range into**
**Calendar Day range for use on further lookup in Required Start Date**
ZYEAR = LOC_VAR_RANGE-LOW(4).
ZMM = LOC_VAR_RANGE-LOW+4(3).
Here, you should put validation like this.
If not LOC_VAR_RANGE-LOW is initial.
If not LOC_VAR_RANGE-HIGH is initial
ZYEAR = LOC_VAR_RANGE-HIGH(4).
ZMM = LOC_VAR_RANGE-HIGH+4(3).
else.
ZYEAR = LOC_VAR_RANGE-LOW(4).
ZMM = LOC_VAR_RANGE-LOW+4(3).
endif.*
else.
put a validation to see that some input is given for fiscal year
endif.
only after these lines go for your function modules. This way, if your variable has range given, it would calculate till the higher range given for fiscal period.
Edited by: Rahul K Rai on Jul 15, 2010 11:17 AM
Edited by: Rahul K Rai on Jul 15, 2010 11:18 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
67 | |
8 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.