Error adding Goods Receipt PO based on Purchase Order

I am working on an add-on that was working against a 2005A version of SAP Business One and I am upgrading it to run against a 2007A Company (PL41)
I am receiving strange errors when testing the add-on.
I can add a Purchase order not based on a Goods Receipt PO without any problems but as soon as I specify a base type, entry and line I get either -1 General Error, or the Tried to Read/Write Protected Memory Error.  The error I receive seems to arbitrarily change between the two.
I have read a few notes on the forums about this but none of them have proven useful in solving my problem.  I have checked the DI-API version on my PC and it is definitely using 8.0.177.0 which matches the version of SBO that I am running.  I have re-installed the DI etc without any success.
The following is the code snippet which I am using to test:  I have verified that the referenced purchase order is open, contains the correct item, customer etc
int iResult = -1;
string sResult = string.Empty;
string sOutput = string.Empty;
try
sOutput += Environment.NewLine + "Connecting to company...";
      sbocoy = new SAPbobsCOM.Company();
      sbocoy.Server = "<insert server name here>";
      sbocoy.CompanyDB = "<insert database name here>";
      sbocoy.LicenseServer = "<insert server name here>:30000";
      sbocoy.UseTrusted = true;
      sbocoy.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005;
      sbocoy.UserName = "manager";
      sbocoy.Password = "<inser sap user here>";
      iResult = sbocoy.Connect();
      sOutput += Environment.NewLine + "Connected";
      SAPbobsCOM.Documents PO = (SAPbobsCOM.Documents)sbocoy.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
      SAPbobsCOM.Documents GoodsReceiptPO = (SAPbobsCOM.Documents)sbocoy.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes);
      sOutput += Environment.NewLine + "Get Purchase Order";
      PO.GetByKey(1402);
      sOutput += Environment.NewLine + String.Format("DocNum: {0}; DocEntry: {1}; ItemCode: {2}; LineNum: {3}", PO.DocNum, PO.DocEntry, PO.Lines.ItemCode, PO.Lines.LineNum);
      GoodsReceiptPO.CardCode = PO.CardCode;
      GoodsReceiptPO.CardName = PO.CardName;
      GoodsReceiptPO.Lines.ItemCode = PO.Lines.ItemCode;
      GoodsReceiptPO.Lines.ItemDescription = PO.Lines.ItemDescription;
      GoodsReceiptPO.Lines.Quantity = 1.0;
      GoodsReceiptPO.Lines.BaseType = int.Parse(PO.DocObjectCodeEx); // If I comment out this and the next two lines the document will add
      GoodsReceiptPO.Lines.BaseEntry = PO.DocEntry;
      GoodsReceiptPO.Lines.BaseLine = PO.Lines.LineNum;
      sOutput += Environment.NewLine + "Adding Goods Receipt...";
      iResult = GoodsReceiptPO.Add();
      sResult = sbocoy.GetLastErrorDescription();
      sOutput += Environment.NewLine + string.Format("Result [{0}] {1}", iResult, sResult);
catch (Exception ex)
sOutput += string.Format(Environment.NewLine + "Exception: {0}{1}SBOError: {2}", ex.Message, Environment.NewLine, sbocoy.GetLastErrorDescription());
The results when I try and reference the purchase order are:
Connecting to company...
Connected
Get Purchase Order
DocNum: 301396; DocEntry: 1402; ItemCode: SEANTESTITEM; LineNum: 1
Adding Goods Receipt...
Exception: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
If I comment out the 3 lines that reference the base document the Goods Receipt Adds and the following is the output...
Connecting to company...
Connected
Get Purchase Order
DocNum: 301396; DocEntry: 1402; ItemCode: SEANTESTITEM; LineNum: 1
Adding Goods Receipt...
Result [0]
The above code will work correctly if we base a Delivery Note on a Sales Order so it appears to be specifically related to the Purchasing Documents.
Edited by: Sean Archer on Feb 2, 2009 2:23 PM

Hi Ganesh,
Thank you for the reply.
I ran the add-on against another database and it is working.
I also verified that the document was failing to create if done via the Data Transfer Workbench so it would appear the issue affects the DI-API irrespective of add-on.
I will need to do more testing to confirm whether this is a bug with PL41 of 2007A or a corrupt database as you suggest.
Cheers,
Sean

