What is an A/P Invoice?
A/P Invoice is abbreviations from Account Payable Invoice. Its account or the bill must be paid to vendor based on the goods we buy. Many vendor allowing to pay after product or service already been received.
To generate document A/P Invoice in SAP B1 is using oPurchaseInvoice object.
Here is the code:Note: If your vendor use Tax amount, you can setup first on Business partner master - allowed taxDim oAPInvoice As sapbobscom.DocumentsSet oAPInvoice = oCompany.GetBusinessObject(sapbobscom.BoObjectTypes.oPurchaseInvoices)With oAPInvoice‘Header area.CardCode = your vendor code.NumAtCard = your reference no.DocDate = your posting date.TaxDate = your document date.DocType = sapbobscom.BoDocumentTypes.dDocument_Items.Comments = your remarks‘Detail area.Lines.SetCurrentLine (detail rows).Lines.itemCode = your item code.Lines.WarehouseCode = your warehouse code.Lines.Quantity = your qty.Lines.VatGroup = "ZI".Lines.UnitPrice = F_Price.Lines.LineTotal = F_AmountLngErr = .Add()If LngErr <> 0 ThenoCompany.GetLastError(LngErr, sErrMsg)Msgbox SErrMsgElseMsgBox “Create A/P Invoice Data Success”End with
hi,
ReplyDeletei have almost the sale code but with C#
the subject is that :
- i read invoices form a CSV file
- i save them in SAP B1
my problem is that it takes just the first invoice
help me plz
here is my code :
try
{
SAPbobsCOM.Documents ofact;
//globals_Renamed.InitializeCompany();
//SAPbobsCOM.Company oCompany = new SAPbobsCOM.Company();
ofact = (SAPbobsCOM.Documents)globals_Renamed.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
csvDataSet = new DataSet(_root);
csvDataTable = new DataTable(_node);
stream = new System.IO.StreamReader("C:/factures1.csv", true);
sLigne = stream.ReadLine();
sLigne = stream.ReadLine();
saEntetes = sLigne.Split(_separator);
while (sLigne != null )
{
ofact.NumAtCard = saEntetes[0];
ofact.DocDate = Convert.ToDateTime(saEntetes[1]);
ofact.DocDueDate = Convert.ToDateTime(saEntetes[2]);
ofact.CardCode = saEntetes[3];
string bcl = ofact.NumAtCard;
while (saEntetes[0] == bcl)
{
ofact.Lines.ItemCode = saEntetes[4];
ofact.Lines.Quantity = Convert.ToDouble(saEntetes[5]);
ofact.Lines.Price = Convert.ToDouble(saEntetes[6]);
ofact.Lines.DiscountPercent = Convert.ToInt64(saEntetes[7]);
ofact.Lines.VatGroup = saEntetes[9];
ofact.Lines.Add();
ofact.Lines.SetCurrentLine(ofact.Lines.Count - 1);
sLigne = stream.ReadLine();
saEntetes = sLigne.Split(_separator);
}
sLigne = stream.ReadLine();
//lRetCode = globals_Renamed.oCompany.Connect();
lRetCode = ofact.Add();
string ErMsg;
globals_Renamed.oCompany.GetLastError(out lRetCode, out ErMsg);
MessageBox.Show(lRetCode + "-" + ErMsg );
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Hi, please I need help ,
ReplyDeletewhen I add the Sales Order via the DI API, Do I have to substract the quantity in OITW and OITM or sap will make the adjustment itself