abap 增强查找小程序
*&---------------------------------------------------------------------*
*& Report ZEXIT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZEXIT_LZX.
TABLES: TSTC , "SAPTransaction Codes
TADIR , " Directory of Repository Objects
MODSAPT , " SAP Enhancements - Short Texts
SXS_ATTRT, " SAPBADI- short text
MODACT , " Modifications
TRDIR , " System table TRDIR
TFDIR , " Function Module
ENLFDIR , " Additional Attributes for Function Modules
TSTCT . " Transaction Code Texts
*&---------------------------------------------------------------------*
*& Variables
*&---------------------------------------------------------------------*
DATA: JTAB LIKE TADIR OCCURS 0 WITH HEADER LINE.
DATA: FIELD1(30).
DATA: V_DEVCLASS LIKE TADIR-DEVCLASS.
DATA: OBJECT LIKE TADIR-OBJECT.
DATA: BDCDATA_WA TYPE BDCDATA,
BDCDATA_TAB TYPE TABLE OF BDCDATA.
DATA: OPT TYPE CTU_PARAMS.
DATA: L_NAME LIKE MODSAP-NAME,
L_MEMBER LIKE MODSAP-MEMBER,
L_STEXT LIKE TFTIT-STEXT.
*&---------------------------------------------------------------------*
*& Selection Screen Parameters
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK A01 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN SKIP.
PARAMETERS: P_TCODE LIKE TSTC-TCODE OBLIGATORY.
SELECTION-SCREEN SKIP.
PARAMETERS: EXIT RADIOBUTTON GROUP 1 DEFAULT 'X',
BADI RADIOBUTTON GROUP 1.
SELECTION-SCREEN END OF BLOCK A01.
DEFINE BDC_PROGRAM.
CLEAR BDCDATA_WA.
BDCDATA_WA-PROGRAM = &1.
BDCDATA_WA-DYNPRO = &2.
BDCDATA_WA-DYNBEGIN = &3.
APPEND BDCDATA_WA TO BDCDATA_TAB.
END-OF-DEFINITION.
DEFINE BDC_DETAIL.
CLEAR BDCDATA_WA.
BDCDATA_WA-FNAM = &1.
BDCDATA_WA-FVAL = &2.
APPEND BDCDATA_WA TO BDCDATA_TAB.
END-OF-DEFINITION.
*&---------------------------------------------------------------------*
*& Start of main program
*&---------------------------------------------------------------------*
START-OF-SELECTION.
IF EXIT = 'X'.
OBJECT = 'SMOD'. " User-exit!
ELSE.
OBJECT = 'SXSD'. " BADI!
ENDIF.
* Validate Transaction Code:
SELECT SINGLE * FROM TSTC WHERE TCODE EQ P_TCODE.
* Find Repository Objects for transaction code:
IF SY-SUBRC EQ 0. " IF 1
SELECT SINGLE * FROM TADIR WHERE PGMID = 'R3TR'
AND OBJECT = 'PROG'
AND OBJ_NAME = TSTC-PGMNA. " Program name!
* 找到事务代码开发类
MOVE: TADIR-DEVCLASS TO V_DEVCLASS. " Package
IF SY-SUBRC NE 0.
SELECT SINGLE * FROM TRDIR WHERE NAME = TSTC-PGMNA.
IF TRDIR-SUBC EQ 'F'.
SELECT SINGLE * FROM TFDIR WHERE PNAME = TSTC-PGMNA.
SELECT SINGLE * FROM ENLFDIR WHERE FUNCNAME = TFDIR