cancel
Showing results for 
Search instead for 
Did you mean: 

Interface FTP to FTP without integration repository - Edit Destination File

Former Member
0 Kudos

Hello guys,

I created interface FTP to FTP without  integration repository, the interface is ok but now, I need know if is possible to create the file of destination like this:

Input File:

GYLABRS_RH_ADPxGY_OUT_PYRB0653_20130205_203046_001.txt

output file:

PYRB0653_20130205_203046_001.dat

It´s possible? If yes, how can I do that?

Thanks a lot.

Felipe

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
Former Member
0 Kudos

Hello Amit Srivastava,

I´m try to develop this solution

http://wiki.scn.sap.com/wiki/display/XI/Dynamic+file+name+for+pass-through+scenario?original_fqdn=wi...

But I not understand in javamapping where this code, get the input name?!

Java Mapping

  // a) Set Output File name   mapParameters.put(DynamicConfigurationKey.create("http://sap.com/xi/XI/Dynamic",                                                         StreamTransformationConstants.DYNAMIC_CONFIGURATION), "");   DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);   DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");


Regards

Felipe

Former Member
0 Kudos

Hello,

Below code will get the input name

mapParameters.put(DynamicConfigurationKey.create("http://sap.com/xi/XI/Dynamic",

                    StreamTransformationConstants.DYNAMIC_CONFIGURATION), "");

            DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

                   

            //Getting Source FileName

               getFileName = conf.get(key);

   //and for setting new filename use below statement

conf.put(key,newtFileName);

Thanks

Amit Sriivastava

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Guys,

The problem got solved!

Thanks All for help me!

Regards,

Felipe Martin

Former Member
0 Kudos

Hi Guys,

I did this java mapping like this post

http://wiki.scn.sap.com/wiki/display/XI/Dynamic+file+name+for+pass-through+scenario?original_fqdn=wi...

I followed all steps, but now the sxi_moni returned this error.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <!--  Request Message Mapping
  -->
- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
  <SAP:Category>Application</SAP:Category>
  <SAP:Code area="MAPPING">LINKAGE_ERROR</SAP:Code>
  <SAP:P1>DynamicFileName_JavaMapping</SAP:P1>
  <SAP:P2>java.lang.NoClassDefFoundError: DynamicFileName_Ja</SAP:P2>
  <SAP:P3>vaMapping (wrong name: com/javaMapping/DynamicFile</SAP:P3>
  <SAP:P4>Name_JavaMapping)</SAP:P4>
  <SAP:AdditionalText />
  <SAP:Stack>Linkage error while loading class DynamicFileName_JavaMapping; java.lang.NoClassDefFoundError: DynamicFileName_JavaMapping (wrong name: com/javaMapping/DynamicFileName_JavaMapping)</SAP:Stack>
  <SAP:Retry>M</SAP:Retry>
  </SAP:Error>


Please suggest??

attached java mapping and imported File in PI

.

package com.javaMapping;

import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;

import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.DynamicConfiguration;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;

public class DynamicFileName_JavaMapping extends AbstractTransformation
{
public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput)
                                                                        throws StreamTransformationException
{
  try
  {
   InputStream inputstream = transformationInput.getInputPayload().getInputStream();
   OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();

   Map mapParameters = (Map) transformationInput.getInputHeader().getAll();

   // a) Set Output File name
   mapParameters.put(DynamicConfigurationKey.create("http://sap.com/xi/XI/Dynamic",
                                                         StreamTransformationConstants.DYNAMIC_CONFIGURATION), "");
   DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
   DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");

   //Depending on your requirement edit this logic. Here, NewDynamicName + CurrentDate will be output file name.

   String filename_in = conf.get(key);  
  
   filename_in = filename_in.substring(filename_in.indexOf("PYRB0653")).replaceAll(".txt", ".dat");
  
  conf.put(key, filename_in);

   // 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)
  {
   getTrace().addDebugMessage(exception.getMessage());
   throw new StreamTransformationException(exception.toString());
  }
}
}

Former Member
0 Kudos

Hello,

Which version of PI u r using?

I think u r not importing archives files properly?

Open ur exported project zip file -> unzip it -> then search and open "bin" folder -> once u do that u will find a folder name with "com" inside it-> zip that folder and import the same in PI and then test ur JM

Thanks

Amit Srivastava

former_member192343
Active Contributor
0 Kudos

one more way is to set OS command in receiver communication channel that will rename your file.

monikandan_p
Active Participant
0 Kudos

Hi Felipe,

Kindly use this udf for dynamic file name.

public class DynamicFileName_JavaMapping extends AbstractTransformation

{

public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput)

                                                                        throws StreamTransformationException

{

  try

  {

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

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

   Map mapParameters = (Map) transformationInput.getInputHeader().getAll();

   // a) Set Output File name

   mapParameters.put(DynamicConfigurationKey.create("http://sap.com/xi/XI/Dynamic",

                                                         StreamTransformationConstants.DYNAMIC_CONFIGURATION), "");

   DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

   //Depending on your requirement edit this logic. Here, NewDynamicName + CurrentDate will be output file name.

   DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");

   conf.put(key, ("NewDynamicName_" + dateFormat.format(new Date())) + ".pdf");

   // 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)

  {

   getTrace().addDebugMessage(exception.getMessage());

   throw new StreamTransformationException(exception.toString());

  }

}

}

Best Regards,

Monikandan

Harish
Active Contributor
0 Kudos

Hi Felip,

you can create a filename without dynamic configuration and without ESR using the variable substitution, but you need to define the file name format.

Please cehck the variable substitution section in below link.

Dynamic file name and directory in Receiver File Adapter - summary of possibilities - Process Integr...

But if you want to use modified source file name then you need to implement that in ESR or adapter mudule.

Regards,

Harish