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-OPTIONS at selection screen?

Former Member
0 Likes
4,793

Hi! I am new in ABAP and have problem in my module pool program.

So, I have selection screen as subscreen:

  SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.

  PARAMETERS: p_fname TYPE dd03l-fieldname MODIF ID fn OBLIGATORY.

  SELECT-OPTIONS: p_fvalue FOR (selected_type) MODIF ID fv.

  SELECTION-SCREEN END OF SCREEN 300.

In selection screen I enter field name in parameter p_fname. Based on this

parameter I search for field name in table dd03l:

SELECT SINGLE a~datatype a~fieldname a~tabname FROM dd03l as a

      INNER JOIN dd02l as b

      ON a~tabname = b~tabname

      INTO wa_table_type

      WHERE ( fieldname = p_fname ) AND

     ( b~tabclass = 'TRANSP' OR b~tabclass = 'CLUSTER' OR b~tabclass = 'POOL').

Then I use selected information to define SELECT-OPTIONS: p_fvalue type dynamicaly:

    selected_type = wa_table_type-tabname && '-' && wa_table_type-fieldname.

The problem is that when I run my Module Pool program, enter p_fname then

first time I get correct SELECT-OPTIONS: p_fvalue type, but when I enter another p_fname

then SELECT-OPTIONS: p_fvalue have old type in my screen. (See images)

Seems that screen is not refreshing.

If You have some misunderstandings or need more info, please let me know!

Hope for Your Help, best regards, Debuger!

13 REPLIES 13
Read only

Former Member
0 Likes
2,690

Hi,

I guess, you have to use Process on value-request for field p_fname.

Thanks & Regards,

Prasanna

Read only

Former Member
0 Likes
2,690

Hello Romans

actually what u want to do let us know first .

do u want to refresh FIELD NAME or u want to keep FIELD VALUE after push back button ..

Thanks & Regards

RKarmakar

Read only

Former Member
0 Likes
2,690

Hi Romans,

As per your above code , i am doing some changes please check below code . but one important things in below code when you change field name then you press 'F8' then automatically your field value change .

Note : Using "LOOT AT SCREEN " to modify the Selection Screen Dynamically based on                  Input Parameter .

===================

TABLES: DD03L,DD02L.

TYPES: BEGIN OF TY_TAB ,

   TABNAME LIKE DD03L-TABNAME ,

   FIELDNAME LIKE DD03L-FIELDNAME,

   DATATYPE LIKE  DD03L-DATATYPE ,

    END OF TY_TAB.

DATA: IT_TABLE_TYPE TYPE STANDARD TABLE OF TY_TAB INITIAL SIZE 0,

       WA_TABLE_TYPE TYPE TY_TAB ,

       SELECTED_TYPE TYPE STRING .

SELECTION-SCREEN BEGIN OF BLOCK BL_DEVC WITH FRAME TITLE TEXT-S06.

PARAMETERS: P_FNAME TYPE DD03L-FIELDNAME MEMORY ID FN  MODIF ID FN DEFAULT 'FLDATE'. "OBLIGATORY.

SELECT-OPTIONS: P_FVALUE FOR (SELECTED_TYPE) MEMORY ID FV MODIF ID FV .

SELECTION-SCREEN END OF BLOCK BL_DEVC.

AT SELECTION-SCREEN OUTPUT .

   CLEAR : WA_TABLE_TYPE ,SELECTED_TYPE .

   SELECT SINGLE A~DATATYPE A~FIELDNAME A~TABNAME FROM DD03L AS A

   INNER JOIN DD02L AS B

   ON A~TABNAME = B~TABNAME

   INTO CORRESPONDING FIELDS OF WA_TABLE_TYPE

   WHERE ( FIELDNAME = P_FNAME ) AND

  ( B~TABCLASS = 'TRANSP' OR B~TABCLASS = 'CLUSTER' OR B~TABCLASS = 'POOL').

   CONCATENATE WA_TABLE_TYPE-TABNAME '-' WA_TABLE_TYPE-FIELDNAME INTO SELECTED_TYPE.

   LOOP AT SCREEN.

     CASE SCREEN-GROUP1.

       WHEN 'FV'.

         IF   P_FNAME IS INITIAL.

           SCREEN-ACTIVE = 0.

           MODIFY SCREEN.

         ELSE.

           SCREEN-ACTIVE = 1.

           MODIFY SCREEN.

         ENDIF.

       WHEN 'FN'.

         IF  P_FNAME IS NOT INITIAL.

           SCREEN-ACTIVE = 1.

           MODIFY SCREEN.

         ELSEIF  P_FNAME IS INITIAL.

           SCREEN-ACTIVE = 0.

           MODIFY SCREEN.

         ENDIF.

     ENDCASE.

   ENDLOOP.

