Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

What are the Mandatory Fields in Transaction ME51

Former Member
0 Kudos

Hello Seniors,

I have a requirement about purchase order creation. In this process, I am using the BAPI named " BAPI_PO_CREATE1 ". I have passed all the fields but when I debug and look into the internal tables, I couldn't find certain records. I even debugged " bapiret2" and I see an error which reads "" All mandatory fields are missing"". I have even created a PO in ME51 and found out the mandatory fields but in vain. BAPIRET2 still says, there are some more mandatory fields missing. I need to know what are all the mandatory fields to create a Purchase order using TCODE - ME51.

Your reply is most awaited and rewarded.

Thanks and Regards,

MARKIV

6 REPLIES 6

Former Member
0 Kudos

Hi,

please check out the following link it might help you

**********please reward points if the information is helpful to you***********

Former Member
0 Kudos

hi ,

Functionality

Function module BAPI_PO_CREATE1 enables you to create purchase orders. The BAPI uses the technology behind the Enjoy purchase order transaction ( ME21N).

Alternatively, the IDoc type PORDCR1 is available. The data from this IDoc automatically populates the interface parameters of the function module BAPI_PO_CREATE1.

Functionality in Detail

Authorization

The following authorization objects are checked when an Enjoy purchase order is created (activity 01):

M_BEST_BSA (document type in PO)

M_BEST_EKG (purchasing group in PO)

M_BEST_EKO (purchasing organization in PO)

M_BEST_WRK (plant in PO)

Controlling adoption of field values via X bar

For most tables, you can determine via your own parameters in the associated X bar in each case (e.g. PoItemX) whether fields are to be set initial, values inserted via the interface, or default values adopted (e.g. from Customizing or master records) (for example, it is not mandatory to adopt the material group from an underlying purchase requisition - you can change it with the BAPI).

Transfer

Header data

The header data of the Enjoy purchase order is transferred in the table PoHeader.

Item data

The item data of the Enjoy purchase order is stored in the table PoItem (general item data). The delivery schedule lines are stored in the table PoSchedule.

Use the table PoAccount to specify the account assignment information. If account assignments have been specified for services and limits, you show the relevant account assignment line in PoAccount in the table PoSrvAccessValues via the package number of the service or the limit.

Services and limits

Services, free limits and limits with contract reference can be specified in the tables PoServices, PoLimits, and PoContractLimits.

Conditions

Conditions are transferred in the table PoCond; header conditions in the table PoCondHeader. Price determination is reinitiated via the parameter CALCTYPE in the table PoItem.

Vendor and delivery address

The vendor's address can be specified individually in the table PoAddrVendor; the delivery address in the table PoAddrDelivery. If you do not make any individual specification, the fields will be populated via the central address managementfacility.

Note

In this method, the following restrictions apply with regard to addresses:

Addresses can only be created with this method - they cannot be changed. You can only change address data with the method BAPI_ADDRESSORG_CHANGE.

When you create addresses, they are not checked by the method. An Enjoy purchase order may therefore contain faulty address data.

Partner roles

The partners can be maintained individually via the table PoPartner (with the exception of the partner role "vendor").

Import/export data

Import/Export data can be specified per item in the table PoExpImpItem. Foreign trade data can only be transferred as default data for new items.

Texts

Header and item texts can be transferred in the tables PoTextHeader and PoTextItem. Texts for services are imported in the table PoServicesText.

Version Management

You can make use of the Version Management facility via the table AllVersions.

Return

The PO number is returned in the parameter ExpPurchaseOrder. In addition, all information except the service and export/import tables is placed in the output structures.

Return messages

Messages are returned in the parameter Return. This also contains information as to whether interface data has been wrongly or probably wrongly (heuristical interface check) populated. If a PO has been successfully created, the PO number is also placed in the return table with the appropriate message.

Example

Example of population of BAPI interface in the Function Builder

Parameter: POHEADER

COMP_CODE = 1000

DOC_TYPE = NB

ITEM_INTVL = 00001

VENDOR = 0000001000

PMNTTRMS = 0001

PURCH_ORG = 1000

PUR_GROUP = 001

CURRENCY = EUR

Parameter: POHEADERX

COMP_CODE = X

DOC_TYPE = X

ITEM_INTVL = X

VENDOR = X

PMNTTRMS = X

PURCH_ORG = X

PUR_GROUP = X

Parameter: POITEM

PO_ITEM = 00001

MATERIAL = 100-100

PLANT = 1000

STGE_LOC = 0001

QUANTITY = 15.000

TAX_CODE = V0

ITEM_CAT = 0

ACCTASSCAT = K

Parameter: POITEMX

PO_ITEM = 00001

MATERIAL = X

PLANT = X

STGE_LOC = X

QUANTITY = X

TAX_CODE = X

