Originally posted by: repanzer
Start WTX info;
Assuming you have an input cobol file (file = top level in type tree) of 10 records and your XML output is a file (top level) with X number of XML groups, and each group has a header, X number of transactions, and a detail record;
As I’m hoping you’re aware, any functional map will run for the number of instances of the type you pull with it.
Looking at the attached picture “EachRecordGetsHeader.JPG”, I’m pulling in the record in the functional map f_MAP_XML, saying, run this functional map for each record in my input file. Being the header and detail record are part of the XML Group, we’re saying that each record will get a header, transaction, and a detail. So the map kicks off, it grabs the first record and runs f_MAP_XML for the that record, builds a header, a transaction, a detail record, then it goes back and grabs the second record, builds the header, trans, and detail, then goes back and grabs the third record, and continues until all input record are processed, so each record produces a header, trans, and detail.
Looking at the picture “OneHeaderOnly.jpg” I pull in the file, NOT the record into f_MAP_XML, and being there is only one “file”, we’re saying run f_MAP_XML just once, so no matter how many input records are in that file, only one header and detail record will be produced. So the map kicks off, it grabs the entire file and runs f_MAP_XML. Then while in f_MAP_XML, there is another functional map on the transaction level that grabs each record and builds a transaction. For you final output, you will have 1 header, 10 transactions, and one detail record.
End WTX info;
The second example sounds like what you’re getting, when you want something closer to the first example.
Still, if you have one input and one output card, even if you make the change and pull at the correct level, you’re still going to wind up with one output file. It will have multiple instances of the entire XML message as the vendor requested, but all the messages will be in the same file.
Does your output currently looks like this (multiple dealerrequest, one for each record) ;
<dealerRequestMsg> 1
....
....
</dealerRequestMsg>
<dealerRequestMsg> 2
....
....
</dealerRequestMsg>
<dealerRequestMsg> 3
....
....
</dealerRequestMsg>
Or does it look like this (one dealerRequestMsg, multiple loops in dealerrequestmsg) ;
<dealerRequestMsg> 1
...<messageHeader>
..<source/>
..<transactionId/>
..<messageName/>
...<messageCreationTime/>
...</messageHeader>
...<dealerInfo> 1
......<dealerCode/>
......<dealerDBAName/>
......<dealerAddress>
......<city/>
......<postalCode/>
......<state/>
......<country/>
......<dealerStreetAddress/>
......<primaryAddress/>
......</dealerAddress>
...</dealerInfo> 2
...<dealerInfo>
......<dealerCode/>
......<dealerDBAName/>
......<dealerAddress>
......<city/>
......<postalCode/>
......<state/>
......<country/>
......<dealerStreetAddress/>
......<primaryAddress/>
......</dealerAddress>
...</dealerInfo>
...<dealerInfo>3
......<dealerCode/>
......<dealerDBAName/>
......<dealerAddress>
......<city/>
......<postalCode/>
......<state/>
......<country/>
......<dealerStreetAddress/>
......<primaryAddress/>
......</dealerAddress>
...</dealerInfo>
</dealerRequestMsg>
?????
How to continue will be dependent on that answer.
I know how to fix it my way, but janhess's input may be a better way, a way that I am not familiar with (but am highly interested in).
All in all, deciding what to pull into a functional map in attempts to create the desired output is undoubtedly one of the more challenging aspects of coding in WTX and even the most experienced programmer has to take a moment or two and figure this part of the mapping, prior to coding.
#IBM-Websphere-Transformation-Extender#DataExchange#IBMSterlingTransformationExtender