Regard's

Smruti


Read only

0 Likes
2,690

Hi, Smruti and others! Thanks for Your replies!

First of all, I want to clearly my user case:

User run my Module Pool app. I have there two fields: P_FNAME and P_FVALUE (it is read only when user run app). The user enters P_FNAME and pressing on 'ENTER'. After that I read P_FNAME value and I want to assign this field TYPE to my P_FVALUE field and allow user to enter data there.

Example: User enters 'FLDATE' in P_FNAME field then P_FVALUE field changes to DATS type and user can enter DATUM in P_FVALUE field. If the user enters 'CARRID' in P_FNAME then P_FVALUE field changes to CHAR type and user can enter CARRID from search help in P_FVALUE field.

Hope now my use case is clear. The problem comes up when user try to change P_FNAME second time, after pressing 'ENTER' the field P_FVALUE have previous type, not new one - CHAR with CARRID search help.

My code looks like:

*&---------------------------------------------------------------------*
*&  Include           ZRDC_TABLES_SEARCH_KR_SEL
*&---------------------------------------------------------------------*

START-OF-SELECTION.
   CLEAR: selected_type, wa_table_type.
   SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.
   PARAMETERS: p_fname TYPE dd03l-fieldname MEMORY ID fn MODIF ID fn OBLIGATORY DEFAULT 'FLDATE'. "OBLIGATORY..
   SELECT-OPTIONS: p_fvalue FOR (selected_type) MEMORY ID fv MODIF ID fv.
   SELECTION-SCREEN END OF SCREEN 300.
AT SELECTION-SCREEN ON p_fname.
   IF ok_code = 'ENTER'.
    CLEAR: selected_type, p_fvalue, wa_table_type.
     PERFORM get_field_type.
     selected_type = wa_table_type-tabname && '-' && wa_table_type-fieldname.
   ENDIF.

AT SELECTION-SCREEN OUTPUT.
   LOOP AT SCREEN.
     IF flag = abap_true AND screen-group1 = 'FV'.
       screen-input = 1.
       MODIFY SCREEN.
     ELSEIF flag = abap_false AND screen-group1 = 'FV'.
       screen-input = 0.
       MODIFY SCREEN.
     ENDIF.
   ENDLOOP.
END-OF-SELECTION.


form GET_FIELD_TYPE .
SELECT SINGLE a~datatype a~fieldname a~tabname FROM dd03l as a
       INNER JOIN dd02l as b
       ON a~tabname = b~tabname
       INTO wa_table_type
       WHERE ( fieldname = p_fname ) AND ( b~tabclass = 'TRANSP' OR b~tabclass = 'CLUSTER' OR b~tabclass = 'POOL').
   IF wa_table_type-datatype = 'LRAW' OR wa_table_type-datatype = 'STRING'.
    wa_table_type-tabname = ''.
    wa_table_type-fieldname = ''.
   ENDIF.
   flag = abap_true.
endform.   

Hope this helps and You can say where I am wrong. Seems that something is not refreshing. Because first time all works great. If You still need more info, please let me know.

Best regards, Kristaps

Read only

0 Likes
2,690

Any ideas how to solve my problem, I am stuck at this point...

Best regards, Kristaps

Read only

0 Likes
2,690

Hi Roman,

Below is a sample code.

You can try this .

DATA comp TYPE c LENGTH 60.

PARAMETERS p_dyn LIKE (comp).

INITIALIZATION.
  comp = 'SPFLI-CARRID'.

here in your case you can set the value for COMP in AT SELECTION SCREEN OUTPUT.

It will dynamically change the data element type.

Regards,

Santanu .

Read only

0 Likes
2,690

Hi, Santanu! I tried like You said, but it doesn't help. Like before the first time I enter p_fname all works great and p_fvalue type changes dynamically, but when I change p_fname and try again, then the old p_fvalue type is shown. Strange is that, when I run Debuger then all values is set to correct ones. Seems that problem is when refreshing selection screen. I have no ideas.

