Skip to Content
author's profile photo Former Member
Former Member

function to a month

hi,

I have the following code.

DATA: FECHA LIKE SY-DATUM(6),

FECHA1 LIKE SY-DATUM.

fecha1 = sy-datum.

fecha = FECHA1(6) - 1.

The result is 200700.

This result not exist like year.month, this result is not the expected for me. What i need is 200612.

There are some functions or some idea to obtain what I need?

I would appreciate your help.

Regards,

Victoria

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 01:44 PM

    Use this FM...

    RP_CALC_DATE_IN_INTERVAL
    

    You can ADD or SUBTRACT days, months or years -;)

    Greetings,

    Blag.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      just check this..

      DATA: FECHA like sy-datum(6),
      FECHA1 LIKE SY-DATUM.
      data: mon(2) type c,
            year(4) type c.
      
      fecha1 = sy-datum.
      mon = FECHA1+4(2) .
      year = FECHA1+0(4).
      
      if mon = '01'.       "need to use this 
      year = year - 1.     "----> 
      mon = '12'.
      endif.
      
      concatenate year mon into fecha.
      write:/ fecha.

      regards,

      vijay

  • Posted on Jan 08, 2007 at 01:43 PM

    hi,

    try CALCULATE_DATE

    with month = -1

    REPORT zforum117 .

    PARAMETERS: date LIKE sy-datum DEFAULT sy-datum,

    mth(4) default -1.

    DATA: fecha LIKE sy-datum(6),

    fecha1 LIKE sy-datum.

    CALL FUNCTION 'CALCULATE_DATE'

    EXPORTING

    • days = '0'

    months = mth

    start_date = date

    IMPORTING

    result_date = fecha1.

    .

    fecha = fecha1(6).

    write: fecha.

    A.

    Message was edited by:

    Andreas Mann

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 01:47 PM

    Hi victoria,

    1. use this FM

    HR_JP_ADD_MONTH_TO_DATE

    2. in that give IV_MONTHCOUNT = -1.

    regards,

    amit m.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 08, 2007 at 02:25 PM

    Use CCM_GO_BACK_MONTHS

    *" IMPORTING

    *" VALUE(CURRDATE) LIKE SY-DATUM

    *" VALUE(BACKMONTHS) TYPE NUMC3

    *" EXPORTING

    *" VALUE(NEWDATE) LIKE SY-DATUM

    regards

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.