Create a PO from a c# program

Hi,

I am trying to create a purchase order from a programme in C#, outside of E10. I have been looking around for a solution for a while, but I still don’t manage to update the database. Find below my code:

Session session = new Session(userID, password, asUrl, LicenseType, pathToConfigurationFile);
Erp.Proxy.BO.POImpl POBO = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Erp.Proxy.BO.POImpl>(session, Erp.Proxy.BO.POImpl.UriPath);
PODataSet pODataSet = new PODataSet();
PODataSet.POHeaderRow pOHeaderRow = pODataSet.POHeader.NewPOHeaderRow();
pOHeaderRow.Company = "RFL";
pOHeaderRow.PONum = 455;
pOHeaderRow.VendorVendorID = "D056";
pOHeaderRow.OrderDate = DateTime.Today;
POBO.Update(pODataSet);

I don’t get any error message, but when I go to E10 and check if anything has been created, I cannot find the new PO.
I am new to coding, so I apologize in advance if it is something easy to do, but I am wondering if it is something even possible, or if there is something I am missing here.

Thanks

Fabien

Try not setting the PONum, Epicor will set that for you.

Also a good tip to create Epicor data via code is to do a trace log. In the settings on the client enable tracing, then create a PO (or whatever you want to create) in Epicor and read the trace log file. It is a big xml file that lists out all the calls the client has made to create the record. You can examine the log file and make the same calls in your code. Note some fields are set by directly assigning a value to the dataset others have methods to set them. You will see that in the trace log. This is not the best written explanation but hopefully it is helpful.

Cheers
Brett

There are a lot of business object calls you are missing. Do a trace on the manual process and then replicate these steps in your code.
Furthermore you can’t set the PO number since it is set by epicor.

-Jose

Thanks for your help. I looked at the trace log and the methods used. By using the code below, it worked as I wanted to.

Session session = new Session(userID, password, asUrl, LicenseType, pathToConfigurationFile);
Erp.Proxy.BO.POImpl POBO =   Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Erp.Proxy.BO.POImpl>(session, Erp.Proxy.BO.POImpl.UriPath);
PODataSet pODataSet = new PODataSet();
POBO.GetNewPOHeader(pODataSet);
POBO.ChangeVendor("D056", pODataSet);
DataRow[] pOHeaderRow = pODataSet.Tables["POHeader"].Select();
pOHeaderRow[0]["BuyerID"] = "Daniel";
POBO.Update(pODataSet);

The trace log was not showing how to select a buyer (which is mandatory to create a PO), so I found this workaround. I think it is fine since pODataset only have one row.

Many thanks for your help.

Fabien