ITEM_CAT = X

ACCTASSCAT = X

Parameter: POSCHEDULE

PO_ITEM = 00001

SCHED_LINE = 0001

DELIVERY_DATE = 02.12.2002

QUANTITY = 6.000

PO_ITEM = 00001

SCHED_LINE = 0002

DELIVERY_DATE = 03.12.2002

QUANTITY = 5.000

PO_ITEM = 00001

SCHED_LINE = 0003

DELIVERY_DATE = 04.12.2002

QUANTITY = 4.000

Parameter: POSCHEDULEX

PO_ITEM = 00001

SCHED_LINE = 0001

PO_ITEMX = X

SCHED_LINEX = X

DELIVERY_DATE = X

QUANTITY = X

PO_ITEM = 00001

SCHED_LINE = 0002

PO_ITEMX = X

SCHED_LINEX = X

DELIVERY_DATE = X

QUANTITY = X

PO_ITEM = 00001

SCHED_LINE = 0003

PO_ITEMX = X

SCHED_LINEX = X

DELIVERY_DATE = X

QUANTITY = X

Parameter: POACCOUNT

PO_ITEM = 00001

SERIAL_NO = 01

QUANTITY = 15.000

GL_ACCOUNT = 0000400000

COSTCENTER = 0000001000

CO_AREA = 1000

Parameter: POACCOUNTX

PO_ITEM = 00001

SERIAL_NO = 01

QUANTITY = X

GL_ACCOUNT = X

COSTCENTER = X

CO_AREA = X

Parameter: POCOND

ITM_NUMBER = 000001

COND_ST_NO = 001

COND_TYPE = PB00

COND_VALUE = 79.900000000

CURRENCY = EUR

CURRENCY_ISO = EUR

COND_UNIT = KG

COND_P_UNT = 1

CHANGE_ID = U

Parameter: POCONDX

ITM_NUMBER = 000001

COND_ST_NO = 000

ITM_NUMBERX = X

COND_TYPE = X

COND_VALUE = X

CURRENCY = X

CHANGE_ID = X

Parameter: POPARTNER

PARTNERDESC = OA

LANGU = EN

BUSPARTNO = 0000001100

PARTNERDESC = GS

LANGU = EN

BUSPARTNO = 0000001200

PARTNERDESC = PI

LANGU = EN

BUSPARTNO = 0000001000

Help in the Case of Problems

1. Note 197958 lists answers to frequently asked questions (FAQs). (Note 499626 contains answers to FAQs relating to External Services Management.)

2. If you have detected an error in the function of a BAPI, kindly create a reproducible example in the test data directory in the Function Builder (transaction code SE37). Note 375886 tells you how to do this.

3. If the problem persists, please create a Customer Problem Message for the componente MM-PUR-PO-BAPI, and document the reproducible example where necessary.

Customer Enhancements

The following user exits (function modules) are available for the BAPI BAPI_PO_CREATE1:

EXIT_SAPL2012_001 (at start of BAPI)

EXIT_SAPL2012_003 (at end of BAPI)

The following user exits (function modules) are available for the BAPI BAPI BAPI_PO_CHANGE:

EXIT_SAPL2012_002 (at start of BAPI)

EXIT_SAPL2012_004 (at end of BAPI)

These exits belong to the enhancement SAPL2012 (see also transaction codes SMOD and CMOD).

There is also the option of populating customer-specific fields for header, item, or account assignment data via the parameter EXTENSIONIN.

Further information

1. Note 197958 contains up-to-date information on the purchase order BAPIs.

2. If you test the BAPIs BAPI_PO_CREATE1 or BAPI_PO_CHANGE in the Function Builder (transaction code SE37), no database updates will be carried out. If you need this function, please take a look at Note 420646.

3. The BAPI BAPI_PO_GETDETAIL serves to read the details of a purchase order. The BAPI cannot read all details (e.g. conditions). However, you can use the BAPI BAPI_PO_CHANGE for this purpose if only the document number is populated and the initiator has change authorizations for purchase orders.

4. Frequently used BAPIs for purchase orders are BAPI_PO_CREATE, BAPI_PO_CREATE1, BAPI_PO_CHANGE, BAPI_PO_GETDETAIL, BAPI_PO_GETITEMS, BAPI_PO_GETITEMSREL, and BAPI_PO_GETRELINFO.

5. For more information on purchase orders, refer to the SAP library (under MM Purchasing -> Purchase Orders) or the Help for the Enjoy Purchase Order, or choose the path Tools -> ABAP Workbench -> Overview -> BAPI Explorer from the SAP menu.

regards

reena

Former Member
0 Kudos

Hi

SPRO => Material Management => External Services Management => Define Screen Layout => ME51 => Price and value fields => Gross Price set to mandatory. It will work.

<b>You would have to add additiional sub screen to your transaction via a screen exit.

First you would create a sub screen with all fields you want to put including a PAI and PBO.

Then you find the appropriate screen exit for it. For ME51/52/53 the following exits apply...

AMPL0001 User subscreen for additional data on AMPL

LMEDR001 Enhancements to print program

LMELA002 Adopt batch no. from shipping notification when posting a GR

LMELA010 Inbound shipping notification: Transfer item data from IDOC

LMEQR001 User exit for source determination

LMEXF001 Conditions in Purchasing Documents Without Invoice Receipt

LWSUS001 Customer-Specific Source Determination in Retail

M06B0001 Role determination for purchase requisition release

M06B0002 Changes to comm. structure for purchase requisition release

M06B0003 Number range and document number

M06B0004 Number range and document number

M06B0005 Changes to comm. structure for overall release of requisn.

M06E0004 Changes to communication structure for release purch. doc.

M06E0005 Role determination for release of purchasing documents

ME590001 Grouping of requsitions for PO split in ME59

MEETA001 Define schedule line type (backlog, immed. req., preview)

MEFLD004 Determine earliest delivery date f. check w. GR (only PO)

MELAB001 Gen. forecast delivery schedules: Transfer schedule implem.

MEQUERY1 Enhancement to Document Overview ME21N/ME51N

MEVME001 WE default quantity calc. and over/ underdelivery tolerance

MM06E001 User exits for EDI inbound and outbound purchasing documents

MM06E003 Number range and document number

MM06E004 Control import data screens in purchase order

MM06E005 Customer fields in purchasing document

MM06E007 Change document for requisitions upon conversion into PO

MM06E008 Monitoring of contr. target value in case of release orders

MM06E009 Relevant texts for "Texts exist" indicator

MM06E010 Field selection for vendor address

MM06E011 Activate PReq Block

MMAL0001 ALE source list distribution: Outbound processing

MMAL0002 ALE source list distribution: Inbound processing

MMAL0003 ALE purcasing info record distribution: Outbound processing

MMAL0004 ALE purchasing info record distribution: Inbound processing

MMDA0001 Default delivery addresses

MMFAB001 User exit for generation of release order

MRFLB001 Control Items for Contract Release Order

You would have to check which applies to ur requirement and then code accordingly.

</b>

Reward all helpfull answers

Regards

Pavan

Former Member
0 Kudos

Hi ,

Try this,

REPORT ZTEST_BAPI .

*- BAPI related declarations

DATA : g_pohdr TYPE bapimepoheader,

g_pohdrx TYPE bapimepoheaderx,

gt_poitem TYPE TABLE OF bapimepoitem,

gt_poitemx TYPE TABLE OF bapimepoitemx,

gt_posched TYPE TABLE OF bapimeposchedule,

gt_poschedx TYPE TABLE OF bapimeposchedulx,

gt_poacct TYPE TABLE OF bapimepoaccount,

gt_poacctx TYPE TABLE OF bapimepoaccountx,

gt_poservice TYPE TABLE OF bapiesllc,

gt_posrvacc TYPE TABLE OF bapiesklc,

gt_return TYPE TABLE OF bapiret2.

perform prepare_header.

PERFORM prepare_items.

PERFORM prepare_schedule.

perform create_po.

&----


*& Form prepare_header

&----


  • Set up header structure

----


FORM prepare_header.

g_pohdr-comp_code = '2000'.

g_pohdrx-comp_code = 'X'.

  • set up doc type

g_pohdr-doc_type = 'NB'.

g_pohdrx-doc_type = 'X'.

g_pohdr-vendor = '0008000330'.

g_pohdrx-vendor = 'X'.

g_pohdr-langu = sy-langu.

g_pohdrx-langu = 'X'.

g_pohdr-purch_org = 'BA01'.

g_pohdrx-purch_org = 'X'.

g_pohdr-pur_group = '800'.

g_pohdrx-pur_group = 'X'.

g_pohdr-currency = 'USD'.

g_pohdrx-currency = 'X'.

ENDFORM. " prepare_header

&----


*& Form prepare_items

&----


  • Set up item values

----


FORM prepare_items.

DATA : ls_poitem TYPE bapimepoitem,

ls_poitemx TYPE bapimepoitemx.

ls_poitem-po_item = '00010'.

ls_poitemx-po_item = '00010'.

ls_poitemx-po_itemx = 'X'.

ls_poitem-short_text = 'ABSORBER,SHOCK:PALLETIZER'.

ls_poitemx-short_text = 'X'.

ls_poitem-material = '000000000001070062'.

ls_poitemx-material = 'X'.

ls_poitem-vend_mat = 'xyz'.

ls_poitemx-vend_mat = 'X'.

ls_poitem-quantity = '100'.

