Skip to Content

I looked for a detailed document about ME51N-ME52N-ME53N add custom field in SCN but i have not found fully described. That’s why i decided create this blog.

Symptom :

Some customers need to add custom fields for their purchasing request documents then try to copy this field other subsequent purchasing documents such a purchase order. You can benefit from this blog for these requirements.

Related OSS Notes : 

1- Add ZZUSER to CI_EBANDB .

2- Create subscreen and fill out modules.

Attributes :

Layout :

Flow Logic :

ABAP Codes :

PBO –> Status module.

*----------------------------------------------------------------------*
*&      Module  STATUS_0111  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0111 OUTPUT.
*/ M.Ozgur Unal - 26.10.2017 - SP IT

*& ZXM02U01 include dan gönderildi.
   IMPORT flag_input FROM MEMORY ID 'Z_FLAG_INPUT_ZXM02U01'.

   LOOP AT SCREEN.
    IF screen-group1 = 'ZPR'.
     IF flag_input = 'X'.
      screen-input = 1.
     ELSE.
      screen-input = 0.
     ENDIF.
      MODIFY SCREEN.
    ENDIF.
   ENDLOOP.

ENDMODULE.

PAI –> Field on request

*----------------------------------------------------------------------*
*&      Module  CHECK_ZZUSER  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE check_zzuser INPUT.
*/ M.Ozgur Unal - 26102017 - SP IT
 DATA : ls_zfi_tek_ony TYPE zfi_tek_ony.

 CHECK NOT ci_ebandb-zzuser IS INITIAL.
 SELECT SINGLE *
   FROM zfi_tek_ony
   INTO ls_zfi_tek_ony
   WHERE zzuser EQ ci_ebandb-zzuser.
 IF sy-subrc IS NOT INITIAL.
   MESSAGE e163(zmm).
 ENDIF.

ENDMODULE.

Note : I did not fill out user_commad_0111 so that there is no details !

3- Development for EXIT_SAPLMEREQ_001 –>  INCLUDE ZXM02U01 .

*&---------------------------------------------------------------------*
*&  Include           ZXM02U01
*&---------------------------------------------------------------------*

*/ M.Ozgur Unal - 261017 - SP IT

DATA   : ls_mereq_item TYPE mereq_item.
DATA   : cur_activity  TYPE aktvt.

* clear eban values if no PReq item
IF im_req_item IS INITIAL.
  CLEAR: ci_ebandb.
ELSE.
* read item data from system
  ls_mereq_item = im_req_item->get_data( ).

* fill customer field with old values
  ci_ebandb-zzuser    = ls_mereq_item-zzuser.

ENDIF.

CALL METHOD im_req_item->get_activity
  RECEIVING re_aktvt = cur_activity.

CASE cur_activity.
  WHEN 'A'.
  flag_input = space.
  WHEN 'V'.
  flag_input = 'X'.     "Modify
ENDCASE.

* MEREQ001 Enh customer sub screen de kullanılacak.
FREE MEMORY ID 'Z_FLAG_INPUT_ZXM02U01'.
EXPORT flag_input FROM flag_input TO MEMORY ID 'Z_FLAG_INPUT_ZXM02U01'.

4- Development for EXIT_SAPLMEREQ_003 –>  INCLUDE ZXM02U03 .

*&---------------------------------------------------------------------*
*&  Include           ZXM02U03
*&---------------------------------------------------------------------*

*/ M.Ozgur Unal - 261017 - SP IT

DATA:   l_mereq_item TYPE mereq_item,
        eban         TYPE eban,
        l_aktvt      TYPE aktvt.

IF NOT im_req_item IS INITIAL.
  " read item data from system
  l_mereq_item = im_req_item->get_data( ).

  l_aktvt = im_req_item->get_activity( ).

  IF l_aktvt EQ 'A'.

  ELSEIF l_aktvt EQ 'V' OR l_aktvt EQ 'H'.
   IF l_mereq_item-zzuser NE ci_ebandb-zzuser.
     l_mereq_item-zzuser = ci_ebandb-zzuser.
     ex_changed = 'X'.
   ENDIF.

   IF ex_changed = 'X'.
     CALL METHOD im_req_item->set_data( l_mereq_item ).
   ENDIF.

  ENDIF.

ENDIF.

RESULTS :

Purchase Requisition 

EBAN is updated correctly !

I hope that you will need to copy custom fields to subsequent documents such a purchase order. You have to add same field to subsequent purchasing document and fill out fields in subscreen referance to purchase requisition.

If you want to copy PR custom field to PO custom field with a referance, you can benefit from PBO of customer screen in SAPMM06E 0111 CUSTSCR1 SAPLXM06 0111 ! (Screen exit PO)

Enhancement IMP –> MM06E005 Customer fields in purchasing document .

Read custom field PR .

 IF i_aktyp EQ 'H' OR i_aktyp EQ 'V'
  SELECT SINGLE zzuser
   FROM EBAN
   INTO @DATA(wa_eban)
   WHERE ebeln = ekpo-ebeln
   AND  ebelp = ekpo-ebelp.
 
  IF sy-subrc IS INITIAL.
   gs_ci_ekpo-zzuser = wa_eban-zzuser.
  ENDIF.
 ENDIF.

Thanks for your time !

M.Ozgur Unal

To report this post you need to login first.

10 Comments

You must be Logged on to comment or reply to a post.

  1. Former Member

    Really very nice document. every time when you are presenting a blog. I am really eager to go through. Requesting to Present more blog like this. Awesome.

    Thanking you.

    Regards,

    Shivakkumar. GV

    (1) 
  2. Mohsin Abbasi

    Dear Mehmet Ozgur Unal ,

    Nice document, As some of the only consultant have ABAP knowledge with functional module, Otherwise Functional will never have any idea about ABAP normally. You are blessed with both. So that’s why document cover functional and technical aspect as well.

     

    Best Regards

    Mohsin Abbasi

    (1) 
  3. Former Member

     

    Regards,

    I have this requirement but in the header of the transactions me51n, me52m, me53n and me54n.
    They have some option to solve it.

    Thanks for any help.

    (0) 
  4. Amiruddin Ayaz Notta

    Excellent blog Mehmet Ozgur Unal.

    My scenario is little different.

    First of all I replaced the field with a pushbutton and modified relevant code.

    Now upon testing I found out that PBO and PAi of Screen 0111 is only called when the Customer Data tab is active. Usually, an end users will not click that tab, and when he clicks on Check or Save button, standard SAP code is called instead of Screen 0111 modules.

    So, how can we ensure this that Screen 0111 PBO and PAi is called irrespective of Customer Data tab being active or not.

    (0) 
  5. Sijin Chandran

    Hi Mehmet,

    First very thanks for this blog.

    Can you please share the screen shot of ME51N where this Custom Fields would be displayed ?

    Thanks,

    Sijin

     

    (0) 

Leave a Reply