Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member182412
Active Contributor

Introduction

As we all know if we use multi mapping we cannot set dynamic file name and folder with dynamic configuration because same header is shared by all the messages,Recently there are many threads asking about this requirement, If the fields used in variable substitution are part of the target payload then dynamic file name or folder is not a problem, only those fields are not part of the target payload then we cannot use variable substitution for dynamic file name and folder but in this blog i will show you how to achieve this using variable substitution.

Approach

We will add separate node under target structure to hold the fields which are used in variable substitution and these fields are not part of the target file, we will use below content conversion parameters for this node and then file adapter will ignore this record at runtime.

Scenario

The scenario is we get one message with multiple orders and we need to generate multiple files at the target side with each file containing single order. We need to create dynamic folders based on plant field in the source message, we need to create dynamic file name with IDoc number.


Design

The below are sender and receiver data types used in this scenario, for simplicity i have created the own data type for IDoc, i have added separate node called 'File' under target structure, FileName(this field used in dynamic file name) and plant(this field used in dynamic folder) are fields under this node, these fields will be used in variable substitution in the receiver file channel in the directory.

As we are creating multiple files from single IDoc we need to change the occurrence of receiver message to unbounded under signature part of the mapping.

The below is mapping between source message and target message, all fields are simple field to field mapping, we will receive multiple IDOC nodes in source message and i am creating multiple StockOrder nodes in target side. DOCNUM (Idoc number) and WERKS i am not passing to the target file, we need these fields to set dynamic file name and folder so we need to map these two fields under File node in the target structure.

The below is FileName field mapping, IDoc number concatenate with '.txt' extension.

Configuration

The below is receive file communication channel configuration, target directory and target file name with variables created under variable substitution section.

The below is content conversion for receiver file, As we don't need to send the fields under File node to the target file we need to use below parameters to ignore these fields in the target file.

The below is 'fname' and 'plant' variables which we used in target directory and file name.

Testing Results

The below is input payload, there are two IDocs with same plant(3204), so at the end we expect two dynamic folders.

The below are four messages in message monitor, one for sender to messaging system, three message for messaging system to receiver(as per our multi mapping one file split into three messages)

We can see IDoc number and the plant number are mapped under File node in the target payload.

We can see in the audit log the variables plant and IDoc number are replaced at runtime.

As we expect the two folders created under target directory.

We can find two files under 3204 directory (source file contains two IDocs with same plant 3204)

The below one of the file content, We can see the IDoc number and plant values are not part of the file, only it contains header and item of the order.

And one file under 3205 folder.

References

A new approach: Multi-mapping Dynamic Configuration using a generic custom module

Multi-mapping with Dynamic Configuration - SOAP loopback approach

Conclusion

With this approach we can still achieve dynamic file name and folder even we use multi mapping, i hope this will be helpful.

8 Comments
Labels in this area