Skip to Content
Author's profile photo Mehmet Ozgur Unal

Add Custom Field to Purchase Requisition – MEREQ001

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

Assigned Tags

      17 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      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

      Author's profile photo Mohsin Abbasi
      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

      Author's profile photo venu gopal
      venu gopal

      Dear Mehmet Ozgur Unal ,

      It is very good documents for functional consultants as well.

       

      Thanks a lot

      Venugopal

      Author's profile photo Osvaldo Lopez
      Osvaldo Lopez

      Great doc! Thanks for share Mehmet !!!

      Keep posting like this! 😉

      Author's profile photo Former Member
      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.

      Author's profile photo Martin Schlegel
      Martin Schlegel

      Very helpful. Thank you for sharing!

      Keep posting.

      Kind regards Martin

      Author's profile photo Mehmet Ozgur Unal
      Mehmet Ozgur Unal
      Blog Post Author

      Hello Martin Schlegel ,

      I hope that someone benefit from it 🙂

      Regards

      M.Ozgur Unal

      Author's profile photo Amiruddin Ayaz Notta
      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.

      Author's profile photo Sijin Chandran
      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

       

      Author's profile photo Mehmet Ozgur Unal
      Mehmet Ozgur Unal
      Blog Post Author

      Hi Sijin,

      You can find screen belongs to Pr in the blog.

      please check again

      M.Ozgur Unal

       

      Author's profile photo Sandra Rossi
      Sandra Rossi

      Links to the SAP notes could be useful:

      Author's profile photo Masoud Eb
      Masoud Eb

      very good

      why Module status_0111 output not work ?

      i create new include and write codes ( by Break point) but not work ?

      Author's profile photo Masoud Eb
      Masoud Eb

      I found my error.

      Even that in CMOD all components showed activated. I had to go to SE38 and activate it there.

      Author's profile photo ERP SAP ABAP
      ERP SAP ABAP

      Nice Document God Bless You!!!!

      Author's profile photo Sagar Bagale
      Sagar Bagale

      Dear Mehmet,

      Thanks a lot for this blog. it has helped me solve my issue.

      Regards,
      Sagar

      Author's profile photo Jose Montoto
      Jose Montoto

      Hi!

      Firstly thanks for the post 🙂

      The issue that i have now is the custom fields must be filled at Header level...Is there any way to create this custom fields at header level?

      Regards!

      Author's profile photo Cristóbal Contreras
      Cristóbal Contreras

      Hi Mehmet Ozgur Unal,

       

      I hope you're doing well. I have a few questions, hope you can answer. I need to add a new column in ME51N, so I add a new field in MEREQ3211GRID structure, exactly in CI_EBANDB, correct? Always I have to add new fields in CI_EBANDB? I added the new field here but I don´t see this new field when I select "Change Layout" in alv options. I need to create this field in screen 0111 to see it in the ALV layout?

      I need to create a validation, in  MEREQ001 the validation apply in screen 0111 or in ALV performance?

       

      Thanks in advance

       

      Cristóbal