ABAP development for Procurement

  • Purchase order
    • Change partners in PO
    • 582221 - FAQ: BAPIs for purchase orders
    • Run ATP 
  • Purchase requisition
    • 499627 - FAQ: BAPIs for purchase requisitions
  • Outline Agreement
    • 1046794 - FAQ: BAPI for Outline Agreement

Purchase order

Run ATP ( MM-PUR-GF-ATP )

IF fc_vorga <> cva_en OR                                    "WP127444
   fc_vorga = cva_en AND gf_ac_prevent_atp <> mmpur_yes.
  PERFORM mepo_check_availability TABLES t_ekkn.            " 1601804
  LOOP AT ett.                                              "^2218409
    IF highetenr < ett-etenr.
      highetenr = ett-etenr.
    ENDIF.
  ENDLOOP.
  lo_bitmask->set_etenr( highetenr ).                       "v2218409

endif.

Change partners in PO

method IF_EX_ME_PROCESS_PO_CUST~CHECK.
  
  DATA:
    ls_header      TYPE MEPOHEADER,
    lt_partners     TYPE MMPUR_PARTNER_ALL_TAB,
    



lo_po_doc TYPE REF TO IF_PURCHASING_DOCUMENT. ls_header = im_header->get_data( ). " header details lo_po_doc ?= im_header. " casting to purchase document lt_partners = lo_po_doc->get_partners( ). IF ( syst-subrc = 0 ). " partner = vendor -> do something, e.g. ch_failed = 'X'. ENDIF. endmethod.

582221 - FAQ: BAPIs for purchase orders

1. Question:

As of which release are the EnjoySAP purchase order BAPIs released?

Answer:

The EnjoySAP BAPIs BAPI_PO_CREATE1 and <BAPI_PO_CHANGE are released
officially in SAP R/3 Enterprise Edition (4.70).
As of this release level, the ALE interface is also available for the first time.

2. Question:

Is there any documentation on EnjoySAP purchase order BAPIs?

Answer:

In Release 4.70 (SAP R/3 Enterprise), the documentation in transaction BAPI for the methods PurchaseOrder.CreateFromData1 and PurchaseOrder.Change can be found under Materials Management -> Purchasing. For SAP R/3 Releases 4.6B and 4.6C, you can find the documentation in Documentation_Enjoy_PO_BAPIs.zip, which is attached to this note.
You should also read the function module documentation.

--------------------------

3. Question:

What options do you have to influence price determination if you create a purchase order using BAPI_PO_CREATE1 or BAPI_PO_CHANGE?

Answer:

See Note 580225.

--------------------------

4. Question:

Why do some purchase orders contain several condition records for the same condition type?

Answer:

See Note 539950.


--------------------------

5. Question:

Can several header conditions of the same condition type be added and/or edited using the BAPI?

Answer:

Due to technical restrictions, only one header condition type can be added or changed. It is not possible to process several header condition types of the same condition type with the BAPI.

--------------------------

6. Question:

Is it possible to carry out a new price determination using BAPI_PO_CHANGE?

Answer:

See Note 428621.

--------------------------

7. Question:

Which condition type is valid (active) if a purchase order contains both PBXX and PB00?

Answer:

See Note 578253.

--------------------------

8. Question:

Is it possible to hold purchase orders using BAPIs?

Answer:

See Note 354771.

--------------------------

9. Question:

Why are all partner roles that are maintained in the vendor master not transferred when a purchase order is created?

Answer:

Make sure that the "Higher lv." indicator (search at higher level) is set in the partner schema for the corresponding partner role. You can find this indicator in purchasing Customizing (transaction OLME) under Partner Determination -> Partner Settings in Purchasing Documents -> Define Partner Schemas.
If this indicator is not set, the system transfers only partner roles that are maintained at plant level.
Also read FAQ Note 459350 (FAQ: Partner determination in purchasing).

--------------------------

10. Question:

Is it possible to change services using BAPI_PO_CHANGE?

Answer:

Yes.

--------------------------

11. Question:

Can I create texts using purchase order BAPIs?

Answer:

See Note 491835.

--------------------------

12. Question:

