Problems in creating a Goods Receipt Draft

Hello,
I am trying to use the DI-API and the SDK to create a Goods Receipt Draft document and link it to an existing Purchase Order.  When I try to add the draft object, I receive an internal error (-2010).  Here is the code that I am using.  Can someone see if anything is wrong with this, or does anyone have any insights into this type of error?
SAPbobsCOM.Documents draft = null;
draft = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
draft.Reference1 = tempDocEntry;
draft.CardCode = tempCardCode;
draft.DocDate = DateTime.Now;
draft.NumAtCard = tempOrderNumber;
draft.DocObjectCode = SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes;     // Used so that the objType will be 20 for a Goods Receipt Draft
draft.Comments = "";
draft.Lines.BaseEntry = System.Convert.ToInt32(tempDocEntry);
draft.Lines.BaseLine = System.Convert.ToInt32(row["Line #"].ToString());
draft.Lines.BaseType = System.Convert.ToInt32(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
draft.Lines.ItemCode = row["Item #"].ToString();
draft.Lines.Quantity = System.Convert.ToInt32(row["Qty"].ToString());
draft.Lines.Price = System.Convert.ToDouble(row["unit price (USD)"].ToString());
draft.Lines.WarehouseCode = "0" + row["Whse Code"].ToString();   // prepend with zero, if the code is of length 1
draft.Lines.Add();
result = draft.Add();        // Add the draft now
if (result != 0)
      thisError = company.GetLastErrorDescription();     //*** THE ERROR RESULT IS RETURNED HERE...
I am hoping that someone can provide some feedback and direction on this one fairly quickly as I am on a pretty tight time constraint to implement this solution.
Thanks,
Jonathan

Hi Jonathan,
I haven't tested your code but I notice that you are calling the Add method of the Lines child object incorrectly. It's a bit confusing but the Lines.Add method should be called first and then you use the SetCurrentLine method to access the properties of this line. To make it more confusing, a new instance of the Documents object automatically gets one, blank line so you only need to call Lines.Add when adding a second line (and each subsequent line).
For example, say I have a recordset of line details from a base PO that I want to add to a new, draft GRPO:
int lineIndex = 0;
while (!rec.EOF)
     if (lineIndex > 0) draft.Lines.Add(); // Only need to add new line after first one
     draft.Lines.SetCurrentLine(lineIndex); // Set focus to newly added line so I can set properties
     draft.Lines.BaseEntry = System.Convert.ToInt32(rec.Fields.Item("DocEntry").Value);
     draft.Lines.BaseLine = System.Convert.ToInt32(rec.Fields.Item("LineNum").Value);
     draft.Lines.BaseType = System.Convert.ToInt32(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
     draft.Lines.ItemCode = System.Convert.ToString(rec.Fields.Item("ItemCode").Value);
     draft.Lines.Quantity = System.Convert.ToDouble(rec.Fields.Item("Quantity").Value);
     draft.Lines.Price = System.Convert.ToDouble(rec.Fields.Item("Price").Value);
     draft.Lines.WarehouseCode = System.Convert.ToString(rec.Fields.Item("WhsCode").Value);
     lineIndex++;
     rec.MoveNext();
Kind Regards,
Owen

Similar Messages

  • Call BAPI_GOODSMVT_CREATE to create a goods receipt for purchase order

    Hi,
    I'm calling the bapi BAPI_GOODSMVT_CREATE to create a goods receipt for purchase order, but the following code doesn't work. It doesn't give me any kind of error message but it does nothing as well...
    Can anyone help me please?
    Thank You
    Hugo
    Code
    DATA: wa_goodsmvt_header  LIKE bapi2017_gm_head_01,
                            wa_goodsmvt_code    LIKE bapi2017_gm_code,
                            wa_bapi2017_gm_head TYPE bapi2017_gm_head_ret-mat_doc.
                      DATA: it_goodsmvt_item LIKE bapi2017_gm_item_create OCCURS  0 WITH HEADER LINE,
                            it_return        LIKE bapiret2 OCCURS  0 WITH HEADER LINE.
                      wa_goodsmvt_header-pstng_date = SY-DATUM.
                      wa_goodsmvt_header-doc_date   = SY-DATUM.
                      wa_goodsmvt_header-ref_doc_no = '4500000020'.
                      wa_goodsmvt_code-gm_code = '01'.          "Goods receipt for purchase Order
                      it_goodsmvt_item-stge_loc  = 'BPF2'.
                      it_goodsmvt_item-move_type = '101' .
                      it_goodsmvt_item-entry_qnt = 17.
                      it_goodsmvt_item-entry_uom = 'KG'.
                      it_goodsmvt_item-mvt_ind   = 'B'.
                      it_goodsmvt_item-po_number = '4500000020'.
                      it_goodsmvt_item-po_item   = '00010'.
                      it_goodsmvt_item-material  = '50'.
                      APPEND it_goodsmvt_item.
                      CALL FUNCTION  'BAPI_GOODSMVT_CREATE'
                        EXPORTING
                          goodsmvt_header  = wa_goodsmvt_header
                          goodsmvt_code    = wa_goodsmvt_code
                        IMPORTING
                          materialdocument = wa_bapi2017_gm_head
                        TABLES
                          goodsmvt_item    = it_goodsmvt_item
                          return            = it_return.
                        data: begin of errmsg occurs 10.
                                include structure bapiret2.
                        data: end of errmsg.
                        data: wmenge like iseg-menge,
                              errflag.
                        clear errflag.
                        loop at errmsg.
                          if errmsg-type eq 'E'.
                            write:/'Error in function', errmsg-message.
                            errflag = 'X'.
                          else.
                            write:/ errmsg-message.
                          endif.
                        endloop.
                        if errflag is initial.
                          commit work and wait.
                          if sy-subrc ne 0.
                            write:/ 'Error in updating'.
                            exit.
                          else.
                            write:/ 'Ok'.
                          endif.
                        endif.
                        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
                        EXPORTING
                        wait = ' '.

    Hi,
    Thank you for the asnwer! I'm a rookie at ABAP so please forgive my stupid questions
    I've changed the code to:
    DATA: wa_goodsmvt_header  LIKE bapi2017_gm_head_01,
                            wa_goodsmvt_code    LIKE bapi2017_gm_code,
                            wa_bapi2017_gm_head TYPE bapi2017_gm_head_ret-mat_doc.
                      DATA: it_goodsmvt_item LIKE bapi2017_gm_item_create OCCURS  0 WITH HEADER LINE,
                            it_return        LIKE bapiret2 OCCURS  0 WITH HEADER LINE.
                      wa_goodsmvt_header-pstng_date = SY-DATUM.
                      wa_goodsmvt_header-doc_date   = SY-DATUM.
                      wa_goodsmvt_header-ref_doc_no = '4500000020'.
                      wa_goodsmvt_code-gm_code = '01'.          "Goods receipt for purchase Order
                      it_goodsmvt_item-plant     = 'BP01'.
                      it_goodsmvt_item-stge_loc  = 'BPF2'.
                      it_goodsmvt_item-move_type = '101' .
                      it_goodsmvt_item-entry_qnt = 10.
                      it_goodsmvt_item-entry_uom = 'KG'.
                      it_goodsmvt_item-mvt_ind   = 'B'.
                      it_goodsmvt_item-po_number = '4500000020'.
                      it_goodsmvt_item-po_item   = '10'.
                      it_goodsmvt_item-material  = '50'.
                      APPEND it_goodsmvt_item.
                      CALL FUNCTION  'BAPI_GOODSMVT_CREATE'
                        EXPORTING
                          goodsmvt_header  = wa_goodsmvt_header
                          goodsmvt_code    = wa_goodsmvt_code
                        IMPORTING
                          materialdocument = wa_bapi2017_gm_head
                        TABLES
                          goodsmvt_item    = it_goodsmvt_item
                          return            = it_return.
                          write:/ it_return-message.
    And the return message is : Material document data and PO data do not match (Material)
    Any idea of what might be the problem?
    Thanks

  • Need BAPI for MIGO to create a Goods Receipt against PO &Outbound Delivery

    Hi Friends,
    GRN’s (Good receipt notifications) created in DHL (Non SAP system) will need to be communicated to SAP.
    I need to post goods receipt using input data in MIGO. Is there any BAPI that i can use.The requirement is like below:
    PO number field in output file is checked against entries in EKKO-EBELN, if a match is found the GR is posted against a Purchase Order otherwise LIKP-VBELN is checked and if a match is found GR is posted against an Outbound Delivery.
              If PO Number = EKKO-EBELN    GR against Purchase Order
                            = LIKP-VBELN      GR against Outbound Delivery
    Based on the above condition I need to create a Goods Receipt. 
    Could you please tell me the GM code, movement types and the required fields to be passed for the BAPI?
    The fields available are with us are...
    Header text. - Bill of Lading- Posting Date-Quantity- UOM--- Vendor Batch / Batch / Serial No --- PO Number or Delivery Number… SLED
    Are these fields sufficient for doing MIGO with the BAPI or do we require more fields???
    Please provide sample code if possible.
    Waiting for replies,
    Thanks and Regards,
    Sudha

    Hi Friends,
    GRN’s (Good receipt notifications) created in DHL (Non SAP system) will need to be communicated to SAP.
    I need to post goods receipt using input data in MIGO. Is there any BAPI that i can use.The requirement is like below:
    PO number field in output file is checked against entries in EKKO-EBELN, if a match is found the GR is posted against a Purchase Order otherwise LIKP-VBELN is checked and if a match is found GR is posted against an Outbound Delivery.
              If PO Number = EKKO-EBELN    GR against Purchase Order
                            = LIKP-VBELN      GR against Outbound Delivery
    Based on the above condition I need to create a Goods Receipt. 
    Could you please tell me the GM code, movement types and the required fields to be passed for the BAPI?
    The fields available are with us are...
    Header text. - Bill of Lading- Posting Date-Quantity- UOM--- Vendor Batch / Batch / Serial No --- PO Number or Delivery Number… SLED
    Are these fields sufficient for doing MIGO with the BAPI or do we require more fields???
    Please provide sample code if possible.
    Waiting for replies,
    Thanks and Regards,
    Sudha

  • Creating a Good Receipt PO via DI API No matching records found (ODBC -2028)

    Hi,
    I trying to create a Good Receipt PO via DI API.  It is working when the user I used to log in to SAP via the DI API is a Professional User but when I changed it to a Limited Logistics User, I'm receiving the No matching records found (ODBC -2028). I have already added the SDK Tools license to that user but still I'm receiving that error.
    So is it that the DI API will only work with a Professional User license or I can still use a Limited Logistics User?

    HI J S L,
    I get same error when I use different user that I just now add the SDK Tools without restarting the database server.  But previous user that I added SDK Tools before restart, no error.
    Today
    User 1 - add SDK Tools, no restart, error
    Last Wednesday
    User 2 - add SDK Tools, no restart, error
    Today - database server restarted this morning
    User 2 - no more error
    Both User 1 and 2 are Limited Logistics User.
    Best regards,
    Dennis

  • Creating Inventory Goods Receipt (oInventoryGenEntry)

    Creating Inventory Goods Receipt (oInventoryGenEntry) gives the error "The inventory account is not defined".  But I do the same in SAP and the works.
    What do I have to do in my code about accounts ?
    I mean for sure I just give the item, the quantity and a bit of header information.

    Dear Marc Roussel,
    Please try to set the AccountCode of Document_Lines then add it again.
    Best Regards
    Jane Jing
    SAP Business One Forums team

  • Find a bapi for Creates a Goods Receipt with correspond to Inbound Delivery

    hi expert!
    exist a bapi for tcode:MIGO_GR ( Goods Receipt with correspond to Inbound Delivery)
    i know one bapI  BAPI_GOODSMVT_CREATE can Creates a Goods Receipt,
      but i can't know to use it to Creates a Goods Receipt with correspond to Inbound Delivery.
    or other bapi exist for MIGO_GR?
    Best Regard!

    Hi Vatcan,
    Chek the Inbound Delivery 1st weather you refer the right PO in it
    You can also chek in  PO i
    1 Me23n Go to confirmation tab here you can see the  Inbound delivery  quantity
    2 Chek  which reference document you recived the goods,  (i.e You recived the goods with reference to PO or  Inbound delivery)
    2 Coz if you refer the inbound delivery then syestem will deafult show the inbound quanity
    And yes the actual quanity will update in inbound delivery if you refer the inbound deivery while reciveing the goods

  • Error in R3 system when create the Goods receipt in EWM

    Dear EWM expert,
    I have an error in R3 system when I confirm the goods receipt in EWM for inbound delivery
    the error in SMQ2 is:
    PALLET is an auxiliary packaging material and cannot be used as pack.mate
    PALLET is a packaging matirial type VERP that I've create in in R3 and I have transfer via  cif it in EWM.
    We have the new EWM 7 and i check some OSS note for a programm error in transfering of pakaging material during the GR but they are available only for EWM 5 and they are not available for EWM 7.
    Could you explain me if this error coul be caused by some customising settings or by some master data field.
    Thank you in advance for your help.
    Best regards
    Alessandro
    Edited by: Alessandro Dapiaggi on Jan 29, 2009 5:11 PM

    Hi
    I am not sure of your problem since there may be quite a few reasons why this would happen. However just try one thing - change the Packing material category from "auxaliary packing material" to "packing material" in Define Packaging Material Types under logistics general--->HU Management ---> Basics for the packing material type you are using in VERP and then create a new packing material and try the inbound delivery. It may work
    Thanks
    DJ

  • Problem related to auto goods receipt- urgent

    please tell me
    is it possible to do auto goods receipt for material with serial number
    or enchancement
    please suggest

    As it is a personal setting, you cant.
    You can preselect it for a user and maintain it for a different users, but the user can always change it to his needs.
    You may need to develope a small programm that updates the user settings every night, then see who has the longer breath.
    I personally do not understand that requirement. If I am not intrested in QM data, because I am working in Accounting, then why should I have this view preselected?
    And even more worse, if somebody creates materials where this view is optional, and does not want that view, then SAP will create this view anytime.
    I saw several threads here where people asked how to remove unwanted views.
    Better rethink your requirement.
    MAterial master has a userexit that is processed while saving, there you can send an error message if the user has not done what you want from him.

  • How to create Zero Goods Receipt

    Hi there world of SAP geniuses,
    How do I create a zero goods receipt order?
    My client's requirements demand that I create a zero goods receipt order.

    The client has a progress payment requirement -  every stage of GR a certificate will be issued indicating workdone.
    This is important because there are two points of information to the GR - interfaced and manual entry. Retention is involved and will be indicated at the GR stage. This has to flow into the invoice.
    E.G.
    Month        Work Done    GR         Cert
    Jan            100                 100         100
    Feb            150                 150         250
    March         0                     0*            250
    So it all boils back down to creating a ZERO QUANTITY Goods receipt!
    Thanks for all your help in advance.

  • How to create a Goods receipt for Purchase order

    Hi All,
    How to create a GR for PO and then i need to invoice the PO
    Please tell me ASAP.
    Regards,
    Sagar.

    Thanks for ur reply
    I understood how to do it.
    Can u please say me how to invoice a PO.
    my mail id is:[email protected]
    Thanks

  • No inbound delivery/TO created for goods receipt into a Lean WM Storage Loc

    Ladies and Gentlemen:
    We are using SAP 46C with Support pack 45. We have quite a few storage locations that are Lean WM managed. The Storage locations are not HU Managed. However everytime run a MB1C or MIGO 501, SAP is receiving the materials directly via a material document. I was under the impression that any time a storage location is either WM, Lean WM or HU managed, SAP always creates an inbound delivery and in case of Lean WM/WM a transfer order to receive the material. Please tell me what am I missing.
    I have created plant, storage location and assigned the combination a lean Warehouse.
    I have done the configuration under:
    Customizing> Logistics Execution> Shipping--> Lean WM.
    Please help me with why my system is not creating inbound deliveries.
    Thanks.

    hi
    i am not 100% percent but I do not think that you can have inbound deliveries in to a lean wm environment. Inbound deliveries need to be pout away and as there are no bins etc in lean wm there is no put away to be done. If you want Inbound deliveries etc you are talking about full WM

  • Problem in posting the goods receipt with reference to the inbound delivery

    Hi All,
    Below is the explanation of the scenario:
    1. Materials are purchased (PO created in CAS as order unit) and inbound delivery document is created in cases as well.
    2. When the TO is created for put away (we are performing put away using the hand held devices) the line item is split resulting in new line item number created
    3. When the TO is confirmed the del quantity on the split line item is zeroing out and as a result the system is treating it as a service item with zero del quantity and is stopping from performing the GR with respect to the inbound delivery document
    And also the inbound delivery is disappearing from the confirmation tab on the PO)
    This is happening only with the materials which have an alternate unit set up in the material master (in this scenario CAS is the order unit and JAR is the base unit of measure)
    Can some one help fix this?

    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

  • No matching record error for good receipt

    hii
    experts,
    i am having a problem ,, while adding the good receipt draft document it is showing error that "no matching records" and one more issue is there that the posting period for that draft is 31 march 2015 and they want to add that document , here the Gl account is correct only but it is showing error .
    please help me solve this.
    thankyou

    Check the other side (Inventory account) of the transaction, depending on your item setting. It could be at item level, or group level, etc.
    Also check your SP_TN, some times wrong code in SP_TN will cause some weird problems.
    Frank

  • PO item on hold and can't create Goods Receipt PO

    We have a situation where a PO was created in our system which is 2007A SP00 PL 15.  The item on the PO has since been placed on hold.  Now when I pull up the po I change the item number to a valid item and click Update.  So far so Good.  No when I gry to copy the PO to a GR PO I get an error that the item is on hold and the document can only be saved as a draft.  It is trying to create the Goods receipt PO with the original item instead of the new item.
    How can I handle these?  It is not possible to edit the original item on the po.
    Thanks,
    don

    Thanks for the quick reply gordon.  I figured it out.  I have a FMS on the Goods Receipt PO screen that was inadvertanlty changing the item number after the GRPO opened.  The item number it changed it to was on hold.  My Bad.
    Thanks,,
    don

  • Create goods receipt using bapi fm

    hi friends,
                  i am geetha, i having a problem like while creating the goods receipt .
       create a goods receipt without purchase order using the tcode MB1C , I NEED EXACT  BAPI function module  to create agoods receipt.
    my fields are :
                         posting date
                          goods receipt issue slip number
                          movement type
                          matnr
                          quantity
                          units of measure
                           plant
                          storage location
    can you please suggest me the bapi  fm and describe the fm
    regards
    geetha.

    follow these links
    [link1|http://abap.wikiprog.com/wiki/BAPI_GOODSMVT_CREATE]
    [link2|Re: How to use bapi 'BAPI_GOODSMVT_CREATE'  in program?;
    Regards,
    SAPient

Maybe you are looking for

  • Transfer of contacts from 8300 to 9900 via BB desktop

    I can't connect my 8300 to bb desktop because the connector/charging port on the phone has developed a fault so can't back it up to transfer data to my new 9900. I do have a back up from June as an IPD file. If I connect the 9900 can I access this IP

  • Can I connect my Mac to my TV via RCA cables?

    I'm trying to connect my new Mac Mini to a TV that doesn't have HDMI nor DVI. It only has RCA connections and a Scart. I bought a converter to VGA from the Mac and another converter to RCA, but I only got a black screen on TV. Does anyone know how ca

  • Lost syntax highlight in Vim after upgrade

    I don't know why, but Vim is not enabling syntax highlight anymore after the upgrade from 7.1.12-1 to 7.1.63-1. I've already searched in Vim's website and with ':help syntax.txt' but no luck. Any guesses? EDITED: I figured out part of the problem. I'

  • Hosting for pdf files online

    I'd like to be able to take the files I have converted in my adobe program and post them on my website so that they can be downloaded. Is there a good service for this? Does adobe provide this service? Thanks!

  • Adobe Reader fails to load Core DLL

    I'm at my wits end here. For some unknown reason my Win 7 Home Premium 64-bit Dell laptop has started popping up  the following message about Protected Mode. If I choose Do Not open, then Reader just closes. If I choose Open with PM disabled, I get: