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: 

Populate SELECT-OPTIONS default value using CALL FUNCTION

Former Member
0 Kudos

Hi Experts,

I would like to populate SELECT-OPTIONS s_currm default with value in w_currm, however, it doesn't seem to work. Can you please advise what the correct syntax is.

Note that CALL FUNCTION 'GET_CURRENT_YEAR' is working correctly and populating w_currm (as I can use it in a SQL SELECT statement), however, it does not seem to work for SELECT-OPTIONS s_currm.

Thank you for your time.

Code snippet is as a follows:

REPORT  Z_DOWNLOAD_BSIS_TEST.

*Data Declaration
DATA: w_currm TYPE BSIS-MONAT.

*Define current fiscal month
CALL FUNCTION 'GET_CURRENT_YEAR'
  EXPORTING
    BUKRS         = 'X999'     " Company Code
    DATE          = SY-DATUM   " Date to find fiscal year for
  IMPORTING
    CURRM         = w_currm.   " Current Fiscal Month

SELECT-OPTIONS s_currm FOR w_currm
               DEFAULT w_currm. " The default value is NOT being populated (appears blank) 

4 REPLIES 4

venkat_o
Active Contributor
0 Kudos

Hi, <li>Try this way.


REPORT  z_download_bsis_test.
*Data Declaration
DATA: w_currm TYPE bsis-monat.

SELECT-OPTIONS s_currm FOR w_currm.
"DEFAULT w_currm. " The default value is NOT being populated (appears blank)
"-----------------------------------------------------------------------
"Above DEFAULT addition will not default.
"-----------------------------------------------------------------------
AT SELECTION-SCREEN OUTPUT.

*   *define current fiscal month
  CALL FUNCTION 'GET_CURRENT_YEAR'
    EXPORTING
      bukrs = 'X999'     " Company Code
      date  = sy-datum   " Date to find fiscal year for
    IMPORTING
      currm = w_currm.   " Current Fiscal Month
  IF w_currm IS INITIAL.
    w_currm = sy-datum+4(2)."I just added for test purpose, you can remove
    "You need to build Select-options table like below.
    s_currm-low = w_currm.
    s_currm-option = 'EQ'.
    s_currm-sign = 'I'.
    APPEND s_currm.
    CLEAR  s_currm.
  ENDIF.
<font color=red>Note:</font> IF w_currm IS INITIAL and ENDIF , I used for testing purpose, you can remove Thanks Venkat.O

Edited by: Venkat.O on Mar 25, 2010 11:22 AM

Former Member
0 Kudos

Hi Venkat.O,

Thank you for your clear response. I have implemented your suggestion and it works, however, I now have a new problem.

Each time the report is executed or the "multiple selection" button is clicked the selection fields are populated once again with the default (low) values.

For example, when report is first opened the s_curry field displays '2010'. Clicking "multiple selection" results in another '2010' being populated. After executing the report the selection screen is populated again with '2010' (so we now have '2010' listed 3 times in the s_curry field).

How do I prevent the default values from repeating?

REPORT  Z_DOWNLOAD_BSIS_TEST


*Data Declaration
DATA:  w_currm TYPE BSIS-MONAT,
       w_curry TYPE BSIS-GJAHR,
       w_prevm TYPE BSIS-MONAT,
       w_prevy TYPE BSIS-GJAHR.


SELECTION-SCREEN BEGIN OF BLOCK b11 WITH FRAME TITLE text-001 .

*Parameters to enter the path
PARAMETERS: FILENAME(128) OBLIGATORY DEFAULT '/usr/sap/tmp/TEST.txt'
                         LOWER CASE.

SELECT-OPTIONS: s_curry FOR w_curry,
                s_currm FOR w_currm.

SELECTION-SCREEN END OF BLOCK b11.

AT SELECTION-SCREEN OUTPUT.

*Define current/previous financial periods
CALL FUNCTION 'GET_CURRENT_YEAR'
  EXPORTING
    BUKRS         = 'X999'     " Company Code
    DATE          = SY-DATUM   " Date to find fiscal year for
  IMPORTING
    CURRM         = w_currm    " Current Fiscal Month
    CURRY         = w_curry    " Current Fiscal Year
    PREVM         = w_prevm    " Previous Fiscal Month
    PREVY         = w_prevy.   " Previous Fiscal Year

    s_curry-low = w_curry.
    s_curry-option = 'EQ'.
    s_curry-sign = 'I'.
    APPEND s_curry.
    CLEAR  s_curry.

    s_currm-low = w_currm.
    s_currm-option = 'EQ'.
    s_currm-sign = 'I'.
    APPEND s_currm.
    CLEAR  s_currm.

venkat_o
Active Contributor
0 Kudos

Hi, <li>You can place the defaulting code under INITIALIZATION event. becuase AT SELECTION-SCREN OUTPUT is triggered for every action done on Selection-screen. *Define current/previous financial periods

"*AT SELECTION-SCREEN OUTPUT. "Comment this event
INITIALIZATION.
"==============
CALL FUNCTION 'GET_CURRENT_YEAR'
  EXPORTING
    BUKRS         = 'X999'     " Company Code
    DATE          = SY-DATUM   " Date to find fiscal year for
  IMPORTING
    CURRM         = w_currm    " Current Fiscal Month
    CURRY         = w_curry    " Current Fiscal Year
    PREVM         = w_prevm    " Previous Fiscal Month
    PREVY         = w_prevy.   " Previous Fiscal Year
 
    s_curry-low = w_curry.
    s_curry-option = 'EQ'.
    s_curry-sign = 'I'.
    APPEND s_curry.
    CLEAR  s_curry.
 
    s_currm-low = w_currm.
    s_currm-option = 'EQ'.
    s_currm-sign = 'I'.
    APPEND s_currm.
    CLEAR  s_currm.
Thanks Venkat.O

Former Member
0 Kudos

Hi,

You can make use the below piece of code.

DATA:w_currm TYPE bsis-monat.

SELECT-OPTIONS s_currm FOR w_currm .

AT SELECTION-SCREEN OUTPUT.

w_currm = sy-datum+4(2).

s_currm-low = w_currm.

s_currm-sign = 'I'.

s_currm-option = 'EQ'.

APPEND s_currm.

Regards,

Smart Varghese