12-26-2013 6:05 PM
Hi Experts,
I m using BAPI_PO_CREATE1 to create multiple POs in a loop. If I m only having a single PO in the file to process, the BAPI is creating the PO without any error. But if I have multiple POs, I m getting an error from the second PO on wards - saying Enter GL Account. I have cleared,refreshed all internal tables including the poaccount and poaccountx. Any suggestions please?
Thanks in advance!
Anjana.
12-27-2013 2:54 AM
Does it create PO for the second line if run alone ...if yes then it is the problem with code. Please share your sample code. Else if it gives error means it expects GL account to be passed with leading zeros..
12-27-2013 2:54 AM
Does it create PO for the second line if run alone ...if yes then it is the problem with code. Please share your sample code. Else if it gives error means it expects GL account to be passed with leading zeros..
12-30-2013 3:53 PM
Hi Nabheet,
I m able to create single PO with multiple line items without any errors, but when I have multiple POs, it doesnt work.
12-30-2013 4:14 PM
Can you please share your sample code for the same...if you create one PO for each line via ME21N it creates right...? Please share your code
12-30-2013 4:27 PM
po_header1-po_number = pohd_tab-po_num.
po_header1-ref_1 = pohd_tab-arib_po.
po_header1-comp_code = pohd_tab-comp_cd.
po_header1-doc_type = w_potyp.
po_header1-doc_date = sy-datum.
po_header1-purch_org = pohd_tab-porg.
po_header1-vendor = pohd_tab-vendor.
po_header1-pur_group = pohd_tab-buyer.
po_header1-created_by = sy-uname.
po_header1-currency = 'USD'.
po_headerx-po_number = 'X'.
po_headerx-ref_1 = 'X'.
po_headerx-comp_code = 'X'.
po_headerx-doc_type = 'X'.
po_headerx-doc_date = 'X'.
po_headerx-purch_org = 'X'.
po_headerx-vendor = 'X'.
po_headerx-pur_group = 'X'.
po_headerx-created_by = 'X'.
po_headerx-currency = 'X'.
LOOP AT podet_tmp.
PERFORM load_item_chg.
PERFORM load_account_chg.
PERFORM load_addr_chg.
PERFORM load_delvry_chg.
ENDLOOP.
FORM load_account_chg .
DATA: w_saknr TYPE saknr,
w_kostl TYPE kostl.
po_acct-po_item = podet_tmp-line.
po_acct-quantity = podet_tmp-qty.
po_acct-gl_account = podet_tmp-gl_acc.
po_acct-costcenter = podet_tmp-costctr.
po_acct-gr_rcpt = podet_tmp-recip.
po_acct-tax_code = podet_tmp-taxable.
po_acct-asset_no = podet_tmp-asset.
po_acct-sub_number = podet_tmp-assetsub.
po_acct-unload_pt = podet_tmp-requis.
APPEND po_acct.
po_acctx-po_item = podet_tmp-line.
po_acctx-quantity = 'X'.
IF po_acct-gl_account NE ' '.
po_acctx-gl_account = 'X'.
ENDIF.
po_acctx-costcenter = 'X'.
po_acctx-gr_rcpt = 'X'.
po_acctx-tax_code = 'X'.
IF po_acct-asset_no NE ' '.
po_acctx-asset_no = 'X'.
ENDIF.
IF po_acct-sub_number NE ' '.
po_acctx-sub_number = 'X'.
ENDIF.
IF po_acct-unload_pt NE ' '.
po_acctx-unload_pt = 'X'.
ENDIF.
APPEND po_acctx.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = po_header1
poheaderx = po_headerx
IMPORTING
exppurchaseorder = ponumber
expheader = poheader
TABLES
return = return
poitem = po_item
poitemx = po_itemx
poaddrdelivery = po_addr
poschedule = po_delv
poschedulex = po_delvx
poaccount = po_acct
poaccountx = po_acctx.
I m putting only the account perform since thats the place where I m getting the error.Please let me know if you can find something in my code causing it. Thanks a lot for your help!!
12-30-2013 4:33 PM
My question is after every iteration are you clearing the tables/work area...? When the BAPI gives error it must be returning the item number where it is accepting GL account...what happens if you pass gl account in debugging
12-30-2013 5:03 PM
In the beginning of the loop before passing values to itabs, I m clearing and refreshing all the itabs. I debugged the code right at bapi call and am able to see the po_acct populated with correct G/L, and po_acctx also has correct values. still from the second line onwards its giving the error. In fact I m using the same line item data in my file for both first and second POs, just changing the PO number.
12-30-2013 5:41 PM
PO item number in accounting internal table shall refer to the corresponding line in PO item internal table. Can you please attach a screen shot showing the various table contents in internal table
When you get message in return internal table it must be showing you the line number in one of the variable. Check whether for that line item do you have accounting data
Nabheet
12-30-2013 6:13 PM
12-30-2013 6:27 PM
It looks ok from the way you are passing data. Next step i would have done is debug the BAPI. Keep a tab on RETURN table and check where it is getting filled to drill down to the place where error is thrown
Nabheet
01-02-2014 7:48 PM
Got it resolved. Had to pass serial number in the itab for account. Thanks for your help!