Can I change (delete) only header and/or item texts using BAPI_PO_CHANGE?

Answer:

You can change header and/or item texts without filling another transfer structure. See Note 782948 for more information about this.

--------------------------

13. Question:

Why are some fields ignored, even though they are filled correctly in the BAPI interface?

Answer:

This is due to the fact that no X is set for the corresponding field in the corresponding X structure.
If, for example, you want to assign your own short text using BAPI_PO_CREATE1, you must fill the field PO_ITEMS-SHORT_TEXT AND PO_ITEMSX-SHORT_TEXT = X.
See Note 484692 also.
For SAP R/3 Enterprise Edition, we introduced a field firewall, which is based on the field selection in the online transaction. If you change a field using BAPI_PO_CHANGE that you cannot change using transaction ME22N, the system does not accept the change.

--------------------------

14. Question:

Are EnjoySAP purchase order BAPIs available in Release 4.6B?

Answer:

See Note 577398.

--------------------------

15. Question:

User-defined fields are supplied with BAPI_PO_CREATE1 and BAPI_PO_CHANGE for the tables EKKO, EKPO, and EKKN. The system terminates with DBIF_RSQL_INVALID_REQUEST during the update.

Answer:

Check in the CI structures of the corresponding database table as to whether there are type P (packed) fields. Refer to the online documentation for user-defined fields and the "ExtensionIn" parameter:
Customers can use only fields of data type CHAR and similar data types in BAPI table extensions. This restriction is due to the reference structure BAPIPAREX of the extension parameters. Furthermore, the customer cannot use fields from the standard table in the APPEND of the BAPI table extension because a 'move corresponding' would also overwrite the SAP field.
Note 509898 describes a solution for this.

--------------------------

16. Question:

You use BAPI_PO_CREATE1 to create a purchase order via the middleware and the system issues an error message for a master record. The user then logs on in the R/3 system and maintains the master data, and then transfers the purchase order again. The same error message appears again. Why?

Answer:

A link to the R/3 system is not always set up when you creation a purchase order via the middleware, rather, it is simply still there. In this case, the system does not generate a new purchase order instance. As a result, the master data buffer is not reset after the first call. Deactivating this function in the BAPI case seriously impairs performance. If you have problems with the buffering of master data when you create a purchase order using BAPI_PO_CREATE1 via middelware, you can call the corresponding initialization or refresh module in the user exit EXIT_SAPL2012_001.

--------------------------

17. Question:

What should I take into account when doing a preliminary analysis of problems with BAPIs?

Answer:

See Note 375886.

--------------------------

18. Question:

For testing purposes, you execute a BAPI in transaction SE37 and you create or change the purchase order. However, the purchase order does not exist or the changes are not visible in transaction ME23N. How can I generate a COMMIT WORK?

Answer:

See Note 420646.

--------------------------

19. Question:

Is it possible to assign foreign trade data (import/export) to BAPIs?

Answer:

See Note 419838.

--------------------------

20. Question:

Why is it impossible to determine the requester (field EKPO-AFNAM) using BAPI_PO_GETDETAIL?

Answer:

This function is not available for technical reasons. See Note 373190 also.
As of Release ERP 2005, a new GetDetail method is available that integrates the structure definitions of the BAPI_PO_CREATE1 and BAPI_PO_CHANGE functions.

--------------------------

21. Question:

When you create a purchase order without account assignment using BAPI_PO_CREATE, the fields CMMT_ITEM (Commitment Item), FUNDS_CTR (Funds Center), and FUND (Funds) are transferred in the table PO_ITEM_ACCOUNT_ASSIGNMENT. Why are these fields not transferred to the purchase order?

Answer:

For technical reasons, the data of the table PO_ITEM_ACCOUNT_ASSIGNMENT can be transferred only if the purchase order is assigned to an account. If you cannot assign an account assignment category, use BAPI_PO_CREATE1. Here, the fields in the table POITEM can be transferred and they are copied irrespective of the account assignment category.

--------------------------

22. Question:

What functions are currently not available?

Answer:

You can find a detailed description in Note 197958.

--------------------------

23. Question:

