BAPI_PO_CREATE1 example
*& Report ZCHARLI *
*& 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 .
*Structures to hold PO account data
DATA : ACCOUNT LIKE BAPIMEPOACCOUNT OCCURS 0 WITH HEADER LINE ,
ACCOUNTX LIKE BAPIMEPOACCOUNTX OCCURS 0 WITH HEADER LINE .
*Structures to hold PO schedule data
DATA : ITEMSCHEDULE LIKE BAPIMEPOSCHEDULE OCCURS 0 WITH HEADER LINE ,
ITEMSCHEDULEX LIKE BAPIMEPOSCHEDULX OCCURS 0 WITH HEADER LINE .
*Structures to hold PO (distrib.imputac.lín.servicios) data
DATA : POSRVACCESSVALUES LIKE BAPIESKLC OCCURS 0 WITH HEADER LINE .
*Structures to hold PO services data
DATA : SERVICES LIKE BAPIESLLC 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 '1000' ,
doctyp like HEADER-DOC_TYPE default 'PM' ,
cdate like HEADER-CREAT_DATE default sy-datum ,
vendor like HEADER-VENDOR default '100006' ,
pur_org like HEADER-PURCH_ORG default '1000' ,
pur_grp like HEADER-PUR_GROUP default '850' ,
sociedad like HEADER-COMP_CODE default '1000' ,
vendedor like HEADER-SALES_PERS default 'Wilda Messina'.
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 'CRANE' ,
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 '350001' ,
plant like ITEM-PLANT default '1000' ,
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 'UP'.
selection-screen end of block b2.
Parámnetros para los servicios
selection-screen begin of block b3 with frame title text-003.
parameters : paquete like SERVICES-PCKG_NO default '956',
numlinin like SERVICES-LINE_NO default '9' ,
numlinea like SERVICES-EXT_LINE default '80',
service like SERVICES-SERVICE default '8010',
srv_cant like SERVICES-quantity default '5' ,
precio like SERVICES-GR_PRICE default '300' ,
impuesto like SERVICES-TAX_CODE default 'I2' .
selection-screen end of block b3.
Parámnetros de imputación
selection-screen begin of block b4 with frame title text-004.
parameters : centro like ACCOUNT-COSTCENTER default '120100',
cuenta like ACCOUNT-GL_ACCOUNT default '6501002000' ,
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 b4.
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 = '10'.
ITEM-QUANTITY = '1'.
*ITEM-MATERIAL = material .
ITEM-SHORT_TEXT = 'prueba bapi_po_create1'.
ITEM-TAX_CODE = 'I2'.
ITEM-ACCTASSCAT = 'K' .
ITEM-ITEM_CAT = 'F' .
ITEM-MATL_GROUP = '350001' .
ITEM-PLANT = '1000' .
ITEM-TRACKINGNO = '99999'.
ITEM-AGREEMENT = '4904000004' .
ITEM-AGMT_ITEM = '0010'.
ITEM-QUANTITY = '1' .
ITEM-PO_UNIT = 'UP'.
*ITEM-ORDERPR_UN = 'UP'.
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 = '2748' .
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-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 .
ITEMX-PCKG_NO = C_X.
APPEND ITEMX. CLEAR ITEMX.
*POPULATE ITEM SCHEDULE DATA.
ITEMSCHEDULE-PO_ITEM = '00010'.
ITEMSCHEDULE-DEL_DATCAT_EXT = 'T'.
ITEMSCHEDULE-DELIVERY_DATE = '21.04.2005'. "sy-datum + 2 dias.
*ITEM_SCHEDULE-QUANTITY = '1'. "ITDETALLE-CANTIDAD.
APPEND ITEMSCHEDULE.
CLEAR ITEMSCHEDULE.
*POPULATE ITEM FLAG FOR SCHEDULE TABLE.
ITEMSCHEDULEX-PO_ITEM = '10'.
ITEMSCHEDULEX-PO_ITEMX = c_x .
ITEMSCHEDULEX-DEL_DATCAT_EXT = c_x.
ITEMSCHEDULEX-DELIVERY_DATE = c_x .
*ITEMSCHEDULEX-QUANTITY = '1' . "ITDETALLE-CANTIDAD.
APPEND ITEMSCHEDULEX.
CLEAR ITEMSCHEDULEX.
*POPULATE ACCOUNT DATA.
ACCOUNT-PO_ITEM = '10' .
ACCOUNT-SERIAL_NO = serial .
ACCOUNT-CREAT_DATE = sy-datum .
ACCOUNT-COSTCENTER = centro .
ACCOUNT-GL_ACCOUNT = cuenta .
ACCOUNT-CO_AREA = 'CD01' .
ACCOUNT-TAX_CODE = 'I2' .
APPEND ACCOUNT. CLEAR ACCOUNT.
*POPULATE ACCOUNT FLAG TABLE.
ACCOUNTX-PO_ITEM = '10' .
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 .
ACCOUNTX-CO_AREA = c_x .
ACCOUNTX-TAX_CODE = c_x .
APPEND ACCOUNTX. CLEAR ACCOUNTX.
*POPULATE POSRVACCESSVALUES TABLE DATA.
FIRST ENTRY
POSRVACCESSVALUES-PCKG_NO = '0000002749' .
POSRVACCESSVALUES-LINE_NO = '0000000002' .
POSRVACCESSVALUES-SERNO_LINE = '01'.
POSRVACCESSVALUES-PERCENTAGE = '100'.
POSRVACCESSVALUES-SERIAL_NO = '01'.
*POSRVACCESSVALUES-QUANTITY = '1'.
POSRVACCESSVALUES-NET_VALUE = '850'.
APPEND POSRVACCESSVALUES . CLEAR POSRVACCESSVALUES.
SECOND ENTRY
POSRVACCESSVALUES-PCKG_NO = '0000002749' .
POSRVACCESSVALUES-LINE_NO = '0000000003' .
POSRVACCESSVALUES-SERNO_LINE = '01'.
POSRVACCESSVALUES-PERCENTAGE = '100'.
POSRVACCESSVALUES-SERIAL_NO = '01'.
*POSRVACCESSVALUES-QUANTITY =
POSRVACCESSVALUES-NET_VALUE = '150'.
APPEND POSRVACCESSVALUES . CLEAR POSRVACCESSVALUES.
*POPULATE SERVICES DATA.
servicio JERARQUIA SUPERIOR
SERVICES-PCKG_NO = '2748'.
SERVICES-LINE_NO = '0000000001' .
SERVICES-EXT_LINE = '0000000000' .
SERVICES-OUTL_LEVEL = '0'.
SERVICES-OUTL_NO = ' '.
SERVICES-OUTL_IND = 'X'.
SERVICES-SUBPCKG_NO = '2749'.
*SERVICES-SERVICE = ' ' .
SERVICES-EDITION = '0000' .
*SERVICES-BASE_UOM = '
SERVICES-QUANTITY = '0' .
SERVICES-OVF_TOL = '0' .
SERVICES-GR_PRICE = '0' .
SERVICES-FROM_LINE = '1' .
SERVICES-PERS_NO = '00000000' .
SERVICES-PLN_PCKG = '0000000000' .
SERVICES-PLN_LINE = '0000000000' .
SERVICES-CON_PCKG = '0000000000' .
SERVICES-CON_LINE = '0000000000' .
SERVICES-TMP_PCKG = '0000000000' .
SERVICES-TMP_LINE = '0000000000' .
SERVICES-LIMIT_LINE = '0000000000' .
SERVICES-TAX_CODE = impuesto .
*SERVICES-SHORT_TEXT = 'prueba creacion BAPI'.
*SERVICES-MATL_GROUP = '350001'.
APPEND SERVICES. CLEAR SERVICES .
servicio 1
SERVICES-PCKG_NO = '2749'.
SERVICES-LINE_NO = '2' .
SERVICES-EXT_LINE = '10' .
SERVICES-OUTL_LEVEL = '0'.
*SERVICES-OUTL_NO = ' '.
*SERVICES-OUTL_IND = 'X'.
SERVICES-SUBPCKG_NO = '0000000000'.
SERVICES-SERVICE = '000000000000008010'.
SERVICES-EDITION = '0000' .
SERVICES-BASE_UOM = 'UNO' .
SERVICES-UOM_ISO = 'C62' .
SERVICES-QUANTITY = '1' .
SERVICES-PRICE_UNIT = '1' .
SERVICES-OVF_TOL = '0' .
*SERVICES-FROM_LINE = '1' .
SERVICES-SHORT_TEXT = 'prueba creacion BAPI'.
SERVICES-PERS_NO = '00000000' .
SERVICES-PLN_PCKG = '0000001980' .
SERVICES-PLN_LINE = '0000000002' .
SERVICES-CON_PCKG = '0000001980' .
SERVICES-CON_LINE = '0000000002' .
SERVICES-TMP_PCKG = '0000000000' .
SERVICES-TMP_LINE = '0000000000' .
SERVICES-LIMIT_LINE = '0000000000' .
SERVICES-TAX_CODE = 'I2' .
SERVICES-GR_PRICE = '850' .
SERVICES-MATL_GROUP = '350001'.
APPEND SERVICES. CLEAR SERVICES .
*POPULATE CONTRACT LIMITS DATA.
POCONTRACTLIMITS-PCKG_NO = '956'.
POCONTRACTLIMITS-CON_NUMBER = '4903000004'.
POCONTRACTLIMITS-CON_ITEM = '10'.
POCONTRACTLIMITS-NO_LIMIT = c_x.
POCONTRACTLIMITS-PRICE_CHG = c_x.
APPEND POCONTRACTLIMITS. CLEAR POCONTRACTLIMITS .
*BAPI CALL
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = HEADER
POHEADERX = HEADERX
POADDRVENDOR =
TESTRUN =
IMPORTING
EXPPURCHASEORDER = PURCHASEORDER
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
RETURN = RETURN
POITEM = ITEM
POITEMX = ITEMX
POSCHEDULE = ITEMSCHEDULE
POSCHEDULEX = ITEMSCHEDULEX
POACCOUNT = ACCOUNT
POACCOUNTX = ACCOUNTX
POSERVICES = SERVICES.
*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.
This is the code I use to get the package number:
vebeln = AGREEMENT. "open purchase order
first = 'N'.
SELECT * FROM eslh WHERE ebeln = vebeln ORDER BY packno.
IF first = 'N'.
first_pack = eslh-packno.
primero = 'S'.
ELSE.
last_pack = eslh-packno.
ENDIF.
ENDSELECT.
SELECT packno introw extrow srvpos package sub_packno meins brtwr FROM esll INTO TABLE itserv
WHERE packno BETWEEN first_pack AND last_pack.
at the end you'll get the ITSERV internal table with all the services for that specific agreement or contract. Agreement is the same as a BAPIMEPOITEM-AGREEMENT. This services will let you populate the BAPI's SERVICES internal table and you'll have in the "first_pack" variable the value you have to put in the item table in the field item-pckg_no.
Similar Messages
-
Hi Experts,
I use BAPI_PO_CREATE1 to create a purchase order(stock transfer order - UD), but does anyone know how to assign parameters to the interface of the BAPI? but when I go to transaction ME21N I enter the purchase org, group, material number, quantity, plant, and supplying plant and I click save, then a purchase order is generated but how can I use this BAPI to generate purchase order? can anyone tell me in detail?
thank you in advance.
Kind regards
DawsonHi,
Please find the code below in order to create a PO from BAPI_PO_CREATE1
Example of population of BAPI interface in the Function Builder
Parameter: POHEADER
COMP_CODE = 1000
DOC_TYPE = UB
ITEM_INTVL = 00001
VENDOR = 0000001000
PMNTTRMS = 0001
PURCH_ORG = 1000
PUR_GROUP = 001
CURRENCY = EUR
Parameter: POHEADERX
COMP_CODE = X
DOC_TYPE = X
ITEM_INTVL = X
VENDOR = X
PMNTTRMS = X
PURCH_ORG = X
PUR_GROUP = X
Parameter: POITEM
PO_ITEM = 00001
MATERIAL = 100-100
PLANT = 1000
STGE_LOC = 0001
QUANTITY = 15.000
TAX_CODE = V0
ITEM_CAT = 0
ACCTASSCAT = K
Parameter: POITEMX
PO_ITEM = 00001
MATERIAL = X
PLANT = X
STGE_LOC = X
QUANTITY = X
TAX_CODE = X
ITEM_CAT = X
ACCTASSCAT = X
Parameter: POSCHEDULE
PO_ITEM = 00001
SCHED_LINE = 0001
DELIVERY_DATE = 02.12.2002
QUANTITY = 6.000
PO_ITEM = 00001
SCHED_LINE = 0002
DELIVERY_DATE = 03.12.2002
QUANTITY = 5.000
PO_ITEM = 00001
SCHED_LINE = 0003
DELIVERY_DATE = 04.12.2002
QUANTITY = 4.000
Parameter: POSCHEDULEX
PO_ITEM = 00001
SCHED_LINE = 0001
PO_ITEMX = X
SCHED_LINEX = X
DELIVERY_DATE = X
QUANTITY = X
PO_ITEM = 00001
SCHED_LINE = 0002
PO_ITEMX = X
SCHED_LINEX = X
DELIVERY_DATE = X
QUANTITY = X
PO_ITEM = 00001
SCHED_LINE = 0003
PO_ITEMX = X
SCHED_LINEX = X
DELIVERY_DATE = X
QUANTITY = X
Parameter: POACCOUNT
PO_ITEM = 00001
SERIAL_NO = 01
QUANTITY = 15.000
GL_ACCOUNT = 0000400000
COSTCENTER = 0000001000
CO_AREA = 1000
Parameter: POACCOUNTX
PO_ITEM = 00001
SERIAL_NO = 01
QUANTITY = X
GL_ACCOUNT = X
COSTCENTER = X
CO_AREA = X
Parameter: POCOND
ITM_NUMBER = 000001
COND_ST_NO = 001
COND_TYPE = PB00
COND_VALUE = 79.900000000
CURRENCY = EUR
CURRENCY_ISO = EUR
COND_UNIT = KG
COND_P_UNT = 1
CHANGE_ID = U
Parameter: POCONDX
ITM_NUMBER = 000001
COND_ST_NO = 000
ITM_NUMBERX = X
COND_TYPE = X
COND_VALUE = X
CURRENCY = X
CHANGE_ID = X
Parameter: POPARTNER
PARTNERDESC = OA
LANGU = EN
BUSPARTNO = 0000001100
PARTNERDESC = GS
LANGU = EN
BUSPARTNO = 0000001200
PARTNERDESC = PI
LANGU = EN
BUSPARTNO = 0000001000
Do not forget to call BAPI_TRANSACTION_COMMIT after bapi call.
KR Jaideep, -
BAPI_PO_CREATE1 error
Hi all,
While creating po through bapi_po_create1 i am getting error In MM ChapterID is not created for 00010.But since this is non-exciseable item i guess chapter ID is not maintained.So please tell me solution to avoid this error in bapi.
Regards.
Akanksha.I ran a search on the function module name here on SDN, got a couple hits. Here are some links to ones that may help you out.
BAPI_PO_CREATE1 FAILURE exception raised
An example program.
BAPI_PO_CREATE1 example
May not hurt to check OSS, see if there is anything relevant.
Regards,
Rich Heilman -
[VERY LOW IMPORTANCE] Creation of a Service Po via BAPI_PO_CREATE1
Hi guys.
I need a complete or maybe a code solution to implement a Service PO creation using BAPI_PO_CREATE1. All the examples I see just only show at least 1 service item and trying to reply those examples was ùnsuccesful...
Pease can anyone provide me a code using BAPI_PO_CREATE1, for a list of N service items.
Thanks in advance.
RR:
Edited by: Julius Bussche on Feb 16, 2010 8:37 AM
Importance "corrected" ...Hi guys...
Finally I found the solution, in a quite clear ABAP code.
As you mention Manesh, we have to increment by2 for each service Item in the package number. I mean: remember we have a service line in ME21N (showing this transaction code as an example) and for each service we can have N position items. In my case, only we need 1:1 relation (service and position).
Considering we need a package number per each service (f.e. 0000013291), a subpackage number per each position (this is the package number incremented by one -0000013292- if there is another position then the subpackage number is 0000013293 and so on). After we've completed all the positions for the previous service wa have to increment by (N + 1) where N is the number of positions taken by the previous service. So if the previous have 3 positions (0000013292, 0000013293 and 0000013294) then the new package number is 0000013295. Don't forget that if we have a service with N positions then we need to complete the POSERVICES table 2XN times (for the N positions and repeat N times the main service declaration for which correspond all these positions:
services-pckg_no = pckg_nro.
services-line_no = gvc_no.
services-subpckg_no = pckg_nro + 1.
I hope you've understood clearly my explanation.
Well here is the code. -
PO creation through BAPI_PO_CREATE1
Hi,
Can I get the fields to be entered in BAPI_PO_CREATE1 for PO creation ( Header and Item details)
Thanks,
AratiHi,
Go to TCode BAPI - Open Path Materials Management - Purchasing - PurchaseOrder - CreateFromData1 - Here on Right Side click on "Documentation" Tab to see the details of fields to be maintained.
Example
Example of population of BAPI interface in the Function Builder
Parameter: POHEADER
COMP_CODE = 1000
DOC_TYPE = NB
ITEM_INTVL = 00001
VENDOR = 0000001000
PMNTTRMS = 0001
PURCH_ORG = 1000
PUR_GROUP = 001
CURRENCY = EUR
Parameter: POHEADERX
COMP_CODE = X
DOC_TYPE = X
ITEM_INTVL = X
VENDOR = X
PMNTTRMS = X
PURCH_ORG = X
PUR_GROUP = X
Parameter: POITEM
PO_ITEM = 00001
MATERIAL = 100-100
PLANT = 1000
STGE_LOC = 0001
QUANTITY = 15.000
TAX_CODE = V0
ITEM_CAT = 0
ACCTASSCAT = K
Parameter: POITEMX
PO_ITEM = 00001
MATERIAL = X
PLANT = X
STGE_LOC = X
QUANTITY = X
TAX_CODE = X
ITEM_CAT = X
ACCTASSCAT = X
Parameter: POSCHEDULE
PO_ITEM = 00001
SCHED_LINE = 0001
DELIVERY_DATE = 02.12.2002
QUANTITY = 6.000
PO_ITEM = 00001
SCHED_LINE = 0002
DELIVERY_DATE = 03.12.2002
QUANTITY = 5.000
PO_ITEM = 00001
SCHED_LINE = 0003
DELIVERY_DATE = 04.12.2002
QUANTITY = 4.000
Parameter: POSCHEDULEX
PO_ITEM = 00001
SCHED_LINE = 0001
PO_ITEMX = X
SCHED_LINEX = X
DELIVERY_DATE = X
QUANTITY = X
PO_ITEM = 00001
SCHED_LINE = 0002
PO_ITEMX = X
SCHED_LINEX = X
DELIVERY_DATE = X
QUANTITY = X
PO_ITEM = 00001
SCHED_LINE = 0003
PO_ITEMX = X
SCHED_LINEX = X
DELIVERY_DATE = X
QUANTITY = X
Parameter: POACCOUNT
PO_ITEM = 00001
SERIAL_NO = 01
QUANTITY = 15.000
GL_ACCOUNT = 0000400000
COSTCENTER = 0000001000
CO_AREA = 1000
Parameter: POACCOUNTX
PO_ITEM = 00001
SERIAL_NO = 01
QUANTITY = X
GL_ACCOUNT = X
COSTCENTER = X
CO_AREA = X
Parameter: POCOND
ITM_NUMBER = 000001
COND_ST_NO = 001
COND_TYPE = PB00
COND_VALUE = 79.900000000
CURRENCY = EUR
CURRENCY_ISO = EUR
COND_UNIT = KG
COND_P_UNT = 1
CHANGE_ID = U
Parameter: POCONDX
ITM_NUMBER = 000001
COND_ST_NO = 000
ITM_NUMBERX = X
COND_TYPE = X
COND_VALUE = X
CURRENCY = X
CHANGE_ID = X
Parameter: POPARTNER
PARTNERDESC = OA
LANGU = EN
BUSPARTNO = 0000001100
PARTNERDESC = GS
LANGU = EN
BUSPARTNO = 0000001200
PARTNERDESC = PI
LANGU = EN
BUSPARTNO = 0000001000 -
Hi,
Currently I'm facing an error "In case of account assignment, please enter acc. assignment data for item" when create a Purchase Order using BAPI_PO_CREATE1. The condition of the data that need to pump into the system is that this PO is an open item PO where does not require a metarial code for input, but it will pump in Short Text and Material Group. Other than that, the account assignment category is "K" and the item category is "9".
Below is the coding that I have implemented.
IF wa_temp_upr1-waers IS NOT INITIAL.
MOVE wa_temp_upr1-waers TO wa_header-currency.
wa_headerx-currency = abap_true.
ENDIF.
MOVE: wa_temp_upr1-lifnr TO wa_header-vendor,
wa_temp_upr1-unsez TO wa_header-collect_no,
wa_temp_upr1-bukrs TO wa_header-comp_code,
sy-datum TO wa_header-doc_date,
sy-langu TO wa_header-langu,
'KTN1' TO wa_header-purch_org,
wa_temp_upr1-bkgrp TO wa_header-pur_group,
wa_temp_upr1-zterm TO wa_header-pmnttrms.
wa_headerx-collect_no = abap_true.
wa_headerx-po_number = abap_true.
wa_headerx-comp_code = abap_true.
wa_headerx-vendor = abap_true.
wa_headerx-doc_date = abap_true.
wa_headerx-langu = abap_true.
wa_headerx-purch_org = abap_true.
wa_headerx-pur_group = abap_true.
wa_headerx-pmnttrms = abap_true.
IF wa_temp_upr1-meins IS NOT INITIAL.
MOVE wa_temp_upr1-meins TO zunit_e.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
INPUT = zunit_e
LANGUAGE = 'E'
IMPORTING
OUTPUT = zunit_e.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ELSE.
MOVE zunit_e TO wa_temp_upr1-meins.
ENDIF.
MODIFY it_upr1 FROM wa_temp_upr1.
ENDIF.
ADD 10 TO line_item.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
NR_RANGE_NR = '01'
OBJECT = 'SERVICE'
IMPORTING
NUMBER = pckg_no.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = wa_temp_upr1-matnr
IMPORTING
OUTPUT = wa_po_item-material.
MOVE: line_item TO wa_po_item-po_item,
wa_temp_upr1-ewerks TO wa_po_item-plant,
wa_temp_upr1-lgort TO wa_po_item-stge_loc,
wa_temp_upr1-matnr TO wa_po_item-material,
wa_temp_upr1-menge TO wa_po_item-quantity,
wa_temp_upr1-peinh TO wa_po_item-price_unit,
wa_temp_upr1-netpr TO wa_po_item-net_price,
wa_temp_upr1-meins TO wa_po_item-po_unit,
wa_temp_upr1-afnam TO wa_po_item-preq_name,
wa_temp_upr1-eeind TO wa_po_item-price_date,
' ' TO wa_po_item-gr_ind,
'X' TO wa_po_item-ir_ind,
'X' TO wa_po_item-prnt_price,
' ' TO wa_po_item-distrib.
wa_po_item-acctasscat = 'K'.
MOVE pckg_no TO wa_po_item-pckg_no.
wa_po_itemx-pckg_no = abap_true.
IF wa_temp_upr1-bismt IS INITIAL.
MOVE: wa_temp_upr1-short_text TO wa_po_item-short_text,
wa_temp_upr1-matl_group TO wa_po_item-matl_group,
'9' TO wa_po_item-item_cat.
wa_po_itemx-short_text = abap_true.
wa_po_itemx-matl_group = abap_true.
wa_po_itemx-item_cat = abap_true.
wa_potext-po_item = wa_po_item-po_item.
wa_potext-text_id = 'F01'.
APPEND wa_potext TO it_potext.
ENDIF.
MOVE wa_po_item-po_item TO wa_po_itemx-po_item.
wa_po_itemx-plant = abap_true.
wa_po_itemx-po_itemx = abap_true.
wa_po_itemx-stge_loc = abap_true.
IF wa_po_item-material IS NOT INITIAL.
wa_po_itemx-material = abap_true.
ENDIF.
wa_po_itemx-quantity = abap_true.
wa_po_itemx-price_unit = abap_true.
wa_po_itemx-net_price = abap_true.
wa_po_itemx-po_unit = abap_true.
wa_po_itemx-preq_name = abap_true.
wa_po_itemx-price_date = abap_true.
wa_po_itemx-acctasscat = abap_true.
wa_po_itemx-gr_ind = abap_true.
wa_po_itemx-distrib = abap_true.
wa_po_itemx-part_inv = abap_true.
APPEND wa_po_item TO it_item.
APPEND wa_po_itemx TO it_itemx.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = wa_temp_upr1-kostl
IMPORTING
OUTPUT = wa_temp_upr1-kostl.
wa_account-costcenter = wa_temp_upr1-kostl.
ADD 1 TO l_acc.
ADD 10 TO v_po_item.
MOVE v_po_item TO wa_account-po_item.
MOVE '01' TO wa_account-serial_no.
APPEND wa_account TO it_account.
wa_accountx-costcenter = abap_true.
MOVE v_po_item TO wa_accountx-po_item.
MOVE '01' TO wa_accountx-serial_no.
wa_accountx-SERIAL_NOX = abap_true.
wa_accountx-po_itemx = abap_true.
APPEND wa_accountx TO it_accountx.
*********** services
wa_services-pckg_no = pckg_no.
wa_services-line_no = '0000000001'.
wa_services-outl_ind = 'X'.
wa_services-subpckg_no = pckg_no + 1.
wa_services-quantity = wa_temp_upr1-menge.
wa_services-base_uom = wa_temp_upr1-meins.
wa_services-price_unit = wa_temp_upr1-peinh.
wa_services-gr_price = wa_temp_upr1-netpr.
IF wa_temp_upr1-short_text IS NOT INITIAL.
wa_services-short_text = wa_temp_upr1-short_text.
ENDIF.
APPEND wa_services TO it_services.
CLEAR: wa_services,
val_lin.
wa_services-pckg_no = pckg_no + 1.
wa_services-line_no = '0000000002'.
wa_services-quantity = wa_temp_upr1-menge.
wa_services-base_uom = wa_temp_upr1-meins.
wa_services-price_unit = wa_temp_upr1-peinh.
wa_services-gr_price = wa_temp_upr1-netpr.
IF wa_temp_upr1-short_text IS NOT INITIAL.
wa_services-short_text = 'SERVICE 1'.
ENDIF.
IF NOT wa_temp_upr1-matl_group IS INITIAL.
wa_services-matl_group = wa_temp_upr1-matl_group.
ENDIF.
APPEND wa_services TO it_services.
************* service account assignment
wa_services_acc-pckg_no = pckg_no + 1.
wa_services_acc-line_no = '0000000002'.
wa_services_acc-serno_line = '01'.
wa_services_acc-quantity = wa_temp_upr1-menge.
wa_services_acc-serial_no = '01'.
wa_services_acc-net_value = wa_temp_upr1-netpr.
APPEND wa_services_acc TO it_services_acc.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = wa_header
POHEADERX = wa_headerx
TESTRUN = pa_test
NO_PRICE_FROM_PO = 'X'
IMPORTING
EXPPURCHASEORDER = va_ebeln
EXPHEADER = wa_expheader
TABLES
RETURN = it_return
POITEM = it_item
POITEMX = it_itemx
POACCOUNT = it_account
POACCOUNTX = it_accountx
POSERVICES = it_services
POSRVACCESSVALUES = it_services_acc
POTEXTITEM = it_potext.
I have done some search regarding this error and try to implemented it, but still does not working.
example website that i found for this error is:
David Klein's Corner: SAP Purchase Order Creation Error via BAPI - "In case of account assignment, please enter acc…
PO Upload through BAPI_PO_CREATE1 - Problem in Service Item
Currently my system is using: SAP_APPL SAPKH60604
I am really stuck on this error. Hope you all can help me on this matter.
Thanks.Hi,
Filling the service line have the problem,
while filling the services we must follow correct order,
Here You entering the new services, first manually create purchase order after that observe the table
'ESLL' and use the FM;-' MS_FETCH_SPEC_FOR_LIST' how the services are inserting after that you also follow the same order.
if service entries are created before the creation of the PO.
then follow as bellow....
SELECT * FROM esll INTO TABLE lt_esll WHERE packno = wa_tmp_spec-packno.
IF sy-subrc = '0'.
LOOP AT lt_esll.
CLEAR : lt_poservices.
lt_poservices-pckg_no = lt_esll-packno .
lt_poservices-line_no = lt_esll-introw .
lt_poservices-ext_line = lt_esll-extrow .
lt_poservices-outl_level = lt_esll-rang .
lt_poservices-outl_no = lt_esll-extgroup .
lt_poservices-outl_ind = lt_esll-del .
lt_poservices-subpckg_no = lt_esll-sub_packno .
lt_poservices-service = lt_esll-srvpos .
lt_poservices-edition = lt_esll-ausgb .
lt_poservices-ssc_item = lt_esll-stlvpos .
lt_poservices-ext_serv = lt_esll-extsrvno.
lt_poservices-quantity = lt_esll-menge .
lt_poservices-base_uom = lt_esll-meins .
lt_poservices-ovf_tol = lt_esll-uebto .
lt_poservices-ovf_unlim = lt_esll-uebtk .
lt_poservices-gr_price = lt_esll-tbtwr .
lt_poservices-from_line = lt_esll-frompos .
lt_poservices-to_line = lt_esll-knt_introw.
lt_poservices-short_text = lt_esll-ktext1 .
lt_poservices-distrib = lt_esll-vrtkz .
lt_poservices-pers_no = lt_esll-pernr .
lt_poservices-wagetype = lt_esll-lgart .
lt_poservices-con_pckg = lt_esll-knt_packno.
lt_poservices-con_line = lt_esll-knt_introw .
lt_poservices-matl_group = lt_esll-matkl .
lt_poservices-taxjurcode = lt_esll-txjcd.
lt_poservices-tax_code = lt_esll-mwskz .
lt_poservices-date = lt_esll-sdate .
APPEND lt_poservices TO lt_poservices[].
CLEAR lt_esll.
ENDLOOP.
ENDIF.
CALL FUNCTION 'MS_FETCH_SPEC_FOR_LIST'
EXPORTING
spec_packno = wa_tmp_spec-packno
* ONLINE_DATA = ' '
* IMPORTING
* LIMIT =
TABLES
servicetab = lt_ml_esll1
* LIMITTAB =
EXCEPTIONS
no_specification_exist = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
LOOP AT lt_ml_esll1 INTO DATA(ls_ml_esll1).
CLEAR : lt_poservices.
lt_poservices-pckg_no = ls_ml_esll1-packno .
lt_poservices-line_no = ls_ml_esll1-introw .
lt_poservices-ext_line = ls_ml_esll1-extrow .
lt_poservices-outl_level = ls_ml_esll1-rang .
lt_poservices-outl_no = ls_ml_esll1-extgroup .
lt_poservices-outl_ind = ls_ml_esll1-del .
lt_poservices-subpckg_no = ls_ml_esll1-sub_packno .
lt_poservices-service = ls_ml_esll1-srvpos .
lt_poservices-edition = ls_ml_esll1-ausgb .
lt_poservices-ssc_item = ls_ml_esll1-stlvpos .
lt_poservices-ext_serv = ls_ml_esll1-extsrvno.
lt_poservices-quantity = ls_ml_esll1-menge .
lt_poservices-base_uom = ls_ml_esll1-meins .
lt_poservices-ovf_tol = ls_ml_esll1-uebto .
lt_poservices-ovf_unlim = ls_ml_esll1-uebtk .
lt_poservices-gr_price = ls_ml_esll1-tbtwr .
lt_poservices-from_line = ls_ml_esll1-frompos .
lt_poservices-to_line = ls_ml_esll1-knt_introw.
lt_poservices-short_text = ls_ml_esll1-ktext1 .
lt_poservices-distrib = ls_ml_esll1-vrtkz .
lt_poservices-pers_no = ls_ml_esll1-pernr .
lt_poservices-wagetype = ls_ml_esll1-lgart .
lt_poservices-con_pckg = ls_ml_esll1-knt_packno.
lt_poservices-con_line = ls_ml_esll1-knt_introw .
lt_poservices-matl_group = ls_ml_esll1-matkl .
lt_poservices-taxjurcode = ls_ml_esll1-txjcd.
lt_poservices-tax_code = ls_ml_esll1-mwskz .
lt_poservices-date = ls_ml_esll1-sdate .
APPEND lt_poservices TO lt_poservices[].
CLEAR ls_ml_esll1.
ENDLOOP.
CLEAR : lt_poservices.
*& Filling the po service values internal table from service internal table
LOOP AT lt_poservices[] INTO lt_poservices WHERE gr_price GT 0.
READ TABLE lt_ml_esll1 INTO wa_msll WITH KEY packno = lt_poservices-pckg_no
introw = lt_poservices-line_no
extrow = lt_poservices-ext_line..
IF sy-subrc EQ 0.
CLEAR lt_posvalues.
lt_posvalues-pckg_no = wa_msll-packno.
lt_posvalues-line_no = wa_msll-introw.
lt_posvalues-quantity = wa_msll-menge.
* lt_posvalues-net_value = wa_msll-netwr.
lt_posvalues-serno_line = '01'.
lt_posvalues-serial_no = '01'.
* lt_posvalues-percentage = '100'.
APPEND lt_posvalues TO lt_posvalues[].
CLEAR : wa_msll.
ENDIF.
ENDLOOP.
note:- if it is correct give points -
Issue when uploading Purchase Order for Services (LSMW and BAPI_PO_CREATE1)
Hi,
I`m getting the error message "In case of account assignment, please enter acc. assignment data for item" when trying to updoad a Service Purchase Order via LSMW using BAPI_PO_CREATE1.
I'm using two files, one for header and item data and the other one to service lines. Even the account assignment is maintained the error persists. What am I doing wrong?
Regards,
EvertonHi
Check If you are giving the Account Assignment Number correct.
I mean....for a value...to be recognized by the BAPI, the number should be exactly same as it is stored in DATABASE.
For example: the number stored in database is 0000123...and you enter 123..in the program, then BAPI would fail to recognise the number. The value should be exactly as the field length.
Regards,
Vishwa. -
PO item characteristic using BAPI_PO_CREATE1
Dear All,
I am uploading open purchase order using BAPI_PO_CREATE1. everything is working fine. but for Semi-finished products i have to upload Individual length. i.e. in characterstics of purchase order item.
kindly helpHi
Please go through the documentation in SE37 for the FM.. It is very clear on how you need to work on this BAPI. It is given with examples.
Regards,
Vishwa. -
PO creation by using BAPI_PO_CREATE1
Hi gurus'
I have to create open po by using bapi BAPI_PO_CREATE1.
Po created properly as per our inputs but in created po created date has take current date.Why is not taken input created date.
can any one suggest me. why is happend and how to corrected throught bapi.
Best regards.
PravinHi
Please go through the documentation in SE37 for the FM.. It is very clear on how you need to work on this BAPI. It is given with examples.
Regards,
Vishwa. -
Problem in Capturing Item text (BAPI_PO_CREATE1 )
HI Experts
I have a problem with the BAPI BAPI_PO_CREATE1 for PO creation.
When I pass the values to the BAPI and passing Header text in the table I_PO_HEADER_TXT and Item text in the table I_PO_ITEM_TXT.
But after the execution of BAPI I_PO_HEADER_TXT is getting cleared and the same is beiong populated in the table I_PO_ITEM_TXT.
Is there any way to differentiate Item text and Header text??/
Thnks in Advance.
Hari KrishnaHi,
For header texts, pass '00000' as the value to structure field POTEXTHEADER-PO_ITEM.
Read BAPI documentation regarding header & item texts
4. Examples of population of BAPI_PO_CREATE1 interface:
Parameter: POTEXTHEADER
PO_NUMBER
PO_ITEM = 00000
TEXT_ID = F01
TEXT_FORM = *
EXT_LINE = HEADER TEXT
Parameter: POTEXTITEM
PO_NUMBER
PO_ITEM = 00010
TEXT_ID = F05
TEXT_FORM = *
EXT_LINE = ITEM TEXT, ITEM 00010
Regards
Vinod
Edited by: Vinod Kumar on May 21, 2010 4:14 PM -
Bapi_po_create1 error--service PO
We are upgradeing to ECC6 and we have a program that is currently working in our old system using bapi_po_create1 to create service PO's.
We are getting an account assignment error in the ECC6system, "In case of account assignment, please enter acc. assignment data for item"
Entering manually works but I can't find out what has changed to correct the bapi.
Any ideas or does someone have an example of a service entry.
Thanks
JulieHi Julie,
please check the following:
The package number should be set according to FAQ note 499626,
question 8.
POITEMX: if there are also fields filled with an X, which were NOT
filled in the POITEM structure, please remove those X entries.
If a field in POITEMX is marked 'X', it means that the corresponding
field in POITEM has a value.
Similar is the case for POACCOUNT and POACCOUNTX.
Please check the FAQ note 420332 about how to fill the data structure correctly for service POs. In most of the cases the error message 06 436 disappeared after the data structures were set up correctly.
Please check / and if needed implement also the note 1236355
Regards,
Edit -
PO created via BAPI_PO_CREATE1 with status 'On HOLD' issue
Dear experts,
We are using BAPI_PO_CREATE1 to create a service
purchase order, PO is created successfully but it is on Hold.
So, we must save this PO via ME22N manually again.
In EKKO, this on hold PO has the field MEMORY set to "X",
MEMORYTYPE set to "H".
We checked the include 'L2012F47', found a BADI:
CL_EXM_IM_ME_BAPI_PO_CUST
Example Implementation for BAdI ME_BAPI_PO_CUST.
METHOD:
IF_EX_ME_BAPI_PO_CREATE_02~INBOUND
METHOD if_ex_me_bapi_po_create_02~inbound.
* distinguish between BAPI_PO_CREATE1 and
BAPI_PO_CHANGE
IF im_aktyp EQ cl_mmpur_constants=>hin.
"BAPI_PO_CREATE1
IF NOT ch_poheader-vendor IS INITIAL.
* hold PO without error====>WHY???
ch_memory_complete = cl_mmpur_constants=>yes.
* do not perform application authority check
ch_no_authority = cl_mmpur_constants=>yes.
ENDIF.
ELSEIF im_aktyp EQ cl_mmpur_constants=>ver.
"BAPI_PO_CHANGE
* clear version management data
CLEAR ch_versions.
ENDIF.
ENDMETHOD.
The question is if we pass a vendor to this BAPI,
the created purchase order will be hold due to the code
above will set the ch_memory_complete to 'X'.
Which means the purchase order will be created but
on hold.
Could you give us a hint on why purchase order will be
hold while a vendor is passed in the BAPI?
Thanks for your kindly help.
Best Regards,
Eason LingHi Mallinath,
We didn't set MEMORY_COMPLETE when calling the BAPI_PO_CREATE1, which means in BAPI_PO_CREATE1 the MEMORY_COMPLETE is ' ', according to NOTE 354771, the purchase order will be saved instead of being held. What's more, our service purchase order is a correct and complete one.
Documentation for the fields:
MEMORY_COMPLETE:
You can use this parameter to control whether a CORRECT and complete purchase order is held or
saved.
If the value of this parameter is 'X', then the purchase order is held.
If the value of this parameter is ' ', then the purchase order is saved.<<<<<<<<
MEMORY_UNCOMPLETE:
You can use this parameter to define whether an INCORRECT or incomplete purchase order is to be held.
If the value of the parameter is 'X', then the purchase order is held.
If the value of the parameter is ' ', then the purchase order NOT is created.
As what i described previously, even we set MEMORY_COMPLETE to ' ' when calling the BAPI_PO_CREATE1,these codes listed below will also set MEMORY_COMPLETE to 'X'.
IF NOT ch_poheader-vendor IS INITIAL.
* hold PO without error
ch_memory_complete = cl_mmpur_constants=>yes.
* do not perform application authority check
ch_no_authority = cl_mmpur_constants=>yes.
ENDIF.
Then in INCLUDE 'L2012F26', line 233(listed below), the code logic will determine if the Purchase order be held or saved.
* docu:
* docu: check document
* check if memory flag can be set
lcl_memory=>process( "Park&Hold
EXPORTING im_po = ch_po
im_memory_complete = ch_memory_complete<<<<<<<<<<
im_memory_uncomplete = ch_memory_uncomplete
IMPORTING ex_save = lf_save
ex_memory = lf_memory
ex_memorytype = lf_memorytype
CHANGING ch_park_complete = ch_park_complete
ch_park_uncomplete = ch_park_uncomplete ).
All above is a standard logic, if we maintained a vendor for this purchase order, the order will be held. But if we don't assgin a vendor to this purchase order, when calling the BAPI, an error message will pop-up...
Am i right?
Best regards,
Eason -
Hello Experts,
How do I force BAPI BAPI_PO_CREATE1 to use my declared purchase order unit of measurement instead
of getting it in the material master data? For example, material A has a default purchase UOM of CV, but
when I create a PO using material A I want the purchase UOM to be EA instead of the default CV.
How do I do that?Sorry settings in inforecord problem.
-
How to pass the condition vallues in bapi BAPI_PO_CREATE1 for items as well
HI,
where to pass the condition value table in bapi BAPI_PO_CREATE1 item level as well as header level
Like Frieght charges,discounts, basic price ,VAT,CST etc.
Is there any BAPI for GR tcode MIGO.
Pl send along with simple examples .
Your answeres will be rewarded.Pass the condition value to the following parameters.
POCONDHEADER =
POCONDHEADERX =
POCOND =
POCONDX =
For GR u case use the following BAPI.
GMCODE Table T158G - 01 - MB01 - Goods Receipts for Purchase Order
02 - MB31 - Goods Receipts for Prod Order
03 - MB1A - Goods Issue
04 - MB1B - Transfer Posting
05 - MB1C - Enter Other Goods Receipt
06 - MB11
Domain: KZBEW - Movement Indicator
Goods movement w/o reference
B - Goods movement for purchase order
F - Goods movement for production order
L - Goods movement for delivery note
K - Goods movement for kanban requirement (WM - internal only)
O - Subsequent adjustment of "material-provided" consumption
W - Subsequent adjustment of proportion/product unit material
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = gmhead
goodsmvt_code = gmcode
* TESTRUN = ' '
IMPORTING
goodsmvt_headret = mthead
* MATERIALDOCUMENT =
MATDOCUMENTYEAR =
tables
goodsmvt_item = itab
GOODSMVT_SERIALNUMBER =
return = errmsg. -
Executing BAPI_PO_CREATE1 in a loop results in multiple success messages
Hi all,
I have a process where I need to create multiple POs with one item each. For creating the POs I use BAPI_PO_CREATE1. The creation itself works fine and created POs are also correct.
But what is a bit confusing is the content of the RETURN table of the BAPI. From the second created PO on I also get ALL messages of the previously created POs although I have a COMMIT WORK AND WAIT after each creation and the return table is always empty when executing the BAPI.
Example:
I need to create two POs.
First run of the BAPI_PO_CREATE: PO A is created and return table has success message "PO A successfully created"
Second run of the BAPI_PO_CREATE: PO B is created and return table has two success messages: "PO A successfully created" and "PO B successfully created"
But for the second run I also would expect to get only one success message.
Why do I get too many messages? Or do I need to initilize the BAPI somehow?
By the way, I have the same problem with BAPI_PO_CHANGE.
regards
RenéHi,
so again: the return table is cleared/refreshed all times when executing the loop and a commit is done!
Unfortunately the whole coding is implemented to the SAP AIF so the AIF is doing the loops. But in debugging I clearly see that the return table is empty before executing the BAPI.
Here is the coding. The AIF calls the here described function module in a loop and executes a commit work and wait after each call of the FM.
FUNCTION POST_PURCHASE_ORDER.
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(TESTRUN) TYPE C
*" REFERENCE(HASH_TAB) TYPE /AIF/HASHTAB_T OPTIONAL
*" REFERENCE(IDX_TAB) TYPE /AIF/IDXTAB_T OPTIONAL
*" TABLES
*" RETURN_TAB STRUCTURE BAPIRET2
*" CHANGING
*" REFERENCE(DATA)
*" REFERENCE(CURR_LINE)
*" REFERENCE(CURR_DATA)
*" REFERENCE(SUCCESS) TYPE /AIF/SUCCESSFLAG
*" REFERENCE(OLD_MESSAGES) TYPE BAL_T_MSG
DATA: lt_po_items TYPE TABLE OF bapimepoitem,
lt_po_itemsx TYPE TABLE OF bapimepoitemx,
lt_bapiparex TYPE TABLE OF bapiparex,
lt_po_conditionx TYPE TABLE OF bapimepocondx,
lt_po_header_texts TYPE TABLE OF bapimepotextheader,
lt_po_item_texts TYPE TABLE OF bapimepotext,
ls_po_headerx TYPE bapimepoheaderx,
ls_po_headerx_cust TYPE bapi_te_mepoheaderx,
ls_po_itemx TYPE bapimepoitemx,
ls_po_condition TYPE bapimepocond,
ls_po_conditionx TYPE bapimepocondx,
l_testrun TYPE bapiflag-bapiflag.
CHECK curr_line IS NOT INITIAL.
REFRESH: return_tab[].
CLEAR: return_tab[].
l_testrun = testrun.
* Get X-structures for PO header
PERFORM fill_x_structure USING curr_line-po_header 0 CHANGING ls_po_headerx.
* Create PO Header Custom Fields.
PERFORM fill_bapiparex USING curr_line-po_header_cust space
CHANGING lt_bapiparex[] return_tab[].
* Get X-structures for PO ExtensionIn fields and post them to ExtensionIn as well
PERFORM fill_x_structure USING curr_line-po_header_cust 0 CHANGING ls_po_headerx_cust.
PERFORM fill_bapiparex USING ls_po_headerx_cust space
CHANGING lt_bapiparex[] return_tab[].
* Get X-structure for PO item
curr_line-po_item-info_upd = 'A'.
curr_line-po_item-po_price = '1'.
PERFORM fill_x_structure USING curr_line-po_item 1 CHANGING ls_po_itemx.
ls_po_itemx-po_item = curr_line-po_item-po_item.
curr_line-po_item-po_price = space.
curr_line-po_item-info_upd = space.
APPEND curr_line-po_item TO lt_po_items.
APPEND ls_po_itemx TO lt_po_itemsx.
* Get X-structures for PO conditions
IF NOT curr_line-po_conditions IS INITIAL.
LOOP AT curr_line-po_conditions INTO ls_po_condition.
CLEAR ls_po_conditionx.
ls_po_conditionx-itm_number = ls_po_condition-itm_number.
PERFORM fill_x_structure_2 USING ls_po_condition 3 0
CHANGING ls_po_conditionx.
APPEND ls_po_conditionx TO lt_po_conditionx.
ENDLOOP.
ENDIF.
* Get header and item texts
APPEND curr_line-po_header_text TO lt_po_header_texts.
APPEND curr_line-po_item_text TO lt_po_item_texts.
* Execute BAPI_PO_CREATE1
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = curr_line-po_header
poheaderx = ls_po_headerx
testrun = l_testrun
no_price_from_po = c_checked
IMPORTING
exppurchaseorder = curr_line-po_number_return
TABLES
return = return_tab
poitem = lt_po_items
poitemx = lt_po_itemsx
pocond = curr_line-po_conditions
pocondx = lt_po_conditionx
extensionin = lt_bapiparex
potextheader = lt_po_header_texts
potextitem = lt_po_item_texts
EXCEPTIONS
error_message = 1.
IF sy-subrc = 1.
IF NOT sy-msgid IS INITIAL
AND NOT sy-msgty IS INITIAL
AND NOT sy-msgno IS INITIAL.
PERFORM util_add_msg USING sy-msgty sy-msgid sy-msgno sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 CHANGING return_tab[].
ENDIF.
ENDIF.
ENDFUNCTION.
Maybe you are looking for
-
Suddenly can't connect to my Time Capsule
I have an Air with only 128GB of storage so I keep my iTunes library on my Time Capsule. Yesterday I was downloading an iTunes U episode and it was going straight to my library on the Capsule. I went to Finder to move some folders around in my Time C
-
Can anyone help with this error message? Description: : URL: /PerformanceManagement/jsp/dm-getpage.jsp? url=AfQJDRWQ3WNOtAoCRk5MQ4U Stack Trace: {"Error":{"error":"null","PageError1":"Your request cannot be processed. Contact your Business Objects ad
-
Re: broadband and landline
Help please. I reported a fault on 30th April. Neighbour's builder has cut through our cable. BT customer service said repair to be fixed by end of: 5th, 7th, 12th, 16th May. We no longer believe anything they say. Customer service is appalling. How
-
how to get link between plpo and afvc table regarding recipe group and and its detailsfor various operations like different group couner, how could we understand the required one
-
Get Start and End times for each step in a job
Can someone tell me how to get the start and end times for each step in a background job? Table TBTCP only stores the time that the step was saved in a background job. Table TBTCO stores the times for the entire job and not each individual step. Th