‎2010 Mar 25 2:57 AM
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)
‎2010 Mar 25 3:07 AM
Hi,
<li>Try this way.
<font color=red>Note:</font> IF w_currm IS INITIAL and ENDIF , I used for testing purpose, you can remove
Thanks
Venkat.O
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.
Edited by: Venkat.O on Mar 25, 2010 11:22 AM
‎2010 Mar 25 4:23 AM
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.
‎2010 Mar 25 4:57 AM
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
Thanks
Venkat.O"*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.
‎2010 Mar 25 3:53 AM
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