Skip to Content
avatar image
Former Member

How can I do a partial delivery with DI programmatically?

Hi at all,

I want to do a partial delivery programmatically, but the base document order gets closed!

This is what I do:

I create an order with Business One and allowed partial delivery. With SDK I create a delivery note based on this order.<BR> Next I manipulate the quantity oDelivery.Lines.Quantity = 1 (itu2019s less than in the base document). <BR>I add the new document. That works fine, but my based document is closed.

What do I wrong?

Thanks for your help!

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 04, 2008 at 11:07 AM

    Hi, thank you for your answers.

    For programming with DI I use the java connector (JCO).

    The partial delivery flag is set in the based order document.

    This is my code snippet, which looks up a docentry and a customer cardcode via SQL. <br>

    With these information I want to add a partial delivery note based on the referenced order document with several positions<br> (ordered quantity ist greater than 2 pieces)

    public void createODLN(int ordernumber) {
      try {
        IDocuments delivery;
        IDocuments order;
        IDocument_Lines pos;
        IRecordset rs = null;
        String sql;
        int docentry;
    
        delivery = SBOCOMUtil.newDocuments(sboCompany, SBOCOMConstants.BoObjectTypes_Document_oDeliveryNotes);
        
        // ordernumber is the DocNum in ORDR
        // but we need the DocEntry
        // 1. get the DocEntry for DocNum
        
        rs = SBOCOMUtil.newRecordset(sboCompany);
        sql = "SELECT DocEntry FROM ORDR WHERE DocNum = " + ordernumber;
        rs .doQuery(sql);
    
        // we have a 1:1 relation between DocNum and DocEntry
        rs.moveFirst();
        if (!rs.isEoF().booleanValue()) {
          // get the docentry
          docentry = rs.getFields().item("DocEntry").getValueInteger();
          // fill the order object
          order = SBOCOMUtil.getDocuments(sboCompany, SBOCOMConstants.BoObjectTypes_Document_oOrders, docentry);
          if (order.getByKey(docentry) == true) {
    	// exists
            pos = order.getLines();
            int rowcount = pos.getCount();
            for (int i=0; i<rowcount; i++) {
    	  pos.setCurrentLine(i);
              delivery.setCardCode(order.getCardCode());
              delivery.getLines().setBaseEntry(new Integer(docentry)); // Referenz aus Auftrag
              delivery.getLines().setBaseType(SBOCOMConstants.BoObjectTypes_Document_oOrders);
              delivery.getLines().setBaseLine(new Integer (pos.getLineNum()));
    	  // for all positions: delivered 2 pcs.          
              delivery.getLines().setQuantity(new Double(2));
    	  // add the line
              delivery.getLines().add();
            }
    	delivery.add();
          }
        }
      }
      catch (Exception e) {
        e.printStackTrace();
      }
    
    }
    

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 04, 2008 at 10:00 AM

    Hi Lars,

    do you set the quantity before or after the basefields?

    It should set after the basefields.

    Can you post your piece of code?

    Regards

    Ad

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 04, 2008 at 10:12 AM

    Hi Lars,

    Willkommen im Forum 😊

    vielleicht hast Du vergessen "Teillieferung" im Auftrag anzuklicken.

    Unter Logistik gibt es ja eine CheckBox dafür ...

    nur so eine Idee 😊

    EDIT:

    probier die Eigenschaft PartialSupply auch in Deinem oDelivery Object 😊

    lg David

    Edited by: David Nussböck on Sep 4, 2008 12:14 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 04, 2008 at 10:14 AM

    Hi Lars,

    I used the following code to add a partial Delivery for order 179 which had one row with a quantity of 2:

    Dim oDoc As SAPbobsCOM.Documents
            oDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes)
    
            oDoc.CardCode = "C1000"
    
            oDoc.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
            oDoc.Lines.BaseEntry = 179
            oDoc.Lines.BaseLine = 0
            oDoc.Lines.Quantity = 1
    
            oReturn = oDoc.Add()
    
            If oReturn <> 0 Then
                oCompany.GetLastError(oError, errMsg)
                MsgBox(errMsg)
            Else
                MsgBox("Partial Delivery Added")
            End If

    My Base document is still open after doing this - I tested this on 2005 A and 2007 A on a Demo database.

    Hope this is useful, let me know if you still have any issues.

    Regards

    Niall

    SAP Business One Forums Team

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 04, 2008 at 01:39 PM

    Thank you very much,

    I don't really know why, but it works.

    Best regards Lars

    Add comment
    10|10000 characters needed characters exceeded