cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the Extension of a file

former_member202642
Participant
0 Kudos

Hi All,

We have a requirement where we have to change the file extension after PGP encryption.

We will not be having only ID objects, as this is a pass-through case.

Ex: If we have a file namely "ABC.txt" at source then PI should pick this file, apply encryption using module tab in Communication

      channel and then change the extension of file i.e. at target folder it should be like "ABC.pgp".

Please help

P.S. Here file name is random.


Regards,

Aamir

Accepted Solutions (0)

Answers (5)

Answers (5)

cacely
Discoverer
0 Kudos

hi aamir khan

I have the same problem of generating a file with ext pgp after encryption from PI, how did you solve it?

RaghuVamseedhar
Active Contributor
0 Kudos

Aamir,

Please follow these blogs

Dynamic file name for pass-through scenario


package javaapplication1;

import com.sap.aii.mapping.api.*;

import java.io.*;

public class DynamicFileName_JavaMap {

    public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {

        try {

            InputStream inputstream = transformationInput.getInputPayload().getInputStream();

            OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();

            // a) Set Output File name

            DynamicConfiguration conf = (DynamicConfiguration) transformationInput.getInputHeader().getAll().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

            DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");

            String FileName = conf.get(key);

            FileName = FileName.replace(".txt", ".pgp");

            conf.put(key, FileName);

            // b) Just copy Input file content to Output file content

            byte[] b = new byte[inputstream.available()];

            inputstream.read(b);

            outputstream.write(b);

        } catch (Exception exception) {

            throw new StreamTransformationException(exception.toString());

        }

    }

}

iaki_vila
Active Contributor
0 Kudos

Hi Aamir,

You can try with an OS command, check also this thread: Need Help on Dynamic File Name | SCN


I already tried with DynamicConfigurationBean but this doesn't work for me

Could you share the exception and your configuration?, we  will can help you better.

Regards.

pvishnuvardan_reddy
Active Contributor
0 Kudos
former_member202642
Participant
0 Kudos

Hi Vishnu,

I already tried with DynamicConfigurationBean but this doesn't work for me.

Thanks..Aamir

former_member186851
Active Contributor
0 Kudos
former_member202642
Participant
0 Kudos

Hi Raghu,

I am getting below error while using DynamicAttributeChangeBean:

Transmitting the message to endpoint <local> using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.engine.services.jndi.persistent.exceptions720.NameNotFoundException: Object not found in lookup of DynamicAttributeChangeBean.

Thanks..Aamir

former_member186851
Active Contributor
0 Kudos

Hello Aamir,

Namespace is wrong.

Change to http://sap.com/xi/XI/System/file

former_member186851
Active Contributor
0 Kudos

Aamir,

change the namespace to http://sap.com/xi/XI/System/File

engswee
Active Contributor
0 Kudos

Aamir

DynamicAttributeChangeBean is a custom adapter module so you need to deploy it into your system before you can use it.

Check out the Source Code section of the article on how to deploy it. If your system is on PI 7.31 SP13 or above, you can directly download the EAR file to deploy.

Rgds

Eng Swee