Cleanup

The TFORM_MAP_ROUTING_VERSION program deletes the transformation results for each table in scope from the previous execution as follows:

  1. Logs new task log record for the current table using the task_name format:
     TFORM_MAP_ROUTING_VERSION -CLEANUP ROUTING_LOCATION_ID=<routing_location_id> SOURCE=<current_source> 
    Note: If the values of routing_location_id and current_source are not specified, all records are deleted.
  2. Determines the <current transformation id> corresponding to the TFORM_MAP_ROUTING_VERSION program or transformation.
  3. Identifies the routings created by the previous execution:
    SELECT routing_id       
        FROM   SC_ROUTING 
        WHERE   created_by = "TFORM_MAP_ROUTING_VERSION" 
            AND routing_location_id = <routing_location_id>  
            AND source              = <current_source>
            AND <item filter>, if exists
            AND <location filter>, if exists
    
  4. Deletes the routing details from the tables in scope (except SC_ROUTING) for each routing identified in the step 3:
    DELETE FROM <table>
        WHERE  routing_id IN (<routing_id from step 3>)
    
  5. Updates the production order tables for each routing identified in step 3 to delete the references to the transformed routings:
    UPDATE <table>
        SET   <table>.scheduling_routing_id = NULL
        WHERE <table>.scheduling_routing_id IN (<routing_id from step 3>)
    
  6. Updates the routing header table for each routing identified in step 3 to delete the references from the original routings to the transformed routings:
    UPDATE SC_ROUTING
        SET    scheduling_routing_id = NULL
        WHERE  scheduling_routing_id IN (<routing_id from step 3>)
    
  7. Deletes all the transformed routings in the routing header table:
    DELETE FROM SC_ROUTING
        WHERE   created_by = "TFORM_MAP_ROUTING_VERSION" 
            AND routing_location_id = <routing_location_id>)  
            AND source              = <current_source>
            AND <item filter>, if exists
            AND <location filter>, if exists
    
  8. Commits changes if the records are successfully deleted or cleared.
  9. Logs an error message and does not continue with the processing if an error occurs.
  10. Completes the task log record with the actual status.