Add Editable Customer fields to ME51n ME52n ME53n

Go to Transaction SE11 table LFA1. Double click in structure CI_EBANDB and create it.



Add your customer fields to structure CI_EBANDB. Rebember to use ZZ as the first two characters so the fields does not conflict with future components that SAP might add to table LFA1.


Go to transaction CMOD and create a project. Implement MEREQ001 enhancement

Screen Exit


Screen 0111 PBO


module status_0111 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

  " We check if we are comming from transactions ME51N/ME52N or ME53N
  " in edit mode
  loop at screen.
    if  sy-tcode = 'ME51N' or sy-tcode = 'ME52N' or
      ( sy-tcode = 'ME53N' and lcl_purchase_order=>get_edit_flag( ) = abap_true ).
      screen-input = 1.
    else.
      screen-input = 0.
    endif.
    modify screen.
  endloop.

endmodule.                 " STATUS_0111  OUTPUT


EXIT_SAPLMEREQ_001


*&---------------------------------------------------------------------*
*&  Include           ZXM02U01
*&---------------------------------------------------------------------*
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     REFERENCE(IM_REQ_ITEM) TYPE REF TO  IF_PURCHASE_REQUISITION_ITEM
*"----------------------------------------------------------------------

DATA: i_mereq_item  TYPE mereq_item,
      lv_garg       TYPE eqegraarg,
      ls_head       TYPE mereq_header,
      lc_header     TYPE REF TO if_purchase_requisition,
      ti_enq        TYPE TABLE OF seqg3 .

IF im_req_item IS INITIAL.
ELSE.
  i_mereq_item = im_req_item->get_data( ).
ENDIF.

" Validation for display/modify the field ( by default the field is always editable )
IF sy-tcode EQ 'ME53N'.
  lc_header = im_req_item->get_requisition( ).
  lv_garg   = sy-mandt && ls_head-banfn && '*****'.
  CALL FUNCTION 'ENQUEUE_READ'
    EXPORTING
      gclient = sy-mandt
      gname   = 'EBAN'
      garg    = lv_garg
      guname  = sy-uname
    TABLES
      enq     = ti_enq.
  IF ti_enq[] IS NOT INITIAL.
    lcl_purchase_order=>set_edit_flag( abap_true ).
  ELSE.
    lcl_purchase_order=>set_edit_flag( abap_false ).
  ENDIF.
ENDIF.

EXIT_SAPLMEREQ_002


*&---------------------------------------------------------------------*
*&  Include           ZXM02U03
*&---------------------------------------------------------------------*
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     REFERENCE(IM_REQ_ITEM) TYPE REF TO  IF_PURCHASE_REQUISITION_ITEM
*"  EXPORTING
*"     REFERENCE(EX_CHANGED) LIKE  SY-CALLD
*"  CHANGING
*"     REFERENCE(CH_UCOMM) TYPE  SYST-UCOMM
*"----------------------------------------------------------------------
tables: ci_ebandb.
data:   l_mereq_item type mereq_item.

if not im_req_item is initial.
  " read item data from system
  l_mereq_item = im_req_item->get_data( ).
  if ( ci_ebandb-zzernam ne l_mereq_item-zzernam ).
    " if customer field changed, update structure
    move-corresponding  ci_ebandb to l_mereq_item .
    " set new item data to system
    call method im_req_item->set_data( l_mereq_item ).
    " tell the system that there has something changed on the customer tab
    ex_changed = abap_true.
  endif.
endif.



1 comment:

  1. Hi, Alguém.
    i have a question about it. where did you define lcl_purchase_order and what type is it?
    Sorry for this noobish question.

    Thank's for sharing.

    ReplyDelete