Skip to Content

AR Invoice + Payment through DI API

Hello everyone.

I have been working with invoice xml for a long time without any problems, but now I want to make invoice + payment directly through an xml. I really have no idea how to do it. I send the code where I currently upload only invoices. If someone wants to help me I would appreciate it very much.

Alvaro

using System;

using System.Data.SqlClient;

using ConectoresBO.Conectores;

namespace SAPBOConector.Documentos

{

public class oInvoice

{

public oInvoice(SAPbobsCOM.Documents oInvoice, SAPbobsCOM.Company sapCompany, Company company, int key, int index)

{

SQLAdapter sqlAdapter = company.Conector.SQLAdapter;

SAPbobsCOM.Documents invoice = (SAPbobsCOM.Documents)sapCompany .GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);

int COUNT = 0;

SqlDataReader reader = sqlAdapter.ejecutarConsulta ("SELECT COUNT('A') FROM " + sapCompany.CompanyDB + ".dbo.OINV WHERE U_BKV_UID='" + oInvoice.UserFields.Fields.Item("U_BKV_UID").Value + "'");

if (reader.Read())

{

COUNT = reader.GetInt32(0);

}

if (COUNT == 0)

{

invoice.CardCode = oInvoice.CardCode;

invoice.TaxDate = oInvoice.TaxDate;

invoice.DocDate = oInvoice.DocDate;

invoice.DocDueDate = oInvoice.DocDueDate;

invoice.ShipToCode = oInvoice.ShipToCode;

invoice.UserFields.Fields.Item("U_BKV_UID").Value = oInvoice.UserFields.Fields.Item("U_BKV_UID").Value; invoice.UserFields.Fields.Item("U_BKV_Nombre").Value = oInvoice.UserFields.Fields.Item("U_BKV_Nombre").Value; invoice.UserFields.Fields.Item("U_BKV_Cedula").Value = oInvoice.UserFields.Fields.Item("U_BKV_Cedula").Value; invoice.UserFields.Fields.Item("U_BKV_Direccion").Value = oInvoice.UserFields.Fields.Item("U_BKV_Direccion").Value; invoice.UserFields.Fields.Item("U_BKV_Telefono").Value = oInvoice.UserFields.Fields.Item("U_BKV_Telefono").Value; invoice.UserFields.Fields.Item("U_BKV_Email").Value = oInvoice.UserFields.Fields.Item("U_BKV_Email").Value;

for (int i = 0; i < oInvoice.Lines.Count; i++)

{

oInvoice.Lines.SetCurrentLine(i);

invoice.Lines.SetCurrentLine(i);

char[] delimiterChars = { '.' };

string[] cantidad = oInvoice.Lines.Quantity.ToString().Split(delimiterChars); invoice.Lines.ItemCode = oInvoice.Lines.ItemCode;

invoice.Lines.Quantity = Convert.ToDouble(cantidad[0]);

invoice.Lines.WarehouseCode = oInvoice.Lines.WarehouseCode; invoice.Lines.ProjectCode = oInvoice.Lines.ProjectCode;

invoice.Lines.UseBaseUnits = SAPbobsCOM.BoYesNoEnum.tNO;

invoice.Lines.Add();

}

invoice.Add();

String Status = "";

if (sapCompany.GetLastErrorCode() != 0)

{

Status = "Error :" + sapCompany.GetLastErrorDescription().ToString();

}

else

{

Status = "Done";

Add comment
10|10000 characters needed characters exceeded

  • Hi Alvaro,

    Since you originally posted your question with a Fiori Application tag rather than a Business Objects tag, I suspect no one in the Fiori community had the background to provide a solution. I have tagged your question with what I think is a more appropriate tag or at least one which will get you much closer to the right people. Apologies for the misleading Fiori tag name. It is entirely up to you whether to reopen the question for potential solutions.

    Regards, Mike (Moderator)
    SAP Technology RIG

  • Get RSS Feed

0 Answers