ls_poitemx-quantity = 'X'.

ls_poitem-po_unit = 'EA'.

ls_poitemx-po_unit = 'X'.

ls_poitem-po_unit_iso = 'EA'.

ls_poitemx-po_unit_iso = 'X'.

ls_poitem-net_price = '6.32'.

ls_poitemx-net_price = 'X'.

ls_poitem-price_unit = '1'.

ls_poitemx-price_unit = 'X'.

ls_poitem-item_cat = 'D'.

ls_poitemx-item_cat = 'X'.

ls_poitem-plant = '1575'.

ls_poitemx-plant = 'X'.

ls_poitem-ACCTASSCAT = 'K'.

ls_poitemx-ACCTASSCAT = 'X'.

  • ls_poitem-acctasscat = <fs_req>-knttp.

  • ls_poitemx-acctasscat = 'X'.

*

  • ls_poitem-distrib = <fs_req>-vrtkz.

  • ls_poitemx-distrib = 'X'.

*

  • ls_poitem-part_inv = <fs_req>-twrkz.

  • ls_poitemx-part_inv = 'X'.

*

  • ls_poitem-gr_ind = <fs_req>-wepos.

  • ls_poitemx-gr_ind = 'X'.

*

  • ls_poitem-gr_non_val = <fs_req>-weunb.

  • ls_poitemx-gr_non_val = 'X'.

*

  • ls_poitem-ir_ind = <fs_req>-repos.

  • ls_poitemx-ir_ind = 'X'.

  • ls_poitem-agreement = <fs_req>-konnr.

  • ls_poitemx-agreement = 'X'.

*

  • ls_poitem-agmt_item = <fs_req>-ktpnr.

  • ls_poitemx-agmt_item = 'X'.

*

  • ls_poitem-preq_no = <fs_req>-banfn.

  • ls_poitemx-preq_no = 'X'.

*

  • ls_poitem-preq_item = <fs_req>-bnfpo.

  • ls_poitemx-preq_item = 'X'.

*

  • ls_poitem-preq_name = <fs_req>-afnam.

  • ls_poitemx-preq_name = 'X'.

*

  • ls_poitem-pckg_no = <fs_req>-packno.

  • ls_poitemx-pckg_no = 'X'.

APPEND : ls_poitem TO gt_poitem,

ls_poitemx TO gt_poitemx.

ENDFORM. " prepare_items

&----


*& Form prepare_schedule

&----


  • Schedule data

----


FORM prepare_schedule.

DATA : ls_posched TYPE bapimeposchedule,

ls_poschedx TYPE bapimeposchedulx.

ls_poschedx-po_item = '00010'.

ls_posched-po_item = '00010'.

ls_poschedx-po_itemx = 'X'.

ls_posched-delivery_date = '10/31/2005'.

ls_poschedx-delivery_date = 'X'.

ls_posched-quantity = '100'.

ls_poschedx-quantity = 'X'.

  • ls_posched-preq_no = <fs_req>-banfn.

  • ls_poschedx-preq_no = 'X'.

*

  • ls_posched-preq_item = <fs_req>-bnfpo.

  • ls_poschedx-preq_item = 'X'.

APPEND : ls_posched TO gt_posched,

ls_poschedx TO gt_poschedx.

ENDFORM. " prepare_schedule

&----


*& Form create_po

&----


  • Create PO with ref to the req

----


FORM create_po.

DATA : lt_return TYPE TABLE OF bapiret2,

l_ponum TYPE banfn.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = g_pohdr

poheaderx = g_pohdrx

  • testrun = 'X'

IMPORTING

exppurchaseorder = l_ponum

TABLES

return = lt_return

poitem = gt_poitem

poitemx = gt_poitemx

poschedule = gt_posched

poschedulex = gt_poschedx

poaccount = gt_poacct

poaccountx = gt_poacctx

poservices = gt_poservice

posrvaccessvalues = gt_posrvacc.

APPEND LINES OF lt_return TO gt_return.

IF NOT l_ponum IS INITIAL.

MESSAGE s398(00) WITH 'Purchase document ' l_ponum

' successfully created'.

ENDIF.

ENDFORM. " create_po

<b>Reward points</b>

Regards

0 Kudos

Hello SKK,

Thank you for your immediate reply sir. I have tried you code but in vain. I was not creating Purchase orders. I crosschecked it twice. Could you please walk through the code which you have sent and also, is there any way to find out all the Mandatory fields other than by creating it manually in ME51. Could there be any process or TCODE which could give us all the mandatory(required) fields to create a purchase order.

Thank you once again,

MARKIV.

Former Member
0 Kudos

Transaction ME51 is for creating Purchase Requisition ( I am on R/3 4.7).

Can you please let me know how are you trying to create a PO from ME51.