Skip to Content
Author's profile photo Former Member

Use a standard search help for characteristic values

Introduction

As we use variant configuration in creative ways, we sometimes want to restrict characteristic values to those maintained in another table (not a variant table). SAP provides a mechanism in CT04 to use a function module to derive the possible values. ScreenHunter_04 Dec. 07 17.51.gif This requires coding the select statements and output displays. This is a bit cumbersome to maintaine and repeat. With the below solution, you can create a search help with SE10 and then easily adapt this function module to use that search help. Maintenance of the search help is easy, and it is easy to create new ones with very little ABAP.

ScreenHunter_05 Dec. 07 18.07.gif

Implementation

This is an example using company code. The blue fields should be changed for your purposes.

   FUNCTION Z_BUKRS_CHECK_F4.
*”———————————————————————-
*”*”Local Interface:
*”  IMPORTING
*”     VALUE(CHARACT_NO) LIKE  CABN-ATINN
*”     VALUE(CHARACT) LIKE  CABN-ATNAM
*”     VALUE(DISPLAY) LIKE  RMCLF-KREUZ DEFAULT SPACE
*”     VALUE(ADDITIONAL_VALUES) LIKE  CABN-ATSON DEFAULT SPACE
*”     VALUE(MULTIPLE_VALUES) LIKE  RCTMV-ATLIS DEFAULT SPACE
*”     VALUE(LANGUAGE) LIKE  SY-LANGU DEFAULT SY-LANGU
*”     VALUE(DISPLAY_WITH_LANGUAGE) LIKE  RMCLF-KREUZ DEFAULT SPACE
*”  TABLES
*”      VALUES STRUCTURE  RCTVALUES
*”  EXCEPTIONS
*”      CANCELLED_BY_USER
*”———————————————————————-

*This function is used in a characteristic to provide an F4 search using a common search help.
*Fill the first three constants as instructed and as needed for the specific characteristic.
*Note that a function without the ‘_F4’ is created for the check and entered in the characteristic.
*Read the help documentation on the characteristic function field for full explanation.
* data definition ——————————————————

  CONSTANTSc_SHLPNAME TYPE SHLPNAME VALUE ‘PCA_SHLP_BUKRS’,
              c_shlpfield TYPE DDSHLPSFLD VALUE ‘BUKRS’,
               c_conv_routine TYPE RS38L_FNAM VALUE ,
              c_multi TYPE c VALUE ‘X’, “Set if multivalue characteristic
              del(1) TYPE c VALUE ‘D’,
              ins(1) TYPE c VALUE ‘I’.
  DATAindx TYPE i,
        rc TYPE sysubrc,
        return_tab TYPE TABLE OF DDSHRETVAL,
        shlp TYPE SHLP_DESCR.
  FIELDSYMBOLS: <int> TYPE ddshiface,
                 <ret> TYPE DDSHRETVAL.

* Get search help data container.
  CALL FUNCTION ‘F4IF_GET_SHLP_DESCR’
    EXPORTING
      SHLPNAME = c_SHLPNAME “Enter the Search help name here
      SHLPTYPE = ‘SH’
    IMPORTING
      SHLP     = shlp.

* Mark the relevant field to be returned.
  LOOP AT shlpinterface ASSIGNING <int>
        WHERE shlpfield = c_shlpfield. “Enter the field to be exported.
    <int>valfield = ‘X’.
  ENDLOOP.

* Call the search help dialogue.
  CALL FUNCTION ‘F4IF_START_VALUE_REQUEST’
    EXPORTING
      SHLP          = shlp
      MAXRECORDS    = 500
      MULTISEL      = c_multi
    IMPORTING
      RC            = rc
    TABLES
      RETURN_VALUES = return_tab.

** Remove any old selected values
*  LOOP AT values.
*    indx = sy-tabix.
*    READ TABLE return_tab WITH KEY fieldval(30) = values-value ASSIGNING <ret>.
*    IF sy-subrc <> 0.
*      values-status = del.
*      MODIFY values INDEX indx.
*    ENDIF.
*  ENDLOOP.

* Add the new values.
  LOOP AT return_tab ASSIGNING <ret>.
    IF c_conv_routine IS NOT INITIAL.
      CALL FUNCTION c_conv_routine
        EXPORTING
          input     = <ret>fieldval(30)
        IMPORTING
          OUTPUT    = valuesvalue
        EXCEPTIONS
          NOT_FOUND = 1
          OTHERS    = 2.
    ELSE.
      valuesvalue = <ret>fieldval(30).
    ENDIF.
    valuesstatus = ins.
    APPEND values.
  ENDLOOP.
