cancel
Showing results for 
Search instead for 
Did you mean: 

changing file name in custom adapter module and resend with diff file name

former_member329434
Participant
0 Kudos

Dear All,

We have a requirement from one of our client, where we need to receive file name inside custom adapter module and based on that input file name ,we need to send equalent value mapping file name for that. As we recieve multiple file formats ,hence we have ignored ESR part development, ( created a dummy interface , PI only used as transfer mechanism)

Logic should be inside receiver file adapter to read file name and based on input file name , output file name has to be changed( value mapping, eg: abc-1234.txt has to change as xyz-1234.txt.. like wise) and generate in the output.

Please guide how to acheive this requirement.

Thanks in Advance.

Suman

Accepted Solutions (0)

Answers (4)

Answers (4)

0 Kudos

Hi Suman,

Did you succeed changing filename/directory within adapter module?

I have the same requirement from one of our client.

I tried to use the code: msg.setMessageProperty("http://sap.com/xi/XI/System/File","FileName", fileName);

but nothing append.

Regards,

Gigi

Former Member
0 Kudos

Hi Suman,

in my scenarion, i get 2 files from two locations (single Comm Channel). I capture the file name dynamically (dynamic file configuration) as i am getting 2 files and then then use UDF and simple mapping to pass on different constants based on the file name.

Mine is PI 7.0 so in PI7.1 if this can also be achieved, it would be good. check out if this logic would work.

kanan

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>> Logic should be inside receiver file adapter to read file name and based on input file name , output file name has to be changed( value mapping, eg: abc-1234.txt has to change as xyz-1234.txt.. like wise) and generate in the output.

Since you dont do ESR objects and mapping, Please follow Stefan's link... might be very helpful..

/people/stefan.grube/blog/2009/06/19/unknown-use-case-of-dynamicconfigurationbean-store-file-name-to-jms-header-without-mapping

Former Member
0 Kudos

Hi Suman,

Check the below Adapter module code:

public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)
                      throws ModuleException{
     try {
        Message msg = (Message) inputModuleData.getPrincipalData();
        Payload payload = msg.getDocument();
        String fileName = msg.getMessageProperty("http://sap.com/xi/XI/System/File","FileName");
 
        // do something with the filename ( Define the receiver file name)
 
        msg.setMessageProperty("http://sap.com/xi/XI/System/File","FileName", fileName);
 
        inputModuleData.setPrincipalData(msg);
 
    } catch (Exception e) {
        throw new ModuleException(e);
    }
 
    return inputModuleData;
 }

Hope this helps you..

Thanks,