Skip to Content
0
Former Member
Mar 27, 2006 at 01:09 PM

Error! Please enter Order unit when use BAPI_PO_CREATE1

1005 Views

Dear All,

I have found information message "Order unit EA cannot be used." and error message "Please enter Order unit" when use BAPI_PO_CREATE1 to crate poitem without material code.

Here is my ABAP Code. please help me, what do I miss?

REPORT ZC1TEST6 .

*DATA DECLARATION

CONSTANTS : C_X VALUE 'X'.

*Structures to hold PO header data

DATA : HEADER LIKE BAPIMEPOHEADER ,

HEADERX LIKE BAPIMEPOHEADERX .

*Structures to hold PO account data

DATA : ACCOUNT LIKE BAPIMEPOACCOUNT OCCURS 0 WITH HEADER LINE ,

ACCOUNTX LIKE BAPIMEPOACCOUNTX OCCURS 0 WITH HEADER LINE .

*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,

*Internal table to hold messages from BAPI call

POCONTRACTLIMITS LIKE BAPIESUCC OCCURS 0 WITH HEADER LINE.

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

PURCHASEORDER LIKE BAPIMEPOHEADER-PO_NUMBER,

DELIVERY_DATE LIKE BAPIMEPOSCHEDULE-DELIVERY_DATE.

data : ws_langu like sy-langu.

*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 '122' ,

doctyp like HEADER-DOC_TYPE default 'NB' ,

cdate like HEADER-CREAT_DATE default sy-datum ,

vendor like HEADER-VENDOR default '2000000012' ,

pur_org like HEADER-PURCH_ORG default 'PU01' ,

pur_grp like HEADER-PUR_GROUP default '005' .

*sociedad like HEADER-COMP_CODE default '122' ,

*vendedor like HEADER-SALES_PERS default 'sale person'.

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 '00010',

material like ITEM-MATERIAL default '12000000' ,

tipo_imp like ITEM-ACCTASSCAT default 'K' ,

*pos_doc like ITEM-ITEM_CAT default 'F' ,

shorttxt like ITEM-SHORT_TEXT default 'PRUEBA BAPI' ,

grup_art like ITEM-MATL_GROUP default '817230000' ,

plant like ITEM-PLANT default '3001' ,

mpe like ITEM-TRACKINGNO default '9999' ,

*contrato like ITEM-AGREEMENT default '4904000003' ,

*quantity like ITEM-QUANTITY default 1 .

po_unit like ITEM-PO_UNIT default 'EA'.

selection-screen end of block b2.

  • Par?mnetros de imputaci?n

selection-screen begin of block b3 with frame title text-004.

parameters : centro like ACCOUNT-COSTCENTER default '1220813150',

cuenta like ACCOUNT-GL_ACCOUNT default '6631400' ,

num_pos like ACCOUNT-PO_ITEM default '10' ,

serial like ACCOUNT-SERIAL_NO default '01' ,

ind_imp like ACCOUNT-TAX_CODE default 'I2' .

selection-screen end of block b3.

&----


START-OF-SELECTION.

&----


*DATA POPULATION

&----


ws_langu = sy-langu. "Language variable

*POPULATE HEADER DATA FOR PO

*HEADER-COMP_CODE = sociedad .

HEADER-DOC_TYPE = doctyp .

HEADER-VENDOR = vendor .

HEADER-CREAT_DATE = cdate .

HEADER-CREATED_BY = 'TD17191' .

HEADER-PURCH_ORG = pur_org .

HEADER-PUR_GROUP = pur_grp .

HEADER-COMP_CODE = company .

HEADER-LANGU = ws_langu .

*HEADER-SALES_PERS = vendedor .

*HEADER-CURRENCY = 'DOP' .

*HEADER-ITEM_INTVL = 10 .

*HEADER-PMNTTRMS = 'N30' .

*HEADER-EXCH_RATE = 1 .

&----


*POPULATE HEADER FLAG.

&----


HEADERX-comp_code = c_x.

HEADERX-doc_type = c_x.

HEADERX-vendor = c_x.

HEADERX-creat_date = c_x.

HEADERX-created_by = c_x.

HEADERX-purch_org = c_x.

HEADERX-pur_group = c_x.

HEADERX-langu = c_x.

*HEADERX-sales_pers = c_x.

*HEADERX-CURRENCY = c_x.

*HEADER-ITEM_INTVL = c_x.

*HEADER-PMNTTRMS = c_x.

*HEADER-EXCH_RATE = c_x.

