SAP ABAP - Sample Report Program Used To Find BAPI's.

This is a sample report program for searching BAPI's.

This Report Program will search for all the remote or local BAPI, based on the description text.

Say for example, If we require customer related or sales related BAPI'S, then we need to put sales or customer in the description fieldand it will display the list of the related BAPI's.


SAMPLE PROGRAM:


REPORT ztest_find_bapi.

TYPES : BEGIN OF ty_tfdir,
funcname TYPE rs38l_fnam,
END OF ty_tfdir.

TYPES : BEGIN OF ty_tftit,
funcname TYPE rs38l_fnam,
stext TYPE rs38l_ftxt,
END OF ty_tftit.

DATA : it_tfdir TYPE STANDARD TABLE OF ty_tfdir,
wa_tfdir TYPE ty_tfdir,
it_tftit TYPE STANDARD TABLE OF ty_tftit,
wa_tftit TYPE ty_tftit.

DATA : ws_bapi TYPE char4, chk TYPE char1, field1(30).
DATA : ws_lines TYPE i.


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: appl_typ TYPE rs38l_appl,
fmode TYPE fmode DEFAULT 'R',
desc_txt TYPE char30 OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.
PERFORM select_fmname.
PERFORM process_table.
PERFORM no_of_records.
PERFORM top_of_page.
PERFORM write_fname.

AT LINE-SELECTION.
PERFORM call_function_module.
*&---------------------------------------------------------------------*
* & Form SELECT_FMNAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM select_fmname .

SELECT funcname FROM tfdir INTO TABLE it_tfdir
WHERE ( appl = appl_typ OR fmode = fmode ).

IF sy-subrc = 0.

SELECT funcname stext FROM tftit INTO TABLE it_tftit
FOR ALL ENTRIES IN it_tfdir
WHERE funcname = it_tfdir-funcname AND spras = sy-langu.
ENDIF.
ENDFORM. "select_fmname


*&---------------------------------------------------------------------*
* & Form process_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM process_table .

LOOP AT it_tftit INTO wa_tftit.
ws_bapi = wa_tftit-funcname+0(4).

IF ws_bapi NE 'BAPI'.
DELETE TABLE it_tftit FROM wa_tftit.
CLEAR wa_tftit.
CLEAR ws_bapi.
CONTINUE.
ENDIF.

IF NOT desc_txt IS INITIAL.
SEARCH wa_tftit-stext FOR desc_txt.

IF sy-subrc NE 0.
DELETE TABLE it_tftit FROM wa_tftit.
CLEAR : wa_tftit.
CONTINUE.
ENDIF.

ENDIF.

ENDLOOP.
ENDFORM. " process_table

*&---------------------------------------------------------------------*
* & FORM NO_OF_RECORDS
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*

FORM no_of_records .
DESCRIBE TABLE it_tftit LINES ws_lines.
FORMAT COLOR COL_POSITIVE INTENSIFIED ON.
WRITE :/5 'No of BAPI Selected for GIVEN APPLICATION TYPE IS-',ws_lines.
ENDFORM. " NO_OF_RECORDS


*&---------------------------------------------------------------------*
* & FORM TOP_OF_PAGE
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*

FORM top_of_page .
WRITE :/1(125) sy-uline. FORMAT COLOR COL_HEADING
INTENSIFIED ON.
WRITE:/1 '|', 2(3) 'SNO', 6 '|' , 7(35) 'BAPI FUNCTION MODULE',
43 '|', 44(80) 'FUNCTION MODULE DESCRIPTION', 125 '|'.
WRITE :/1(125) sy-uline.
ENDFORM. " top_of_page


*&---------------------------------------------------------------------*
* & FORM WRITE_FNAME
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*

FORM write_fname .
DATA: loc_sl TYPE i VALUE '0'.
LOOP AT it_tftit INTO wa_tftit.
loc_sl = loc_sl + 1. FORMAT COLOR COL_GROUP INTENSIFIED OFF.

WRITE :/1(125) sy-uline. WRITE:/1 '|', 2(3) loc_sl, "CHK AS CHECKBOX, 6
'|' , 7(35) wa_tftit-funcname HOTSPOT ON, 43 '|', 44(80) wa_tftit-stext,
125 '|'.

ENDLOOP.
ENDFORM. " WRITE_FNAME


*&---------------------------------------------------------------------*
* & FORM CALL_FUNCTION_MODULE
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*

FORM call_function_module .
DATA: ws_fname TYPE tfdir-funcname.
GET CURSOR FIELD field1.
CHECK field1(17) EQ 'WA_TFTIT-FUNCNAME'.
READ TABLE it_tftit INTO wa_tftit WITH KEY funcname = sy-lisel+6(30).
MOVE wa_tftit-funcname TO ws_fname.
SET PARAMETER ID 'LIB' FIELD ws_fname.

CALL TRANSACTION 'SE37' AND SKIP FIRST SCREEN.
ENDFORM. "CALL_FUNCTION_MODULE

************************END********************************************

SELECTION SCREEN:









OUTPUT:





















Your suggestions and comments are welcome in this section.

Please mail all your contributions to administrator@abapmadeeasy.com We request you to mention your Name, Designation, Experience & Organization you are working for. Your posts will be verified and posted in this site with your name.