Why is the address number (field PO_ITEMS-ADDRESS) not checked by BAPI_PO_CREATE?

Answer:

For technical reasons, this is not possible. See Note 180172 also.

--------------------------

24. Question:

In a customer program, BAPI_PO_CREATE1 is called to create a purchase order and then BAPI_PO_CHANGE is called. In this case, a program termination/update termination occurs in the program SAPLEKPA with SAPSQL_ARRAY_INSERT_DUPREC. Why?

Answer:

When BAPI_PO_CREATE is called, the parameter YMMPA_FILLED is set by the partner determination. To avoid dumps during partner processing, the routine PERFORM MEPO_REFRESH(saplmepo). should be called in the customer program to reset all data before calling BAPI_PO_CHANGE.

--------------------------

25. Question:

Can you use the function module BAPI_P_CREATE1 or BAPI_PO_CHANGE to carry out the material configuration?

Answer:

This function for the variant configuration in the purchase order is not currently contained in the standard SAP system.

--------------------------

26. Question:

Can service specifications also be changed or created using the EnjoySAP purchase order BAPIs?

Answer:

Yes, see Note 754879 for further information.

--------------------------

27. Question:

Why is the deletion indicator that was assigned via BAPI_PO_CHANGE for an item not displayed in the online transaction (ME22N, ME23N)?

Answer:

See Note 698686.

--------------------------

28. Question:

Is it possible to use the ALE interface for BAPI_PO_CREATE1 and BAPI_PO_CHANGE in SAP R/3 Release 4.6C?

Answer:

SAP only provides standardized ALE interfaces for these two methods as of the official release of the two BAPIs in the R/3 Enterprise Edition. If you want to use the ALE interface in SAP R/3 Release 4.6C, you have to generate these interfaces yourself. Use transaction BDBG to do so. Instructions are provided in the user guide for transaction BAPI via the menu Environment -> BAPI User Guide.

--------------------------

29. Question:

Why does the system issue error message MEPO 034 when you set the inward delivery completed indicator using BAPI_PO_CHANGE?

Answer:

You used the field DELIV_COMPL (see structure BAPIMEPOITEM) to set the inward delivery completed indicator. However, this field is assigned to the outward delivery completed indicator. Use the field NO_MORE_GR to set the inward delivery completed indicator.

--------------------------

30. Question:

Can BAPI_PO_CREATE1 and BAPI_PO_CHANGE be used for stack processing (several calls are completed with one COMMIT WORK)?


Answer:

The API BAPI_PO_CREATE1 supports stack processing. The API BAPI_PO_CHANGE does not support stack processing. After each call, a COMMIT WORK or a ROLLBACK WORK must be carried out; in particular, if you try to change a purchase order several times. In this context, also check the online documentation http://help.sap.com -> Cross-Application Components -> Business Framework Architecture (CA-BFA) -> BAPI User Guide -> Programming with BAPIs -> Transaction Model for Developing BAPIs. The suboption "Transaction Control in Client" contains additional information about this.

--------------------------

31. Question:

Can foreign trade data be displayed using BAPI_PO_GETDETAIL1?

Answer:

No. At present, this function is not implemented.


--------------------------

32. Question:

Can the BAPI_PO_CREATE1 or BAPI_PO_CHANGE be called several times in a sequence?

Answer:

No. If you use the BAPIs for the same business object - for example, purchase orders (BUS2012) - in a sequence in customer-specific programs, this may lead to the following problems:

Example: Let us assume you want to update the price for several purchase orders. If several documents are processed in a sequence, this may lead to the dump 'OBJECTS_OBJREF_NOT_ASSIGNED'.

Solution: We recommend using the parameter DESTINATION 'NONE'. This has the result that the BAPIs are executed in a separate context, thus preventing the data of one BAPI from overlapping another.

--------------------------

33. Question:

With BAPI_PO_CREATE1 and BAPI_PO_CHANGE, can the same material be used multiple times as a component in the BAPI structure POCOMPONENTS?

Answer:

No. Due to the complexity during sorting and updating of the RESB table, SAP strongly recommends NOT using the same materials multiple times in the BAPI structure POCOMPONENTS.

