Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Badi or Enhancement

Former Member
0 Kudos

hi frnds,

how to know the badi or enhancement for any transaction. i have one program with that program i am able to find the enhancements for any Tcode. but i need to know the answer in the interview point of view.

regards,

balu

3 REPLIES 3

0 Kudos

Hi,

You can check the program for "CL_EXITHANDLER" if this class is used mostly that program will have BADI call for clasic BADI's this is require for new badis search the code for GET BADI or CALL BADI.

Else you can check the program for "ENHANCEMENT". if this returns you some result check if there is any SPOT.

But if the question is to choose between BADI and Enhancement options then I would say BADI since it gives you option of calling more than one implementation.

Regards,

Sesh

.

Peter_Inotai
Active Contributor
0 Kudos

I don't think this would exist....you can have some enhacement from the IMG documentation or the best is to check the OSS notes.

Peter

Former Member
0 Kudos

hI,

Simple, go to SMOD, press F4 with all selections.

Give function exit name on enhancement component by checking function exits check box.

It will list you the enhancement name.

BADI:

If you know the Tcode, then go to the se93 transaction.

get the package name.

go to se18 and press f4 and give the package name to filter.

You will get a list of badi definitions.

Follow the below steps to find out what all BADI's are called when you press any button in any transaction.

1) Goto se24 (Display class cl_exithandler)

2) Double click on the method GET_INSTANCE.

3) Put a break point at Line no.25 (CASE sy-subrc).

Now

4) Execute SAP standard transaction(MIGO)

5) Press the required button for which you need to write an exit logic, the execution will stop at the break point.

6) Check the values of variable 'exit_name', it will give you the BADI name called at that time.

7) This way you will find all the BADIs called on click of any button in any transaction.

Try with this Z program:

REPORT zuserexit NO STANDARD PAGE HEADING.

************************************************************************

  • Renewed by Peluka *

************************************************************************

TABLES : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir, tstct,

tdevct, doktl, modattr, help_info.

INCLUDE .

CONSTANTS: true(1) TYPE c VALUE 'X',

false(1) TYPE c VALUE ' ',

active LIKE modattr-status VALUE 'A'.

TYPE-POOLS: slis.

DATA: gt_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,

gs_layout TYPE slis_layout_alv,

g_repid LIKE sy-repid,

i_list_comments TYPE slis_t_listheader,

w_list_comments LIKE LINE OF i_list_comments,

pt_events TYPE slis_t_event.

DATA : BEGIN OF jtab OCCURS 0.

INCLUDE STRUCTURE tadir.

DATA : nombre_proj LIKE modact-name,

estado_proj LIKE modattr-status,

document(1) TYPE c,

modtext LIKE modsapt-modtext,

END OF jtab.

TYPES: BEGIN OF type_salida,

obj_name LIKE tadir-obj_name,

nombre_proj LIKE modact-name,

estado_proj(4),

document(4),

modtext LIKE modsapt-modtext,

END OF type_salida.

DATA: t_salida TYPE STANDARD TABLE OF type_salida WITH HEADER LINE.

DATA : field1(30).

DATA : v_devclass LIKE tadir-devclass,

tab_projects LIKE modact OCCURS 0 WITH HEADER LINE.

DATA: g_exists(1) TYPE c.

PARAMETERS : p_tcode LIKE tstc-tcode OBLIGATORY.

INITIALIZATION.

g_repid = sy-repid.

START-OF-SELECTION.

SELECT *

FROM modact INTO TABLE tab_projects.

SORT tab_projects.

SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode.

IF sy-subrc EQ 0.

SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR'

AND object = 'PROG'

AND obj_name = tstc-pgmna.

MOVE : tadir-devclass TO v_devclass.

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-funcname.

SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR'

AND object = 'FUGR'

AND obj_name EQ enlfdir-area.

MOVE : tadir-devclass TO v_devclass.

ENDIF.

ENDIF.

SELECT * FROM tadir INTO TABLE jtab

WHERE pgmid = 'R3TR'

AND object = 'SMOD'

AND devclass = v_devclass.

SELECT SINGLE * FROM tstct WHERE sprsl EQ sy-langu AND

tcode EQ p_tcode.

LOOP AT jtab.

CLEAR tab_projects.

READ TABLE tab_projects WITH KEY member = jtab-obj_name.

IF NOT tab_projects-name IS INITIAL.

jtab-nombre_proj = tab_projects-name.

SELECT SINGLE *

FROM modattr

