Wednesday, 13 April 2022

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.

7. Create custom table to store custom field data


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

Wednesday, 6 April 2022

SAP ABAP - Add Custom Screen In Header VL01N/VL02N/VL03N

 1. Append Structure in standard table LIKP

open transaction SE11


Click Append Structure


Create new append structure and activate



2. Implement BADI

goto transaction SE18, select BAdI Name -> LE_SHP_TAB_CUST_HEAD and click display


Select Implementation and click create








double click Name of Implementing Class -> ZCL_IM_E_SHP_TAB_CUST_HEAD


  METHOD if_ex_le_shp_tab_cust_head~activate_tab_page.
    IF sy-uname 'ABAP01'.
      ef_caption     'KB Document'" screen caption
      ef_program     'SAPLZFG_DELV'."sapl followed by the function group created zsd537_head
      ef_position    13" tab position
      ef_dynpro      '8001'" screen number
      cs_v50agl_cust 'X'.
    ENDIF.

  ENDMETHOD.


  METHOD if_ex_le_shp_tab_cust_head~transfer_data_to_subscreen.
    CALL FUNCTION 'ZSET_DELIVERY_HEAD_SCREEN_VAL'
      EXPORTING
        i_likp is_likp.

  ENDMETHOD.


  METHOD if_ex_le_shp_tab_cust_head~transfer_data_from_subscreen.
    CALL FUNCTION 'ZGET_DELIVERY_HEAD_SCREEN_VAL'
      IMPORTING
        e_likp cs_likp.

  ENDMETHOD.


3. Create Function Group In SE80



Include LZFG_DELVTOP

DATA :
  ls_ztkbdoc     TYPE ztkbdoc,
  kb_type        TYPE char30,
  kb_number      TYPE char30,
  kb_date        TYPE mkpf-budat.

Create new Subscreen





MODULE status_8001 OUTPUT.
  IF sy-tcode 'VL03' OR sy-tcode 'VL03N'.
    LOOP AT SCREEN.
      screen-input 0.
      MODIFY SCREEN.
    ENDLOOP.
  ENDIF.
ENDMODULE.

Create function module : ZGET_DELIVERY_HEAD_SCREEN_VAL




Create function module : ZSET_DELIVERY_HEAD_SCREEN_VAL





Activate function group and BAdI Implementation and see the result








ABAP CDS View Part 10 : Authorization & DCL untuk ABAP CDS

Authorization & DCL di ABAP CDS | Panduan Lengkap (PFCG, @AccessControl, DCL) Authorization & DCL untuk ABAP CDS — Pandua...