Posting costs in Advanced Purchase Costing (APC)

3 minute read time.

In purchasing, there can be myriads of component costs, and sometimes it may be desirable to post some or all these individually. 

Below is a cost structure with 12 costs. There is no accounting code attached to a cost structure to post these component costs individually. 

These costs are "consolidated" in receipt posting and not posted individually. At receipt level, the cost tab looks as below, where the figure of 14187.85 are all the component costs from the cost structure.

The cost structure detail shows the component costs.

The journal entry for the receipt is posted as below when the stock accounting interface is run.

I will show how to get the component costs posted individually  with an example involving just two components for simplicity and clarity, as below.

We consider two costs, Freight and Insurance that have to be posted to two separate accounts, 801000 and 801001 respectively

Freight

Insurance

The cost structure is set up as below.

The costs component costs

Insurance

Transport

The cost structure is attached to the purchased product as below. The product has a supplier too.

The default  receipt auto-journal, STKRE, posts the purchase cost (cost structure costs) using line 250, where the accounting code is product and index 73 Additional cost accrual.

Accounting code "Product", line 73.

Auto Journal STKRE

We will modify STKRE by making a copy of STKRE into XSTRE, and adding two new lines, 251 and 252 by copying line 250, and disable line 250 by adding a condition 1 = 2.

The two new XSTRE lines, 251 and 252 will post to accounting code index lines, 74 & 75 that we have to add to the product accounting code.

First we need to add new text to the local menu 853 as below. 

These texts are then added to the Product accounting code

We add index line 74 on XSTKE line 251

We need to write a script to read the cost amounts from the cost structure table COSTSTCD

On the Formula tab, Amount line, we enter the expression ar2(func ZCOSTSTRCT.READCOST([F:STJ]VCRNUM, [F:STJ]VCRLIN , "COST021", [F:STJ]VCRNUMREG, [F:STJ]VARVAL, [F:STJ]AMTDEV))

This function call will read the cost "COST021" from the cost structure table COSTSTCD, which is our Transport (Freight) cost.

We compile the following script in the script editor.

Funprog READCOST(DOCNUM, LINNUM, CSTCOD, DOCNUM2, VARVAL, AMTDEV) #This script reads amounts from the cost structure table, COSTSTCD.
Value Char DOCNUM
Value Integer LINNUM
Value Char CSTCOD
Value Char DOCNUM2 
Value Decimal VARVAL 
Value Decimal AMTDEV 
Local Decimal AMOUNT
AMOUNT=0
If clalev ([F:STCD])=0 : Local File COSTSTCD [STCD] Where VCRNUM=DOCNUM and VCRLIN=LINNUM and FCSCOD=CSTCOD: Endif
Read [F:STCD] First
AMOUNT=[F:STCD]FCSAMTSOC
If VARVAL = 0 & DOCNUM2 = ""
AMOUNT = AMTDEV
Endif
If VARVAL = 0 & DOCNUM2 <> ""
RESULT = 0
Endif
Close Local File [STCD]
End AMOUNT

We add index line 75 on XSTKE line 252 Insurance

On the Formula tab, Amount line, we enter the expression ar2(func ZCOSTSTRCT.READCOST([F:STJ]VCRNUM, [F:STJ]VCRLIN , "COST010", [F:STJ]VCRNUMREG, [F:STJ]VARVAL, [F:STJ]AMTDEV))

This function call will read the cost "COST010" from the cost structure table COSTSTCD, which is our Insurance cost.

The customized auto-journal XSTRE is entered in the purchase receipt entry transaction as below.

Finally, creating a Purchase Order, and Purchase receipt for the product with the cost structure, and running the stock accounting interface, will post the two costs in two separate lines.

I trust you find this helpful and can adapt it to your own needs.