Generic Logic

Create a generic feeder logic that emits the Quote objects for use in the Analytics logic:

def quotesRecieved = true
int i = 0
int step = 200
def qs = []
def quotes = []
while (quotesRecieved) {
  // lastRunTime - last run time of the Data Load. For the first run, it should be an old date which includes all the quotes.
  qs = api.find("Q", i, step, null,
                Filter.greaterOrEqual("lastUpdateDate", lastRunTime))
  if (qs.size() != 0) {
    quotes += qs
    i += step
  } else {
    quotesRecieved = false
  }
}

for (q in quotes) {
  if (q?.id != null) api.emitPersistedObject("Q", q.id)
}

Analytics Logic

Retrieve the target rowset from the Datamart:

def targetRs = api.getDatamartRowSet("target")

Fetch the Quote from the feeder logic:

def targetRs = api.getDatamartRowSet("target")

Fetch header inputs/output values from the Quote:

def clic = api.getCalculableLineItemCollection(quote?.typedId)
for (input in clic?.inputs) {
  if (input.name == "OpportunityType") {
    opptyType = input.value
    continue
  }    
}

for (output in clic?.outputs) {
  if (output.resultName == "Country") {
    country = output.result
    continue
  } 
}

Fetch line-level inputs/output values from the Quote (you can use api.getCalculableLineItemResult to fetch line-level outputs):

for (li in clic.lineItems) {
  def lineId = li.lineId 
  def cli = api.getCalculableLineItem(clic.typedId, lineId)
	for (input in cli?.inputs) {
      if (input.name == "Apply Quantity Break Pricing Structure") {
        applyQtyBreak = input.value
        continue
      }
  }
  def tierDiscount = api.getCalculableLineItemResult(cli, "TierDiscount")
}

Create a map object mapping values to Datamart fields. (Map keys MUST match the Datamart field names). Add the row to the target rowset:

def row = [:]
row.Quote = quote.uniqueName
row.CustomerNumber = customerNum
row.CustomerName = customerName
row.NationalAccount = nationalAcct

targetRs?.addRow(row)

Create global variables for all field values:

row?.each {
    api.global[it.key] = it.value
}

Create logic elements for each Datamart field. Return the global variables in each logic element with the Display Mode "Everywhere", so they can be accessed in the Data Load.

Data Load

If the target is a Datamart, create a calculation data load for Datamart that runs incrementally and assign the appropriate Analytics and generic logics as the Formula and Feeder logics respectively. If the target is a Data Source, update the existing 'Flush' type Data Load for the Data Source by configuring the Formula and Feeder logics in the Calculation section.