My updated SEL screen code looks like:

START-OF-SELECTION.
   CLEAR: selected_type, wa_table_type.
   SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.
   PARAMETERS: p_fname TYPE dd03l-fieldname MEMORY ID fn MODIF ID fn OBLIGATORY DEFAULT 'FLDATE'.
   SELECT-OPTIONS: p_fvalue FOR (selected_type) MEMORY ID fv MODIF ID fv.
   SELECTION-SCREEN END OF SCREEN 300.
AT SELECTION-SCREEN on p_fname.
   IF ok_code = 'ENTER'.
    CLEAR: selected_type, p_fvalue, wa_table_type.
     PERFORM get_field_type.
"There I get p_fvalue type
   ENDIF.


AT SELECTION-SCREEN OUTPUT.
   selected_type = wa_table_type-tabname && '-' && wa_table_type-fieldname.
   LOOP AT SCREEN.
     CASE screen-group1.
       WHEN 'FV'.
         IF flag = abap_true.
           screen-active = 1.
           MODIFY SCREEN.
         ELSE.
           screen-active = 0.
           MODIFY SCREEN.
         ENDIF.
       WHEN 'FN'.
         IF  p_fname IS NOT INITIAL.
           screen-active = 1.
           MODIFY SCREEN.
         ELSEIF  p_fname IS INITIAL.
           screen-active = 0.
           MODIFY SCREEN.
         ENDIF.
     ENDCASE.
   ENDLOOP.

END-OF-SELECTION.

Best regards, Kristaps

Message was edited by: Kristaps Romans

Read only

0 Likes
2,690

Hi Romans,

I have also tried and faced the same problem.

May be we have to use CALL TRANSACTION and call the selection screen again to get rid of the problem of refreshing the selection screen.

Will let you know if find any solution.

Regards,

Santanu.

Read only

0 Likes
2,690

Hi, Santanu! Thanks for Your reply. I also tried to implement CALL TRANSACTION variant. But there is problem, when the user try to enter P_FNAME value multiple times then he can reach maximum number of transactions. When I use CALL TRANSACTION then there is opened new transactions and when the user want to Exit program, he need to push exit comannd button two or more times. Thats way I can't use CALL TRANSACTION in my program.

Hope for any ideas how to solve the problem. If You understand why selection screen isn't refreshing, please explain me that, because it seems strange.

Best regards, Kristaps

Read only

0 Likes
2,690

Hi, Santanu! Did You find the solution on this problem? I still can't find. Maybe it is SAP bug?

BR, Kristaps

Read only

0 Likes
2,690

Hi,

My previous program was with type Module Pool. Now I recreated it without module pool (standard report). There is the code:

START-OF-SELECTION.
   SELECTION-SCREEN BEGIN OF BLOCK b1.
   PARAMETERS: p_fname TYPE dd03l-fieldname MEMORY ID fn MODIF ID fn OBLIGATORY DEFAULT 'FLDATE'.
   SELECT-OPTIONS: p_fvalue FOR (selected_type) MEMORY ID fv MODIF ID fv.
   SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN ON p_fname.
   IF sy-ucomm = ''.
     sscrfields-ucomm = 'ONLI'.
   ENDIF.

AT SELECTION-SCREEN OUTPUT.
   PERFORM get_field_type.
   selected_type = wa_table_type-tabname && '-' && wa_table_type-fieldname.
END-OF-SELECTION.

In this program dynamic selections works fine, screen is refreshed. My question is, why my program works fine in standard report program, but do not works with Module Pool program? Where might be the problem? Any ideas...

BR, Kristaps

Read only

Former Member
0 Likes
2,690

Hi Kristaps

DATA: w_carrid TYPE sflight-carrid.

** Selection Screen

SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE aaa.

SELECT-OPTIONS:   s_carrid FOR w_carrid.

SELECTION-SCREEN: END   OF BLOCK blk1.

*

INITIALIZATION.

* Description for the parameter

  IF sy-uname = 'TEST'.

    %_s_carrid_%_app_%-text = 'Carrier ID'.

  ELSE.

    %_s_carrid_%_app_%-text = 'Flight ID'.

  ENDIF.

Read only

Former Member
0 Likes
2,690

The easy way is to use COMPLEX_SELECTIONS_DIALOG Function.