SAP ABAP - Add Custom Screen In MIGO Header
1. Create BAdI MB_MIGO_BADI Implementation from tcode SE19
2. Enter Implementation Name
3. Create Enhancement Implementation
4. Open Implementing Class
5. Create variable declaration on class attribute
6. Append custom structure to GOHEAD structure from SE11
save & activate structure.
8. Create custom ABAP program in SE38
9. create 2 sub screen for input and display
All source code custom ABAP program
*&---------------------------------------------------------------------*
*& Report ZMIGO_CUSTOMFIELD
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zmigo_customfield.
TABLES : gohead.
DATA cs_goitem TYPE goitem.
*&---------------------------------------------------------------------*
*& Module STATUS_8000 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_8000 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_8000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_8000 INPUT.
* CASE sy-ucomm.
* WHEN 'OK_GO'.
* WHEN 'OK_POST1'.
* WHEN OTHERS.
* ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_8001 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_8001 OUTPUT.
IMPORT cs_goitem TO cs_goitem FROM MEMORY ID 'MIGO_CUSTOMFIELD'.
SELECT SINGLE zcustomfield FROM ztt_cstomfield
INTO gohead-zcustomfield WHERE mblnr = cs_goitem-mblnr AND mjahr = cs_goitem-mjahr.
ENDMODULE.
All BAdI Method source code :
METHOD if_ex_mb_migo_badi~init.
APPEND class_id TO ct_init.
ENDMETHOD.
METHOD if_ex_mb_migo_badi~mode_set.
IF i_refdoc = 'R01' AND i_action = 'A01'.
CLEAR : display_mode.
ELSEIF i_action = 'A04' OR i_action = 'A03'.
display_mode = 'X'.
ELSE.
display_mode = 'Z'.
ENDIF.
ENDMETHOD.
METHOD if_ex_mb_migo_badi~pbo_header.
CHECK i_class_id = class_id.
IF display_mode = ''.
e_cprog = 'ZMIGO_CUSTOMFIELD'.
e_dynnr = '8000'. "External fields: Input
e_heading = 'MIGO Custom Field'.
ELSEIF display_mode = 'X'.
e_cprog = 'ZMIGO_CUSTOMFIELD'.
e_dynnr = '8001'. "External fields: Display
e_heading = 'MIGO Custom Field'.
ENDIF.
ENDMETHOD.
method IF_EX_MB_MIGO_BADI~PAI_HEADER.
ls_gohead = is_gohead.
endmethod.
METHOD if_ex_mb_migo_badi~post_document.
DATA :
ls_ztt_cstomfield TYPE ztt_cstomfield.
IF display_mode IS INITIAL.
CLEAR ls_ztt_cstomfield.
ls_ztt_cstomfield-mblnr = is_mkpf-mblnr.
ls_ztt_cstomfield-mjahr = is_mkpf-mjahr.
ls_ztt_cstomfield-zcustomfield = ls_gohead-zcustomfield.
MODIFY ztt_cstomfield FROM ls_ztt_cstomfield.
ENDIF.
ENDMETHOD.
10. Activate Badi Implementation from SE18
11. Open MIGO transaction GR Other and here the custom screen result :D
:D :D :D
Comments
Post a Comment