Purchase requisition 

BADI

ME_PROCESS_REQ_CUST 

Check of Commitment Relevance of Purchase Requisitions

ME_REQ_OI_EXT

ME_COMMTMNT_REQ_RE_C 

Check of Commitment Relevance of Purchase Requisitions

ME_COMMTMNT_REQ_RELE 

PO BADI

ME_PROCESS_PO_CUST

Enhancements for Processing Enjoy Purchase Order: Customer

ME_PROCESS_PO_CUST 

Enhancements for Processing Enjoy Purchase Order: Intern.

ME_PROCESS_PO 

Processing of Component Default Data at Time of GR: Custome

ME_PROCESS_COMP 

BAdI: Service Tab Page for Subcontracting

ME_PO_SC_SRV 

Enhancements to Price Determination: Customer

ME_PO_PRICING_CUST

Enhancements to Price Determination: Internal

ME_PO_PRICING 

Capture/Send Purchase Info Record Changes - Internal Use

ME_INFOREC_SEND 

Hold Enjoy Purchase Orders: Activation/Deactivation

ME_HOLD_PO 

FM Account Assignment Behavior for Stock PR/PO

ME_FIELDSTATUS_STOCK 

Check for Commitment-Relevance of Purchase Orders

ME_COMMTMNT_PO_REL_C 

Check for Commitment-Relevance of Purchase Orders

ME_COMMTMNT_PO_RELEV 

499627 - FAQ: BAPIs for purchase requisitions

1. Question:

Can I use the BAPI BAPI_REQUISITION_CHANGE to add new items?

Answer:

No.

--------------------------

2. Question:

Is the bill of material (BOM) exploded in the purchase requisition for subcontracting items?

Answer:

You cannot explode the BOM in a purchase requisition that has been created using BAPI_REQUISITION_CREATE. However, the explosion takes place when the purchase requisition is converted into a purchase order. For more information, read Notes 182787 and 102595.

As of SAP ERP 6.0, it is possible to trigger the BOM explosion for a subcontracting item.

--------------------------

3. Question:

If the function module BAPI_REQUISITION_CREATE is used and the field ITEM_CAT (item category) in the table REQUISITION_ITEMS is filled with the value K, L, S, U, W, or D, the system issues error message ME 719:

Item category ... does not exist (Please correct).

Why?

Answer:

You must enter the internal item category instead of the external item category. You can find the assignment in purchasing Customizing (transaction OLME) in the "Define External Representation of Item Categories" area.

--------------------------

4. Question:

Can I use ALE (using IDocs/EDI) to call the BAPIs BAPI_REQUISITION_CREATE and BAPI_REQUISITION_CHANGE?

Answer:

The logical message category PREQCR is provided for the BAPI BAPI_REQUISITION_CREATE. An ALE connection is not going to be provided for BAPI_REQUISITION_CHANGE. PREQCR is only delivered with a Support Package for Releases 4.0B to 4.6C.

---------------------------

5. Question:

Can I use BAPI_REQUISITION_CREATE to set the fixed indicator?

Answer:

You cannot use the BAPI BAPI_REQUISITION_CREATE to set the fixed indicator.
When the BAPI BAPI_REQUISITION_CHANGE is used to make changes, the system sets the fixed indicator automatically only if the purchase requisition originates from requirements planning.
For more information, refer to Note 330206.

---------------------------

6. Question:

Can the BAPIs of the purchase requisition with the "CreateFromData1" and "Change" methods cover all of the functions of the EnjoySAP purchase requisition (transactions ME51N and ME52N)?

Answer:

The function modules BAPI_REQUISITION_CREATE and BAPI_REQUISITION_CHANGE do not cover all of the functions of the EnjoySAP purchase requisition transactions. This is because the two asynchronous BAPIs have been developed based on ME51 and ME52 (program SAPMM06B). The user exits from the function group MEREQ (for example, MEREQ001) are therefore not available.
In SAP R/3 Release 4.70, two new API methods are developed that are based on the EnjoySAP technology of the purchase requisition transactions ME51N and ME52N. The function modules BAPI_PR_CREATE and BAPI_PR_CHANGE are released in Release 6.00 (ERP2005).

