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

Using BAPI_PO_CREATE1

Former Member
0 Likes
518

I would like use bapi to create po, once call the function, some warning occur,

"No instance of object type PurchaseOrder has been created. External reference:

Purchase order still contains faulty items

Can delivery date be met?"

Can i bypass the warning and generate a po document. Thanks!

3 REPLIES 3
Read only

Former Member
0 Likes
430

***********************************************************************

** Program ID :

** Program Desc : PO Creation Using BAPI

** Process Overview :

** Created By : P.KARTHIKEYAN

** Created Date : 25/10/2006

** Company Name : Infoview Technologies Limited

************************************************************************

&----


*& Report ZBAPI_CREATE_PO *

*& *

&----


REPORT ZBAPI_CREATE_PO .

&----


*DATA DECLARATION

CONSTANTS : C_X VALUE 'X'.

*Structures to hold PO header data

DATA : HEADER LIKE BAPIMEPOHEADER ,

HEADERX LIKE BAPIMEPOHEADERX .

*Internal Tables to hold PO ITEM DATA

DATA : ITEM LIKE BAPIMEPOITEM OCCURS 0 WITH HEADER LINE,

ITEMX LIKE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE,

**Internal table to hold messages from BAPI call

RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

data : w_header(40) value 'PO Header'.

data : ws_langu like sy-langu.

data: V_EXPPURCHASEORDER like BAPIMEPOHEADER-PO_NUMBER.

*text-001 = 'PO Header' - define as text element

selection-screen begin of block b1 with frame title text-001.

parameters : company like header-comp_code default '1000' ,

doctyp like HEADER-DOC_TYPE default 'NB' ,

cdate like HEADER-CREAT_DATE default sy-datum ,

vendor like HEADER-VENDOR default 'RAJ',

pur_org like HEADER-PURCH_ORG default '0001' ,

pur_grp like HEADER-PUR_GROUP default '001' .

selection-screen end of block b1.

selection-screen begin of block b2 with frame title text-002.

parameters : item_num like ITEM-PO_ITEM default '00020',

material like ITEM-MATERIAL default 'M-127' ,

plant like ITEM-PLANT default '0001' ,

quantity like ITEM-QUANTITY default 200.

selection-screen end of block b2.

*&----


**START-OF-SELECTION.

*&----


**DATA POPULATION

*&----


ws_langu = sy-langu. "Language variable

*POPULATE HEADER DATA FOR PO

HEADER-COMP_CODE = company .

HEADER-DOC_TYPE = doctyp .

HEADER-CREAT_DATE = cdate .

HEADER-VENDOR = vendor .

HEADER-LANGU = ws_langu .

HEADER-PURCH_ORG = pur_org .

HEADER-PUR_GROUP = pur_grp .

&----


*POPULATE HEADER FLAG.

&----


HEADERX-comp_code = c_x.

HEADERX-doc_type = c_x.

HEADERX-creat_date = c_x.

HEADERX-vendor = c_x.

HEADERX-langu = c_x.

HEADERX-purch_org = c_x.

HEADERX-pur_group = c_x.

*HEADERX-doc_date = c_x.

&----


*POPULATE ITEM DATA.

&----


ITEM-PO_ITEM = item_num.

ITEM-MATERIAL = material.

ITEM-PLANT = plant.

ITEM-QUANTITY = quantity.

APPEND ITEM.

&----


*POPULATE ITEM FLAG TABLE

&----


ITEMX-PO_ITEM = item_num.

ITEMX-MATERIAL = C_X.

ITEMX-PLANT = C_X .

*ITEMX-STGE_LOC = C_X .

ITEMX-QUANTITY = C_X .

*ITEMX-TAX_CODE = C_X .

*ITEMX-ITEM_CAT = C_X .

*ITEMX-ACCTASSCAT = C_X .

APPEND ITEMX.

&----


*BAPI CALL

&----


CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

POHEADER = HEADER

POHEADERX = HEADERX

  • POADDRVENDOR =

  • TESTRUN =

IMPORTING

EXPPURCHASEORDER = V_EXPPURCHASEORDER

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

TABLES

RETURN = RETURN

POITEM = ITEM

POITEMX = ITEMX.

&----


*Confirm the document creation by calling database COMMIT

&----


CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

  • IMPORTING

  • RETURN =

.

end-of-selection.

***&----


****Output the messages returned from BAPI call

***&----


*LOOP AT RETURN.

WRITE / v_EXPPURCHASEORDER.

*ENDLOOP.

Read only

former_member404244
Active Contributor
0 Likes
430

Hi,

Yes u can do that..by the way as it warning message no need to worry about that.

reward if helpful

Regards,

nagaraj

Read only

Former Member
0 Likes
430

The problem still occur, after i call the function 'BAPI_PO_CREATE1', the return message said that

No instance of object type PurchaseOrder has been created. External reference:

Purchase order still contains faulty items

Can delivery date be met?

Net price must be greater than 0

And here is my header and item table

GV_HEADER-COMP_CODE = '5000'.

GV_HEADER-DOC_TYPE = 'NB'.

GV_HEADER-CREAT_DATE = sy-datum.

GV_HEADER-VENDOR = '00001000'.

GV_HEADER-LANGU = sy-langu.

GV_HEADER-PURCH_ORG = '112'.

GV_HEADER-PUR_GROUP = '382'.

  • &---------------------------------------------------------------------*

  • POPULATE HEADER FLAG.

  • &---------------------------------------------------------------------*

GV_HEADERX-comp_code = 'X'.

GV_HEADERX-doc_type = 'X'.

GV_HEADERX-creat_date = 'X'.

GV_HEADERX-vendor = 'X'.

GV_HEADERX-langu = 'X'.

GV_HEADERX-purch_org = 'X'.

GV_HEADERX-pur_group = 'X'.

  • HEADERX-doc_date = 'X'.

  • &---------------------------------------------------------------------*

  • POPULATE ITEM DATA.

  • &---------------------------------------------------------------------*

GV_ITEM-PO_ITEM = '10'.

GV_ITEM-MATERIAL = 'D1-203956'.

GV_ITEM-PLANT = '125'.

GV_ITEM-QUANTITY = '15'.

GV_ITEM-PRICE_UNIT = '11'.

APPEND GV_ITEM.

  • &---------------------------------------------------------------------*

  • POPULATE ITEM FLAG TABLE

  • &---------------------------------------------------------------------*

GV_ITEMX-PO_ITEM = '10'.

GV_ITEMX-MATERIAL = 'X'.

GV_ITEMX-PLANT = 'X' .

GV_ITEMX-QUANTITY = 'X'.

GV_ITEMX-PRICE_UNIT = 'X'.

APPEND GV_ITEMX.

Message was edited by:

Portfolio