cancel
Showing results for 
Search instead for 
Did you mean: 

Customer Exit for Prior Month

Former Member
0 Kudos

Dear All,

I have a requirement to calculate the Prior month.

I have a Manual Input Varialbe (Example 07.2014 - 09-2014) we have written the below logic in customer exit.

The logic is working fine but output is not coming correctly..

for the month 07.2014 it is giving same value which is there in current sales.

CalMonth           Current sales                    Prior Sales

                                                                   1234

07.2014               2345                                  2345

08.2014                3456                                  3456

09.2014               4567

But I need output as below.

CalMonth           Current sales                    Prior Sales

                                                                  

07.2014               2345                                  1234

08.2014                3456                                  2345

09.2014               4567                                   3456.

I can try for offset but problem is if my selection is January. So please suggest if any one come accorss the sme situation.

                                      

FORM *****_002 

TABLES   I_T_VAR_RANGE TYPE rrs0_t_var_range
          e_t_range 
TYPE  rsr_t_rangesid
                                 

USING    i_vnam LIKE  rszglobv-vnam i_step TYPE i.


 
DATA : l_s_range TYPE rsr_s_rangesid,
        loc_var_range
TYPE rrrangeexit

data:   p1(4) TYPE n,
     p2
(2) TYPEn,

     p3(6) TYPE n,
     p4
(4) type n,

     p5(2)TYPE n,
     p6
(6) TYPEn.



READ TABLE i_t_var_range INTO loc_var_range WITH KEY vnam = '******_001'.
 

  p1
= loc_var_range-low+0(4).
  p2
= loc_var_range-low+4(2).
  p4
= loc_var_range-high+0(4).
  p5
= loc_var_range-high+4(2).


 
if p2 = '01'.
    p2
= '12'.
    p1
= p1 - 1.
 
ELSEIF p2 ne '01'.
    p2
= p2 - 1.
 
ENDIF.
 
CONCATENATE p1 p2 INTO p3.

 
if p5 = '01'.
    p4
= p4 - 1.
    p5
= '12'.
 
ELSEIF p5 ne '01'.
    p5
= p5 - 1.
 
ENDIF.
 
CONCATENATE p4 p5 INTO p6.
 
if sy-subrc = 0 .
    l_s_range
-low = p3.
    l_s_range
-high = p6.
    l_s_range
-sign     = 'I'.
    l_s_range
-opt      = 'EQ'.
   
APPEND l_s_range TO e_t_range.
 
ENDIF.
 
ENDFORM.

Let me know if you need more details.....

Thanks,

Areef

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Areef,

Have you tried changing:

    l_s_range-opt      = 'EQ'.

to

    l_s_range-opt      = 'BT'.

I think it could work. Other than that I don't see any issue with your code.

Thanks

Amit


Former Member
0 Kudos

Also I think Offset handles the first month issue by itself. So have you tried it already and it is not working as expected?

Thanks

Amit

Former Member
0 Kudos

Hello Amit,

That for Quick Responce.. I have tried with " BT " Option but no luck result is showing same.

And I haven;t tried offset as you know we will Month 1 issue so not tried for that.

Answers (2)

Answers (2)

former_member202718
Active Contributor
0 Kudos

Hi Areef,

The easiest way is to try out Off Setting...Variable-ZCALMONTH..-1,-2,-3....

Its flexible also..and can be changed easily as per needs.

rgds

SVU

Former Member
0 Kudos

Thank you all for the Inputs,

There are 2 problems,

1. We are usng Camonth Range Variable for which the offset will not work correctly and also with offset the problem will be during the CALMONTH="01" so we caqn not use this.

User want Range of Variable.

2. If we want Prior Calculated and to be populated at the same line then query designer should be static not dinamic for each month we need to have conditional keyfigure which will work according to the Month,

Work Around: We have requested client to execute the report for only one month and not to put Camonth in Rows which will show all the data in single line.

0 Kudos

Hi Areef,

Make sure all your variables used are correct, like "vnam = '******_001'", are you sure is this your manual entry variable?

Other than that your code look good.

Also, as Amit suggested try 2 use Offset.

Thanks,

Shreya J