Application Development and Automation 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: 
Read only

dynamic select-option

Former Member
0 Likes
4,602

Hi Gurus,

I need to write a report in which select fields and select-option should be dynamic. i.e user selects the

number of fields from the list (checkbox). Then I have to

put the ticked fields in an internal table and show it

as select-options in the next list.

EX : itab has 4 rows avm_nr,pos_nr,erfdate,erfuser.

My select-option should have avm_nr for jhak-avm_nr,

pos_nr for jhaea-pos_nr,

erfdate for jhak-erfdate,

erfuser for jhak-erfuser.

Could anybody give me some clue on how to go about it.

Thanks,

Harsha

7 REPLIES 7
Read only

Vinod_Chandran
Active Contributor
0 Likes
2,146

Hi Harsha,

If you sure about the fields in the selection screen, this can be achieved using the following logic.

1. Create a selection screen with all the fields

2. You get the selected fields from the user

3. In the event 'AT SELECTION-SCREEN OUTPUT', loop through this internal table and use the SCREEN structure to deactivate the non selected fields.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

READ TABLE ITAB WITH KEY FIELD = 'ABCD'. " ABCD is the name of the field in the selection screen

IF SY-SUBRC = 0 AND

ITAB-SEL IS INITIAL. "Field is not selected

SCREEN-ACTIVE = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

Hope this will help you.

Thanks

Vinod

Read only

Former Member
0 Likes
2,146
Read only

0 Likes
2,146

use module prog.

use field f1 module m1. and so on.

then on the basis of selected values, create the ranges in corresponding modules.

assign these ranges to select options.

regards

Read only

0 Likes
2,146

also check out FM

FREE_SELECTIONS_INIT and do a where used list to see how it is used.

Regards

Raja

Read only

0 Likes
2,146

I would like to use the only the reports not a dialog.

Could you give me some examples ?

Thanks,

Harsha

Read only

0 Likes
2,146

hi,

read F1 for SELECT-OPTIONS SELDYN FOR (FNAME)

example:

select-options s1 for (f1) .

INITIALIZATION. 
  f1 = 'T001-BUKRS'.

Andreas

Read only

Former Member
0 Likes
2,146

This program will give the user to select the field on which he/she wants the selection and can include the where condition with out a typing a single word.

N.B. Please always use non-numeric fields for selection( for the time being )

*********************************

REPORT ZMART_SELECTION_SCREEN_NEW .

TYPE-POOLS: VRM.

DATA: dref TYPE REF TO DATA,tab type ref to data.

DATA : ndref TYPE REF TO DATA,ntab TYPE REF TO DATA,fref type ref to data.

field-symbols : <f> TYPE any,<fcd>,<fc> type any,<ft> type standard table,<fn> TYPE STANDARD TABLE.

DATA : FIELDTAB LIKE DFIES OCCURS 0 WITH HEADER LINE.

DATA : DOM(30).

DATA : DFEY TYPE DFIES OCCURS 0 WITH HEADER LINE.

DATA : FIRST(30),SECOND(70),THIRD(70).

DATA : CH.

DATA: NAME TYPE VRM_ID,

LIST TYPE VRM_VALUES,

VALUE LIKE LINE OF LIST.

DATA : NUM TYPE I VALUE 1.

DATA : WA_ZMART LIKE ZMART_ST_MAIN-NAME.

DATA : scrtab TYPE dynpread OCCURS 0 WITH HEADER LINE.

DATA : BEGIN OF OPTIONS OCCURS 0,

SIGN TYPE ZSIGN,

END OF OPTIONS.

DATA : WA LIKE OPTIONS.

DATA : BEGIN OF ptab OCCURS 0,

scode LIKE DD03L-FIELDNAME,

END OF ptab.

DATA : BEGIN OF T_TAB OCCURS 0,

THIS TYPE DD03L-FIELDNAME,

END OF T_TAB.

DATA : VAL(30).

SELECTION-SCREEN BEGIN OF BLOCK MAIN WITH FRAME.

PARAMETERS : TABNAME TYPE DD03L-TABNAME MODIF ID COM.

PARAMETERS : ORDINARY RADIOBUTTON GROUP RAD1 USER-COMMAND ABC.

PARAMETERS : WHERE RADIOBUTTON GROUP RAD1.

SELECTION-SCREEN END OF BLOCK MAIN .

SELECTION-SCREEN BEGIN OF BLOCK FIRST WITH FRAME TITLE TEXT-001.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 3(5) TEXT-002.

PARAMETERS : FIELD(30) MODIF ID OPT.

SELECTION-SCREEN COMMENT 45(5) TEXT-003.

PARAMETERS : OPTION(2) MODIF ID OPT.

SELECTION-SCREEN COMMENT 65(5) TEXT-004.

