Application Development 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: 

Dates

former_member125931
Active Participant
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

5 REPLIES 5

Former Member
0 Kudos

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.

0 Kudos

ThankYou Swapna,my problem solved.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

former_member787646
Contributor
0 Kudos

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.