<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Java mapping for dynamic file name in sap pi in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/java-mapping-for-dynamic-file-name-in-sap-pi/qaa-p/12455825#M4665152</link>
    <description>&lt;P&gt;Hi Akash,&lt;/P&gt;&lt;P&gt;While configuring sender communication channel under Processing Mode, specify what is to happen to files that have been processed successfully. &lt;/P&gt;&lt;OL&gt;
&lt;LI&gt;Under Handling of Empty Files, specify how empty files (length 0 bytes) are to be handled there are three options&lt;UL&gt;
&lt;LI&gt;Do Not Create Message
&lt;P&gt;No XI messages are created from empty files.&lt;/P&gt;&lt;P&gt;The files are processed according to the selected processing mode.&lt;/P&gt;&lt;P&gt;For example, if the processing mode is Delete, empty files are deleted in the source directory.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;Process Empty Files
&lt;P&gt;XI messages are created with an empty main payload.&lt;/P&gt;&lt;P&gt;The files are processed according to the selected processing mode.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;Skip Empty Files
&lt;P&gt;No XI messages are created from empty files.&lt;/P&gt;&lt;P&gt;Empty files are skipped and remain in the source directory.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;you need to use "Process Empty files".&lt;/P&gt;&lt;P&gt;Java mapping code seems to be fine.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anupam &lt;/P&gt;</description>
    <pubDate>Sun, 01 Aug 2021 14:55:49 GMT</pubDate>
    <dc:creator>anupam_ghosh2</dc:creator>
    <dc:date>2021-08-01T14:55:49Z</dc:date>
    <item>
      <title>Java mapping for dynamic file name in sap pi</title>
      <link>https://community.sap.com/t5/technology-q-a/java-mapping-for-dynamic-file-name-in-sap-pi/qaq-p/12455824</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
  &lt;P&gt;I have requirement to change the input filename from "ABC_zyxinputfile.txt" to "zyxinputfile.txt" in the output.&lt;BR /&gt;I am using the java mapping for the same -&lt;/P&gt;
  &lt;P&gt;Code - &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;import java.io.InputStream;


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.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;


public class FileToSFTP_DynamicFileName extends AbstractTransformation {
	@Override
	 public void transform(TransformationInput in , TransformationOutput out) throws StreamTransformationException {
	  try {
															
	   DynamicConfiguration dc = in.getDynamicConfiguration(); //getting the instance of Dynamic Configuration to access the adapter specific attributes																
	   DynamicConfigurationKey dckey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName"); //creating a Dynamic Configuration key to get the Input File FileName
	   String inFilename = dc.get(dckey);
	   String outFilename = inFilename.split("_")[1];
	   dc.put(dckey,outFilename);
	  } catch (Exception e) {
	   throw new StreamTransformationException("Error in java mapping:" + e.getMessage()); //any exception occured in mapping execution will be captured here
	  }
	 }
}


&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;However, I am getting the below error in the sender file channel -&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Channel CC_File_Sender: Empty document found - proceed without sending message&lt;/STRONG&gt;&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;ASMA for filename is activated.&lt;/P&gt;
  &lt;P&gt;Please suggest if any code changes are required so resolved this error -&lt;/P&gt;
  &lt;P&gt;Regards,&lt;/P&gt;
  &lt;P&gt;Akash&lt;/P&gt;</description>
      <pubDate>Sun, 01 Aug 2021 12:10:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/java-mapping-for-dynamic-file-name-in-sap-pi/qaq-p/12455824</guid>
      <dc:creator>former_member60331</dc:creator>
      <dc:date>2021-08-01T12:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Java mapping for dynamic file name in sap pi</title>
      <link>https://community.sap.com/t5/technology-q-a/java-mapping-for-dynamic-file-name-in-sap-pi/qaa-p/12455825#M4665152</link>
      <description>&lt;P&gt;Hi Akash,&lt;/P&gt;&lt;P&gt;While configuring sender communication channel under Processing Mode, specify what is to happen to files that have been processed successfully. &lt;/P&gt;&lt;OL&gt;
&lt;LI&gt;Under Handling of Empty Files, specify how empty files (length 0 bytes) are to be handled there are three options&lt;UL&gt;
&lt;LI&gt;Do Not Create Message
&lt;P&gt;No XI messages are created from empty files.&lt;/P&gt;&lt;P&gt;The files are processed according to the selected processing mode.&lt;/P&gt;&lt;P&gt;For example, if the processing mode is Delete, empty files are deleted in the source directory.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;Process Empty Files
&lt;P&gt;XI messages are created with an empty main payload.&lt;/P&gt;&lt;P&gt;The files are processed according to the selected processing mode.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;Skip Empty Files
&lt;P&gt;No XI messages are created from empty files.&lt;/P&gt;&lt;P&gt;Empty files are skipped and remain in the source directory.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;you need to use "Process Empty files".&lt;/P&gt;&lt;P&gt;Java mapping code seems to be fine.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anupam &lt;/P&gt;</description>
      <pubDate>Sun, 01 Aug 2021 14:55:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/java-mapping-for-dynamic-file-name-in-sap-pi/qaa-p/12455825#M4665152</guid>
      <dc:creator>anupam_ghosh2</dc:creator>
      <dc:date>2021-08-01T14:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Java mapping for dynamic file name in sap pi</title>
      <link>https://community.sap.com/t5/technology-q-a/java-mapping-for-dynamic-file-name-in-sap-pi/qaa-p/12455826#M4665153</link>
      <description>&lt;P&gt;You need to copy the input payload to the output payload.&lt;/P&gt;&lt;P&gt;Add this code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;            InputStream inputstream = in.getInputPayload().getInputStream();
            OutputStream outputstream = out.getOutputPayload().getOutputStream();
            byte[] b = new byte[inputstream.available()];
            inputstream.read(b);
            outputstream.write(b);
&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 01 Aug 2021 16:06:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/java-mapping-for-dynamic-file-name-in-sap-pi/qaa-p/12455826#M4665153</guid>
      <dc:creator>stefan_grube</dc:creator>
      <dc:date>2021-08-01T16:06:17Z</dc:date>
    </item>
  </channel>
</rss>

