‎2011 Jun 06 2:32 PM
Hi,
I have a requirement as below:
For a report program, there need to be a checkbox on the seletion screen .If that is ticked then, there some select options which are saved in a TVARVC variable should appear on the screen. Then we need to make selections in the program
according to these select options.It can be possible that user can add or delete select options in the TVARVC variable.
Need help to know how to achieve this.
Ex below for more understanding:
Check box : Name
If ticked,
Treament : _______ To _______ (select-option)
Germination : _____ To _______ (select-option) should appear on screen.
Then further selection in program based on values entered for these select -options like Treatment between ABC and DEF.
Regards,
Neethu
‎2011 Jun 06 2:36 PM
Hi,
Use "At Selection screen" event and then loop on screen to disable or enable desired screen fields.
-Muktar
‎2011 Jun 06 5:00 PM
HI,
To perform dynamic select options you can use the below code.
Here p_tab is the table name where fields of enterd table are dynamically fecthed and shown to user on screen. Where he can add/ delete the selections.
WA_TABS-PRIM_TAB = P_TAB.
APPEND WA_TABS TO IT_TABS.
CALL FUNCTION 'FREE_SELECTIONS_INIT'
EXPORTING
KIND = 'T'
EXPRESSIONS = GX_TEXPR " Variable to hold Expression
IMPORTING
SELECTION_ID = GV_SELID"Variable to hold Selid
NUMBER_OF_ACTIVE_FIELDS = GV_ACTNUM"Variable to hold no of fields
TABLES
TABLES_TAB = IT_TABS " Table name
FIELDS_TAB = IT_FLDS "Table fields
EXCEPTIONS
FIELDS_INCOMPLETE = 01
FIELDS_NO_JOIN = 02
FIELD_NOT_FOUND = 03
NO_TABLES = 04
TABLE_NOT_FOUND = 05
EXPRESSION_NOT_SUPPORTED = 06
INCORRECT_EXPRESSION = 07
ILLEGAL_KIND = 08
AREA_NOT_FOUND = 09
INCONSISTENT_AREA = 10
KIND_F_NO_FIELDS_LEFT = 11
KIND_F_NO_FIELDS = 12
TOO_MANY_FIELDS = 13.
if you couldnt solve this problem pls drop a mail i will send you the code.
Srikanth.
‎2011 Jun 06 7:26 PM
SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS: p_name TYPE string.
PARAMETERS: p_more AS CHECKBOX USER-COMMAND pmore.
SELECTION-SCREEN COMMENT /1(7) comm1 FOR FIELD p_field1.
PARAMETERS: p_field1 TYPE string.
SELECTION-SCREEN COMMENT /1(7) comm2 FOR FIELD p_field2.
PARAMETERS: p_field2 TYPE string.
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION.
"SELECT a ZTABLE containing all screen fields
SELECT *
FROM ztable
INTO TABLE ztable.
START-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form handle_screen
*&---------------------------------------------------------------------*
FORM handle_screen.
LOOP AT SCREEN.
" Handle FIELD 1
IF screen-name CS 'COMM1'.
IF p_more NE 'X'.
"Hide it!
screen-active = 0.
MODIFY SCREEN.
ELSE.
"READ TABLE ZTABLE and if not found, you can hide it as well
READ TABLE ztable INDEX 1.
IF sy-subrc <> 0.
screen-active = 0.
MODIFY SCREEN.
"Else, change COMM1 text
ELSE.
comm1 = ZTABLE-FIELD_DESC.
ENDIF.
ENDIF.
ENDIF.
IF screen-name CS 'P_FIELD1'.
IF p_more NE 'X'.
"Hide it!
screen-active = 0.
MODIFY SCREEN.
ELSE.
"READ TABLE ZTABLE and if not found, you can hide it as well
READ TABLE ztable INDEX 1.
IF sy-subrc <> 0.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDIF.
" Handle FIELD 2
IF screen-name CS 'COMM2'.
IF p_more NE 'X'.
"Hide it!
screen-active = 0.
MODIFY SCREEN.
ELSE.
"READ TABLE ZTABLE and if not found, you can hide it as well
READ TABLE ztable INDEX 2.
IF sy-subrc <> 0.
screen-active = 0.
MODIFY SCREEN.
"Else, change COMM2 text
ELSE.
comm2 = ZTABLE-FIELD_DESC.
ENDIF.
ENDIF.
ENDIF.
IF screen-name CS 'P_FIELD2'.
IF p_more NE 'X'.
"Hide it!
screen-active = 0.
MODIFY SCREEN.
ELSE.
"READ TABLE ZTABLE and if not found, you can hide it as well
READ TABLE ztable INDEX 2.
IF sy-subrc <> 0.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. "handle_screen