Home > SAP software/management Tips > SAP ABAP/Java developer tips > Finding transaction codes
SAP Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

SAP ABAP/JAVA DEVELOPER TIPS

Finding transaction codes


Martin Maruskin
11.21.2003
Rating: -3.62- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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.

Code

*----------------------------------------------------------------------*
*                  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)         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

Rate this Tip
To rate tips, you must be a member of SearchSAP.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
SAP ABAP/Java developer tips
How to do additional dialog processing after SAP COMMIT WORK statement
How to find a piece of SAP ABAP code without debugging
How to read an SAP transaction in an ABAP code
How to provide an SAP R/3 4.5B application server with a Web service interface
How to find owners and transports of deleted ABAP programs
Fixing a common OPEN_FORM and START_FORM error in SAPscript
Select Text fields: Case-insensitive
Is this the quickest way to find a BADI?
Easily debug error messages in SAP processes
Accessing private attributes in ABAP Objects

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

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.



NetWeaver SAP White Papers
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
SearchSAP.com is a search service provided by TechTarget and is completely
independent of and not affiliated with SAP AG.
  TechTarget - The IT Media ROI Experts