Program logic

The M3_EXECUTE_GENERATE_STAGING_ENTITY program generates the entity definition XML for each BOI in scope as follows:

  • Logs a new task log record. The program uses task_name format = <program name>:<staging table in current BOI>. For example, M3_EXECUTE_GENERATE_STAGING_ENTITY:ST_M3_IN_CRS610_LstByNumber.
  • Uses <staging table in current BOI> as table name in task log. For example, ST_M3_IN_CRS610_LstByNumber.
  • Generates the entity definition XML for each BOI in scope, using the following logic:
    • Validates the format of the specified STAGING_TABLE value in the XML as follows:
      BOI.sc_indicator BOI.direction Expected staging table name format
      S IMPORT ST_<prefix>_IN_<entity>
      S EXPORT ST_<prefix>_OUT_<entity>
      C IMPORT SUT_<prefix>_IN_<entity>
      C EXPORT SUT_<prefix>_OUT_<entity>
      Note: If the specified STAGING_TABLE value does not match the expected format, an error message is logged, and the execution is stopped.
    • Validates the entity name extracted from the specified STAGING_TABLE value in the XML with the existing entities in SZ_ENTITY as follows:
      Entity exists in SZ_ENTITY? BOI.direction Entity.Switches Expected end status Generate entity XML? Comments
      No N/A N/A Success Yes Create new entity.
      Yes IMPORT Import Staging = On Warning Yes Update matching existing entity.
      Yes EXPORT Export Staging = On Warning Yes Update matching existing entity.
      Yes IMPORT Export Staging = On Error No Mismatch with existing entity.
      Yes EXPORT Import Staging = On Error No Mismatch with existing entity.
      Yes N/A Inbox = On Error No Mismatch with existing entity.
      Yes N/A Core = On Error No Mismatch with existing entity.
      Yes N/A Outbox = On Error No Mismatch with existing entity.
      Yes N/A Planning Config. = On Error No Mismatch with existing entity.
      Note: These are the possible scenarios after completing the validations:
      • If the Expected end status value is Success, the program continues with XML generation.
      • If the Expected end status value is Warning, the program logs a warning message and continues with XML generation.
      • If the Expected end status value is Error, the program logs an error message, and stops execution.
    • Generates the ScvEntity element in the XML as follows:
      • If <current BOI>.DIRECTION is IMPORT:
        Element Value Example
        ScvEntity
        ScvEntity / Name All characters after the last occurrence of _IN_ in <current BOI>.STAGING_TABLE CRS610_LstByNumber or PRODUCT
        ScvEntity / displayName All characters after the last occurrence of _IN_ in <current BOI>.STAGING_TABLE CRS610_LstByNumber or PRODUCT
        ScvEntity / isSystem If <current BOI>.isSystem is True, the isSystem is set to True. Else, set to False.
        ScvEntity / processingStatus Building
        ScvEntity / isEnabled True
        ScvEntity / stagingPrefix If <current BOI>.isSystem = "True, the stagingprefix is all characters between the first occurrence of ST_ and the last occurrence of "_IN_" in <current BOI>.STAGING_TABLE. Else, the stagingprefix is all characters between the first occurrence of SUT_ and the last occurrence of "_IN_" in <current BOI>.STAGING_TABLE M3 or CUSTX
        ScvEntity / isPlanTable False
        ScvEntity / inboxEnabled False
        ScvEntity / coreEnabled False
        ScvEntity / outboxEnabled False
        ScvEntity / stagingEnabled True
        ScvEntity / stagingDirection Import
        ScvEntity / generateFlag True
      • If <current BOI>.DIRECTION is set to Export:
        Element Value Example
        ScvEntity
        ScvEntity / Name All characters after the last occurrence of _OUT_ in <current BOI>.STAGING_TABLE SPS101MI_SndDOP or TRANSFER_PLAN
        ScvEntity / displayName All characters after the last occurrence of _OUT_ in <current BOI>.STAGING_TABLE SPS101MI_SndDOP or TRANSFER_PLAN
        ScvEntity / isSystem If <current BOI>.isSystem is True, the isSystem is set to True. Else, set to False.
        ScvEntity / processingStatus Building
        ScvEntity / isEnabled True
        ScvEntity / stagingPrefix If <current BOI>.isSystem = "True, the stagingprefix is all characters between the first occurrence of ST_ and the last occurrence of "_OUT_" in <current BOI>.STAGING_TABLE. Else, the stagingprefix is all characters between the first occurrence of SUT_ and the last occurrence of "_OUT_" in <current BOI>.STAGING_TABLE M3 or CUSTX
        ScvEntity / isPlanTable True
        ScvEntity / inboxEnabled False
        ScvEntity / coreEnabled False
        ScvEntity / outboxEnabled True
        ScvEntity / stagingEnabled True
        ScvEntity / stagingDirection Export
        ScvEntity / generateFlag True
    • Generates the ScvEntityProperty element in the XML as follows:
      • If <current BOI>.DIRECTION is IMPORT:
        • If the <current BOI>.PROGRAM is EXPORTMI and <current BOI>.TRANSACTION is Select, the program retrieves the table metadata by calling EXPORTMI-LstFields for the current M3 table as specified in <current BOI>.QUERY_VALUE.TABLE. When <current BOI>.QUERY_VALUE.TABLE_FIELDS.TABLE_FIELD is *, includes all columns available in the current M3 table. Else, includes only the explicitly listed columns as specified in <current BOI>.QUERY_VALUE.TABLE_FIELDS.TABLE_FIELD.
        • Else, the program retrieves the API metadata for the current M3 API <current BOI>.PROGRAM-<current BOI>.TRANSACTION.
        For each <OUTPUT FIELD> in M3 API or in M3 table:
        Element Value Example
        ScvEntityProperty
        ScvEntityProperty / scvEntityId All characters after the last occurrence of _IN_ in <current BOI>.STAGING_TABLE CRS610_LstByNumber or PRODUCT
        ScvEntityProperty / name <OUTPUT FIELD> DIVI
        ScvEntityProperty / displayName

        For M3 APIs, the displayName value is not specified.

        For M3 tables, the displayName value is set to M3.FLDS

        ScvEntityProperty / dbDataType Possible values:
        • Text*
        • Decimal*
        • DateTime*
        ScvEntityProperty / nrOfCharacters

        For M3 APIs: If M3.Ftp is A, the nrOfCharacters value is set to M3.Lngth. Else, the value is not specified.

        ScvEntityProperty / displaySequence Counter value starting from 0 for first element and increasing by 1.
      • If <current BOI>.DIRECTION is set to Export:
        • For each <INPUT FIELD> in M3 API <current BOI>.PROGRAM-<current BOI>.TRANSACTION:
          Element Value Example
          ScvEntityProperty
          ScvEntityProperty / scvEntityId All characters after the last occurrence of _OUT_ in <current BOI>.STAGING_TABLE SPS101MI_SndDOP or TRANSFER_PLAN
          ScvEntityProperty / name <INPUT FIELD> CONO
          ScvEntityProperty / dbDataType Possible values:
          • Text*
          • Decimal*
          • DateTime*
          ScvEntityProperty / nrOfCharacters If M3.Ftp is A, the nrOfCharacters value is set to M3.Lngth. Else, the value is not specified.
          ScvEntityProperty / displaySequence Counter value starting from 0 for first element and increasing by 1.
          Note: * uses the following mapping logic for dbDataType:
          • If M3.Ftp is A or M3.FLTY is A, Text is considered.
          • If M3.Ftp is N or M3.FLTY is N, Decimal is considered.
          • If M3.Ftp is D or M3.FLTY is D, DateTime is considered
  • Generates the table registry definition XML for each BOI in scope, where <current BOI>.PROGRAM is EXPORTMI and <current BOI>.TRANSACTION is Select, using the following logic:
    • Generates the ScvTable element in the XML as follows:
      Element Value Example
      ScvTable
      ScvTable / Name <Staging Table Name>
      ScvTable / displayName Primary Key
      ScvTable / isSystem If <current BOI>.isSystem is True, the isSystem value is set to True. Else, set to False.
      ScvTable / isEnabled True
      ScvTable / tableArea If <current BOI>.DIRECTION is IMPORT, the tableArea value is set to M3_Import. Else, set to M3_Export.
      ScvTable / isPlanTable False
  • Generates the PK constraint definition XML for each BOI in scope, where <current BOI>.PROGRAM is EXPORTMI and <current BOI>.TRANSACTION is Select, using the following logic:
    • Retrieves the PK columns for the specified M3 table from the EVS001MI-LstLFFields M3 API, using the FILE=<current BOI>.QUERY_VALUE.TABLE, and INDX=00 parameters.
    • Generates the ScvConstraint element in the XML as follows:
      Element Value Example
      ScvConstraint
      ScvConstraint / Name If <current BOI>.isSystem is True, the Name value is set to BASE_<Staging Table Name>_PK. Else, set to <Staging Table Name>_PK. SUT_M3_IN_PRODUCT_PK, BASE_ST_M3_IN_PRODUCT_PK
      ScvConstraint / displayName Primary Key
      ScvConstraint / isSystem If <current BOI>.isSystem is True, the isSystem value is set to True. Else, set to False.
      ScvConstraint / processingStatus Building
      ScvConstraint / isEnabled True
      ScvConstraint / constraintType PrimaryKey
      ScvConstraint / tableName lt;Staging Table Name>
      ScvConstraint / isParentReferenceFlag False
    • Generates the scvConstraintColumn element in the XML as follows:

      For each PK column in M3 table:

      Element Value Example
      ScvConstraintColumn
      ScvConstraintColumn / scvConstraintId If <current BOI>.isSystem is True, the Name value is set to BASE_<Staging Table Name>_PK. Else, set to <Staging Table Name>_PK. SUT_M3_IN_PRODUCT_PK, BASE_ST_M3_IN_PRODUCT_PK
      ScvConstraintColumn / name EVS001MI-LstLFFields.FLNA MMCONO
      ScvConstraintColumn / columnSequenceNr Order in which EVS001MI-LstLFFields returns PK columns 1
  • Completes the task log record with the actual status, also considering the expected end status after validations.
  • Finalizes the XML to create a valid SCP template XML as follows:
    <?xml version="1.0" encoding="UTF-8"?>
        <Template xmlns:i18n="http://www.infor.com/namespaces/i18n">
        <scvEntities>
            <ScvEntity> 
                // ScvEntity elements generated as above ...
            </ScvEntity>
        </scvEntities>
        <scvEntityProperties>
        <ScvEntityProperty>
                // ScvEntityProperty elements generated as above ...
        </ScvEntityProperty>
        </scvEntityProperties>
    
        If <current BOI>.PROGRAM = "EXPORTMI" and <current BOI>.TRANSACTION = "Select":
        <scvTables>
            <ScvTable>
                // ScvTable elements generated as above ...
            </ScvTable>
        </scvTables>
        <scvConstraints>
            <ScvConstraint>
                // ScvConstraint elements generated as above ...
            </ScvConstraint>
        </scvConstraints>
        <scvConstraintColumns>
            <ScvConstraintColumn>
                // ScvConstraintColumn elements generated as above ...
            </ScvConstraintColumn>
        </scvConstraintColumns>
    </Template>
    
  • Logs the generated final XML as message at the job level.