Execute a pre-determined Transaction Code after User Logs in.
Your client will not always come to you complaining about the performance of some custom report (read HANA implementation) or come with a requirement to build some complex Interface which talks to the non-SAP world without RFCs and Web Services (read OData & UI5 development). Let us assume, there still exist some Clients who come with normal SAP specifications which can be designed using normal SAP ABAP. 🙂
One such request which I recently received was to make specific users execute certain sets of custom programs/t-codes after they log on to SAP GUI.
And each selected users have specific/different custom program to be executed right after logging in. For example, these custom programs are alert/notification programs that inform users about some business.
Let me elaborate a little more.
User_A will be presented with a custom modal program (say ZVOIDED) that will list all void cheques made on the previous days.
Then, User_B will be presented with two programs. First with the ZNOTIF_01 program and a payment notification due for the week (ZNOTIF_02).
You might argue, for such requirement why not “Set Start Transaction“? The SAP standard “Set start transaction” will be of little use for this request and besides, the user has the capability to delete it if it is deemed annoying for them.
To achieve this request, we will use what we know best, i.e. our own Customer Exit (Enhancement Technique). The below t-codes, functions and include would be used.
i) T-Code CMOD
ii) Standard SAP Enhancement SUSR0001 (found from SMOD)
iii) Component/Function Module EXIT_SAPLSUSF_001
iv) Include program ZXUSRU01
v) T-Code SU01
Let us dive a little deeper.
1) Execute CMOD, enter the custom project and click “Create”. Follow the standard transport request.
PS: We assume, you know how to find Customer Exits. If you do not know, please let us know. We would be happy to write something on Enhancement Techniques as well.
Also Read: How to Find BADIs?
2) Enter any short text description and click on “Enhancement assignments” button.
3) Input “SUSR0001” on the Enhancement column and click “Components” button.
4) Double click on the “EXIT_SAPLUSF_001” function exit.
5) Double click the include “ZXUSRU01” and press “ENTER”.
6) But before we start coding on the include “ZXUSRU01”, we will first proceed to SU01 (User profile) to add some identification role for the User.
7) Execute SU01 and input the username. For this project, we decided to use the TELETEX field on the communication method to identify what program/t-codes need to be triggered for the user on log on. Double click “Other communication” button.
8) Select TTX (Teletex). Click OK.
9) It is here on the Maintain Teletex numbers, where we input the transaction code assigned to the certain user. For User_A, input ZVOIDED. And for the User_B, input ZVOIDED and ZNOTIF accordingly. So, User_B will have two rows while User_A just have only 1 row. Whatever entered on TTX will be executed on the Customer-exit we have created.
10) Back on the CMOD t-code, double click on the include “ZXUSRU01” and enter the following code. The logic is simple. Whatever t-code is maintained for the User in the Teletex field, that should be executed in the Customer-Exit for the user (i.e. CALL TRANSACTION “TxCode”).
*& Include ZXUSRU01 *
DATA: t_ttx TYPE TABLE OF BAPIADTTX.
DATA: TxCode(30) TYPE c.
DATA: tab_return TYPE bapiret2 OCCURS 1.
FIELD-SYMBOLS: <fs_ttx> TYPE BAPIADTTX.
Call Function 'BAPI_USER_GET_DETAIL'
username = sy-uname
** address = s_address
return = tab_return
ADDTTX = t_ttx.
IF SY-SUBRC EQ 0.
LOOP AT t_ttx ASSIGNING <fs_ttx>.
TxCode =< fs_ttx>-TELETEX.
IF TxCode IS NOT INITIAL.
CALL TRANSACTION TxCode.
11) Check and activate CMOD project.
12) Test the code by logging as the user. Program(s) will be executed based on the data maintained in his/her profile.
i. Payment Due List Notification.
ii. Voided Cheque Details.
That is it. The requirements from the Clients are need based. And to provide them an innovative solution is the duty of any Developer. We do not need to be on HANA or build Fiori Apps to help our Clients. Sometimes the same age old SAP blue screen with traditional DB and the same ABAP language can be a life saver.
Hope this simple article helps some in need. 🙂
Maraming Salamat! (translated to “Thanks a lot!” in the Filipino Language). 🙂
So…What Do You Think?
Now we want to hear from you.
Do you think you have a better solution?
Whether you like our solution or feel you have something better, in either case, please leave a quick comment below.