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

default date on selection-screen.

Hi ABAPers,

My requirement is that, i have one period(date) select-option in my selection screen.

Now the problem was basing on the month the first and last date of that particular month should be initialised.

For Ex:- present month was may, so in selection screen the date should be,

PERIOD 05/01/2007 TO 05/31/2007

Can any one send me the code for that.

Thanks in Advance.

Regards,

Ramana Prasad. T

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

17 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 10:02 AM

    Hi,

    you can use this code just copy paste and run

    SELECT-OPTIONS: s_date FOR sy-datum OBLIGATORY.

    DATA: l_date TYPE sy-datum.

    INITIALIZATION.

    s_date-sign = 'I'.

    s_date-option = 'EQ'.

    s_date-low = sy-datum.

    s_date-low+6(2) = '01'.

    s_date-sign = 'I'.

    s_date-option = 'EQ'.

    s_date-high = sy-datum - l_date+6(2) .

    s_date-high4(2) = s_date-high4(2).

    CASE sy-datum+4(2).

    WHEN '1' OR '3' OR '5' OR '7' OR '8' OR '10' OR '12'.

    s_date-high+6(2) = '31'.

    WHEN '4' OR '6' OR '9' OR '11'.

    s_date-high+6(2) = '30'.

    WHEN '2' .

    s_date-high+6(2) = '28'.

    ENDCASE.

    APPEND s_date.

    regards ,

    Sudha.

    reward points if useful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 08:54 AM

    Hi

    Select-options : s_date for sy-datum

    in the intialization write the code as

    Initialization.

    data: v_date1 like sy-datum, v_date2 like sy-datum.

    concatenate sy-datum+0(6) '01' to date1.

    concatenate sy-datum+0(6) '31' to date2. (you can give, 30 or 28 depending on month condition).

    s_date-low = date1.

    s_date-high= date2.

    s_date-sign = 'I'.

    s_date-option = 'BT'.

    append s_date.

    now month start date and end date are defaulted into Low and high fields of date

    Reward points if useful

    Regards

    Anji

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 08:55 AM

    Hi Ramana ,

    Use the event Initialization ,

    Since the first day will always be 1st so you can assign this value as the start date and to get the last date use the FM RP_LAST_DAY_OF_MONTHS.

    Pass the current date to this FM , this will give the last day of the month.

    Hope this helps.

    Regards

    Arun

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 09:10 AM

    Hi Ramana Prasad ,

    just try this code.....

    LOAD-OF-PROGRAM.

    DATA: v_date TYPE sy-datum.

    v_date = sy-datum.

    v_date+6(2) = '01'.

    SELECT-OPTIONS: s_dat FOR sy-datum .

    INITIALIZATION.

    CALL FUNCTION 'LAST_DAY_OF_MONTHS'

    EXPORTING

    day_in = sy-datum

    IMPORTING

    last_day_of_month = s_dat-high.

    s_dat-low = v_date.

    APPEND s_dat TO s_dat[].

    Regards,

    Naveen Natarajan

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Try this code.

      SELECT-OPTIONS so_datum FOR sy-datum.

      INITIALIZATION.

      so_datum-low = sy-datum.

      so_datum-low+6(2) = '01'.

      CALL FUNCTION 'LAST_DAY_OF_MONTHS'

      EXPORTING

      day_in = sy-datum

      IMPORTING

      last_day_of_month = so_datum-high.

      APPEND so_datum.

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 08:50 AM

    use sy-datum

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 08:52 AM

    select-options: s_date for coep-budat default '01012007' to '31122007'

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 08:53 AM

    use this function module to get the last days of the month

    RP_LAST_DAY_OF_MONTHS

    regards

    gowri

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 08:56 AM

    Hi

    SELECT-OPTIONS SO_DATUM FOR SY-DATUM.
    
    INITIALIZATION.
    
      SO_DATUM(3)  = 'IBT'.
      SO_DATUM-LOW = SY-DATUM.
    
      CALL FUNCTION 'LAST_DAY_OF_MONTHS'
           EXPORTING
                DAY_IN            = SY-DATUM
           IMPORTING
                LAST_DAY_OF_MONTH = SO_DATUM-HIGH.
    
      APPEND SO_DATUM.

    Max

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 08:59 AM

    initalization

    call the function module BAPI_COAREA_GETPERIODLIMITS for getting the start data and end date for the peroid using the Controlling area ...

    then passit to the 2 variable like start_date and end_date .....

    select-options : period for sy-datum defualt sy-datum.

    at selection-screen .

    loop at sceen .

    if screen-fields = period-low

    period = start_date

    elseif screen-fields = period-high

    period = end_date

    endif .

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 09:01 AM

    HI,

    select-OPTIONS date for sy-datum.

    DATA:DAT TYPE SY-DATUM.

    INITIALIZATION.

    DAT = SY-DATUM.

    date-sign = 'I'.

    date-option = 'BT'.

    DAT+6(2) = '01'.

    DATE-LOW = DAT.

    DAT4(2) = DAT4(2) + 1.

    DAT = DAT - 1.

    DATE-HIGH = DAT.

    APPEND DATE.

    rgds,

    bharat.

    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.