Showing results for 
Search instead for 
Did you mean: 

Cross Applications - Logic

0 Kudos

Hi All!

I am trying to use a script for calculate a new record with the cost of goods (quantity * unit cost). I am using two applications: sales and prices_costs with the following dimensions:

- Sales (category,customer,entity,family,rptcurrency,salesaccount,salesorg,subfamily1,time)

- Prices_Costs (category,customer,entity,family,salesaccount,time)

Here it is my script logic (located in the default.LGF of sales application):













But this is not working...

Any help is appreciated!

Regards, Fred

View Entire Topic
Former Member
0 Kudos

Hi Frederico,

Your lookup syntax is not quite right, and you may need to define your main or source data region, which must come from the application in which this logic is the default logic -- your sales app.

For the lookup, you only need to define a label (to the left of the colon) for those *DIM entries that are being referenced later on in a LOOKUP() inside the *REC. It's a little hard to explain, and you actually can use the same label for multiple *DIM lines. The example below should work.


// don't you want to get the unit cost (not cogs amount) from the prices_costs app?


// skip dim doesn't work in a lookup, only in a *destination_app
// it's not required here, although you may want or need to fix an *XDIM_MEMBER SalesOrg=MySalesOrg ??

// to multiply quantity * unit cost, you start with the quantity account from the main sales app
*IS "quantity"

// the following will work equally well, and takes a few less seconds to type... =)
// *REC(Factor=Lookup(MyLabel))



Note that this code won't recalculate things in the sales app on the fly, if you change the unit cost in the prices_costs app. There are ways to do that, using *RUNLOGIC in the prices_costs default logic to call the sales app's default logic, but don't get involved in that complexity if you can avoid it.

Also note that you can only have 1 lookup in a commit section, so this limits your flexibility in case you have a really complex cogs situation (or lots of other things to do in your default logic, and you want to limit the number of commits). One way around that is to bring the unit cogs account into the main sales app, which may have both benefits and costs (pardon the pun) in terms of overall design. If all the data is in one app, you can get fancy with your XDIM_MEMBERSET to get the unit cost account into the source region, and then use a GET() rather than a LOOKUP() in your *REC statement, to use it in the calc.

Performance-wise, you might also consider limiting the account dim to exactly what you need, if this is the only logic in the *COMMIT block.

*XDIM_MEMBER SalesAccount =quantity

// lookup code goes here

*IS *