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

Dates

Hi All,

I need the FM or Logic to findout the same date in the next month and so,if user gives the date range 01.01.2008 to 01.06.2008 .it means 01.02.2008,01.03.2008,01.04.2008,01.05.2008.

Thanks&regds,

Sree.

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 Jul 04, 2008 at 09:56 AM

    Hi Snicky,

    Try this code it is working.

    SELECT-OPTIONS:
      s_date FOR sy-datum.
    
    DATA :
      w_split LIKE sy-datum.
    
    
    w_split = s_date-low.
    
    
    WHILE w_split GE s_date-low.
    
      IF w_split+4(2) gt s_date-high+4(2).
    
        EXIT.
    
      ELSE.
    
          WRITE :/ w_split.
    
        w_split+4(2) = w_split+4(2) + 1.
    
      ENDIF.
    ENDWHILE..

    Regards,

    Swapna.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 04, 2008 at 09:59 AM

    Hi ,

    Start date of a month is 1 for any month. But then use FM FIRST_DAY_IN_PERIOD_GET

    CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
        EXPORTING
        i_gjahr              =  sp_gjahr
    *     i_monmit        =  gp_monat
          i_periv             =  'K4'
          i_poper           =  sp_monat
     IMPORTING
         e_date             =  gv_firstday
     EXCEPTIONS
       input_false          =  1
       t009_notfound     =  2
       t009b_notfound   =  3
       OTHERS            =  4
                .
      IF sy-subrc  0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF. ...

    If Found Help Full Do reward.

    Regards.

    Eshwar.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 04, 2008 at 10:03 AM

    hi,

    Select Options is an internal table. You can pick the date values from the internal Table and you can process that thing with the help of the OFFSET.

    w_date = s_date-low.

    check this thing with the high value of the internal table and if it is not then add one to the month field.

    w_date4(2) = w_date4(2) + 1.

    This will solve ur problem By and Large.

    But keep in mind the months of December because Next month is January, First Month of next year.

    Take Necessary precaution of that.

    Reward if useful.

    Sumit Agarwal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 04, 2008 at 10:05 AM

    Hi,

    Try the following code and check.

    DATA: D1 TYPE D, D2 TYPE D.

    DATA: MIN(2) TYPE N, MAX(2) TYPE N, CTR(2) TYPE N.

    DATA: BEGIN OF WA,

    COL1 TYPE D,

    END OF WA,

    ITAB LIKE WA OCCURS 0.

    D1 = '20080101'.

    D2 = '20080601'.

    MIN = D1+4(2).

    MAX = D2+4(2).

    CTR = MIN.

    WHILE ( CTR <= MAX ).

    WA-COL1 = D1.

    WA+4(2) = CTR.

    APPEND WA TO ITAB.

    CTR = CTR + 1.

    ENDWHILE.

    LOOP AT ITAB INTO WA.

    WRITE:/ WA-COL1.

    END

    Hope it helps you.

    Murthy.

    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.