How to Create a Variant for a Transaction Using SHD0?

How to Create a Variant for a Transaction Using SHD0?

How to Create a Variant for a Transaction Using SHD0?

Clarification of the Question

In one of my earlier posts, I described the steps required to hide a field in a transaction. The mechanism that allows this is well known to many consultants. Let me remind you that this mechanism is the SHD0 transaction.

See the article: SHD0 to the Rescue, or How to Quickly Hide a Field in a Transaction

In this post, I’d like to outline the steps needed to implement the following requirement:

  • Split access to certain fields of the same infotype between two user groups who share the same authorization level. In other words, some fields should be available to one group of users, while different fields should be available to the other.

Initial Data

The transaction in use is PA30. The specific infotype isn’t critical, but in this example, I’ll use a Personnel Administration infotype. A good example would be Infotype 0002 – “Personal Data”.

The Task: Segregation of Access

We’ll define the requirement for access control as follows:

  • The Mar. Status field of Infotype 0002 “Personal Data” must be read-only (non-editable);
  • The Valid From Date of Current Marital Status field of Infotype 0002 “Personal Data” must be hidden.

Solution

To achieve this, several steps must be performed sequentially, as described below. In brief:

  1. Create a separate transaction for the user group that requires different field access;
  2. Create a screen variant, configure the field visibility, and assign this screen variant to the newly created transaction variant;
  3. Create a transaction variant, assigning it the screen variant where the required visibility rules are defined;
  4. Create a custom role, include the new transaction in it, and assign this role to the users;
  5. Test the result.

1. Creating a New Transaction

Since the base transaction is PA30, we’ll use it as the foundation and copy it to a new transaction. This can be done using transaction SE93.

0:00
/0:38

In table T588A, copy the existing entry for transaction PA30 to the new one, and try launching the newly created transaction.

0:00
/0:27

The transaction launches successfully. Proceed to the next step.

2. Creating a Variant for the New Transaction

Now, create a variant for the new transaction where the field access levels for the infotype will be defined. As mentioned, I need to change access for the fields "Mar. Status" and "Valid From Date of Current Marital Status".
This is done via transaction SHD0.

In the Transaction Code field, enter the name of the new transaction (see Step 1).

2.1 Creating a Screen Variant

Under the "Screen Variants" tab, create a screen variant to be used for Infotype 0002. In this variant, define the desired display rules for the fields.
All you need to know is the relevant module pool and screen number (you can find this via System → Status on the infotype editing screen).

The following video fragment outlines the steps needed to create the screen variant.

0:00
/0:52

The screen variant is now created. No changes will be visible yet.

2.2 Assigning the Screen Variant to the Transaction Variant

Now assign the created screen variant to the transaction variant, and activate the transaction variant afterward.

0:00
/0:21

2.3 Testing

The testing scenario is straightforward:

  • Launch PA30, select a personnel number, open Infotype 0002 for editing, and verify that the specified fields appear as usual.
0:00
/0:08
  • Then launch the new transaction (e.g., ZPA30) and perform the exact same steps.
0:00
/0:19

The difference should be clear — meaning the task has been successfully completed.