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

date field

Former Member
0 Likes
850

hi,

i have a select option(s_date) for date field and i want to initialize the s_date-high equal to previous month of last date. for ex: this is the month of may then i want 30-apr-2006.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
814

Hi Kiran,

u can also use this code

data:

first_day like sy-datum

<b>Intialization</b>

first_day = sy-datum.

first_day+6(2) = '01'.

first_day = first_day - 1.

now assign the value of first_day to the high value of ur select option

8 REPLIES 8
Read only

former_member480923
Active Contributor
0 Likes
814

hi

Hope the following can be useful

get the month from sy-datum.

decrement it by one, if this value comes 0 take it as 12( this is to take care of January ie 1 - 1 = 0 )

pass the date with the decremented month into FM

SLS_MISC_GET_LAST_DAY_OF_MONTH

Anirban

Read only

Former Member
0 Likes
814

Hi,

lv_day type i,

lv_date_last_month type dats

In the initialize event.

lv_day = sy-datum+0(2).

lv_date_last_month = sy-datum - lv_day.

lv_date_last_month = lv_date_last_month + 1.

s_date-high = lv_date_last_month.

append s_date.

Date calulation is done internally u dont need to worry.

this is the purpose of date data type.

Close the thread if solved.

mark helpful answers

Regards

Message was edited by: Manoj Gupta

Read only

Former Member
0 Likes
814
REPORT ychatest.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_date FOR sy-datum.
SELECTION-SCREEN END OF BLOCK b1 .

INITIALIZATION.

  CALL FUNCTION 'CCM_GO_BACK_MONTHS'
    EXPORTING
      currdate   = sy-datum
      backmonths = '01'
    IMPORTING
      newdate    = s_date-low.


  CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
    EXPORTING
      i_date = s_date-low
    IMPORTING
      e_date = s_date-low.

  APPEND s_date.

Reward pts if helpful and close thread if solved

Message was edited by: Chandrasekhar Jagarlamudi

Read only

Former Member
0 Likes
814

Hi Kiran,

Use the following code.

CALL FUNCTION 'CCM_GO_BACK_MONTHS'

EXPORTING

currdate = sy-datum

backmonths = '001'

IMPORTING

newdate = lv_date_for_fmonth.

<b>Also, reward points if it helps and close the thread.</b>

Regards,

Amit Mishra

Read only

Former Member
0 Likes
814

Hi,

I have written test program for it.

use this .

PARAMETERS s_date TYPE dats.

DATA : lv_day TYPE i,

lv_date TYPE dats.

initialization.

lv_day = sy-datum+0(2).

lv_date = sy-datum - lv_day.

lv_date = lv_date + 1.

s_date = lv_date.

Please close the thread ; ur problem is solved

and Mark Helpfull Answers

Read only

rahulkavuri
Active Contributor
0 Likes
814

THIS THREAD GIVES A ANSWER TO GET FIRST DAY OF THE CURRENT MONTH

THEN SUBSTRACT ONE DAY FROM THE OUTPUT TO GET LAST DAY OF THE LAST MONTH INTO A VARIABLE

Read only

Former Member
0 Likes
814

Hi,

As already some of our friends mentioned, you can use

'CCM_GO_BACK_MONTHS' to get date from previous months and if you want to format it as you have mentioned e.g. 30APR2006 then additionaly use : 'CONVERSION_EXIT_IDATE_OUTPUT' FM

Regards,

Akshay

Note: Pls mark helpful answers

Read only

Former Member
0 Likes
815

Hi Kiran,

u can also use this code

data:

first_day like sy-datum

<b>Intialization</b>

first_day = sy-datum.

first_day+6(2) = '01'.

first_day = first_day - 1.

now assign the value of first_day to the high value of ur select option