*HEADER-EXCH_RATE = c_x.

&----


*POPULATE ITEM DATA.

&----


ITEM-PO_ITEM = item_num.

ITEM-QUANTITY = '1'.

*ITEM-MATERIAL = material .

ITEM-SHORT_TEXT = 'prueba bapi_po_create1'.

*ITEM-TAX_CODE = ''.

ITEM-ACCTASSCAT = 'K' .

*ITEM-ITEM_CAT = 'D' .

ITEM-MATL_GROUP = '817230000' .

ITEM-PLANT = '3001' .

ITEM-TRACKINGNO = '99999'.

ITEM-PREQ_NAME = 'test'.

*ITEM-AGREEMENT = '' .

*ITEM-AGMT_ITEM = ''.

ITEM-QUANTITY = '1' .

ITEM-PO_UNIT = 'EA'.

*ITEM-ORDERPR_UN = 'EA'.

ITEM-CONV_NUM1 = '1'.

ITEM-CONV_DEN1 = '1'.

ITEM-NET_PRICE = '1000000' .

ITEM-PRICE_UNIT = '1'.

ITEM-GR_PR_TIME = '0'.

ITEM-PRNT_PRICE = 'X'.

ITEM-UNLIMITED_DLV = 'X'.

ITEM-GR_IND = 'X' .

ITEM-IR_IND = 'X' .

ITEM-GR_BASEDIV = 'X'.

*ITEM-PCKG_NO = '' .

APPEND ITEM. CLEAR ITEM.

&----


*POPULATE ITEM FLAG TABLE

&----


ITEMX-PO_ITEM = item_num.

ITEMX-PO_ITEMX = c_x.

*ITEMX-MATERIAL = C_X.

ITEMX-SHORT_TEXT = C_X.

ITEMX-QUANTITY = C_X.

*ITEMX-TAX_CODE = C_X.

ITEMX-ACCTASSCAT = C_X.

*ITEMX-ITEM_CAT = c_x.

ITEMX-MATL_GROUP = C_X.

ITEMX-PLANT = C_X.

ITEMX-TRACKINGNO = C_X.

ITEMX-PREQ_NAME = C_X.

*ITEMX-AGREEMENT = C_X.

*ITEMX-AGMT_ITEM = c_x.

ITEMX-STGE_LOC = C_X.

ITEMX-QUANTITY = C_X.

ITEMX-PO_UNIT = C_X.

*ITEMX-ORDERPR_UN = C_X.

ITEMX-CONV_NUM1 = C_X.

ITEMX-CONV_DEN1 = C_X.

ITEMX-NET_PRICE = C_X.

ITEMX-PRICE_UNIT = C_X.

ITEMX-GR_PR_TIME = C_X.

ITEMX-PRNT_PRICE = C_X.

ITEMX-UNLIMITED_DLV = C_X.

ITEMX-GR_IND = C_X .

ITEMX-IR_IND = C_X .

ITEMX-GR_BASEDIV = C_X .

APPEND ITEMX. CLEAR ITEMX.

&----


*POPULATE ACCOUNT DATA.

&----


ACCOUNT-PO_ITEM = item_num.

ACCOUNT-SERIAL_NO = serial .

ACCOUNT-CREAT_DATE = sy-datum .

ACCOUNT-COSTCENTER = centro .

ACCOUNT-GL_ACCOUNT = cuenta .

ACCOUNT-GR_RCPT = 'tester'.

APPEND ACCOUNT. CLEAR ACCOUNT.

&----


*POPULATE ACCOUNT FLAG TABLE.

&----


ACCOUNTX-PO_ITEM = item_num .

ACCOUNTX-PO_ITEMX = c_x .

ACCOUNTX-SERIAL_NO = serial .

ACCOUNTX-SERIAL_NOX = c_x .

ACCOUNTX-CREAT_DATE = c_x .

ACCOUNTX-COSTCENTER = c_x .

ACCOUNTX-GL_ACCOUNT = c_x .

ACCOUNT-GR_RCPT = C_X.

APPEND ACCOUNTX. CLEAR ACCOUNTX.

&----


*BAPI CALL

&----


CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

POHEADER = HEADER

POHEADERX = HEADERX

IMPORTING

EXPPURCHASEORDER = PURCHASEORDER

TABLES

RETURN = RETURN

POITEM = ITEM

POITEMX = ITEMX

POACCOUNT = ACCOUNT

POACCOUNTX = ACCOUNTX.

&----


*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 / RETURN-MESSAGE.

ENDLOOP.