cancel
Showing results for 
Search instead for 
Did you mean: 

How do i post Payments, PaymentOnInvoice and PaymentCheques at the same time ? using sdk ? in c#.net vs 2010

Former Member
0 Kudos

How do i post Payments, PaymentOnInvoice and PaymentCheques  at the same time ? using sdk ? in c#.net vs 2010

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

What do you refer as posting them at the same time? Give an example.

Thanks,

Gordon

Former Member
0 Kudos

SAPbobsCOM.Payments oPay = default(SAPbobsCOM.Payments);                 oPay = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);                 try                 {                     SqlConnection conInv;                     conInv = new SqlConnection(connV);                     SqlCommand com;                     SqlDataReader redInv;                     com = new SqlCommand("SELECT * FROM tblPayments WHERE AutoId='" + AutoId + "' AND Posted='" + "False" + "' AND Confirmed='" + "True" + "'", conInv);                     conInv.Open();                     redInv = com.ExecuteReader();                     if (redInv.HasRows && redInv.Read())                     {                         oPay.DocNum = int.Parse(redInv["DocNum"].ToString());                         string DocType = redInv["DocType"].ToString();                         string HandWritten = redInv["HandWritten"].ToString();                         string Printed = redInv["Printed"].ToString();                         if (DocType == "C")                         {                             oPay.DocType = BoRcptTypes.rCustomer;                         }                         if (HandWritten == "Y")                         {                             oPay.HandWritten = BoYesNoEnum.tYES;                         }                         else if (HandWritten == "N")                         {                             oPay.HandWritten = BoYesNoEnum.tNO;                         }                         oPay.DocDate = DateTime.Parse(DocDate);//DateTime.Parse(redInv["DocDate"].ToString());                         oPay.CardCode = redInv["CardCode"].ToString();                         oPay.Address = redInv["Address"].ToString();                         oPay.CashAccount = redInv["CashAccount"].ToString();                         oPay.DocCurrency = redInv["DocCurrency"].ToString();                         oPay.CashSum = double.Parse(redInv["CashSum"].ToString());                         oPay.TransferAccount = redInv["TransferAccount"].ToString();                         oPay.TransferSum = double.Parse(redInv["TransferSum"].ToString());                         oPay.TransferDate = DateTime.Parse(TransferDate);//DateTime.Parse(redInv["TransferDate"].ToString());                         oPay.TransferReference = redInv["TransferReference"].ToString();                         oPay.Reference1 = redInv["Reference1"].ToString();                         oPay.Reference2 = redInv["Reference2"].ToString();                         oPay.Remarks = redInv["Remarks"].ToString();                         oPay.BankCode = redInv["BankCode"].ToString();                         oPay.BankAccount = redInv["BankAccount"].ToString();                         oPay.UserFields.Fields.Item("U_Walkin_CardName").Value = redInv["U_Walkin_CardName"].ToString();                     }                     redInv.Close();                     redInv.Dispose();                     conInv.Close();                     conInv.Dispose();                 }                 catch (Exception ex)                 {                     System.Windows.Forms.MessageBox.Show(ex.Message + ex.Source + ex.StackTrace);                 }                 try                 {                     SqlConnection ConnLines;                     ConnLines = new SqlConnection(connV);                     SqlCommand comLines;                     SqlDataReader redLines;                     comLines = new SqlCommand("SELECT * FROM tblPaymentsOnInvoices WHERE ParentKey='" + RecordKey + "' AND Posted='" + "False" + "' AND Confirmed='" + "True" + "'", ConnLines);                     ConnLines.Open();                     redLines = comLines.ExecuteReader();                     while (redLines.HasRows && redLines.Read())                     {                         oPay.Invoices.DocEntry =int.Parse(redLines["NewDocEntry"].ToString());                         oPay.DocNum =int.Parse(redLines["DocNum"].ToString());                         oPay.Invoices.Add();                     }                     redLines.Close();                     redLines.Dispose();                     ConnLines.Close();                     ConnLines.Dispose();                 }                 catch (Exception ex)                 {                     System.Windows.Forms.MessageBox.Show(ex.Message + ex.Source + ex.StackTrace);                     // throw ex;                 }                 try                 {                     SqlConnection ConnLines;                     ConnLines = new SqlConnection(connV);                     SqlCommand comLines;                     SqlDataReader redLines;                     comLines = new SqlCommand("SELECT * FROM tblPaymentsCheque WHERE DocNum='" + RecordKey + "' AND Posted='" + "False" + "' AND Confirmed='" + "True" + "'", ConnLines);                     ConnLines.Open();                     redLines = comLines.ExecuteReader();                     while (redLines.HasRows && redLines.Read())                     {                         oPay.Checks.CheckNumber =int.Parse(redLines["CheckNumber"].ToString());                         oPay.Checks.BankCode =redLines["BankCode"].ToString();                         oPay.Checks.CheckSum = double.Parse(redLines["CheckSum"].ToString());                         oPay.Checks.CountryCode = redLines["CountryCode"].ToString();                         oPay.Checks.CheckAccount = redLines["CheckAccount"].ToString();                          oPay.Checks.Add();                     }                     redLines.Close();                     redLines.Dispose();                     ConnLines.Close();                     ConnLines.Dispose();                 }                 catch (Exception ex)                 {                     System.Windows.Forms.MessageBox.Show(ex.Message + ex.Source + ex.StackTrace);                     // throw ex;                 }                  int ith = 0;                 try                 {                     ith = oPay.Add(); //oINV.Add(); }

edy_simon
Active Contributor
0 Kudos

Hi Dickson,

in Payment Object below :

oPay.Checks     -> fill in all the check information.

oPay.Invoices     -> fill in all the invoices that you are paying against

oPay.CashSum     -> fill in the total amount paid by check

oPay.TransferSum     -> fill in the total amount paid by bank transfer.

And i notice that you place the oPay.Checks.Add() everytime you add the checks.

The last loop you need not put the oPay.Checks.Add().

Regards
Edy

Former Member
0 Kudos

Do you have a C# Sample code on how i should post ?

Former Member
0 Kudos

Hi Dickson,

     I think you should go to "C:\Program Files\SAP\SAP Business One SDK\Samples\COM DI"

Regards,

Former Member
0 Kudos

Assist me with your email address

Former Member
0 Kudos

I DONT HAVE THE SDK, KINDLY PROVIDE ME WITH IT OR GIVE ME A LINK I CAN DOWNLOAD.

Former Member
0 Kudos

Hi Dickson,

     Kindly ask your SAP Partner to give you a link to download SDK.

Regards,

Former Member
0 Kudos

I managed to post and its worked well.

Answers (0)