Generate

The TFORM_GENERATE_VALID_COMBINATIONS program generates valid item-location-customer combinations from the selected SCV Core tables, in the ascending processing order as follows:
  1. Selects the <current table> from selected SCV Core tables.
  2. Verifies if the <current table> contains all dimensions (item-location-customer).
    Note: 
    • If all dimensions are available, continue with the next step.
    • If the location dimension is missing, generate a Cartesian product of records with the SC_LOCATION table, using only the Warehouses (type=Warehouse).
    • If the customer dimension is missing, generate a Cartesian product of records with the SC_CUSTOMER table.

    This table lists the SCV Core tables and the column to use for the Cartesian product:

    SCV Core table Cartesian product to table Column(s) to use for Cartesian product Effective start date column Spreading factor column
    SC_ITEM_AVAILABILITY SC_CUSTOMER

    item_id

    location_id

    customer_id

    start_date 1
    SC_ITEM_CUSTOMER

    SC_LOCATION

    (type=Warehouse)

    item_id

    location_id

    customer_id

    effective_from_date spreading_factor
    SC_ITEM_LOCATION SC_CUSTOMER

    item_id

    location_id

    customer_id

    SCP_DEFAULT_START_DATE 1
    SC_ITEM_NPI

    new_item_id

    location_id

    customer_id

    effective_from_date spreading_factor
    SC_ITEM_SALES

    item_id

    location_id

    customer_id

    SCP_DEFAULT_START_DATE spreading_factor
    SC_ITEM_SUPERSESSION

    new_item_id

    new_location_id

    new_customer_id

    effective_from_date history_transfer_factor
    SC_SALES_HIST_AGGR

    item_id

    shipfrom_location_id

    customer_id

    SCP_DEFAULT_START_DATE 1
    SC_SALES_HIST_TRX

    item_id

    shipfrom_location_id

    customer_id

    SCP_DEFAULT_START_DATE 1
  3. Processes the newly generated records in the list, after the required Cartesian products are applied:
    • If the item-location-customer combination generated from the <current table> already exists in SC_VALID_COMBINATIONS:
      • The data generated is ignored, if the existing item-location-customer combination in SC_VALID_COMBINATIONS is imported through Inbox. The priority is provided to imported data when compared to generated data.
      • All existing records in SC_VALID_COMBINATIONS for the item-location-customer combination are replaced with the data generated, if the existing item-location-customer combination in SC_VALID_COMBINATIONS is generated.
        Note: This process replaces all existing records with new data that match item-location-customer combinations.
    • If the item-location-customer combination generated from the <current table> does not exist in SC_VALID_COMBINATIONS, the generated data is inserted in SC_VALID_COMBINATIONS.
    • If the <current table> contains multiple records for an item-location-customer combination (for example, open sales orders), all records are combined. Therefore, the common values (such as source and ae_id) are retrieved as the maximum value of the group.
    • The generated data is saved in SC_VALID_COMBINATIONS as follows:
      item_id = From the input SCV Core table     
          location_id = If exists then from the input SCV Core table, otherwise from Cartesian product to SC_LOCATION (type=Warehouse)    
          customer_id = If exists then from the input SCV Core table, otherwise from Cartesian product to SC_CUSTOMER     
          effective_start_date = If exists and not-null then from the input SCV Core table, otherwise from the SCV configuration parameter SCP_DEFAULT_START_DATE  
          effective_end_date = If exists and not-null then from the input SCV Core table  
          spreading_factor = If exists and not-null then from the input SCV Core table, otherwise "1"  
          valid_combination_source = "Generated"  
          status = "Open"  
          source = From the input SCV Core table where location_id value is retrieved from: 
              If the input table already contains the location, then use the source value from the table itself. Examples: sales orders or item-location. 
              If the input table does not contain the location (in other words cartesian product is applied to locations)m then use the source value from the location table. Example: item-customer.  
          ae_id = From the input SCV Core table  
          created_by = "TFORM_GENERATE_VALID_COMBINATIONS:" + <current execution id>  
          creation_time = <current timestamp in UTC>
          modified_by = "TFORM_GENERATE_VALID_COMBINATIONS:" + <current execution id>  
          modification_time = <current timestamp in UTC>
      
      Note: The data processing logic can be implemented in the following ways:
      • Process one table at a time. When processing the current table, delete all existing records with matching item-location-customer combinations generated from the previous table, and insert the newly generated records from the current table.
      • Process all tables at the same time. The program sorts generated records based on the rank of the selected tables in the SCV Valid Combination definition. Insert only the records from the table with the highest rank. Currently, the implementation uses this process.
  4. Logs an error message and processing is stopped, if an error occurs.
  5. Commits the changes if all selected tables are processed successfully.
  6. Completes the task log record with the actual status.