DI to create draft goods receipt

Hi,
I am trying to use the DI to create a draft goods receipt but am receiving the following error:
System.Exception: -5001 - Object type for draft is missing
Any ideas how to do this?
Thanks,
Michael

Hi Michael,
Did you set the Object Type for the draft (property DocObjectCode) in your code?
Dim vDrafts As SAPbobsCOM.Documents
Set vDrafts = vCmp.GetBusinessObject(oDrafts)
vDrafts.DocObjectCode = oInventoryGenEntry
Kind Regards,
Friederike
SAP Business One Forums Team

Similar Messages

  • 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

  • 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

  • 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

  • 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

  • New batch number for Draft Good Receipt Purchase Order

    Hello,
    I'm using SBO 8.81
    I'm looking for the table that contains the information about the batch number of a draft good receipt.
    DRF16 contains quantity of batch, but when itu2019s new batch, they are not in OBTN yet (in the table, SBO define object type as 10000068 while itu2019s 10000044 for existing batch)
    The query defined here  is not working as the batches are not in OBTN yet (not in stock)
    I used the profiler trying to understand in which table these data are recorder, without success.
    Any idea ?
    Thank you for your help
    Sébastien
    Edited by: Sébastien Danober on Aug 24, 2011 6:31 PM
    Sorry, wrong forum, I recreate it under SDK

    Hi Sébastien,
    The link is from DRF16 to ODBN:
    select * from DRF16 T0 inner join ODBN T1 on T0.ObjAbs = T1.AbsEntry
    DRF16 has a zero-to-many relationship with DRF1 (ie draft lines)
    Kind Regards,
    Owen

  • 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

  • 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

  • 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

  • Difference between creating a "Item" Goods Receipt PO and a "Service" one

    I use following codes to create a Goods Receipt PO. It works fine while creating an "item-type" goods recript PO, but got the following error
    message when creating a "service-type" one?
            "-5--2 Data cannot be empty in one of the tables Doc1, Doc3, Doc10. OPDN.DocNum Line: 0"
    I have read many articles on the forum about -5002 error  and realize that is caused mostly by mandatory fields or foreign keys.
    But  does someone give me more clear idea on this?  
    oPD = Nothing
                oPD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes)
                ocb = oFormIQC.Items.Item("cbDocType").Specific
                If ocb.Selected.Value = "I" Then
                    oPD.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items
                Else
                    oPD.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Service
                End If
                oed = oFormIQC.Items.Item("13").Specific
                oPD.CardCode = oed.Value
                oed = oFormIQC.Items.Item("edComments").Specific
                oPD.Comments = oed.Value
                For offset As Integer = 0 To PDcount - 1
                    If offset > 0 Then
                        oPD.Lines.Add()
                    End If
                    oPD.Lines.SetCurrentLine(offset)
                    If oPD.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items Then
                        oPD.Lines.ItemCode = oDataTable.GetValue("U_ItemCode", offset)
                        oPD.Lines.ItemDescription = oDataTable.GetValue("U_Descrp", offset)
                        oPD.Lines.Quantity = oDataTable.GetValue("U_AcptQty", offset)
                        oPD.Lines.UnitPrice = oDataTable.GetValue("U_Price", offset)
                    Else
                        oPD.Lines.ItemDescription = oDataTable.GetValue("U_Descrp", offset)
                        oPD.Lines.LineTotal = oDataTable.GetValue("U_LineTtl", offset)
                    End If
                Next
                RetVal = oPD.Add()
                If RetVal <> 0 Then ' If the addition failed
                    oCompany.GetLastError(ErrCode, ErrMsg)
                    SBO_Application.MessageBox( ErrCode & ", " & ErrMsg)
                    Return False
                End If
    Edited by: Chao-Yi Wu on Aug 24, 2009 5:16 AM

    The G/L Account (AcctCode) field in doc line is mandotary if it is service type. So you should add this as well.
    oPD.Lines.AccountCode = ****

  • Create Goods Receipt with an Inbound Delivery

    Hi,
    Can you anybody help me, how to create a Goods Receipt with correspond to Inbound Delivery.
    Which FM or BAPI avaliable for this. Anybody did it before please pass to me with details?
    Thanks in Advance
    Cino C B
    Edited by: Cili on Feb 11, 2008 8:19 PM

    Check BAPI_GOODSMVT_CREATE
    Look at the documentation if you want to make a goods issue or a good receipt for purchase order or production order, etc.
    Inbound delivery only means is going to enter the plant (ie. mvt 101)

Maybe you are looking for