Skip to Content

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.

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. 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.

    (0) 
  2. Vishwasi Vasishta

    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.

    (0) 
  3. Karl Rockwell

    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.

    (0) 

Leave a Reply