cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Customizing Tables (SM30); Allow Wildcard (*) Field-Input but still with foreign checks

master1980
Explorer
0 Kudos

Hello,

when we have a Customizing-Table, we want the user to enter only allowed values. To achieve this, we define Foreign-Key-Checks in SE11. Excample:

WERKS
LGORT
MY_Z_FIELD

We define a Foreign-Key to Table T001L(Storage-Locations). Very often the Customers want to allow Wildcard-Input (*) like this:

WERKS LGORT MY_Z_FIELD

1000     1000    A

1000     *          B

*            *         C

In ABAP we implement a FALLBACK-LOGIC:

  • Read an entry with KEY 1000/1000
  • if not found READ an Entry 1000/*
  • if not found READ an Entry */*

To do so, we must not definie Foreign-Key's because the Plant * neither the Storage-Location * exist. This has several drawbacks....To create a Plant/Stor-Loc * in the Foreign Tables is not a good solution(....) Lets imagine we have 100 Plants with 100 Storage-Locations each. In this case we would have to create 101 new entries in T001L, all with a description *****DO NOT USE*****

Has someone delt with this Problem before and can offer a simple solution?

 

 

 

 

Accepted Solutions (1)

Accepted Solutions (1)

DominikTylczyn
Active Contributor
0 Kudos

Hello @master1980 

That can't be done with foreign key definition only. You'd need to implement a custom check in SM30. See how it is done for instance in the LE-WM view V_T321 for the field LGNUM. It allows *** entry, which of course is not a valid warehouse number:

DominikTylczyn_0-1714642692321.png

The foreign key and screen check are defined for V_T321-LGNUM:

DominikTylczyn_1-1714642793189.png

However the foreign key check is deactivated in Screen Painter:

DominikTylczyn_2-1714642883490.png

That allows to put any value in the LGNUM (warehouse number) field. That is not what we need yet, as we want to validate if the LGNUM value is either a valid warehouse number or *** mask.

Then a check is implemented in the flow logic in V_T321_CHECK module:

PROCESS AFTER INPUT.
 MODULE LISTE_EXIT_COMMAND AT EXIT-COMMAND.
 MODULE LISTE_BEFORE_LOOP.
 LOOP AT EXTRACT.
   MODULE LISTE_INIT_WORKAREA.
   CHAIN.
    FIELD V_T321-LGNUM.
    FIELD V_T321-RBLVS.
    FIELD V_T321-BSLVS.
    FIELD V_T321-KZBEW.
    FIELD V_T321-SOBKZ.
    FIELD V_T321-BSSKZ.
    FIELD V_T321-LGREF.
    FIELD V_T321-BWLVS.
*   field v_t321-bestq.
*   field v_t321-bstqa.
*   field v_t321-bstqe.
    FIELD V_T321-TBFKZ.
    FIELD V_T321-UBFKZ.
    FIELD V_T321-TAFKZ.
    FIELD V_T321-MAILK.
    FIELD V_T321-WEDKZ.
    FIELD V_T321-WENUM.
    FIELD V_T321-KUNWE.
    FIELD V_T321-LFART.
    FIELD V_T321-LIFNR.
    MODULE V_T321_CHECK ON CHAIN-REQUEST.
    MODULE SET_UPDATE_FLAG ON CHAIN-REQUEST.
   ENDCHAIN.
   FIELD VIM_MARKED MODULE LISTE_MARK_CHECKBOX.
   CHAIN.
    FIELD V_T321-LGNUM.
    FIELD V_T321-RBLVS.
    FIELD V_T321-BSLVS.
    FIELD V_T321-KZBEW.
    FIELD V_T321-SOBKZ.
    FIELD V_T321-BSSKZ.
    MODULE LISTE_UPDATE_LISTE.
   ENDCHAIN.
 ENDLOOP.
MODULE V_T321_CHECK.

*........Lagernummer  prüfen ( Tabelle T300 )...........................
  IF NOT V_T321-LGNUM IS INITIAL AND V_T321-LGNUM <> MASK3.
    PERFORM T300_LESEN USING V_T321-LGNUM.
    IF SY-SUBRC NE 0.
      MESSAGE E001 WITH V_T321-LGNUM.
    ENDIF.
  ENDIF.

I think you can use a similar approach to implement your requirements.

Best regards

Dominik Tylczynski

 

Answers (2)

Answers (2)

master1980
Explorer
0 Kudos

This is a good point, thank you. But It want the system to check the foreign Key's (error Message) with the Exception of (*). The User must  inpu either an existing Value of the check Table or (*).

 

Sandra_Rossi
Active Contributor
0 Kudos
Then create your own custom ABAP check.
Sandra_Rossi
Active Contributor
0 Kudos

There's no screen check of the entered value if you unselect "Check required":

Sandra_Rossi_0-1714638852958.png

The value help will still be available.

DominikTylczyn
Active Contributor
0 Kudos
Those are data dictionary details, that are copied to screen painter, where they can modified further.