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

Change the selection-screen field attributes dynamically

Former Member
0 Likes
4,043

Hi there dear SDN members.

I would like to prepare such functionality.

In the selection screen I have got 2 fields.

In field A user specifies some field name of table ADRC (Field A has got a searchhelp with ADRC fields list assigned. I use DDIF_FIELDINFO_GET FModule to get field parameters).

After user choses a field name, then Field B should change it's type to the chosen field's datatype.

So for example:

I choose in field A 'DATE_TO' value.

Then Field B should become of type 'DATS' dynamically.

( Further issue is a searchhelp, or control table of the new B field chosen. But it would be probably my next topic to discuss )

I will be thankful for help.

Regards, P.

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
1,510

Hi, <li>You might have used AT SELECTION-SCREEN ON VALUE-REQUEST field_a for search help for field_a. Under this event finally you call DYNP_VALUES_UPDATE function module and populate that second field with the data type. <li>Check the below sample program given by me . I hope that it helps you. Thanks Venkat.O

5 REPLIES 5
Read only

Former Member
0 Likes
1,510

Declare screen fields for all the Data type.

In the event AT SELECTION-SCREEN OUTPUT, depending on the value chosen for FIELD A, display the relevant screen-field, and hide others

SELECT-OPTIONS: s_fld1 FOR mara-matnr modif ID M1.

SELECT-OPTIONS: s_fld2 FOR vbak-vbeln modif ID M2.

SELECT-OPTIONS: s_fld3 FOR vbak-erdat modif ID M3.

AT SELECTION-SCREEN OUTPUT.

  • Perform to modify the screen.

PERFORM f_modify_screen.

&----


*& Form F_modify_screen *

&----


  • Subroutine to modify screen *

----


FORM f_modify_screen .

  • Check the Type of field chosen for FIELD-A

  • IF <Field-A date-type> = <date>.

LOOP AT SCREEN.

IF screen-group1 = 'M1'.

  • Make File field invisible

screen-active = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDFORM. " F_modify_screen

Read only

0 Likes
1,510

Ipsita De

ADRC table has got 88 fields, so according your solution I would have to create lot of fields, and theh hide/unhide them. But it seems to be a solution.

I try:


SELECTION-SCREEN BEGIN OF BLOCK main WITH FRAME TITLE text-001.
  ..
  PARAMETERS :   p_vnew LIKE (ftype) .
SELECTION-SCREEN END OF BLOCK main .


AT SELECTION-SCREEN .
* Here I re-load a ftype variable each time user changes field, something like this
  READ TABLE it_dfies INTO wa_dfies WITH KEY fieldname = p_fname .
  IF sy-subrc = 0 .
    CLEAR ftype .
    CONCATENATE 'ADRC-' wa_dfies-fieldname INTO ftype .
  ENDIF .

It works! But only once!! Why?

Debugger steps into AT SELECTION-SCREEN each time change field name in field A. But changes type of field B only once

Venkat.O

Unfortunately I can't change screen field's type using DYNP_VALUES_UPDATE

Read only

venkat_o
Active Contributor
0 Likes
1,511

Hi, <li>You might have used AT SELECTION-SCREEN ON VALUE-REQUEST field_a for search help for field_a. Under this event finally you call DYNP_VALUES_UPDATE function module and populate that second field with the data type. <li>Check the below sample program given by me . I hope that it helps you. Thanks Venkat.O

Read only

Former Member
0 Likes
1,510

Hi ,

try this way....


  refresh t_dynpfields.
  t_dynpfields-fieldname  = p_value.  "p_value is the DDIF_FIELDINFO_GET FModule to get field parameters
  append t_dynpfields.
  w_repid = sy-repid.
* reading Screen variables and Values
  call function 'DYNP_VALUES_READ'
       exporting
            dyname     = w_repid
            dynumb     = sy-dynnr
       tables
            dynpfields = t_dynpfields
       exceptions
            others.
  read table t_dynpfields index 1.
  p_w_value = t_dynpfields-fieldvalue.     "if you select date_to it will return date_to
                                                                  "or you you select werks it will act as werks


  call function 'HELP_VALUES_GET'
       exporting
            display      = ' '
            fieldname    = fieldname "pass p_w_value
            tabname      = tabname  "pass the table
       importing
            select_value = p_waers
       exceptions
            others       = 0.

regards,

Prabhudas

Read only

Former Member
0 Likes
1,510

Run this code Then after DBTAB = ADRC AND EXECUTE


PARAMETERS dbtab TYPE tabname DEFAULT 'ADRC'.

TYPE-POOLS rsds.

DATA tadir_wa  TYPE tadir.
DATA selid     TYPE  rsdynsel-selid.
DATA field_tab TYPE TABLE OF rsdsfields.
DATA table_tab TYPE TABLE OF rsdstabs.
DATA table     LIKE LINE OF table_tab.
DATA cond_tab  TYPE  rsds_twhere.
DATA cond      LIKE LINE OF cond_tab.
DATA dref      TYPE REF TO data.
DATA alv       TYPE REF TO cl_salv_table.

FIELD-SYMBOLS <table> TYPE STANDARD TABLE.

SELECT SINGLE *
       FROM tadir
       INTO tadir_wa
       WHERE pgmid = 'R3TR' AND
             object = 'TABL' AND
             obj_name = dbtab.
IF sy-subrc <> 0.
  MESSAGE 'Database not found' TYPE 'I' DISPLAY LIKE 'E'.
  LEAVE PROGRAM.
ENDIF.

table-prim_tab = dbtab.
APPEND table TO table_tab.
CALL FUNCTION 'FREE_SELECTIONS_INIT'
  EXPORTING
    kind         = 'T'
  IMPORTING
    selection_id = selid
  TABLES
    tables_tab   = table_tab
  EXCEPTIONS
    OTHERS       = 4.
IF sy-subrc <> 0.
  MESSAGE 'Error in initialization' TYPE 'I' DISPLAY LIKE 'E'.
  LEAVE PROGRAM.
ENDIF.

CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
  EXPORTING
    selection_id  = selid
    title         = 'Free Selection'
    as_window     = ' '
  IMPORTING
    where_clauses = cond_tab
  TABLES
    fields_tab    = field_tab
  EXCEPTIONS
    OTHERS        = 4.
IF sy-subrc <> 0.
  MESSAGE 'No free selection created' TYPE 'I'.
  LEAVE PROGRAM.
ENDIF.

READ TABLE cond_tab WITH KEY tablename = dbtab INTO cond.
IF sy-subrc <> 0.
  MESSAGE 'Error in condition' TYPE 'I' DISPLAY LIKE 'E'.
  LEAVE PROGRAM.
ENDIF.

CREATE DATA dref TYPE TABLE OF (dbtab).
ASSIGN dref->* TO <table>.

TRY.
    SELECT *
           FROM (dbtab)
           INTO TABLE <table>
           WHERE (cond-where_tab).
  CATCH cx_sy_dynamic_osql_error.
    MESSAGE 'Error in dynamic Open SQL' TYPE 'I' DISPLAY LIKE 'E'.
    LEAVE PROGRAM.
ENDTRY.

TRY.
    cl_salv_table=>factory(
      IMPORTING r_salv_table = alv
      CHANGING  t_table      = <table> ).
    alv->display( ).
  CATCH cx_salv_msg.
    MESSAGE 'Error in ALV display' TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.

Edited by: Krupaji on Feb 25, 2010 11:19 AM