WHERE name = tab_projects-name.

jtab-estado_proj = modattr-status.

ENDIF.

SELECT SINGLE *

FROM tdevct

WHERE spras EQ 'EN'

AND devclass EQ jtab-devclass.

doktl-object = jtab-obj_name.

PERFORM check_documentation USING doktl-object

CHANGING g_exists.

SELECT SINGLE * FROM modsapt

WHERE sprsl = 'E' AND

name = jtab-obj_name.

jtab-modtext = modsapt-modtext.

jtab-document = g_exists.

MODIFY jtab.

ENDLOOP.

IF NOT jtab[] IS INITIAL.

PERFORM mostrar_reporte_alv TABLES jtab.

ELSE.

FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.

WRITE:/(95) 'No existe ninguna user exit'.

ENDIF.

ELSE.

FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.

WRITE:/(95) 'El código de transacción no existe'.

ENDIF.

*----


*

  • FORM CHECK_DOCUMENTATION *

*----


*

  • --> P_DOKTL_OBJECT *

  • --> P_EXISTS *

*----


*

FORM check_documentation USING p_doktl_object

CHANGING p_exists.

SELECT *

FROM doktl

WHERE id = 'MO'

AND object = p_doktl_object

AND langu = 'EN'.

ENDSELECT.

IF sy-subrc = 0.

p_exists = true.

ELSE.

p_exists = false.

ENDIF.

ENDFORM. " GET_DOCUMENTATION

*&----


*

*& Form mostrar_reporte_alv

*&----


*

  • text

*----


*

  • -->P_JTAB text

*----


*

FORM mostrar_reporte_alv TABLES jtab STRUCTURE jtab.

LOOP AT jtab.

MOVE-CORRESPONDING jtab TO t_salida.

IF jtab-estado_proj EQ 'A'.

t_salida-estado_proj = '@BF@'.

ELSE.

t_salida-estado_proj = '@BG@'.

ENDIF.

IF jtab-document EQ 'X'.

t_salida-document = '@96@'.

ELSE.

t_salida-document = ''.

ENDIF.

APPEND t_salida.

ENDLOOP.

  • Estructura y formato de salida

PERFORM init_fieldcat.

PERFORM init_layout.

PERFORM seteo_eventos TABLES pt_events.

  • Mostrar listado

PERFORM listado.

ENDFORM. " mostrar_reporte_alv

*&----


*

*& Form init_fieldcat

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM init_fieldcat.

gt_fieldcat-seltext_l = 'Ampliación'.

gt_fieldcat-fieldname = 'OBJ_NAME'.

gt_fieldcat-fix_column = 'X'.

gt_fieldcat-outputlen = '10'.

gt_fieldcat-just = 'C'.

gt_fieldcat-hotspot = 'X'.

gt_fieldcat-tabname = 'T_SALIDA'.

APPEND gt_fieldcat. CLEAR gt_fieldcat.

gt_fieldcat-seltext_l = 'Proyecto'.

gt_fieldcat-fieldname = 'NOMBRE_PROJ'.

gt_fieldcat-outputlen = '10'.

gt_fieldcat-just = 'C'.

gt_fieldcat-hotspot = 'X'.

gt_fieldcat-tabname = 'T_SALIDA'.

APPEND gt_fieldcat. CLEAR gt_fieldcat.

gt_fieldcat-seltext_l = 'Estado Proyecto'.

gt_fieldcat-fieldname = 'ESTADO_PROJ'.

gt_fieldcat-outputlen = '15'.

gt_fieldcat-just = 'C'.

gt_fieldcat-tabname = 'T_SALIDA'.

APPEND gt_fieldcat. CLEAR gt_fieldcat.

gt_fieldcat-seltext_l = 'Documentación'.

gt_fieldcat-fieldname = 'DOCUMENT'.

gt_fieldcat-outputlen = '13'.

gt_fieldcat-just = 'C'.

gt_fieldcat-hotspot = 'X'.

gt_fieldcat-tabname = 'T_SALIDA'.

APPEND gt_fieldcat. CLEAR gt_fieldcat.

gt_fieldcat-seltext_l = 'Descripción'.

gt_fieldcat-fieldname = 'MODTEXT'.

gt_fieldcat-outputlen = '60'.

gt_fieldcat-just = 'L'.

gt_fieldcat-tabname = 'T_SALIDA'.

APPEND gt_fieldcat. CLEAR gt_fieldcat.

ENDFORM.

*&----


*

*& Form init_layout

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM init_layout.