PARAMETERS : THIS(10) AS LISTBOX visible length 10 MODIF ID OPT.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK FIRST.

*constants c1 type c value text-005.

DATA : CONT(40).

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF WHERE = 'X'.

IF SCREEN-GROUP1 = 'OPT'.

IF FIELD IS NOT INITIAL AND OPTION IS NOT INITIAL AND THIS IS NOT INITIAL.

SCREEN-INPUT = '0'.

ENDIF.

SCREEN-ACTIVE = '1'.

ENDIF.

IF SCREEN-GROUP1 = 'COM'.

SCREEN-INPUT = '0'.

ENDIF.

ELSE.

IF SCREEN-GROUP1 = 'OPT'.

SCREEN-ACTIVE = '0'.

ENDIF.

IF SCREEN-GROUP1 = 'COM'.

SCREEN-INPUT = '1'.

ENDIF.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

IF tabname IS NOT INITIAL AND FIELD IS NOT INITIAL.

  • LOOP AT FIELDTAB WHERE FIELDNAME = FIELD.

  • MOVE FIELDTAB-DOMNAME TO DOM.

  • ENDLOOP.

CREATE DATA dref TYPE (TABNAME).

ASSIGN dref->* TO <f>.

create data tab like table of <f>.

assign tab->* to <ft>.

  • CREATE DATA NDREF TYPE (DOM).

CONCATENATE '(TABNAME)' 'FIELDNAME' INTO CONT SEPARATED BY '-'.

CREATE DATA NDREF LIKE CONT.

ASSIGN NDREF->* TO <FCD>.

CREATE DATA NTAB LIKE TABLE OF <FCD>.

ASSIGN NTAB->* TO <fn>.

CLEAR LIST[].CLEAR THIS.

CALL FUNCTION 'DDIF_FIELDINFO_GET'

EXPORTING

tabname = TABNAME

  • FIELDNAME = ' '

  • LANGU = SY-LANGU

  • LFIELDNAME = ' '

  • ALL_TYPES = ' '

  • GROUP_NAMES = ' '

  • UCLEN =

  • IMPORTING

  • X030L_WA =

  • DDOBJTYPE =

  • DFIES_WA =

  • LINES_DESCR =

TABLES

DFIES_TAB = DFEY

  • FIXED_VALUES =

  • EXCEPTIONS

  • NOT_FOUND = 1

  • INTERNAL_ERROR = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

READ TABLE DFEY INDEX 1.

MOVE DFEY-INTTYPE TO CH.

IF CH = 'C'.

CLEAR CH.CLEAR DFEY[].

SELECT (FIELD) INTO table <fn> from (TABNAME).

loop at <fn> into <fcd>.

value-key = <fcd>.

value-text = <fcd>.

append value to list.

endloop.

NAME = 'THIS'.

CALL FUNCTION 'VRM_SET_VALUES' EXPORTING ID = NAME VALUES = LIST.

ENDIF.

ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FIELD.

SELECT FIELDNAME FROM DD03L INTO TABLE ptab WHERE TABNAME = tabname.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'FIELD'

dynpprog = sy-cprog

dynpnr = sy-dynnr

dynprofield = 'FIELD'

value_org = 'S'

TABLES

value_tab = ptab

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR OPTION.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'SIGN'

dynpprog = sy-cprog

dynpnr = sy-dynnr

dynprofield = 'OPTION'

value_org = 'S'

TABLES

value_tab = OPTIONS

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

INITIALIZATION.

WA-SIGN = 'EQ'.APPEND WA TO OPTIONS.CLEAR WA.

WA-SIGN = 'BT'.APPEND WA TO OPTIONS.CLEAR WA.

WA-SIGN = 'GT'.APPEND WA TO OPTIONS.CLEAR WA.

WA-SIGN = 'LT'.APPEND WA TO OPTIONS.CLEAR WA.

WA-SIGN = 'NE'.APPEND WA TO OPTIONS.CLEAR WA.

name = THIS.

START-OF-SELECTION.

concatenate TEXT-005 this TEXT-005 into second.

  • CONCATENATE 'INTO TAB WHERE' INTO FIRST.

  • CONCATENATE FIELD OPTION THIS INTO SECOND.

CONCATENATE FIELD OPTION second INTO FIRST SEPARATED BY SPACE.

CLEAR : FIELD,OPTION,THIS,LIST[].

SELECT * FROM (TABNAME) INTO TABLE <ft> WHERE (FIRST).

LOOP AT <ft> INTO <f>.

do.

assign component sy-index

of structure <f> to <fcd>.

if sy-subrc <> 0.

exit.

endif.

if sy-index = 1.

write:/ <fcd>.

else.

write: <fcd>.

endif.

enddo.

ENDLOOP.