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

Using a function module in a search help.

Former Member
0 Likes
1,609

People,

I make a function module for a search help. Into the function module I call a function 'K_GROUP_SELECT' that show me a screen to make another search but I don't know how can I put the value that this function return me in the field that the user click the button of the search help in my program.

This is the code that I put in the function module.

Thanks!


FUNCTION Z_GROUP_SELECT_ZFINCOKOH1_B.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      SHLP_TAB TYPE  SHLP_DESCT
*"      RECORD_TAB STRUCTURE  SEAHLPRES
*"  CHANGING
*"     VALUE(CALLCONTROL) LIKE  DDSHF4CTRL STRUCTURE  DDSHF4CTRL
*"     VALUE(SHLP) TYPE  SHLP_DESCR
*"----------------------------------------------------------------------
tables: setheader.

data: setname type setheader-setname.

  CONSTANTS:
              CLASS         TYPE SETCLASS VALUE '0103',
              FIELD_NAME    TYPE RGSBS-FIELD  VALUE '*',
              KOKRS         TYPE TKA01-KOKRS  VALUE 'BPPR',
              KTOPL         TYPE TKA01-Ktopl VALUE 'CAPI'.


IF callcontrol-step = 'SELECT'.

*PERFORM k_group_select USING: CLASS, FIELD_NAME, KOKRS, KTOPL.

CALL FUNCTION 'K_GROUP_SELECT'
  EXPORTING
   BUTTONS                  = 'X'
   CLASS                    = CLASS
   CRUSER                   = '*'
   field_name               = FIELD_NAME
   SEARCHFLD                = '    '
   SEARCHFLD_INPUT          = 'X'
   SEARCHFLD_REQUIRED       = 'X'
   SET                      = '*'
   START_COLUMN             = 10
   START_ROW                = 5
   TABLE                    = 'CCSS'
   TYPELIST                 = 'BS'
   UPDUSER                  = '*'
   KOKRS                    = KOKRS
   KTOPL                    = KTOPL

 IMPORTING
   SET_NAME                 = setname

EXCEPTIONS
   NO_SET_PICKED            = 1
   OTHERS                   = 2
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

endif.

ENDFUNCTION.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,118

OK,

Thanks for the help!

The function that I call 'K_GROUP_SELECT' return me only a field not a table and I run the program and I don't receive any dump. The thing that I only need is put in the field of the search help the value that I receive from the function: 'K_GROUP_SELECT'.

6 REPLIES 6
Read only

Former Member
0 Likes
1,118

Use the function module F4UT_RESULTS_MAP.

call function 'F4UT_RESULTS_MAP'

tables

shlp_tab = shlp_tab

record_tab = record_tab

source_tab = lt_rec

changing

shlp = shlp

callcontrol = callcontrol

exceptions

illegal_structure = 1

others = 2.

check sy-subrc is initial.

callcontrol-step = 'DISP'.

Refer to function module ACTEXP_F4_FUNCTION_PARAMETERS.

Award points if helpfull.

Read only

Former Member
0 Likes
1,118

Hi,

wait a minute !! you mean that FM 'K_GROUP_SELECT' calls a screen, where the user has to enter a value and press a button for continuing the process in this module ??? I´m not sure if this is gonna work; probably you´re gonna cause a dump.

Perhaps you can expand the import interface of the search help with a new field, so that the user enters the value before.

Read only

Former Member
0 Likes
1,119

OK,

Thanks for the help!

The function that I call 'K_GROUP_SELECT' return me only a field not a table and I run the program and I don't receive any dump. The thing that I only need is put in the field of the search help the value that I receive from the function: 'K_GROUP_SELECT'.

Read only

0 Likes
1,118

Carlos, if you are getting a value back from your function module, then all you need to do is move the value to your screen field at the right time.

Here P_VALUE is the name of the screen field.




at selection-screen on value-request for p_value.

Call function 'Z_GROUP_SELECT_ZFINCOKOH1_B'
     .....
        .....
            ....

p_value = value_from_FM.
 


REgards,

Rich Heilman

Read only

0 Likes
1,118

Or you may have to do a DYNP_VALUES_UPDATE as well to update the field on the screen.

REgards,

Rich Heilman

Read only

0 Likes
1,118

Carlos, Please see the following program. It is working well in my system. The only difference is that I've implemented you function module as a subroutine instead of in a FM. You can see that it will return the selected value back to the screen field.



report zrich_0002 .


data: setname type setheader-setname.

parameters: p_val type setheader-setname.


data: dynfields type table of dynpread with header line.
data: return type table of ddshretval with header line.

at selection-screen on value-request for p_val.

  perform f4_help.

  p_val = setname.

start-of-selection.


*---------------------------------------------------------------------*
*       FORM f4_help                                                  *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form f4_help.
  constants: class  type setclass value '0103',
             field_name    type rgsbs-field  value '*',
             kokrs  type tka01-kokrs  value 'BPPR',
             ktopl  type  tka01-ktopl value 'CAPI'.

  call function 'K_GROUP_SELECT'
       exporting
            buttons            = 'X'
            class              = class
            cruser             = '*'
            field_name         = field_name
            searchfld          = '    '
            searchfld_input    = 'X'
            searchfld_required = 'X'
            set                = '*'
            start_column       = 10
            start_row          = 5
            table              = 'CCSS'
            typelist           = 'BS'
            upduser            = '*'
            kokrs              = kokrs
            ktopl              = ktopl
       importing
            set_name           = setname
       exceptions
            no_set_picked      = 1
            others             = 2.

endform.

REgards,

Rich HEilman