Search
Search

# Customer Exit for Prior Month

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