Skip to Content

Post intercompany COGS to deviating GL account via enhancement implementation

My customer is doing 3rd-party order procurement. He sells materials that he buys from third parties with direct shipment. Some of these third parties are group companies and he wants to see those COGS at another GL account.

Account determination does not allow a business partner specific posting of COGS, but here is how you can achieve this via an SDK solution:

  1. Create the new GL account. In my case, it is 450235, while 450230 is the regular COGS account.
  2. In SAP Cloud Applications Studio, create the Enhancement Implementation AccountDetermination, Operation SUBSTITUTE_ACCOUNT. You will find a coding example below. In my case, it will replace the accounts for COGS postings in case it has been delivered by supplier S10040. Here, it could get a little bit nicer by determination of the supplier's account determination group.

This solution might be adaptable also for GL account substitutions in other processes. Important is to determine the correct subledger account line item type (aka SLALITTYPE), source document type and accounting business transaction type.

The solution comes with one limitation: In case you are using reveue recognition, it will not work. The realisation of COGS will be done unsing the G/L Account Origin of the deferral - and there's no possibility to influence that. But even for this, there is a special solution. Don't assign an accrual method at first (so no defaulting to be defined in Fine-Tuning for affected transactions), so the system will realize costs at first. Afterwards, assign an accrual method, for example manually or with another skript. You can use Action ModifyMainAccrualParameter at NodeItem-ItemSetOfBooks level of Business Object FinancialAccountingViewOfSalesAndServiceDocument.

As an alternative to this, you might consider to create a functional area for IC COGS and use Enhancement Option FunctionalAreaSubstitution.


Hint: this piece of code is an example implementation only. It does not implement any error handling.

import ABSL;

import AP.FinancialAccounting.Global;

import AP.LogisticsExecution.Global;

var result : ChartOfAccountsItemCode;

       //if COGS posting, i.e.

       // - SLALITTYPE = 99010

       // - AccountingBusinessTransactionTypeCode = 349 - Goods Issue for Customer (Third Party)

       // - Source Document Type = 55 - Goods and Activity Confirmation

       if(InputData.SubledgerAccountLineItemType == "99010" &&

          InputData.AccountingBusinessTransactionTypeCode == "349" &&

          InputData.OriginalEntryDocumentItemReference.ObjectTypeCode.content == "55")

          {

                    //go to goods and activity confirmation, retrieve PO

                    var confirmtnQury = GoodsAndActivityConfirmation.QueryByElements;

                    var confirmtnQerySel = confirmtnQury.CreateSelectionParams();

                    confirmtnQerySel.Add(confirmtnQury.ID.content, "I", "EQ", InputData.OriginalEntryDocumentContainingObjectReference.ObjectID.content);

                   

                    var confirmtnRslt = confirmtnQury.Execute(confirmtnQerySel);

                    var vendor = confirmtnRslt.OutboundDelivery.VendorParty.GetFirst();

                    //next query - now you could search the BO AccountsReceivablePayableLedgerAccount to

                    //retrieve the AccountDeterminationGroupCode, as an example.

                    //for simplicity reasons, I will only check for a hard-coded supplier.

                    if(vendor.PartyKey.PartyID.content == "S100400")

                    {

                           switch (InputData.ChartOfAccountsCode)

                           {

                                  case "ZIAS"

                                        {

                                               result.listID = "ZIAS";

                                               result.content = "450235";

                                        } //if COA = IFRS, then replace GL account for IC postings to 450235

                           }

                    }

           }

        //GR-IR Clearing Run

        if(InputData.SubledgerAccountLineItemType == "99010" &&

          InputData.AccountingBusinessTransactionTypeCode == "610" &&

          InputData.OriginalEntryDocumentItemReference.ObjectTypeCode.content == "57")

          {

                    //get sales ledger item

                    var saLItQry = FinancialAccountingViewOfSalesAndServiceDocument.Item.QueryByElements;

                    var saLItSel = saLItQry.CreateSelectionParams();

                    saLItSel.Add(saLItQry.UUID.content, "I", "EQ", InputData.FinancialAccountingViewOfSalesAndServiceDocumentItemUUID.content);

                    var saLItRslt = saLItQry.Execute(saLItSel);

                    var saLItLine = saLItRslt.GetFirst();

                    var vendor = saLItLine.VendorSupplier.InternalID; //there shouldn't be several.

                    if( vendor == "S100400")

                    {

                           switch (InputData.ChartOfAccountsCode)

                           {

                                  case "ZIAS"

                                        {

                                               result.listID = "ZIAS";

                                               result.content = "450235";

                                        } //if COA = IFRS, then replace GL account for IC postings to 450235

                           }

                    }

          }

return result;

Tags: