Application Development 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: 
guilherme_frisoni
Contributor

Sometimes we need to create a custom search help and fill more than one field in screen with a single selection.

This can be easily achieved by using FM to create this Search Help.

Here is an example to use in a screen with two fields.

Considering our screen has two fields:

VBAP-VBELN

VBAP-POSNR

We are going to set a Search help for VBAP-POSNR, but popup will show VBELN and POSNR, and will fill this two fields in our screen.

First we need to set PROCESS ON VALUE-REQUEST for VBAP-POSNR.

In screen Flow Logic, insert this code after PAI.

PROCESS ON VALUE-REQUEST.

  FIELD vbap-posnr MODULE zm_sh_posnr.

 

Now we have to code zm_sh_posnr module.

Here it is:

MODULE zm_sh_posnr INPUT.

  " Types

  " Table type for SH popup

  TYPES: BEGIN OF ys_sh,

           vbeln TYPE vbap-vbeln,

           posnr TYPE vbap-posnr,

         END OF ys_sh.

  " Local Vars

  DATA: lt_sh  TYPE TABLE OF ys_sh,

        ls_sh  TYPE ys_sh,

        lt_map TYPE TABLE OF dselc,

        ls_map TYPE dselc.

  " Load data

  SELECT vbeln posnr

    FROM vbap

    INTO TABLE lt_sh

    UP TO 50 ROWS.

  " Set return fields

  " Order

  CLEAR ls_map.

  ls_map-fldname = 'F0001'.        " Set that field 1 of SH table fills VBAP-VBELN

  ls_map-dyfldname = 'VBAP-VBELN'.

  APPEND ls_map TO lt_map.

  " Item

  CLEAR ls_map.

  ls_map-fldname = 'F0002'.        " Set that field 2 of SH table fills VBAP-VBELN

  ls_map-dyfldname = 'VBAP-POSNR'.

  APPEND ls_map TO lt_map.

  " Call Search Help Popup Function

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

      retfield        = 'POSNR'

      dynpprog        = sy-repid

      dynpnr          = sy-dynnr

      dynprofield     = 'VBAP-POSNR'

      value_org       = 'S'

    TABLES

      value_tab       = lt_sh

      dynpfld_mapping = lt_map

    EXCEPTIONS

      parameter_error = 1

      no_values_found = 2

      OTHERS          = 3.

ENDMODULE.

It's Done!

3 Comments