Tip

Finding transaction codes

Perhaps you know some keywords about a transaction, but not the transaction code? You probably know about SEARCH_SAP_MENU, which helps you see the path in the menu tree. This transaction code is very useful but it would be better if it was possible to directly run the transactions that has been found. We can achieve this with modification of ABAP program SS_SEME. In SE80 or SE38, make a copy of SS_SEME to ZSS_SEME (also copy user interface and screen). Modify the source code of the new report ZSS_SEME with the following code.

You can copy and paste the code into the original code or change the lines marked between the comment flags ("*--").

After activation, we can make new transaction codes for the new report (via SE93), for example ZSEARCH_SAP_MENU.
The code was written in R/3 4.6C.
*----------------------------------------------------------------------*
*                  REPORT SSM_SEME                                     *
*----------------------------------------------------------------------*
*   advanced search_sap_menu, based on SSM_SEME
*----------------------------------------------------------------------*
REPORT  zSSM_SEME.

DATA: SWITCH TYPE C.
DATA: I_SMENSAPNEW LIKE SMENSAPNEW OCCURS 0 WITH HEADER LINE.
DATA: I_SMENSAPT LIKE SMENSAPT OCCURS 0 WITH HEADER LINE.
DATA: LIN LIKE SY-TABIX.
DATA: TEXT(80) TYPE C.
DATA: TEXT_UPPER_CASE(80) TYPE C.

data: type like SMENSAPNEW-CUSTOMIZED value 'S'.

*data for hotspot position:
DATA: f(10)

    Requires Free Membership to View

TYPE c, off TYPE i, len TYPE i, val(40) TYPE c. * lin TYPE i. PERFORM ASK_FOR_TEXT USING TEXT. IF TEXT = SPACE. EXIT. ENDIF. TEXT_UPPER_CASE = TEXT. TRANSLATE TEXT_UPPER_CASE TO UPPER CASE. select * from smensapnew into table i_smensapnew. select * from smensapt into table i_smensapt where spras = sy-langu. DESCRIBE TABLE I_SMENSAPNEW LINES LIN. IF LIN = 0. MESSAGE S265(SF). ENDIF. SORT I_SMENSAPT BY OBJECT_ID. SORT I_SMENSAPNEW BY OBJECT_ID. LOOP AT I_SMENSAPNEW. CLEAR SWITCH. IF I_SMENSAPNEW-REPORT = TEXT OR I_SMENSAPNEW-REPORT = TEXT_UPPER_CASE. SWITCH = 'X'. ENDIF. READ TABLE I_SMENSAPT WITH KEY OBJECT_ID = I_SMENSAPNEW-OBJECT_ID BINARY SEARCH. IF SY-SUBRC NE 0. I_SMENSAPT-TEXT = '???'. ENDIF. SEARCH I_SMENSAPT-TEXT FOR TEXT. IF SY-SUBRC = 0. SWITCH = 'X'. ENDIF. IF SWITCH = ' '. CONTINUE. EXIT. ENDIF. READ TABLE I_SMENSAPT WITH KEY OBJECT_ID = I_SMENSAPNEW-OBJECT_ID BINARY SEARCH. IF SY-SUBRC NE 0. I_SMENSAPT-TEXT = '???'. ENDIF. * output is HERE, added hotspot on transaction code: WRITE: / TEXT-016. IF I_SMENSAPNEW-REPORT(20) <> ''. WRITE: AT 20 I_SMENSAPNEW-REPORT(20) HOTSPOT ON. ENDIF. WRITE: AT 40 I_SMENSAPT-TEXT(40). FORMAT INTENSIFIED OFF. DO. READ TABLE I_SMENSAPNEW WITH KEY OBJECT_ID = I_SMENSAPNEW-PARENT_ID BINARY SEARCH. IF SY-SUBRC NE 0. EXIT. ENDIF. IF SY-SUBRC EQ 0. READ TABLE I_SMENSAPT WITH KEY OBJECT_ID = I_SMENSAPNEW-OBJECT_ID BINARY SEARCH. ELSE. I_SMENSAPT-TEXT = '???'. ENDIF. IF I_SMENSAPNEW-REPORTTYPE = SPACE. CLEAR I_SMENSAPNEW-REPORT. ENDIF. * output is HERE, added hotspot on transaction code: WRITE: / TEXT-016. IF I_SMENSAPNEW-REPORT(20) <> ''. WRITE: AT 20 I_SMENSAPNEW-REPORT(20) HOTSPOT ON. ENDIF. WRITE: AT 40 I_SMENSAPT-TEXT(40). ENDDO. FORMAT INTENSIFIED ON. ULINE. ENDLOOP. WRITE: /. * Single click AT LINE-SELECTION. GET CURSOR FIELD f OFFSET off LINE lin VALUE val LENGTH len. IF val <> ''. CALL TRANSACTION val. ENDIF. *&---------------------------------------------------------------------* *& Form ASK_FOR_TEXT *&---------------------------------------------------------------------* FORM ASK_FOR_TEXT USING P_TEXT. DATA: I_SVAL LIKE SVAL OCCURS 0 WITH HEADER LINE. DATA: RETURNCODE TYPE C. CLEAR I_SVAL. REFRESH I_SVAL. I_SVAL-TABNAME = 'SMENSAPNEW'. I_SVAL-FIELDNAME = 'PAR_MENU'. I_SVAL-FIELD_OBL = 'X'. I_SVAL-FIELDTEXT = TEXT-017. I_SVAL-NOVALUEHLP = 'X'. APPEND I_SVAL. CALL FUNCTION 'POPUP_GET_VALUES' EXPORTING POPUP_TITLE = TEXT-026 IMPORTING RETURNCODE = RETURNCODE TABLES FIELDS = I_SVAL EXCEPTIONS ERROR_IN_FIELDS = 1 OTHERS = 2. CHECK RETURNCODE EQ SPACE. READ TABLE I_SVAL INDEX 1. P_TEXT = I_SVAL-VALUE(60). ENDFORM. " ASK_FOR_TEXT

This was first published in November 2003

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.