Skip to Content
author's profile photo Former Member
Former Member

Create New Supplier Invoice (with Purchase Order) in ABSL

Dear Experts,

I would like to create a new supplier invoice based on Purchase Order using ABSL codes in SAP Cloud Application Studio. How can I create the correct supplier invoice based on purchase order? Please kindly let me know.

I did the codes as shown in following to create the supplier invoice based on purchase order. The new supplier invoice is created but it's document flow is not correct as shown in attachment. What is wrong with me? Please kindly light us.

import ABSL;

import AP.SupplierInvoicing.Global;

var SI_Root: elementsof SupplierInvoice;

var toSIV: elementsof SupplierInvoice;

var SI_BTD: elementsof SupplierInvoice.BusinessTransactionDocumentReference;

var SI_Item1_BTD: elementsof SupplierInvoice.Item.ItemBusinessTransactionDocumentReference;

var SI_SParty: elementsof SupplierInvoice.Party;

var SI_BParty: elementsof SupplierInvoice.Party;

var SI_PParty: elementsof SupplierInvoice.Party;

var SI_InvoicingParty: elementsof SupplierInvoice.Party;

var SI_Item: elementsof SupplierInvoice.Item;

var SI_DueDate: elementsof SupplierInvoice.CashDiscountTerms;

var SI_AssignCode:elementsof SupplierInvoice.Item.ItemAccountingCodingBlockDistribution.AccountingCodingBlockAssignment;

var SI_GLAcc:elementsof SupplierInvoice.Item.ItemAccountingCodingBlockDistribution;

var Ins_AssignCode;

var AssignCode;

var BTDRef: elementsof SupplierInvoice.BusinessTransactionDocumentReference;

var SI;

var SI_Item1;

// Set document type to Invoice

SI_Root.TypeCode = "004";

SI_Root.DocumentItemsGrossAmountIndicator = false;

// Set Invoice Date

SI_Root.Date = Context.GetCurrentSystemDate();

SI_Root.ReceiptDate = Context.GetCurrentSystemDate();

SI_Root.TransactionDate = Context.GetCurrentSystemDate();

// Gross Amount

SI_Root.GrossAmount.currencyCode = "THB";

SI_Root.GrossAmount.content = 234422;

// Root node creation

SI = SupplierInvoice.Create(SI_Root);

// Set External Document ID

BTDRef.BusinessTransactionDocumentReference.ID.content = "IDN-123";

SI.CustomerInvoiceReference.Create(BTDRef);

// Purchase Order : Predecessor

SI_BTD.BusinessTransactionDocumentReference.ID.content = "123";

SI_BTD.BusinessTransactionDocumentReference.TypeCode = "001";

SI_BTD.BusinessTransactionDocumentRelationshipRoleCode = "1";

SI.BusinessTransactionDocumentReference.Create(SI_BTD);

// Inbound Delivery : Predecessor

SI_BTD.Clear();

SI_BTD.BusinessTransactionDocumentReference.ID.content = "CID-123";

SI_BTD.BusinessTransactionDocumentReference.TypeCode = "24";

SI_BTD.BusinessTransactionDocumentRelationshipRoleCode = "1";

SI.BusinessTransactionDocumentReference.Create(SI_BTD);

// Outbound Delivery

SI_BTD.Clear();

SI_BTD.BusinessTransactionDocumentReference.ID.content = "IDN-123";

SI_BTD.BusinessTransactionDocumentReference.TypeCode = "73";

SI_BTD.BusinessTransactionDocumentRelationshipRoleCode = "7";

SI.BusinessTransactionDocumentReference.Create(SI_BTD);

// Set Supplier ID

SI_SParty.PartyKey.PartyID.content = "SUP-001";

SI.SellerParty.Create(SI_SParty);

// Set Bill-To Party

SI_BParty.PartyKey.PartyID.content = "BUYER-001";

SI.BuyerParty.Create(SI_BParty);

//Set Payee Party

SI_PParty.PartyKey.PartyID.content = "PAYEE-001";

SI.PayeeParty.Create(SI_PParty);

//Set Bill-From Party

