Add Custom Field To Purchase Requisition - MEREQ001 - SAP

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

Products
Products Industries
Industries Support
Support Training
Training Community
Community Developer
Developer Partner
Partner About
About  
Home / Community / Blogs + Actions

Add Custom Field to Purchase Requisition –


MEREQ001
October 27, 2017 | 668 Views |

Mehmet Ozgur Unal


more by this author

ABAP Development

MM (Materials Management) | CI_EBANDB | ME51N add custom field | ME51N SCREEN-EXIT | MEREQ001

share
0 share
11 tweet share
90

Follow

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 1/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

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 :

408017 - MERQ001: Implementation sample code

496083 - FAQ: Customer enhancements (user exits) in purchasing

Related SCN Links :


https://archive.sap.com/discussions/thread/698154

https://archive.sap.com/discussions/thread/3257475

https://archive.sap.com/discussions/thread/1665217

https://archive.sap.com/discussions/thread/390068

I suggest that please read MEREQ001 enhancement document ! Because, SAP inform you how to
design your developments step by step.

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 2/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

When you finish explainations of SAP , you will get information about this user-exit.

Sum up ;

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 3/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

1- Append your custom field to CI_EBANDB .

2- Create subscreen and add custom field to screen number 111.

3- EXIT_SAPLMEREQ_001 is used to Export Data to Customer Subscreen for

Purchase Requisition(PBO).

4- EXIT_SAPLMEREQ_003 is used to Import Data from Customer Subscreen for

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 4/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

Purchase Requisition.

5- If you get DUMP like a –> Runtime error : DBSQL_SQL_ERROR , Exception :


CX_SY_OPEN_SQL_DB., go to SE14 for EBEV then ‘Adjust and activate’ !

I created a project for implementation in CMOD named ZMM and MEREQ001 is added such a
component. Then you can work on it.

SOLUTION :

1- Add ZZUSER to CI_EBANDB .

2- Create subscreen and fill out modules.

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 5/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

Attributes :

Layout :

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 6/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

Flow Logic :

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 7/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

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.
https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 8/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

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.
https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 9/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

* 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'.

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 10/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

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

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 11/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

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

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 12/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

Alert Moderator

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

shivakkumar Geetha venkatesan

October 31, 2017 at 1:17 am

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

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 13/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

Mohsin Abbasi

October 31, 2017 at 3:44 am

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

venu gopal

November 2, 2017 at 8:37 am

Dear Mehmet Ozgur Unal ,

It is very good documents for functional consultants as well.

Thanks a lot

Venugopal

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 14/15
11/20/2017 Add Custom Field to Purchase Requisition – MEREQ001 | SAP Blogs

Share & Follow Privacy Terms of Use Legal Disclosure Copyright Trademark Sitemap Newsletter

https://blogs.sap.com/2017/10/27/add-custom-field-to-purchase-requisition-mereq001/ 15/15

You might also like