Issue :
To make the program to pick the data from the database using the secondary index
Sol :
%_HINTS ORACLE 'INDEX("table" "table name~index name")'.
Dynamic selection screen can be created using push buttons declared in
single program
1. Declare parameters with modif id and declare push buttons.
2.In initialization get the user command stored in the memory location using import function and update the selection screen accordingly(disabling some parameters)
3. Selection screen gets displayed, whenever other button is clicked then event AT SELECTION-SCREEN gets triggered, if the sy-ucomm is ‘FC01 or FC02’ export it to the memory location else do screen validations.
4. In the event AT SELECTION-SCREEN OUTPUT change the screen by using LOOP AT SCREEN and MODIF ID
Dynamic selection screen using PF status between two programs
1. Changing initial screen options can be done as follows
2. PF status (MENU from SE41 Menu painter) need to be created.
3. In the event AT SELECTION-SCREEN OUTPUT following need to used
AT SELECTION-SCREEN OUTPUT.
*Use a custom PF-STATUS instead of the standard one
CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'.
EXPORTING
p_status = 'EDIT_TEXT'
TABLES
p_exclude = exclitab.
DATA: exclitab TYPE TABLE OF sy-ucomm.
4. While creating the push button following need to be taken care, ie Function type need to be ‘E’—Exit command
5. Later in the event AT SELECTION-SCREEN ON EXIT-COMMAND, depending on the command declared in the menu painter get the selection screen inputs if required and submit it to the program.
AT SELECTION-SCREEN ON EXIT-COMMAND.
IF sy-ucomm = <command declared in menu painter>
PERFORM submit_program.
ENDIF.
FORM submit_program .
DATA: sel_table TYPE TABLE OF rsparams.
CLEAR sel_table.
CLEAR p_detlay.
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
curr_report = sy-repid
TABLES
selection_table = sel_table.
SUBMIT < to_which_program this need to be submitted>
VIA SELECTION-SCREEN
WITH SELECTION-TABLE sel_table
AND RETURN.
ENDFORM. " submit_program
In general we use DYNP_VALUES_READ to read data in the screen. It will be very simple to get data from the screen when the required field is declared from parameter.
1. Declaration: Declare data for input and for output
DATA: dynfields TYPE TABLE OF dynpread WITH HEADER LINE,
return_tab TYPE TABLE OF ddshretval WITH HEADER LINE.
2.Pass the required value to dynfields
dynfields-fieldname = 'P_BUKRS'.
APPEND dynfields.
3.Get the data from selection screen
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-cprog
dynumb = sy-dynnr
translate_to_upper = 'X'
TABLES
dynpfields = dynfields
4.Get the data from to the fields from selection to the fields
READ TABLE dynfields WITH KEY fieldname = 'P_BUKRS'.
lv_bukrs = dynfields-fieldvalue.
5.Get the data from the required table to display
SELECT bukrs branch name
FROM j_1bbranch
INTO CORRESPONDING FIELDS OF TABLE it_j_1bbranch
WHERE bukrs = lv_bukrs.
6.Display the using FM F4IF_INT_TABLE_VALUE_REQUEST
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BRANCH'
dynprofield = 'S_BRANCH-LOW'
value_org = 'S'
TABLES
value_tab = it_j_1bbranch
return_tab = return_tab.
7.Pass the data to output field
READ TABLE return_tab WITH KEY fieldname = 'BRANCH'.
IF lv_shelp_low = 'X'.
s_branch-low = return_tab-fieldval.
ENDIF.
But when to get the data from SELECT-OPTIONS will be challenge, in order to overcome this we need to follow the below procedure in the attached document.
Attachement for select options