Similar Messages

  • Good receipt problem for subcontracting purchase order

    Good receipt problem for subcontracting purchase order
    with account assignment type ‘E’.
    After update to ECC 6.0. Do good receipt for subcontracting purchase order with account assigment 'E'.The system show the error message(KI235)----Two cost elements (Change in Stock (Subcontracting)&Outside processed fee) haven't CO account assignment.but the field status  for sale order is option entry , when I default cost center for the cost element  in OKB9.the system post the material document and generate the following accounting document.
    Doc.Type : WE ( Goods receipt ) Normal document
    Doc. Number    5000056065       Company code    1000         Fiscal year     2007
    Doc. date      2007.12.04       Posting date    2007.12.04   Period          12
    Calculate Tax
    Doc.currency   HKD
    tm PK Account    Account short text   Tx Cost Ctr   SaleOrder               Amount
    1 89 13500000   Stock-Work in proces                   1007823  10             274.4
    2 96 21210010   GR/IR Clearing                             1007823  10             205
    3 91 41010102   Chg in Stock(Subcon)    10901099  1007823  10            274.4
    4 86 41031000   Outside processed fe     10901099  1007823  10            205  
    5 99 13500000   Stock-Work in proces                    1007823  10            69.4
    6 81 41010101   Cost of Prod (Subco)                      1007823  10           69.40
    My problem is:
    When use MIGO to do good receipt for subcontracting Purchase order, for consumption account((Change in Stock (Subcontracting)-41010102&Outside processed fee--41031000) ,why the system don’t recognize the sale order filled as CO account assignment?

    Dear fanny chen
    Did you get a solution for your open question?
    I`m facing the same problem, so any help yould be appreciated.
    Regards

  • Goods Receipt for Account-assigned Purchase Orders

    Hello,
      We want to make Goods Receipt for Account-assigned Purchase Orders. When we try, SAP gives the error 'Account determination for entry PCOA KBS 0001 not possible'. According to SAP online help, account assignment is adopted from the purchase orders for the transaction/event 'KBS' and we cannot assign transaction key 'KBS' to an account using transaction OBYC. How do you make it work? Any solution pointers will be appreciated and rewarded.
    Thanks,
    Venu

    create an implicit enhancement point in function module CKMV_AC_DOCUMENT_CREATE.
    IN STRUCTURE IT_ACCIT U CAN MODIFY THE gl ACCOUNT IN RUN TIME .

  • Goods receipt with reference to Purchase Order

    the requirment is that we should be able to restrict the one Goods receipt posting for one Purchase order.  The standard system is supporting processing of multiple P.O's of different vendors in on GR.
    could anybody suggest to configure the functionality
    regards

    Hi,
    There is no standard option available and I don't think that there is any feasible way of stopping this without the use of a user exit (as already suggested).
    But even the user exit option would be complex because it would have to block off the PO number field after enter (or any other key) was pressed.
    It would also have to stop the use of multiple entries via the "find" option.
    If you have a valid reason for doing this, have you thought of trying to get your users to do as they are told instead of changing the system?
    Why is it important to have one PO per GR ?
    Steve B

  • Edit goods receipt copied from approved purchase order?

    Hi everyone
         Is it possible to edit quantity field or add a new row to a goods receipt copied from a purchase order that has been approved ?
      if  this behavior was changed from past releases or it always was like that?
    i appreciate your help and thanx in advance
    (any link to a official document, guide, how to doc that describes this point would be great)

    hi gordon thanx for your response
    just another thing before i mark my question as answered, is there a official guide or SAP document that describes every detail of approval procedures including this question?
         once again i appreciate your kind help.
    Aley Chena

  • DTW : How to Create goods receipt with quantity exceeding purchase order ?

    Hello DTW Experts,
    is there any way to deliver or receive an quantity exceeding the quantiy of the purchase order using DTW, or the only way is to create additional order (create a goods receipt is based on a purchase order).
    When i try the system gives me these 2 different messages :
    1 - One of the base documents has already been closed  PDN1.BaseEntry[line: 1]Erreur définie par l'application ou par ...
    2 - One of the base documents has already been closed Erreur définie par l'application ou par l'objetoPurchaseDeliveryNotes
    Thanks,
    Hafid

    The best way is to draw the purchse order through then add an additional line to the Goods Receipt for the additional quantity. This will close the PO properly, but record the additional quantity

  • Goods Receipt against account assigned Purchase Order

    Respected members,
      I am doing the good receipt with movement type 101 and special stock E with ref to po.
    In my purchase order in account assignment there is everything like sales order,internal order and profit centre and inventory gl account.
    The inventory gl account made as a cost element 90.Account assigment category i am usingis M.
    My problem is when i am doing good receipt it is generating only accounting document and in that value of profit centre and internal order is not coming for inventory gl account.It is not generating the profit centre document and co document.
    But in Material Document everything is getting , I am able to have the all the values for the respective field.
    I am not understanding where the values getting cleared off when it is generating a accounting document and why it is not geneating a controlling document.
    The accounting document is posted to both balance sheet accounts
    that is debit and credit entry.
    I have checked the all configurations in obyc and omjj. but i am notgetting any clue.
    And interesting thing is previously it is picking the values but now settings have been disturbed and now it is not picking ,why it so.
    Please help me out as soon as possible.
    Thanks a lot.

    dear,
    kindly ckeck in omjj in "gbb" account whether your g/l acc..has been assigned or not..
    kindly also check whether you have maintained profit center and cost center in"okb9" ..
    also see in mm03 costing views 1 you have entered correct profit center...
    or create a new g/l acc in fr00 and see its postings..
    regards
    rewa

  • Goods Receipt check box on Purchase Order

    Hi All,
    I am creating a NB Purchase order (non-account assigned). Immediately on entering the Material, in the Line Item 'Delivery' tab, "Goods Receipt" is automatically checked and this option is disabled.
    Does anyone know the configuration that defaults "Goods Receipt" as checked and disabled?
    Thanks much,
    Sheetal

    Hi Sheetalnn,
    You can check the field selection set up for the purchase order document. It is found in the following path:
    SAP IMG -> Materials Management -> Purchasing -> Purchase Order -> Define Screen Layout at Document Level
    Just read the accompanying documentation for you to have a better understanding of what influences the field selection for the purchase order.
    As a side note, the GR requirement for the PO item is influenced by the Account Assignment Category used.
    Best regards,
    DeLo

  • Price difference in goods receipt with ref of purchase order

    Dear all,
               I am getting a difference in price with a goods receipt( movement type 101) which was created with reference to a purchase order. The purchase order price and G.R price are extremely different. I checked the inforecord..but price was not maintained in that.Price was entered manually in purchase order in conditions tab. can some one point out from where the price might have been calculated in Goods receipt.
    Regards,
    Edamanayil

    Hi,
    If its a standard price in material master record...then it will pick price from material master record ...
    otherwise it will pick PO's price if no valid info record exists.
    It can also read last PO's price....depending upon the setting.
    Brgds,
    Ashok

  • MIGO PROBLEM in the Good Receipt  with reference to purchase order

    Hello Everybody.
    i m getting one problem with reference to MIGO tcode.
    Might be anyone notice or not but i want to share with you.
    in MIGO selected goods receipt then beside it ask for the different actions.
    I use the purchase order no.
    suppose i given po no 1
    enter
    now it will display the details of that po number (1) but at the same time po number field is again in the input mode and you can give more po number .
    suppose now i have given po no 2.
    enter
    Then in same gr we will be having the item details of both po number( 1 & 2) .
    This is my problem .I want to make restriction that in single gr it should take only one po number not more than that ,after giving one po ,it should make that field in display mode.
    How to do that please guide me .
    I will be grateful to you.
    Thanks a lot

    You can use a field exit on any field that gets filled when the first PO is entered
    check that field (Something like challan Number , Delivery date)
    if is if filled use the "screen" Table to make the PO Number field Display only .

  • Cannot switch base units on Goods Receipt PO copied from Purchase Order

    Hi,
    I am wondering if there is a simple trick or setting for this or if we have to use a UDF/FMS...
    When using Uom for sales and purchasing, you cannot switch between Yes and No for base units on the target document(GRPO) when copying a PO to GRPO.
    For example, enter a purchase order selecting 'No' for base units and enter quantity 1 for item with Uom case(25 pcs in a case). 25 are ordered. If the warehouse receives 23 instead of a full case from the supplier,  they want to be able to enter 23 on the GRPO(copied from PO). They don't want the warehouse staff calculating what percentage to put in for quantity (23/25 = 0.92),  they would just like them to use the drop down box and change the base units to Yes and receive the quantity 23 units.
    Any suggestions?

    Hi,
    How often this would happen?  If it is very frequent, my suggestion would be considering it when you create PO.  You know, if you could change that option, the link between PO and GRPO will be broken.  It is not recommended.
    Thanks,
    Gordon

  • Runtime Error in Goods Receipt

    Dear Experts,
    The runtime error while posting Goods Receipt.
    The Current application triggered a termination with short dump.
    Error analysis
    Shirt text of Error Message
    Document number 1000 (Company Code) 5000000000 2008 was already assigned.
    Long text for Error message:
    Diagnosis
    Document number 5000000000 in company code 1000 and Fiscal year 2008 has already
    been assigned.
    System Response -
    Termination of Processing
    Procedure
    Check document number range 50 in company code 1000 and fiscal year 2008 and correct the number range status. 
    Please guide me on this runtime error while Goods receipt.
    Thanks in Advance

    This means that the system tried to create a document with the number from the number range status but since the document with the same number was already in the system the system could not proceed overwriting hence resulted in a dump.
    How to over come. Give a number range or give a current status to the number range for which documents does not exist in the system.
    Edited by: Anand Patel on Oct 7, 2008 1:12 PM

  • Error during Goods Receipt:Check table XMCHB: Entry 'Material no.', 'Plant

    Dear All,
    I am trying to post Goods Receipt for a Stock Transport Order.
    The error message appears as " Check table XMCHB: entry 'material no.' 'plant', '____' , 'batch no.' does not exist. (message no. M7001)
    The Supplying plant stock from which Goods Issue is done,  is a Normal storage location Unrestricted stock.
    The receipt has to be taken into Vendor stock (Goods Receipt movement type 101 O )
    Inputs will be appreciated.

    technically spoken.
    table MCHB is the storage location segment of a batch record.
    System tries to create an entry in MCHB without a storage location, which does not make sense.
    Vendor stock does not go to MCHB, instead it is recorded in table MKOL.
    If you do STOs then you may transfer vendor consignment stock, but you cannote issue own stock and receive into vendor consignment stock.

  • Posting to different GR/IR account based on purchase order type

    We are implementing cross company stock transport orders that require an AP invoice to be posted against the goods receipt.  Our AP department does not want the GR/IR postings to go to the account used for traded AP.  I cannot determine a method using OBYC to specify a different account based on purchase order type.  Is there a way to do this?

    Hi Jud
    You should make these posting to a cost center then..The only way you can control account postings via PO type is having a account assignement category. You can make this as mandatory filed for this PO type..
    Please let me know if your requirement is different..
    CHeers
    R K Bolla

  • Invoice based on purchase order no

    Hi Experts,
    how i can get invoice no based on purchase order no
    thanks in advance
    narendra

    Hello Narendra
    Call BAPI_PO_GETDETAIL1 with your purchase order number.
    TABLES parameter POHISTORY returns you the purchase order history.
    These records have a field HIST_TYPE ( PO history category ) with the following values (value table T163B):
    1     AAf     Down Payment Req.
    2     AAfV     DP Request Clearing
    3     AnzV     Down Payt Clearing
    A     Anz     Down payment
    B     NAbr     Subseq. settlement
    C     NeuR     Miscell. provision
    D     Lerf     Service entry
    E     WE     Goods receipt
    F     BzWE     Delivery costs
    G     BzRE     Delivery costs
    I     BzKP     Del.costs acct.maint
    J     RLfs     Return delivery
    K     KtoP     Account maintenance
    L     Lfs     Delivery note
    M     BzRe     Del. costs log. inv.
    N     NB-L     Subs. deb. log. IV
    O     LB     Subcontracting
    P     NB-B     Subs. deb. dl. costs
    Q     RE-L     Invoice receipt                    " <<<
    R     RE     Invoice receipt                    " <<<
    S     Sped     Subs.deb.: forwarder
    T     VRe     Parked invoice
    U     WA     Goods issue
    W     NeuB     Revaluation log. IV
    X     NB     Subs.deb.: general
    Z     Zahl     Payment
    Presumably you are interested in categories 'Q' and 'R'.
    Regards
      Uwe

Maybe you are looking for