SI_InvoicingParty.PartyKey.PartyID.content = "SUP-001";

SI.BillFromParty.Create(SI_InvoicingParty);

// Set Product Quantity

SI_Item.Quantity.content = 100;

SI_Item.Quantity.unitCode = "PCS";

// Set Net Amount

SI_Item.NetAmount.content = 234422;

// Set Net Price or Gross Price

SI_Item.NetUnitPrice.Amount.content = 2344.22;

// Set Price Per Item

SI_Item.NetUnitPrice.BaseQuantity.content = 1;

// Line Item Creation

SI_Item1 = SI.Item.Create(SI_Item);

// Product ID

SI_Item1.ItemProduct.ProductKey.ProductID.content = "TESTPRODUCT-0016";

// Product Type

SI_Item1.ItemProduct.ProductKey.ProductTypeCode = "1";

// Purchase Order

SI_Item1_BTD.BusinessTransactionDocumentReference.ID.content = "123";

SI_Item1_BTD.BusinessTransactionDocumentReference.ItemID = "1";

SI_Item1_BTD.BusinessTransactionDocumentReference.ItemTypeCode = "18";

SI_Item1_BTD.BusinessTransactionDocumentReference.TypeCode = "001";

SI_Item1_BTD.BusinessTransactionDocumentRelationshipRoleCode = "5";

//SI_Item1.ItemBasePurchaseOrderItemReference.Create(SI_Item1_BTD);

SI_Item1.ItemBusinessTransactionDocumentReference.Create(SI_Item1_BTD);

// Supplier Invoice Request for PO

SI_Item1_BTD.BusinessTransactionDocumentReference.ID.content = "228";

SI_Item1_BTD.BusinessTransactionDocumentReference.ItemID = "1";

SI_Item1_BTD.BusinessTransactionDocumentReference.ItemTypeCode = "18";

SI_Item1_BTD.BusinessTransactionDocumentReference.TypeCode = "128";

SI_Item1_BTD.BusinessTransactionDocumentRelationshipRoleCode = "3";

SI_Item1.ItemBusinessTransactionDocumentReference.Create(SI_Item1_BTD);

// Inbound Delivery

SI_Item1_BTD.BusinessTransactionDocumentReference.ID.content = "CID-123";

SI_Item1_BTD.BusinessTransactionDocumentReference.ItemID = "10";

SI_Item1_BTD.BusinessTransactionDocumentReference.ItemTypeCode = "14";

SI_Item1_BTD.BusinessTransactionDocumentReference.TypeCode = "24";

SI_Item1_BTD.BusinessTransactionDocumentRelationshipRoleCode = "5";

SI_Item1.ItemBusinessTransactionDocumentReference.Create(SI_Item1_BTD);

// Supplier Invoice Request for Inbound

SI_Item1_BTD.BusinessTransactionDocumentReference.ID.content = "225";

SI_Item1_BTD.BusinessTransactionDocumentReference.ItemID = "10";

SI_Item1_BTD.BusinessTransactionDocumentReference.TypeCode = "128";

SI_Item1_BTD.BusinessTransactionDocumentRelationshipRoleCode = "3";

SI_Item1.ItemBusinessTransactionDocumentReference.Create(SI_Item1_BTD);

// Set Tax Code

SI_Item1.TaxCalculationItem.TaxationCharacteristicsCode.content = "5";

// G/L Account SIV

SI_Item1.ItemAccountingCodingBlockDistribution.GeneralLedgerAccountAliasCode.content = "TEST-000005";

foreach(var inst in SI_Item1.ItemAccountingCodingBlockDistribution.AccountingCodingBlockAssignment) {

// Set Account Assignment Type to "Cost Center"

inst.AccountingCodingBlockTypeCode.content = "CC";

// Set Cost Center ID

inst.CostCentreID = "2250";

}

SI.CalculateGrossAmount();

SI.CalculateTaxAmount();

Best Regards,

Thiri

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Aug 23, 2016 at 01:21 AM

    Hi Experts,

    Anyone knows? Please light us. I need your help. 😭

    Thanks and Regards,

    Thiri

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.