SAP does not provide support for this because these function modules have not been released for Releases lower than 6.00. If you use these BAPIs in customer-defined programs, you must bear in mind that you are responsible for any problems that might occur. In addition, you must read Notes 109533 and 415983.

A downport to a release lower than 4.70 is not provided because developing this would involve considerable time and effort.

---------------------------

7. Question:

Can BAPI_REQUISITION_CHANGE process the customer enhancements ExtensionIn?

Answer:

See Note 584902.

---------------------------

8. Question:

Can service items be created using BAPI_REQUISITION_CREATE or changed using BAPI_REQUISITION_CHANGE?

Answer:

No, this is only possible with the new API functions for the object BUS2105. See the following point.

---------------------------

9. Question:

Can service items be created using BAPI_PR_CREATE or changed using BAPI_PR_CHANGE?

Answer:

Yes. Release 6.04 (Enhancement Package 4) provides new API functions for the object BUS2105 that include this function. In addition the business function LOG_MM_CI_2 or the switch MM_SFWS_SC2 must be active.
See Note 1312947 for further information.

---------------------------

10. Question:

In online transaction ME51, you can assign a 35 character vendor material number to an item. However, I can maintain only 22 characters in the BAPI. Can I change this?

Answer:

When the BAPIs for the business object BUS2105 (PurchaseRequisiton) were developed, the field for the vendor's material number (EBAN-IDNLF) was only 22 characters long. This definition has changed in SAP R/3 Release 4.5B to include 35 characters.
You cannot change the field VEND_MAT in the relevant API methods for compatibility reasons.
However, the full length of this field is provided in the new API methods.

---------------------------

11. Question:

I can use the user parameter CNT to maintain a cost center in the user master record; BAPI_REQUISITION_CREATE can import this cost center.
What is the correct format for entering this cost center if the cost center is only numeric?

Answer:

You must enter the cost center with leading zeros. The BAPI does not convert the format.

---------------------------

12. Question:

What must I take into account when I use the BAPI BAPI_REQUISITION_CHANGE to change or delete texts?

Answer:

To ensure the persistent processing of the texts, you must always call the function module COMMIT_TEXT after BAPI_REQUISITION_CHANGE.

--------------------------

13. Question:

Can the BAPI_PR_CREATE or BAPI_PR_CHANGE be called several times in a sequence?

Answer:

No. If you use the BAPIs for the same business object - for example, purchase requisitions (BUS2105) - in a sequence in customer-specific programs, this may lead to the following problems: 

Example: Let us assume you want to update the price for several purchase requisitions. If several documents are processed in a sequence, this may lead to the dump 'OBJECTS_OBJREF_NOT_ASSIGNED'.

Solution: We recommend using the parameter DESTINATION 'NONE'. This has the result that the BAPIs are executed in a separate context, thus preventing the data of one BAPI from overlapping another.

--------------------------

14. Question: 

Can I use BAPI_PR_CREATE and BAPI_PR_CHANGE to use the same material in the BAPI structure PRCOMPONENTS as a component several times?

Answer:

No. Due to the complexity occurring during sorting and updating of the RESB table, SA strongly recommends NOT using the same materials in the BAPI structure PRCOMPONENTS several times.

Outline Agreement

1046794 - FAQ: BAPI for Outline Agreement

1. Question:

You want to change a scheduling agreement via BAPI_SAG_CHANGE and receive the error message MEOUT 019: "Scheduling agreements with time-independent conditions are not supported". Why?

Answer:

BAPI_SAG_CHANGE (and BAPI_SAG_CREATE) can only treat scheduling agreements with time-dependent conditions. Document conditions are not supported. Therefore, this kind of scheduling agreements cannot be processed. This is a missing functionality.

--------------------------

2. Question:

You change the scheduling agreement via BAPI_SAG_CHANGE successfully and afterwards all conditions are deleted. Why can this happen?

Answer:

lease, be so kind to implement SAP-Notes 1034912 and 1046851.

--------------------------

3. Question:

You use either BAPI_SAG_CREATE or BAPI_CONTRACT_CREATE to create a scheduling agreement or a contract with some accounting data. Why is the accounting data not always taken into account?