gs_layout-f2code = 'VER_DOC'.

ENDFORM. " init_layout

*&----


*

*& Form seteo_eventos

*&----


*

  • text

*----


*

  • -->P_PT_EVENTS text

*----


*

FORM seteo_eventos TABLES pt_events.

  • Para que utilice el encabezado.

DATA: lt_events TYPE slis_alv_event.

*

CLEAR lt_events.

lt_events-name = 'TOP_OF_PAGE'.

lt_events-form = 'TOP_OF_PAGE'.

APPEND lt_events TO pt_events.

lt_events-name = 'USER_COMMAND'.

lt_events-form = 'USER_COMMAND'.

APPEND lt_events TO pt_events.

ENDFORM. " seteo eventos

*&----


*

*& Form listado

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM listado.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_repid

i_callback_user_command = 'USER_COMMAND'

is_layout = gs_layout

it_fieldcat = gt_fieldcat[]

i_save = 'A'

it_events = pt_events

TABLES

t_outtab = t_salida

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. " listado

*----


*

  • FORM TOP_OF_PAGE *

*----


*

FORM top_of_page.

DATA: lc_texto LIKE w_list_comments-info.

CLEAR: i_list_comments[].

w_list_comments-typ = 'H'. "H=Header, S=Selection, A=Action

w_list_comments-key = ''.

w_list_comments-info = p_tcode.

APPEND w_list_comments TO i_list_comments.

CONCATENATE 'Transaction Code -' p_tcode tstct-ttext

INTO lc_texto SEPARATED BY space.

w_list_comments-typ = 'S'. " H = Header, S = Selection, A = Action

w_list_comments-key = ''.

w_list_comments-info = lc_texto.

APPEND w_list_comments TO i_list_comments.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

i_logo = 'ENJOYSAP_LOGO'

it_list_commentary = i_list_comments.

ENDFORM. " seteo_eventos

*----


*

  • FORM user_command *

*----


*

  • ........ *

*----


*

  • --> L_UCOMM *

  • --> LS_SELFIELD *

*----


*

FORM user_command USING l_ucomm ls_selfield TYPE slis_selfield.

  • Nos aseguramos que no haya pinchado sobre una linea sin nada

CHECK NOT ls_selfield-tabname IS INITIAL.

CHECK NOT ls_selfield-fieldname IS INITIAL.

READ TABLE t_salida INDEX ls_selfield-tabindex.

CASE ls_selfield-fieldname.

WHEN 'OBJ_NAME'.

SET PARAMETER ID 'MON' FIELD t_salida-obj_name.

CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.

WHEN 'NOMBRE_PROJ'.

IF NOT t_salida-nombre_proj IS INITIAL.

SET PARAMETER ID 'MON_KUN' FIELD t_salida-nombre_proj.

CALL TRANSACTION 'CMOD' AND SKIP FIRST SCREEN.

ENDIF.

WHEN 'DOCUMENT'.

IF NOT t_salida-document IS INITIAL.

doktl-object = t_salida-obj_name.

PERFORM get_documentation USING doktl-object.

ENDIF.

ENDCASE.

ENDFORM.

*----


*

  • FORM GET_DOCUMENTATION *

*----


*

  • --> P_DOKTL_OBJECT *

*----


*

FORM get_documentation USING p_doktl_object.

DATA: lt_line LIKE tline OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF lt_exclude OCCURS 10,

func(4),

END OF lt_exclude.

DATA: overlay_header LIKE thead,

l_lines LIKE sy-tabix.

REFRESH lt_line.

CALL FUNCTION 'DOCU_GET_FOR_F1HELP'

EXPORTING

id = 'MO'

langu = 'E'

object = p_doktl_object

IMPORTING

head = overlay_header

TABLES

line = lt_line

EXCEPTIONS

ret_code = 1

OTHERS = 2.

IF sy-subrc EQ 0.

DESCRIBE TABLE lt_line LINES l_lines.

IF l_lines = 0.

EXIT.

ENDIF.

help_info-title = p_doktl_object.

help_info-docuid = p_doktl_object.

help_info-docuobject = p_doktl_object.

help_info-spras = overlay_header-tdspras.

CALL FUNCTION 'HELP_DOCULINES_SHOW'

EXPORTING

help_infos = help_info

overlay_header = overlay_header

TABLES

excludefun = lt_exclude

helplines = lt_line

EXCEPTIONS

OTHERS = 1.

ENDIF.

ENDFORM.

Reward points

regards