1. 对select-options的显示作约束
在Report的Initialization event中调用FM: SELECT_OPTIONS_RESTRICT (该Function的Help文档中有较仔细的用法说明和示例程序)
2. 动态获取屏幕的值的FMs
DYNP_VALUES_READ : Parameter
DYNPRO_FIELD_GET
RS_REFRESH_FROM_SELECTOPTIONS : Select-Options
e.g:
<!----> FORM GET_DYN_VALUE USING P_NAME
CHANGING P_VALUE.
DATA: LT_DYN_VALUES TYPE TABLE OF DYNPREAD,
WA_DYN_FIELD LIKE LINE OF LT_DYN_VALUES.
TRANSLATE P_NAME TO UPPER CASE.
WA_DYN_FIELD-FIELDNAME = P_NAME.
APPEND WA_DYN_FIELD TO LT_DYN_VALUES.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-REPID
DYNUMB = SY-DYNNR
TRANSLATE_TO_UPPER = 'X'
TABLES
DYNPFIELDS = LT_DYN_VALUES.
READ TABLE LT_DYN_VALUES INDEX 1 INTO WA_DYN_FIELD.
P_VALUE = WA_DYN_FIELD-FIELDVALUE.
ENDFORM. " get_dyn_value
3. AT SELECTION-SCREEN OUTPUT时修改Screen上的element显示相关属性
LOOP AT screen.
screen-active = 0/1.
MODIFY SCREEN.
ENDLOOP.
4. 隐藏标准选择屏幕的执行按钮
REPORT ZTXXX.
DATA it_exclude TYPE TABLE OF sy-ucomm.
PARAMETER p_1 TYPE lifnr.
AT SELECTION-SCREEN OUTPUT.
APPEND 'ONLI' TO it_exclude.
CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
EXPORTING
p_status = sy-pfkey
TABLES
p_exclude = it_exclude.
5. Interact with radiobutton/ checkbox on selection screen
SAP demo program: DEMO_SEL_SCREEN_USER_COMMAND
6. Search Help
7. 在subscreen中调用selection screen (1000)
...
zt: http://www.saptechies.com/selection-screen/
Selection Screen Contents
1. Using select options to select records
2. Select options with more than one default value or range
3. Making a frame around groups of fields on the selection screen.
4. making a checkbox
5. Making a radiobutton group
6. How to add an option programmatically after the user has finished the selection screen
7. Selection screen events
8. Making an option invisible
9. Selection screen - Parameters on a single line
10. Setting the title text of a selection screen dynamically
11. Using a custom toolbar in a selection screen
12. Skip line on selection screen
13. Using a matchcode
1. Using select options to select records
SELECT-OPTIONS: S_CPUDT FOR BKPF-CPUDT DEFAULT SY-DATUM,
S_USNAM FOR BKPF-USNAM.
SELECT * FROM BKPF
WHERE CPUDT IN S_CPUDT AND
USNAM IN S_USNAM.
2. Select options with more than one default value or range
If you want to use more than one default value or default range, you add the values to the internal table selection table.
Note: You don't have to declare the table, it is created automatically. The table has the same name as the select variable ( In the example below s_hkont ).
SELECT-OPTIONS: S_HKONT FOR ZTSAPSPEC-HKONT.
INITIALIZATION.
MOVE: 'I' to s_hkont-sign,
'BT' TO S_HKONT-OPTION,
'87111100' TO S_HKONT-LOW,
'87111124' TO S_HKONT-HIGH.
APPEND S_HKONT.
MOVE: 'I' to s_hkont-sign,
'EQ' TO S_HKONT-OPTION,
'87111300' TO S_HKONT-LOW,
APPEND S_HKONT.
3. Making a frame around groups of fields on the selection screen.
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_CPUDT FOR BKPF-CPUDT OBLIGATORY
DEFAULT SY-DATUM.
SELECTION-SCREEN END OF BLOCK 1.
You can add further blocks (block2.......)
4. making a checkbox
parameters: x_afstem as checkbox default 'X'.
5. Making a radiobutton group
PARAMETERS: RADIOBUTTON GROUP ,
RADIOBUTTON GROUP .
Example:
PARAMETERS: BUTTON1 RADIOBUTTON GROUP RAPT,
BUTTON2 RADIOBUTTON GROUP RAPT.
In the program you test for the radiobuttons like this:
if button1 = 'X' then.
< Here comes some code>
elseif button2 = 'X' then.
< Here comes some code>
endif.
5. How to add an option after the user has finished the selection screen
Use the at selection-screen event to add options as showed above in example 2.
7. Selection screen events
Initialization Before processing the selection screen
at selection-screen output Before the contents of selections screen is displayed
at selection-screen on p/s Processed after the user has specified the Parameter p
or Select option s
at selection-screen After the user has specified all selection criteria
8. Making an option invisible
If you don't want the user to be able to see the option you want to add, define it as No-DISPLAY.
SELECT-OPTIONS: S_HKONT FOR ZTSAPSPEC-HKONT NO-DISPLAY,
S_BUKRS FOR ZTSAPSPEC-BUKRS,
9. Selection screen - Parameters on a single line
SELECTION-SCREEN BEGIN OF LINE.
* The system does not output selection texts for parameters.
* Set your own
SELECTION-SCREEN COMMENT 1(15) text-001.
* Parameters
PARAMETERS: p1(3) TYPE c,
p2(5) TYPE c.
SELECTION-SCREEN COMMENT 55(10) p_wmunit.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
MOVE 'Unit' TO p_wmunit.
10. Setting the title text of a selection screen dynamically
Define GUI titles for the report. In this example the GUI titles COLLILABEL
and PALLETLABEL has been defined. In the INITIALIZATION event, dynamically
set which GUI title to show with the SET TITELBAR statement.
INITIALIZATION.
IF p_colli = 'X'.
SET TITLEBAR 'COLLILABEL'.
ELSEIF p_pallet = 'X'.
SET TITLEBAR 'PALLETLABEL'.
ENDIF.
11. Using a custom toolbar in a selection screen
When you use your own custom toolbar in a selection screen, the flow of the
report changes. Below is an example of how to use the events in such a
report.
Important! To be abel to submit your report, the submit button on the custom
toolbar of the selection screen must be named
'ONLI' (= Execute) or 'PRIN' (= Execute and Print).
INITIALIZATION.
* Your custom toolbar for the selection screen
SET PF-STATUS '0002'.
AT SELECTION-SCREEN.
* Handle sy-ucomm from your custom toolbar on the selection screen. Note
that it is not necessary explicitly to handle 'ONLI' or 'PRIN'
CASE sy-ucomm.
WHEN 'GETDATA'.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
START-OF-SELECTION.
..... retreieve data for the ereport.....
END-OF-SELECTION.
* PF status for the report
SET PF-STATUS '0001'.
..... write report ......
Henrik Frank
12. Skip line on selection screen
Selection-screen skip 1.
13. Using a matchcode
Parameters:
matnr like mara-matnr matchcode object mat1.
Note: Matchcode objects can be found in SE11