Add custom tab to me51n at item level in ABAP
* Customer exit for ME51N is - MEREQ001
* To implement the customer exit in CMOD.
Step 1: Goto T-code: CMOD.
Step 2: Give project name and click on create.
Step 3: Give short text and click on Enhancement assignments. Press enter and click on save.
Step 4: Click on components. Double click on CI_EBANDB include and create the include.
Step5: Give your field names (If your enhancement category can't be enhanced) as per our requirement. Otherwise click on append structure and create. Field names must started with ZZ.
Step 6: Save and activate the structure.
Step 7: Double click on C_EBANDBX and create structure like this.
Step 7: Double click on screen number (0111) and design layout (Pls ignore email field).
Fields: EBAN-ZZGL_NUM, EBAN-ZZGL_TEXT, EBAN-ZZCC_NUM, EBAN- ZZCC_TEXT.
Step 8: Save and activate the screen.
*****************************Create class To set and get the values*************************
* Goto T-code- SE24.
* Give class name and click on create and give description.
* Create methods GET & SET.
* Create Attributes under Attributes tab.
* Implement the methods.
- Double click on GET_GL (Returning = variable)
METHOD get_gl.
r_p_gl = a_gl.
ENDMETHOD.
- Double click on SET_GL (Variable = Importing).
METHOD set_gl.
a_gl = i_p_gl.
ENDMETHOD.PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
CLASS-METHODS get_gl
RETURNING
VALUE(r_p_gl) TYPE saknr .
CLASS-METHODS set_gl
IMPORTING
!i_p_gl TYPE saknr .
CLASS-METHODS get_gl_text
RETURNING
VALUE(r_p_gl_text) TYPE txt50_skat .
CLASS-METHODS set_gl_text
IMPORTING
!i_p_gl_text TYPE txt50_skat .
CLASS-METHODS get_cc
RETURNING
VALUE(r_p_cc) TYPE kostl .
CLASS-METHODS set_cc
IMPORTING
!i_p_cc TYPE kostl .
CLASS-METHODS get_cc_text
RETURNING
VALUE(r_p_cc_text) TYPE kltxt .
CLASS-METHODS set_cc_text
IMPORTING
!i_p_cc_text TYPE kltxt .
CLASS-METHODS get_aktyp
RETURNING
VALUE(r_aktyp) TYPE aktyp .
CLASS-METHODS set_aktyp
IMPORTING
!i_aktyp TYPE aktyp .
PROTECTED SECTION.
PRIVATE SECTION.
CLASS-DATA a_gl TYPE saknr .
CLASS-DATA a_gl_text TYPE txt50_skat .
CLASS-DATA a_cc TYPE kostl .
CLASS-DATA a_cc_text TYPE kltxt .
CLASS-DATA a_aktyp TYPE aktyp .
ENDCLASS.
CLASS zab_cl_add_gl_cc IMPLEMENTATION.
METHOD get_aktyp.
r_aktyp = a_aktyp.
ENDMETHOD.
METHOD get_cc.
r_p_cc = a_cc.
ENDMETHOD.
METHOD get_cc_text.
r_p_cc_text = a_cc_text.
ENDMETHOD.
METHOD get_gl.
r_p_gl = a_gl.
ENDMETHOD.
METHOD get_gl_text.
r_p_gl_text = a_gl_text.
ENDMETHOD.
METHOD set_aktyp.
a_aktyp = i_aktyp.
ENDMETHOD.
METHOD set_cc.
a_cc = i_p_cc.
ENDMETHOD.
METHOD set_cc_text.
a_cc_text = i_p_cc_text.
ENDMETHOD.
METHOD set_gl.
a_gl = i_p_gl.
ENDMETHOD.
METHOD set_gl_text.
a_gl_text = i_p_gl_text.
ENDMETHOD.
ENDCLASS.
********************************************End of class****************************************
Step 9: Goto CMOD.
Step 10: Double click on first function module (if asks create implementation). Double click on include.
TABLES : ci_ebandb,meacct1000,
eban,zab_t_yn.
DATA : l_mereq_item TYPE mereq_item.
IF sy-tcode EQ 'ME51N' OR sy-tcode EQ 'ME52N' OR sy-tcode EQ 'ME53N'.
l_mereq_item = im_req_item->get_data( ).
MOVE-CORRESPONDING l_mereq_item TO ci_ebandb.
IF eban-zzgl_num IS NOT INITIAL.
SELECT SINGLE saknr, ktopl,txt20,txt50
FROM skat
INTO @DATA(lr_skat)
WHERE saknr EQ @eban-zzgl_num
AND ktopl EQ 'CACH'
AND spras = @sy-langu.
eban-zzgl_text = lr_skat-txt50.
ENDIF.
IF eban-zzcc_num IS NOT INITIAL.
SELECT SINGLE kostl,ltext
FROM cskt
INTO @DATA(lr_cskt)
WHERE kostl = @eban-zzcc_num.
eban-zzcc_text = lr_cskt-ltext.
ENDIF.
zab_cl_add_gl_cc=>set_gl( eban-zzgl_num ).
zab_cl_add_gl_cc=>set_gl_text( lr_skat-txt50 ).
zab_cl_add_gl_cc=>set_cc( eban-zzcc_num ).
zab_cl_add_gl_cc=>set_cc_text( lr_cskt-ltext ).
ENDIF.
Step 12: Save and activate the include.
Step 13: Double click on third function module (if asks create implementation). Double click on include.
DATA : i_mereq_item TYPE mereq_item.
IF NOT im_req_item IS INITIAL.
*read item data from system
i_mereq_item = im_req_item->get_data( ).
ENDIF.
DATA(lv_gl) = zab_cl_add_gl_cc=>get_gl( ).
DATA(lv_gl_text) = zab_cl_add_gl_cc=>get_gl_text( ).
DATA(lv_cc) = zab_cl_add_gl_cc=>get_cc( ).
DATA(lv_cc_text) = zab_cl_add_gl_cc=>get_cc_text( ).
IF i_mereq_item-zzgl_num NE lv_gl.
i_mereq_item-zzgl_num = lv_gl.
ex_changed = 'X'.
ENDIF.
IF i_mereq_item-zzgl_text NE lv_gl_text.
i_mereq_item-zzgl_text = lv_gl_text.
ex_changed = 'X'.
ENDIF.
IF i_mereq_item-zzcc_num NE lv_cc.
i_mereq_item-zzcc_num = lv_cc.
ex_changed = 'X'.
ENDIF.
IF i_mereq_item-zzcc_text NE lv_cc_text.
i_mereq_item-zzcc_text = lv_cc_text.
ex_changed = 'X'.
ENDIF.
IF ex_changed = 'X'.
CALL METHOD im_req_item->set_data( i_mereq_item ).
ENDIF.
Step 14: Save and activate the include.
Step 15: Finally activate the project.
Checking
* Go to T-code ME51N.
* Give the required fields.
* The g/l number, description, cost center and description are stored in DATA base table EBAN.
******************************Thank You***************************
Comments
Post a Comment