Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

user exit.

Former Member
0 Likes
291

hi Abap Gurus,

Can some body help me to get code.My requirement is display previous 12 months with format "First three Chars of Month" space year.I have code for one month.

But i need code to display 11 months at a time.If i enter 01.2007 the result should be.

DEC 2006

NOV 2006

OCT 2006

SEP 2006

AUG 2006

JUL 2006

JUN 2006

MAY 2006

APR 2006

MAR 2006

FEB 2006

JAN 2006

Sample CODE:

CASE I_VNAM.

WHEN 'ZT_PVM01'.

  • Data : month_nam(3) type c.

CLEAR : MONTH_NAM.

IF i_step = 2.

CLEAR l_s_range.

LOOP AT i_t_var_range INTO loc_var_range

WHERE vnam EQ 'ZPPRVMTH'.

l_s_range-low = loc_var_range-low.

wa_month = loc_var_range-low+4(2).

wa_year = loc_var_range-low(4).

wa_month = wa_month - 1.

If wa_month = 00.

wa_month = 12.

wa_year = wa_year - 1.

Endif.

CASE wa_month.

WHEN '01'.

month_nam = 'JAN'.

WHEN '02'.

month_nam = 'FEB'.

WHEN '03'.

month_nam = 'MAR'.

WHEN '04'.

month_nam = 'APR'.

WHEN '05'.

month_nam = 'MAY'.

WHEN '06'.

month_nam = 'JUN'.

WHEN '07'.

month_nam = 'JUL'.

WHEN '08'.

month_nam = 'AUG'.

WHEN '09'.

month_nam = 'SEP'.

WHEN '10'.

month_nam = 'OCT'.

WHEN '11'.

month_nam = 'NOV'.

WHEN '12'.

month_nam = 'DEC'.

ENDCASE.

CONCATENATE month_nam wa_year INTO L_S_RANGE-LOW SEPARATED BY ' '.

l_s_range-sign = 'I'.

l_s_range-opt = 'EQ'.

APPEND l_s_range TO e_t_range.

EXIT.

ENDLOOP.

ENDIF.

please help me points will be assigned.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
268

Check the below code.

> CASE I_VNAM.
> 
> WHEN 'ZT_PVM01'.
> 
> * Data : month_nam(3) type c.
> 
> CLEAR : MONTH_NAM.
> 
> IF i_step = 2.
> 
> CLEAR l_s_range.
 
    CALL FUNCTION 'MONTH_NAMES_GET'
      TABLES
        month_names                 = IL_MONTH_NAMES.

> LOOP AT i_t_var_range INTO loc_var_range
> 
> WHERE vnam EQ 'ZPPRVMTH'.
> 
> l_s_range-low = loc_var_range-low.
> 
> wa_month = loc_var_range-low+4(2).
> 
> wa_year = loc_var_range-low(4).
> 
> wa_month = wa_month - 1.
> 
> If wa_month = 00.
> 
> wa_month = 12.
> 
> wa_year = wa_year - 1.
> 
> Endif.
> 
> CASE wa_month.
> 
> WHEN c_01.
> 
> Read table IL_MONTH_NAMES into wa_MONTH_NAMES with key mn eq c_01.
> month_name = wa_month_names-ktx.

> WHEN c_02.
> 
> Read table IL_MONTH_NAMES into wa_MONTH_NAMES with key mn eq c_02.
> month_name = wa_month_names-ktx.

>....................
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
 
> ENDCASE.
> 
> CONCATENATE month_nam wa_year INTO L_S_RANGE-LOW
> SEPARATED BY ' '.
> 
> l_s_range-sign = 'I'.
> 
> l_s_range-opt = 'EQ'.
> 
> APPEND l_s_range TO e_t_range.
> 
> EXIT.
> 
> ENDLOOP.
> 
> ENDIF.
>

Rgds,

Naren

2 REPLIES 2
Read only

Former Member
0 Likes
268

use fm to get month name - MONTH_NAMES_GET

Read only

Former Member
0 Likes
269

Check the below code.

> CASE I_VNAM.
> 
> WHEN 'ZT_PVM01'.
> 
> * Data : month_nam(3) type c.
> 
> CLEAR : MONTH_NAM.
> 
> IF i_step = 2.
> 
> CLEAR l_s_range.
 
    CALL FUNCTION 'MONTH_NAMES_GET'
      TABLES
        month_names                 = IL_MONTH_NAMES.

> LOOP AT i_t_var_range INTO loc_var_range
> 
> WHERE vnam EQ 'ZPPRVMTH'.
> 
> l_s_range-low = loc_var_range-low.
> 
> wa_month = loc_var_range-low+4(2).
> 
> wa_year = loc_var_range-low(4).
> 
> wa_month = wa_month - 1.
> 
> If wa_month = 00.
> 
> wa_month = 12.
> 
> wa_year = wa_year - 1.
> 
> Endif.
> 
> CASE wa_month.
> 
> WHEN c_01.
> 
> Read table IL_MONTH_NAMES into wa_MONTH_NAMES with key mn eq c_01.
> month_name = wa_month_names-ktx.

> WHEN c_02.
> 
> Read table IL_MONTH_NAMES into wa_MONTH_NAMES with key mn eq c_02.
> month_name = wa_month_names-ktx.

>....................
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
 
> ENDCASE.
> 
> CONCATENATE month_nam wa_year INTO L_S_RANGE-LOW
> SEPARATED BY ' '.
> 
> l_s_range-sign = 'I'.
> 
> l_s_range-opt = 'EQ'.
> 
> APPEND l_s_range TO e_t_range.
> 
> EXIT.
> 
> ENDLOOP.
> 
> ENDIF.
>

Rgds,

Naren