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
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 |
---|---|
68 | |
8 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.