Question
· 12 hr ago

Help in Creating Index in DTL based of a variable value

Hello. I need to transform a message

FROM:

MSH|^~\&|
SCH||61490||
PID|1||
RGS|1||1
AIS|1||
AIS|2||
AIS|3||
AIL|1||
AIP|1||

TO:

MSH|^~\&|
SCH||61490||
PID|1||
RGS|1||1
AIS|1||
AIL|1||
AIP|1||
RGS|1||1
AIS|2||
AIL|1||
AIP|1||
RGS|1||1
AIS|3||
AIL|1||
AIP|1||

The RGS, AIS, AIL and AIP are all under the RGS group. The one RGS segment that comes in will be copied across the group. If 3 AIS segments come in then I need 3 RGS groups, if 2 I need 2 RGS groups etc.

In my DTL (screenshot below) I have currently hardcoded the RGS index (1,2,3) but this will not be sufficient incase 4 AIS segments are sent in. I need this index to be variable based off the number of AIS segments that are sent in. 

I have seen posts about using "increment and a while" and I did try that but it didn't work. In the DTL above instead of setting the index to 1, 2, 3 I had set it to "trgs". tais is the count of the AIS sent in. 

Schema:

<?xml version="1.0"?> <Category name="TEST_Schema_2.3.1" 
          description="Orders scheduling." 
          base="2.3.1">     <MessageType name="SIU_S12" structure="SIU_ALL" returntype="base:ACK_S12"/>
    <MessageType name="SIU_S13" structure="SIU_ALL" returntype="base:ACK_S13"/>
    <MessageType name="SIU_S14" structure="SIU_ALL" returntype="base:ACK_S14"/>
    <MessageType name="SIU_S15" structure="SIU_ALL" returntype="base:ACK_S15"/>     <MessageStructure name="SIU_ALL" 
          definition="base:MSH~base:SCH~base:PID~{~base:RGS~base:AIS~base:AIL~base:AIP~}" 
          description="Custom structure with repeating RGS group"/>
</Category>

 

Any leads please?

Product version: IRIS 2021.1
Discussion (4)2
Log in or sign up to continue

A foreach (possibly multiple foreaches) is what you need. Getting the iterators right is the issue. You're iterating over the AISgrp in the first RGSgrp of the source message and placing them in target RGSGroups with the same iteration count of the source AISgrp. Here's an example based on the 2.3.1:SIU_S12 schema structure that should do what you want, and also handles repetitions of the AIL, AIP and AIG groups: