Skip to Content
0
Former Member
Jul 08, 2014 at 08:51 AM

Found error in BAPI_PR_CREATE

758 Views

Dear All,

I am facing problem while i am using BAPI_PR_CREATE to add purchase req. automatically.Can anybody help me

error is ME 083 Enter Document Type

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

My Code is

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,

prheader1 LIKE TABLE OF bapimereqheader WITH HEADER LINE,

prheaderx LIKE TABLE OF bapimereqheaderx WITH HEADER LINE,

PRITEMEXP LIKE TABLE OF BAPIMEREQITEM WITH HEADER LINE,

WA_PRITEMEXP LIKE BAPIMEREQITEM ,

return LIKE TABLE OF bapiret2 WITH HEADER LINE,

WA_return LIKE bapiret2 ,

pritem LIKE TABLE OF bapimereqitemimp WITH HEADER LINE,

pritemx LIKE TABLE OF bapimereqitemx WITH HEADER LINE,

PRITEMTEXT LIKE TABLE OF BAPIMEREQITEMTEXT WITH HEADER LINE,

pw_pr_number TYPE bapimereqheader-preq_no.

DATA auxfilename LIKE rlgrap-filename.


prheader-PR_TYPE = 'ZRAW'.

prheader-GENERAL_RELEASE = 'X'.

APPEND prheader.

CLEAR prheader.

prheaderx-PR_TYPE = 'X'.

prheaderx-GENERAL_RELEASE = 'X'.

*prheaderx-CREATE_IND = ''.

*prheaderx-CTRL_IND = 'X'.

*prheaderx-ITEM_INTVL = 'X'.

*prheaderx-LAST_ITEM = 'X'.

*prheaderx-MEMORY = 'X'.

APPEND prheaderx.

CLEAR prheaderx.

pritem-preq_item = 00010.

pritem-material = 'R8101140006-0000'.

pritem-plant = 2210.

pritem-store_loc = 2001.

pritem-pur_group = 104.

pritem-quantity = 101.

pritem-trackingno = 'HR'.

pritem-deliv_date = '20140930'.

APPEND pritem.

CLEAR pritem.

pritemx-PREQ_ITEM = 00010.

pritemx-preq_itemX = 'X'.

pritemx-material = 'X'.

pritemx-plant = 'X'.

pritemx-store_loc = 'X'.

pritem-pur_group = 'X'.

pritemx-quantity = 'X'.

pritemx-trackingno = 'X'.

pritemx-deliv_date = 'X'.

*pritemx-SHORT_TEXT = 'X'.

APPEND pritemx.

CLEAR pritemx.


CALL FUNCTION 'BAPI_PR_CREATE' "#EC *

EXPORTING

prheader = prheader

prheaderx = prheaderx

* TESTRUN = TESTRUN

IMPORTING

number = pw_pr_number

TABLES

return = return

pritem = pritem

pritemx = pritemx

* pritemexp = pritemexp

* pritemsource = t_itemsource

* pritemtext = t_itext

EXCEPTIONS

OTHERS = 1.

*****

****** Check whether any error exist. If not commit the changes else rollback the changes.

READ TABLE return

* TRANSPORTING NO FIELDS dar013009

INTO wa_return . "dar013009

* WITH KEY type = c_msgty_e.

IF sy-subrc = 0.

* pw_flag = c_error.

* pw_msg = wa_return-message. "dar013009

ELSE.

* pw_flag = c_success.

ENDIF.


CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

REFRESH PRITEM.

REFRESH prheader.

REFRESH prheaderx.

REFRESH PRITEMX.

REFRESH PRITEMTEXT.

data : str type string.

CONCATENATE 'purchase req no is : ' pw_pr_number into str SEPARATED BY space.

message str type 'S'.