ENDFUNCTION.

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Ritesh Dube
      Ritesh Dube

      Nice document Karl Rockwell, it will be more informative and usefull , if you attach a example with screen shot.

      Thanks for sharing it.

      Ritesh

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Now with pictures

      Author's profile photo Luisa Noscal
      Luisa Noscal

      Hi, Karl.

      We're on SAP ERP 6.0 EHP7. I have implemented similar solution, that is, to use check fm instead of check table. This is due to table like QPMK is not supported because it has too many key fields.

      My *_F4 fm (that calls the search help QPMK) for the characteristic works on GUI side:

      Shelp for charval - GUI.jpg

      However, it errors on WebUI side for the same characteristic:

      Shelp for charval - WUI.jpg

      Have you encountered or are you aware of this issue? Any help on how to resolve this?

      By the way, I also found your reply on the same topic in this thread:

      F4 Help for Characteristics

      Thanks in advance.

      Author's profile photo Former Member
      Former Member

      Hi,

      I have the same issue as Luisa. If anyone has a solution, please post here.

      Thanks in advance.

      Author's profile photo Former Member
      Former Member

      Hi, Karl.

      We're on SAP ERP 6.0 EHP7. I have implemented similar solution, that is, to use check fm instead of check table. This is due to table like QPMK is not supported because it has too many key fields.

      My *_F4 fm (that calls the search help QPMK) for the characteristic works on GUI side:

      Shelp for charval - GUI.jpg

      However, it errors on WebUI side for the same characteristic:

      Shelp for charval - WUI.jpg

      Have you encountered or are you aware of this issue? Any help on how to resolve this?

      Thanks in advance.

      Author's profile photo Former Member
      Former Member

      This example only works in SAPGUI. If you are using web dynpro, you need to fill the values table using an alternate selection and code.

      Condition the above search help code with:

      if cl_web_dynpro=>is_active is initial.

      *use search help code.

      else.

      * select your data into values table.

      endif.
      .

      If I was able to copy and paste or attach, I would give you code sample.

      Author's profile photo Former Member
      Former Member

      Yes, I did the same and it worked. I posted my response on the thread F4 Help with Custom FM works on GUI and fails on WEBUI.

      Could you take a look at this thread PLM WebUI: Linking custom screen or report to the Additional functions drop down menu and let me know if you have anything helpful.

      Thanks in advance.

      Author's profile photo Sergiu Iatco
      Sergiu Iatco

      Useful functions to understand passed in and out data.
      CALL FUNCTION FUNCTION_F4 is called from function CTHE_FUNCTION_F4.
      CALL FUNCTION FUNCTION is called from function CTHE_FUNCTION_VALUE_EXISTS.
      CALL FUNCTION FUNCTION_DCR IS called from function CTHE_FUNCTION_DESCR

      Useful functions to extract values characteristics from saved data in sales order:
      VC_I_GET_CONFIGURATION
      VC_I_GET_CONFIGURATION_IBASE

      Question.
      How to get at runtime actual sales order characteristics values in functions Z_BUKRS_CHECK_F4 and Z_BUKRS_CHECK for additional checks?

      Author's profile photo Sergiu Iatco
      Sergiu Iatco

      I found an usefull tip on how to get characteristics values on blog Variant Function with PFUNCTION & FUNCTION call.

      Author's profile photo Sergiu Iatco
      Sergiu Iatco

      Functions for debugging.

      *INCLUDE LCTHEUXX.
      *****************************************************************
      *   THIS FILE IS GENERATED BY THE FUNCTION LIBRARY.             *
      *   NEVER CHANGE IT MANUALLY, PLEASE!                           *
      *****************************************************************
      INCLUDE LCTHEU01.   "CTHE_SELECT_DATATYPE
      INCLUDE LCTHEU02.   "CTHE_CHECK_TABLE_F4
      INCLUDE LCTHEU03.   "CTHE_FUNCTION_VALUE_EXISTS
      INCLUDE LCTHEU04.   "CTHE_FUNCTION_F4
      INCLUDE LCTHEU06.   "CTHE_CHECK_TABLE_VALUE_EXISTS
      INCLUDE LCTHEU09.   "CTHE_VALUE_F4
      INCLUDE LCTHEU10.   "CTHE_FUNCTION_DESCR
      INCLUDE LCTHEU07.   "CTHE_CHARACT_VALUE_F4
      
      Author's profile photo Sergiu Iatco
      Sergiu Iatco

      In transaction CT04, tab Values, button Other Value Check, button Function Module, field Function, press F1 and documentation pop-up.

      At the end of documentation you will find following:

      Note

      Please note that the program code must be based on the predefined interfaces. If your program is not based on these interfaces, the program may terminate with a short dump.

      Please note also that the function module cannot take into account any restrictions on allowed values that are due to inheritance or object dependencies, because the function can only read data that is already saved to database tables. The function cannot read current user entries.

      Notice the bold text, that means you can not use values of characteristics when you enter data dynamically let's assume that for sales order in transactions VA01 and VA02.

      To solve the problem and access dynamically values of other characteristics you may create a function for dependency with transaction CU65 with input characteristics you need to access for further processing. In function include code to EXPORT characteristics values to a MEMORY ID and then you can IMPORT values from MEMORY ID in functions <function module for value check> + suffix "_F4 and <function module for value check> + suffix "_DC"  for further processing.

      I provided a snippet code for MEMORY ID in comments of the blog Variant Functions with an example.