C# PO Write Fails BOI

SOLVED

First, thanks in advance for taking a look at this.  I'm looking at doing PO creation from C# and have been able to connect, get the next PO number etc., but everytime I try to finalize the PO, such as call the "nWrite" command, it always fails.  Any insight into what could be happening?  Below is my code.

using (DispatchObject poObject = new DispatchObject(pvx.InvokeMethod("NewObject", "PO_PurchaseOrder_bus", oSS.GetObject())))
{
try
{
string poNumber = "";
//int test1 = (int)poObject.InvokeMethod("nGetNextPurchaseOrderNo");
object[] poPass = new object[] {poNumber};
successCheck((int)poObject.InvokeMethodByRef("nGetNextPurchaseOrderNo", poPass), "GetNextPurchaseOrder");

//this was just to see what the PO number was coming back.
poNumber = poPass[0].ToString();

//we continue
successCheck((int) poObject.InvokeMethodByRef("nSetKey", poPass), "SetKey");
object[] divisionNoObject = new object[] {"APDivisionNo$", "00"};
successCheck((int) poObject.InvokeMethodByRef("nSetValue", divisionNoObject), "SetDivisionNo");
object[] vendorObject = new object[] { "VendorNo$", "0006630" };
successCheck((int)poObject.InvokeMethodByRef("nSetValue", vendorObject), "SetVendorNo");
object[] taxObject = new object[] { "TaxSchedule$", "NONTAX" };
successCheck((int)poObject.InvokeMethodByRef("nSetValue", taxObject), "SetTaxSchedule");

DispatchObject poLines = new DispatchObject(poObject.GetProperty("oLines"));
successCheck((int)poLines.InvokeMethod("nAddLine"), "AddLine");
object[] firstLine = new object[] { "ItemCode$", "/1." };
successCheck((int)poLines.InvokeMethodByRef("nSetValue", firstLine), "PoLineItemCode");
firstLine[0] = "QuantityOrdered";
firstLine[1] = "1";
successCheck((int)poLines.InvokeMethodByRef("nSetValue", firstLine), "PoLineQuantityOrdered");
successCheck((int)poLines.InvokeMethod("nWrite"), "PoLinesWrite");
successCheck((int) poObject.InvokeMethod("nWrite"), "Write");

MessageBox.Show("SUCCESS! " + poNumber.ToString());

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

}

And below is my successCheck method to see what fails.

public void successCheck(int checkValue, string call)
{
if (checkValue == 0)
{
MessageBox.Show("Error! " + call);

}

}

Parents
  • 0

    did you solved the problem? are you caable to receive a po?

  • 0 in reply to yoandy valdes

    I have got the purchase order and line items details but I can not get below fields data

    I have used the below custom code

    I got and its working 
    purchaseOrder.ItemCode = so_line.GetDataObject("ItemCode$");
    purchaseOrder.ItemCodeDescription = so_line.GetDataObject("ItemCodeDesc$");

    its not working code ---- please does it correct keyword
    purchaseOrder.Quantity = so_line.GetDataObject("QuantityOrdered$");
    purchaseOrder.QuantityShipped = so_line.GetDataObject("QuantityReceived$");
    purchaseOrder.QtyOnHand = so_line.GetDataObject("QuantityBackordered$");

    please can you help me?

Reply
  • 0 in reply to yoandy valdes

    I have got the purchase order and line items details but I can not get below fields data

    I have used the below custom code

    I got and its working 
    purchaseOrder.ItemCode = so_line.GetDataObject("ItemCode$");
    purchaseOrder.ItemCodeDescription = so_line.GetDataObject("ItemCodeDesc$");

    its not working code ---- please does it correct keyword
    purchaseOrder.Quantity = so_line.GetDataObject("QuantityOrdered$");
    purchaseOrder.QuantityShipped = so_line.GetDataObject("QuantityReceived$");
    purchaseOrder.QtyOnHand = so_line.GetDataObject("QuantityBackordered$");

    please can you help me?

Children