How to Hide Unused Subtypes of an SAP Infotype?

How to Hide Unused Subtypes of an SAP Infotype?

How much time do you spend working with PA20/PA30 transactions during your workday? And how much time specifically working with infotype subtypes in those same transactions? If the honest answer is “quite often,” then you’re probably a seasoned consultant (though what’s the connection?). And most likely, you already know how to quickly select the required subtypes without wasting too much time. Or, even simpler—you’ve memorized the numbers of the needed subtypes.

Let’s direct the same question to business users. The answers may vary. But most likely, there will be a group of users who are clearly unhappy with the large number of entries in the dropdown list, which is “just too inconvenient to work with.” If such complaints start surfacing among your target group, be prepared: soon you’ll be asked to shorten the list of subtypes for a certain infotype—because “it’s too annoying to find the right one, and I can’t remember them all.” So, how do we hide unused subtypes of an infotype?

An example of what might irritate business users

Open transaction PA20/PA30 and select, say, infotype 0057, followed by opening its subtypes.

0:00
/0:15

The Task

Let’s assume there’s a group of users who do not want to see all subtypes of this infotype. One particularly proactive user insists that you restrict the list to only three subtypes. Other users are fine with seeing the full list.

Solving the Task

First, define the user group—more precisely, determine how to distinguish them. One way to do this is by using SPA/GPA parameters.

See note: SPA/GPA parameters in ABAP

For demonstration, I’ll create an SPA parameter called ZIT0057. Create the new parameter in transaction SE80:

Assign this parameter to users via transaction SU3:

Note: The approach to segmenting users suggested here isn’t ideal. A more elegant and correct way to control subtype visibility is by checking authorization values in the P_ORGIN or P_ORGXX objects (if your processes use the latter).

Now, create an implementation for the BAdI HR_F4_GET_SUBTYPE in transaction SE18:

For the new implementation, set a filter value corresponding to the infotype for which this logic applies.

N.B. Only one implementation of the BAdI HR_F4_GET_SUBTYPE is allowed per infotype. If you encounter activation issues, check whether another implementation already exists for the same infotype.

From here on, it’s straightforward. In my simple example, the logic might look like this:

DATA: wa_subty       TYPE subty,
          wa_moabw       TYPE subty,
          wa_stext       TYPE sbttx,
          wa_value_tab   LIKE LINE OF value_tab,
          wa_help_fields LIKE LINE OF help_fields,
          lv_param       TYPE c.
 
    retfield = 'SUBTY'.
 
    CLEAR wa_help_fields.
    REFRESH help_fields.
    wa_help_fields-tabname    = 'T591A'.
    wa_help_fields-fieldname  = 'SUBTY'.
    APPEND wa_help_fields TO help_fields.
 
    wa_help_fields-tabname    = 'T591S'.
    wa_help_fields-fieldname  = 'STEXT'.
    APPEND wa_help_fields TO help_fields.
 
    GET PARAMETER ID 'ZIT0057' FIELD lv_param.
 
    IF lv_param EQ abap_true.
 
      SELECT  subty
      INTO wa_subty
      FROM  t591a
          WHERE  infty = flt_val.
 
        IF ( wa_subty = '1' OR wa_subty = '2' OR wa_subty = '3' ).
          APPEND wa_subty TO value_tab.
          SELECT stext FROM t591s INTO wa_stext WHERE infty = flt_val AND subty = wa_subty AND sprsl = sy-langu.
 
            APPEND wa_stext TO value_tab.
          ENDSELECT.
        ENDIF.
 
 
      ENDSELECT.
    ENDIF.
 
    IF lv_param NE abap_true.
 
      SELECT  subty
      INTO wa_subty
      FROM  t591a
          WHERE  infty = flt_val.
 
        APPEND wa_subty TO value_tab.
        SELECT stext FROM t591s INTO wa_stext WHERE infty = flt_val AND subty = wa_subty AND sprsl = sy-langu.
 
          APPEND wa_stext TO value_tab.
        ENDSELECT.
      ENDSELECT.
 
    ENDIF.

You can refer to standard SAP implementations of this BAdI to see similar examples of this code.

Testing

Test Scenarios:

  • Open subtypes of infotype 0057 as a user who has the ZIT0057 parameter set to “X” in their user settings;
  • Change the value of the ZIT0057 parameter and reopen the subtypes of infotype 0057 as the same user;
  • Completely remove the ZIT0057 parameter from the user master record and then open the subtypes of infotype 0057 again.
0:00
/2:17

That’s it. Please enjoy your day!