Application Development and Automation Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
13,904
  1. Create an internal table and populate it with the values that should appear in             the F4 Help.
  2. Create another internal table and populate it with the positions of the previously selected values from the F4 Help. (This is done to check those values which were previously selected by the user).
  3. Call the function module “F4IF_INT_TABLE_VALUE_REQUEST”.

    

Note: The Parameter “Multiple_Choice” should be set to “X” for the Multiple Selection Checkbox to be enabled and the parameter “Mark_Tab” must take the internal table which is populated with the positions of the values selected by the user on previous execution so that those values remain checked on next execution.

The F4 help will look as below -

    

    

3 Comments
Former Member
0 Kudos

Hi Felix,

Excellent work!!! I learnt something new!!

Best Regards,

Santhosh

0 Kudos
Nice 😉
Sandra_Rossi
Active Contributor

Full working code corresponding to the given screenshots:

REPORT zdemo.

PARAMETERS material TYPE string.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR material.
  TYPES ty_dynpread_s TYPE STANDARD TABLE OF dynpread WITH EMPTY KEY.

  DATA i_marktab   TYPE ddshmarks.
  DATA i_returntab TYPE STANDARD TABLE OF ddshretval.

  DATA(dynpfields) = VALUE ty_dynpread_s( ( fieldname = 'MATERIAL' ) ).
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING  dyname     = sy-repid
               dynumb     = sy-dynnr
    TABLES     dynpfields = dynpfields
    EXCEPTIONS OTHERS     = 9.
  IF sy-subrc = 0.
    material = dynpfields[ fieldname = 'MATERIAL' ]-fieldvalue.
  ENDIF.

  SELECT matnr, aenam FROM mara INTO TABLE @DATA(i_matnr) UP TO 100 ROWS.
  SPLIT material AT ',' INTO TABLE DATA(materials).
  LOOP AT materials REFERENCE INTO DATA(material_2).
    DATA(line_index) = line_index( i_matnr[ matnr = CONV #( |{ material_2->* ALPHA = IN }| ) ] ).
    IF line_index <> 0.
      INSERT line_index INTO TABLE i_marktab.
    ENDIF.
  ENDLOOP.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING  retfield        = 'MATNR'
               dynpprog        = sy-repid
               dynpnr          = sy-dynnr
               dynprofield     = 'MATERIAL' " NB: useless when multiple_choice = 'X'
               window_title    = 'List of materials'
               value_org       = 'S'
               multiple_choice = 'X'
               mark_tab        = i_marktab
    TABLES     value_tab       = i_matnr[]
               return_tab      = i_returntab[]  " user selected table
    EXCEPTIONS parameter_error = 1
               no_values_found = 2
               OTHERS          = 3.
  IF sy-subrc = 0.
    material = concat_lines_of( sep   = ','
                                table = VALUE string_table( FOR <return_line> IN i_returntab
                                                            ( EXACT #( <return_line>-fieldval ) ) ) ).
    dynpfields = VALUE #( ( fieldname = 'MATERIAL' fieldvalue = material ) ).
    CALL FUNCTION 'DYNP_VALUES_UPDATE'
      EXPORTING  dyname     = sy-repid
                 dynumb     = sy-dynnr
      TABLES     dynpfields = dynpfields
      EXCEPTIONS OTHERS     = 8.
  ENDIF.

 

Labels in this area