on 2021 Aug 01 1:10 PM
Hi Experts,
I have requirement to change the input filename from "ABC_zyxinputfile.txt" to "zyxinputfile.txt" in the output.
I am using the java mapping for the same -
Code -
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
}
}
}
However, I am getting the below error in the sender file channel -
Channel CC_File_Sender: Empty document found - proceed without sending message
ASMA for filename is activated.
Please suggest if any code changes are required so resolved this error -
Regards,
Akash
Hi Akash,
While configuring sender communication channel under Processing Mode, specify what is to happen to files that have been processed successfully.
No XI messages are created from empty files.
The files are processed according to the selected processing mode.
For example, if the processing mode is Delete, empty files are deleted in the source directory.
XI messages are created with an empty main payload.
The files are processed according to the selected processing mode.
No XI messages are created from empty files.
Empty files are skipped and remain in the source directory.
you need to use "Process Empty files".
Java mapping code seems to be fine.
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need to copy the input payload to the output payload.
Add this code:
InputStream inputstream = in.getInputPayload().getInputStream();
OutputStream outputstream = out.getOutputPayload().getOutputStream();
byte[] b = new byte[inputstream.available()];
inputstream.read(b);
outputstream.write(b);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
73 | |
10 | |
9 | |
8 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.