cancel
Showing results for 
Search instead for 
Did you mean: 

Previous month data should display in report

sai_v
Participant
0 Kudos

Hi All,

We have a report requirement like, when ever we run the,it should get the previous month data based on current month. I mean to say if we run the report on Oct it should bring the data for Sep.

How to work out on this can any one help me pls.

Thanks in advance,

Sai.

Accepted Solutions (1)

Accepted Solutions (1)

anshu_lilhori
Active Contributor
0 Kudos

Hi,

Drag and drop 0calmonth in char restriction in query designer--Restrict--Variable--0CMONTH--OFFSET -1.

As 0CMOMTH gives the data for current month so offset of -1 will give for the previous month.

Hope this helps.

Regards,

AL

sai_v
Participant
0 Kudos

Hi AL,

yes we tried with this but the offset is not working and not showing the correct values for previous month

anshu_lilhori
Active Contributor
0 Kudos

Hi,

How you are trying to restrict and hopefully this should work as i have been using in same way for so many queries which we developed.

Please check the restrictions properly.

Regards,

AL

former_member182470
Active Contributor
0 Kudos

Keep Current month variable in default values pane.

Restrict with offset to your KF. this should work.

Answers (1)

Answers (1)

former_member182196
Contributor
0 Kudos

i think you wants to enter cal month for the current month but for last month you want data from 1 to 30-31.

1. Create a calday var for user input.

2. For Current month  KF value create replacement path and replace with calday var.

3. Customer exit for previous month

WHEN 'Cust Exit'.

      LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = Input Var(calday).

        IF SY-SUBRC = 0.

          CLEAR L_S_RANGE.

          L_DD = '01'.

          L_MM = LOC_VAR_RANGE-LOW+4(2).

          L_YY = LOC_VAR_RANGE-LOW+0(4).

          L_DD1 = LOC_VAR_RANGE-LOW+6(2).

          CONCATENATE L_YY L_MM L_DD INTO L_S_RANGE-LOW.

          CONCATENATE L_YY L_MM L_DD1 INTO L_S_RANGE-HIGH.

          L_S_RANGE-SIGN = 'I'.

          L_S_RANGE-OPT = 'EQ'.

        ENDIF.

        APPEND L_S_RANGE TO E_T_RANGE.

      ENDLOOP.