Answer:

Please revise your accounting test data and ensure that a valid value for the serial number is given. Please observe that even for single account assignment the value '01' has to be provided in the field corresponding to SERIAL_NO in both tables ACCOUNT and ACCOUNTX.

--------------------------

4. Question:

You use either BAPI_SAG_CREATE or BAPI_CONTRACT_CREATE to create a scheduling agreement or a contract with some accounting data. Even if you have provided all mandatory accounting data (customizing settings), you receive the error message ME 083: "Enter & &". Why?

Answer:

Same answer as above.

--------------------------

5. Question:

You want to change schedule lines of a scheduling agreement via BAPI_SCHEDULE_MAINTAIN and receive the error message MEOUT 019: "Scheduling agreements with time-independent conditions are not supported". Why?

Answer:

BAPI_SCHEDULE_MAINTAIN can only treat scheduling agreements with time-dependent conditions. Document conditions are not supported. Therefore, this kind of scheduling agreements cannot be processed. This is a missing functionality.

--------------------------

6. Question:

You maintain the same document type for a requisition and a contract. Now, when you change the field 'Our reference' via BAPI_CONTRACT_CHANGE, the field 'Invoicing Party'(LIFRE) gets cleared. Why?

Answer:

Please check if the same document type is used for requisition and contract. If yes, in this case: in customizing 'assign parter schemas to document types', you can maintain a partner schema only for an entry corresponding to contracts and not for Purchase requisitions. This results in the partner schema not being identified correctly and the result is LIFRE being cleared.
We recommend NOT to maintain the same document type for Purchase requisitions and contracts.

--------------------------

7. Question:

Goods supplier (GS) is maintained in BAPI structure 'PARTNER' of BAPI_SAG_CREATE or BAPI_SAG_CHANGE. This partner is located in a different country/region of the company code of the plant. Even though you have maintained import data in master data and in the BAPI, the import data is not created or changed. Why?

Answer:

This is a missing functionality. The workaround is to maintain it manually directly in the document via ME32L.

--------------------------

8. Question:

You want to change import data using BAPI_SAG_CHANGE, even though the document exists and already has import data, message 06 698 "Import data incomplete or does not exist" is returned. Why?

Answer:

This is a missing functionality. Import data are not changeable via BAPI_SAG_CHANGE, the workaround is to change it via ME32L.

--------------------------

9. Question:

You want to execute either BAPI_CONTRACT_CREATE or BAPI_CONTRACT_CHANGE in a sequence, is that allowed?

No: As you are calling BAPIs in a sequence for the same business object like Outline Agreements (BUS2013 / BUS2014) in your custom programs, this might lead to following problems.

Example: You use custom inbound IDoc to update the prices for some purchase orders. When processed in a sequence, this sometimes leads to a dump 'OBJECTS_OBJREF_NOT_ASSIGNED' in SAPLMEOUT.
Due to overlapped events from one BAPI to another.

Solution: It is always advisable to use DESTINATION 'NONE' clause. This will execute the BAPIs in their own separate contexts, which will avoid the overlapping of the data of one BAPI with another.

--------------------------

10. Question:

Is it possible to create or change a contract with multiple Partner Data Retention Levels via BAPI_CONTRACT_CREATE or BAPI_CONTRACT_CHANGE?

Answer:

No. This is a missing functionality.
At this moment the BAPI structure 'PARTNER' for business object BUS2014 is not prepared to consider deviant EKORG information.
The workaround is to maintain it manually in the document via ME32(K).

--------------------------

11. Question:

When an outline agreement is changed via BAPI, system does not create version data, even if Version Management is activated. Why?

Answer:

Version Management is not supported in the outline agreement BAPIs. This is a missing functionality. The workaround is to change the document in ME32K or ME32L.

--------------------------

12. Question:

System throws the error message ME 664: Change REVLV could not be effected, even if you can change the field via online transaction. Why?

Answer:

The revision level (EKPO-REVLV) cannot be changed via BAPI because various quality management routines were not implemented. The workaround is to change the document in online transaction.

Comments