IBM Support

How to map to a repeating SDQ segment with 10 element pairs in each.

Question & Answer


Question

The objective is to map a repeating XML element, StoreInfo, which contains StoreNum and StoreQty, to element pairs of the SDQ EDI segment. There are 10 pairs of Identification code (element 67) and Quantity (element 380) allowed per SDQ segment. But, these (10) pairs are not a repeating construct to the WDI Client mapping tool. Hence, the mapping tool does not accommodate a simple loop-to-loop style mapping, such as what ForEach is designed to do. In which case, each ForEach iteration creates a new SDQ segment, hence you get a one-for-one relationship between StoreInfo and SDQ segment. Furthermore, the objective includes the creation of a new, 2nd SDQ segment after the 1st SDQ's 10 element pairs are filled, and so on.

Answer

One suggestion is to modify your existing Target-based map. Assignment statements are used to populate the EDI side SDQ instead of via MapFrom commands. Note in the example below that the ForEach command has been moved to the FOB segment. We chose this because a ForEach tied to the actual SDQ affects its creation. Hence, we chose the FOB, which is at the same loop level as the SDQ, and it is currently not being used, i.e. the ForEach is put on an unused (unpopulated) repeating segment. Also, note how the local variable, StoreInfoCount, is used to keep track of the StoreInfo iteration, then inspected to see which SDQ pair it should be output to, then reset to 0 after filling the 10th pair. This is done so as to start a new SDQ (first pair) upon the 11th StoreInfo iteration, and so on. The Create() and CloseOccurrence() commands are being used here to control the beginning and end (when to output) the SDQ.

For example:





An alternative would be to use a Source-based style map instead of Target-based. However, since your map is currently defined as target.-based, this approach would require remapping of the entire map, i.e. there is no way to copy a target-based map to a source-based map or vice versa. Assignment statements are used to populate the EDI side instead of MapFrom commands. Note in the example below, how the local variable, StoreInfoCount, is used to keep track of the StoreInfo iteration, then inspected to see which SDQ pair it should be output to, then reset to 0 after filling the 10th pair. This is done so as to start a new SDQ (first pair) upon the 11th StoreInfo iteration, and so on. The Create() and CloseOccurrence() commands are being used here to control the beginning and end (when to output) the SDQ. This is in lieu of the (target-based) ForEach command.

For example:




[{"Product":{"code":"SSFKTZ","label":"WebSphere Data Interchange"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"WDI 3.3 MP","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF033","label":"Windows"},{"code":"PF035","label":"z\/OS"}],"Version":"3.3","Edition":"All Editions","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Document Information

Modified date:
01 August 2018

UID

swg21978932