Program logic

The M3_EXECUTE_EXPORT program determines the sequence in which multiple BOIs in scope are processed as follows:

  • Generates the dependency tree for the BOIs in scope using the references between BOIs.
  • Determines the processing sequence:
    • If the SOURCE_TABLE_GROUP_NAME parameter is specified, the processing_sequence from the table group is used in ascending order, when processing_sequence is defined for all tables in the specified table group. Else, the BOIs in scope are processed using the generated dependency tree.
    • BOIs with no dependency or BOIs that depend only on BOIs that are already processed are considered first.
  • Validates each BOIs in scope:
    • If valid_flag is set to N or NULL, the program validates the BOI and updates valid_flag accordingly.
    • If validation fails, an error message is logged and the execution is stopped.
    • If validation passes or valid_flag is set to Y, the program continues with BOI execution.
  • Determines which BOI definition to use:
    • If sc_indicator is set to S and user_boi_xml is not specified, the definition in boi_xml is considered.
    • If sc_indicator is set to S and user_boi_xml is specified, the definition in user_boi_xml is considered.
    • If sc_indicator is set to C, the definition in user_boi_xml is considered.
  • Marks records in all staging tables, as being exported:
    • If the SOURCE parameter is specified, the program updates only the records where source = <SOURCE>.
    • If the SOURCE parameter is not specified, the program updates all records as follows:
      • status = Started
      • modified_by = M3_EXECUTE_EXPORT:<execution id>
      • modification_time = <Current timestamp in UTC>
  • Executes each <current BOI> in scope as follows:
    • Logs a new task record, using the <program name>:<current BOI> format. For example, M3_EXECUTE_EXPORT:SPS101MI_SndPOP.
    • Retrieves the M3 program-transaction for each record in the staging table that is marked as being exported, using the metadata in <current BOI>. The program uses source table columns as input parameters.
      • If M3 program-transaction type is MI, all values in <INPUT_FIELD> are passed as input parameters to the MI program. The program calls the M3 program-transaction for each combination of input parameters that is defined in <INPUT_FIELD>.
      • If M3 program-transaction type is API, the program passes only values in <INPUT_FIELD> with PARAMETER = Y, as input parameters to the API.
        Note: The program uses <base endpoint>/supplychainplanning as the actual endpoint for the M3 API.
      • The program prepares the payload for the API call, using the values that are defined in <INPUT_FIELD> with PARAMETER = N. If PARAMETER attribute is not available for an <INPUT_FIELD>, the program uses N as the default value. The program calls the M3 API for each combination of input parameters that is defined in <INPUT_FIELD> with PARAMETER = Y and sends all other <INPUT_FIELD> values in the payload.
    • Retries API calls if an M3 program-transaction fails:
      • The program calls the failed API one more time with the same input parameters when all following conditions are True:
        • <RETRY> is specified
        • The error code returned from M3 program-transaction = <RETRY>.<RETRY_ON_ERROR> or the error description returned from M3 program-transaction contains <RETRY>.<RETRY_ON_ERROR>
        • The current retry count is less than or equal to <RETRY>.<RETRY_MAX_NUMBER>
    • Marks records in the staging table as exported, using the actual export status:
      • status = "Exported"
      • modified_by = M3_EXECUTE_EXPORT:<execution id>
      • modification_time = <Current timestamp in UTC>
    • Completes the task log record with the result of the M3 API call.
    • Continues with the next BOI and executes each <current BOI> in scope.
  • Completes the log record in SZ_EXECUTION_LOG with the execution details.