2007 Feb 01 7:56 AM
Hello,
I am creating purchase orders using function BAPI_PO_CREATE1.
But the function creates an Inforecord for the ordered material (if no inforecord for the material exists then a new is created).
How to avoid it? I don't want any new info records, I just need to create a normal purchase order.
In POITEM table I set the following parameter:
poitem-INFO_UPD = ' '.
poitemx-INFO_UPD = 'X'.
but it doesn't work!
Please, help!
Thanks
Pawel
Hello,
I am creating purchase orders using function BAPI_PO_CREATE1.
But the function creates an Inforecord for the ordered material (if no inforecord for the material exists then a new is created).
How to avoid it? I don't want any new info records, I just need to create a normal purchase order.
In POITEM table I set the following parameter:
poitem-INFO_UPD = ' '.
poitemx-INFO_UPD = 'X'.
but it doesn't work!
Please, help!
Thanks
Pawel
2007 Feb 01 8:17 AM
constants : c_x value 'X'.
refresh pohead.
refresh poheadx.
clear pohead.
refresh poitem.
refresh poitemX.
pohead-DOC_TYPE = i_tab-bsart.
pohead-VENDOR = i_tab-lifnr.
pohead-PURCH_ORG = c_ekorg.
pohead-CREAT_DATE = i_tab-verkf1.
pohead-PUR_GROUP = c_ekgrp.
pohead-COMP_CODE = c_bukrs.
pohead-SALES_PERS = I_TAB-VERKF2.
pohead-doc_date = sy-datum.
pohead-langu = sy-langu.
IF I_TAB-CURRKEY = 'USD'.
pohead-CURRENCY = 'USDN'.
ELSE.
pohead-CURRENCY = I_TAB-CURRKEY.
ENDIF.
pohead-ITEM_INTVL = ''.
append pohead.
poheadx-DOC_TYPE = c_x.
poheadx-VENDOR = c_x.
poheadx-PURCH_ORG = c_x.
poheadx-PUR_GROUP = c_x.
poheadx-COMP_CODE = c_x.
poheadx-SALES_PERS = c_x.
poheadx-ITEM_INTVL = c_x.
poheadx-doc_date = c_x.
poheadx-CURRENCY = c_x.
poheadx-langu = c_x.
append poheadx.
refresh poitem.
clear poitem.
refresh poitemsch.
refresh poitemschx.
clear poitemsch.
clear poitemschx.
sort i_tab3 by verkf ebelp1.
loop at i_tab3 WHERE VERKF = I_TAB-VERKF.
clear poitem.
poitem-PO_ITEM = i_tab3-ebelp1.
poitem-MATERIAL = i_tab3-MATNR.
poitem-QUANTITY = i_tab3-MENGE.
poitem-PO_UNIT = i_tab3-BPRME.
poitem-NET_PRICE = i_tab3-NETPR.
poitem-NO_ROUNDING = 'X'.
poitem-PLANT = i_tab3-WERKS.
poitem-INFO_UPD = ''.
if i_tab3-PSTYP <> ''.
poitem-item_cat = i_tab3-PSTYP.
endif.
poitem-VEND_MAT = i_tab3-IDNLF.
append poitem.
clear poitemx.
poitemx-PO_ITEM = i_tab3-ebelp1.
poitemx-MATERIAL = c_x.
poitemx-QUANTITY = c_x.
poitemx-PO_UNIT = c_x.
poitemx-NET_PRICE = c_x.
poitemx-NO_ROUNDING = c_x.
poitemx-PLANT = c_x.
poitemx-GR_TO_DATE = c_x.
poitemx-INFO_UPD = c_x.
poitemx-tax_code = c_x.
poitemx-item_cat = c_x.
POITEMx-ACCTASSCAT = c_x.
poitemx-VEND_MAT = c_x.
append poitemx.
poitemsch-PO_ITEM = i_tab3-ebelp1.
poitemsch-SCHED_LINE = '0001'.
poitemsch-DELIVERY_DATE = i_tab3-LEWED.
poitemsch-QUANTITY = i_tab3-MENGE.
append poitemsch.
poitemschx-PO_ITEM = i_tab3-ebelp1.
poitemschx-SCHED_LINE = '0001'.
poitemschx-PO_ITEMX = C_X.
poitemschx-DELIVERY_DATE = c_x.
poitemschx-QUANTITY = C_X.
append poitemschx.
2007 Feb 01 8:31 AM
Hi,If you want a Normal Purchase order ... Look below sample code ..
*&---------------------------------------------------------------------*
*& Report ZBAPI_CREATE_PO *
*& *
*&---------------------------------------------------------------------*
*& Program demonstrates the BAPI call to create Purchase Order *
*& Minimum required parameters are used are as per the current *
*& system configuration *
*&---------------------------------------------------------------------*
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.
*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 '2700' ,
doctyp like HEADER-DOC_TYPE default 'NB' ,
cdate like HEADER-CREAT_DATE default sy-datum ,
vendor like HEADER-VENDOR default '0010000023',
pur_org like HEADER-PURCH_ORG default '2700' ,
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 '00001',
material like ITEM-MATERIAL default 'CRANE' ,
plant like ITEM-PLANT default '2700' ,
quantity like ITEM-QUANTITY default 100.
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 =
* 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 / RETURN-MESSAGE.
ENDLOOP./people/sap.user72/blog/2005/03/22/sample-code-to-create-purchase-order-using-bapi-in-r3
Regards
Sudheer
2007 Feb 01 8:37 AM
Hi
see below code
*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.
*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 '2700' ,
doctyp like HEADER-DOC_TYPE default 'NB' ,
cdate like HEADER-CREAT_DATE default sy-datum ,
vendor like HEADER-VENDOR default '0010000023',
pur_org like HEADER-PURCH_ORG default '2700' ,
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 '00001',
material like ITEM-MATERIAL default 'CRANE' ,
plant like ITEM-PLANT default '2700' ,
quantity like ITEM-QUANTITY default 100.
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 =
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 / RETURN-MESSAGE.
ENDLOOP.
2007 Feb 01 8:49 AM
Thank you all for the answers, but creating purchase orders works - my program works in this issue well.
The problem is that every time the purchase order is created and saved, new purchasing Info Record is created, and I don't know why and how to avoid it. I don't want any info records.
Pawel
2007 Feb 01 8:53 AM
Discuss with the functional consultant if any setting is there to remove to do not info record
2016 Sep 08 2:19 PM
Pay attention to not put a space between ''. I tried before with a space and it didn't work. So you have to left it empty:
poitem-INFO_UPD = ' '.
poitemx-INFO_UPD = 'X'.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |