Skip to Content
avatar image
Former Member

create ap credit memo using DI

Hello Experts.....

I am creating credit memo against AP invoice .It gives me error row without tax code.......

Following is my code.

Please help me its urgent......

SAPbobsCOM.Documents oMemo = (SAPbobsCOM.Documents)clsAddOn.EDEL_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseCreditNotes);

//code to get entry

SAPbobsCOM.Recordset entry = clsAddOn.EDEL_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

string strentry = "select Docentry,Docdate,Cardcode,Numatcard,ShipToCode from OPCH where Docentry=" + entry1.Fields.Item("Entry").Value;

entry.DoQuery(strentry);

Int32 docentry = entry.Fields.Item("Docentry").Value;

string cardcode = entry.Fields.Item("Cardcode").Value;

string numatcard = entry.Fields.Item("Numatcard").Value;

string shipfrom = entry.Fields.Item("ShipToCode").Value;

//string billsupply = "GA";

oMemo.CardCode = cardcode;

oMemo.DocDate = entry.Fields.Item("Docdate").Value;

oMemo.DocDueDate = entry.Fields.Item("Docdate").Value;

oMemo.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items; oMemo.ATDocumentType = "GA";

oMemo.ShipFrom = shipfrom.Trim();

oMemo.DocumentSubType = SAPbobsCOM.BoDocumentSubType.bod_GSTTaxInvoice; oMemo.OriginalRefDate = entry.Fields.Item("Docdate").Value;

oMemo.OriginalRefNo = docentry.ToString();

//code to get place of supply' SAPbobsCOM.Documents opch = (SAPbobsCOM.Documents)clsAddOn.EDEL_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseInvoices);

opch.GetByKey(docentry);

string str2 = opch.AddressExtension.PlaceOfSupply.ToString(); oMemo.AddressExtension.PlaceOfSupply = str2.Trim();

oMemo.RelevantToGTS = SAPbobsCOM.BoYesNoEnum.tYES;

oMemo.NumAtCard = numatcard;

oMemo.ShipToCode = entry.Fields.Item("ShipToCode").Value;

SAPbobsCOM.Recordset linedata = null;

// oMemo.DocumentSubType = SAPbobsCOM.BoDocumentSubType.bod_PurchaseDebitMemo; SAPbobsCOM.Documents oinv = (SAPbobsCOM.Documents)clsAddOn.EDEL_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseInvoices)

; oinv.GetByKey(docentry);

string str1 = oinv.DocumentSubType.ToString();

linedata = clsAddOn.EDEL_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

string strlinedata = "select * from PCH1 where Docentry="entry1.Fields.Item("Entry").Value;

linedata.DoQuery(strlinedata);

linedata.MoveFirst(); int j = 0;

while (!linedata.EoF)

{ oMemo.Lines.SetCurrentLine(j);

oMemo.Lines.BaseType = 18;

oMemo.Lines.BaseEntry = docentry;

oMemo.Lines.BaseLine = 0;

oMemo.Lines.WTLiable = SAPbobsCOM.BoYesNoEnum.tNO;

string itemcode = linedata.Fields.Item("ItemCode").Value;

oMemo.Lines.ItemCode = linedata.Fields.Item("ItemCode").Value;

double qty = linedata.Fields.Item("U_DebitQty").Value;

oMemo.Lines.Quantity = 1;linedata.Fields.Item("U_DebitQty").Value;

//Convert.ToDouble(oMat.Columns.Item("U_DebitQty").Cells.Item(i).Specific.Value); oMemo.Lines.Price = 100;// linedata.Fields.Item("Price").Value;

oMemo.Lines.BaseType = 18;

oMemo.Lines.BaseEntry = docentry;

int le = linedata.Fields.Item("LineNum").Value;

oMemo.Lines.BaseLine = linedata.Fields.Item("LineNum").Value;

string rejwhs = clsAddOn.WH_REJECT;

oMemo.Lines.WarehouseCode = clsAddOn.WH_REJECT;

string taxcode = linedata.Fields.Item("TaxCode").Value;

oMemo.Lines.LocationCode = 2;

oMemo.Lines.TaxCode = taxcode.Trim();

oMemo.Lines.TaxType = SAPbobsCOM.BoTaxTypes.tt_Yes;

oMemo.Lines.TaxOnly = SAPbobsCOM.BoYesNoEnum.tNO;

oMemo.Lines.TaxLiable = SAPbobsCOM.BoYesNoEnum.tYES;

oMemo.Lines.Add();

j++;

linedata.MoveNext(); }

//string xml = oMemo.GetAsXML();

int result = oMemo.Add();

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers