Application Development and Automation 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: 
Read only

Create PR using BAPI_PR_create

Former Member
0 Likes
7,152

Hi Friends,

Can any body send step by step procedure to create PR using BAPI.

Also when i try to create pr using bapi_pr_create , im getting following error.

T ID NUM MESSAGE

E ME 083 Enter Document Type

E BAPI 001 No instance of object type PurchaseRequisition has been created. External reference: # 5

E ME 083 Enter Plant

E KI 205 Cost accounting is not active in company code QP01

Regards,

Jaya

8 REPLIES 8
Read only

Former Member
0 Likes
2,423

The item numbers must be empty in the item table.

Read only

0 Likes
2,423

Hi Jayalakshmi,

Did u find the solution for the error:

E BAPI 001 No instance of object type PurchaseRequisition has been created. External reference: # 5

Can you please update it in this thread.

Thanks,

Read only

Former Member
0 Likes
2,423

Did you find a solution to this issue yet?

I am having the same problem:

E ME 083 Enter Document Type

E BAPI 001 No instance of object type PurchaseRequisition has been created. External reference: # 2

E ME 083 Enter Plant

Edited by: dieter habig on Mar 1, 2010 8:50 AM

Read only

0 Likes
2,423

Must leave filed PREQ_ITEM, you dont need to fill it.

Read only

Former Member
0 Likes
2,423

Example


TABLES:eban.
DATA: BEGIN OF itab OCCURS 0,
     NO(5),
     bnfpo LIKE eban-bnfpo,
     bsart LIKE eban-bsart,
     matnr LIKE eban-matnr,
     lgort LIKE eban-lgort,
     menge LIKE eban-menge,
     bednr LIKE eban-bednr,
     lfdat LIKE eban-lfdat,
     TX(132),
     END OF itab.


DATA :

prheader LIKE TABLE OF bapimereqheader WITH HEADER LINE,
prheaderx LIKE TABLE OF bapimereqheaderx WITH HEADER LINE,
PRITEMEXP LIKE TABLE OF BAPIMEREQITEM WITH HEADER LINE,
return LIKE TABLE OF bapiret2 WITH HEADER LINE,
pritem LIKE TABLE OF bapimereqitemimp WITH HEADER LINE,
pritemx LIKE TABLE OF bapimereqitemx WITH HEADER LINE,
PRITEMTEXT LIKE TABLE OF BAPIMEREQITEMTEXT WITH HEADER LINE.


DATA auxfilename LIKE rlgrap-filename.

CALL FUNCTION 'UPLOAD'
 EXPORTING
   filename     = 'C:\PRCREATE.TXT'
   filetype     = 'DAT'
 IMPORTING
   act_filename = auxfilename
 TABLES
   data_tab     = itab.

IF sy-subrc <> 0.
 MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
         WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.


Read only

0 Likes
2,423

Hi

Is this here really correct?

Guest wrote:


prheader LIKE TABLE OF bapimereqheader WITH HEADER LINE,
prheaderx LIKE TABLE OF bapimereqheaderx WITH HEADER LINE,

In my opinion, BAPI_PR_CREATE wants prheader and prheaderx as structures (and not as tables).

This solution worked:

DATA prheader LIKE bapimereqheader,
            prheaderx LIKE bapimereqheaderx.


Read only

Former Member
0 Likes
2,423

Continue.........


LOOP AT ITAB .

 prheader-pr_type = itab-bsart.
 APPEND prheader.
 CLEAR prheader.

 prheaderx-pr_type = 'X'.
 APPEND prheaderx.
 CLEAR prheaderx.

 pritem-preq_item = itab-bnfpo.
 pritem-material = itab-matnr.
 pritem-plant = '0100'.
 pritem-store_loc = itab-lgort.
 pritem-quantity = itab-menge.
 pritem-trackingno = itab-bednr.
 pritem-deliv_date = itab-lfdat.

 APPEND pritem.
 CLEAR pritem.

 pritemx-PREQ_ITEM = itab-bnfpo.
 pritemx-preq_itemX = 'X'.
 pritemx-material = 'X'.
 pritemx-plant = 'X'.
 pritemx-store_loc = 'X'.
 pritemx-quantity = 'X'.
 pritemx-trackingno = 'X'.
 pritemx-deliv_date = 'X'.
 pritemx-SHORT_TEXT = 'X'.

 APPEND pritemx.
 CLEAR pritemx.

 PRITEMTEXT-PREQ_ITEM = itab-BNFPO.
 PRITEMTEXT-TEXT_ID = 'B01'.
 PRITEMTEXT-TEXT_LINE = ITAB-TX.
 append PRITEMTEXT.
  CLEAR PRITEMTEXT.

ENDLOOP.

CALL FUNCTION 'BAPI_PR_CREATE'

 TABLES
   RETURN     =  RETURN
   pritem     =  PRITEM
  PRITEMX     =  PRITEMX

  PRITEMTEXT  = PRITEMTEXT

 CHANGING
  PRHEADER   = PRHEADER
  PRHEADERX  = PRHEADERX .

Read only

Former Member
0 Likes
2,423

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
REFRESH PRITEM.
REFRESH prheader.
REFRESH prheaderx.
REFRESH PRITEMX.
REFRESH PRITEMTEXT.