on 01-18-2017 7:23 PM
Hi All
I need your help on below requirement.
PI version: 7.0
PI to pick pdf file from AL11 and convert to base64 then send to third party using SOAP adapter.
This is achieved successfully through Java mapping.
Now additional requirement is to pass dynamic file name to some of the fields in WSDL.
For example:
File name is 200345666742_67834_1287945090523567_20170117153350.PDF in AL11
Expected Output:
200345666742 - Invoice number
67834 - Merchant ID
1287945090523567 - Card num
20170117 - Date
153350 - Time
Thanks in advance!! Please let me know if you need more information.
Hi Anitha!
You say that you use java mapping. So why can't you read Dynamic Configuration parameter in your mapping and put results to corresponding payload elements?
String[] lineParts = line.split("_");
After that you'll get all of your desired fields, only date/time part should be additionaly splitted with substring() method, for example.
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
Did you set parameters in your sender channel to store file name to Dynamic configuration?
Error message says that your fileName variable is null. It means, that you didn't get its value from Dynamic configuration.
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Closing this thread as I opened new thread for warning error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please correct me if anything wrong in this JAVA code: Part of code is pasted here:
package base64;
import java.io.InputStream;
import java.io.OutputStream;
import com.sap.aii.mapping.api.DynamicConfiguration;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;
import org.xml.sax.helpers.DefaultHandler;
import sun.misc.BASE64Encoder;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
public class Base64encode extends DefaultHandler implements
StreamTransformation {
StringBuffer sbfXml = null;
String MSG_TYPE = "ServiceSysDocuploadV2_0";
String NAME_SPACE = "http://servicegate.infolock.com/ns/sv/v2.0/docupload/soap";
public void setParameter(Map map) {
param = map;
if(param == null)
param = new HashMap();
}
public void execute(InputStream inputstream, OutputStream outputstream) throws StreamTransformationException {
try {
byte[] b = new byte[inputstream.available()];
inputstream.read(b);
BASE64Encoder encoder = new BASE64Encoder();
String strB64Res = encoder.encode(b);
DynamicConfiguration dynamicconfiguration = (DynamicConfiguration)param.get("DynamicConfiguration");
DynamicConfigurationKey dynamicconfigurationkey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
String fileName = dynamicconfiguration.get(dynamicconfigurationkey);
String arr[] = fileName.split("_"); //it will split the string into multiple token
String InvoiceNumber = arr[0]; //it will take the first token
String MerchantNumber = arr[1]; // second token
String CardNumber = arr[2];
//String date = arr[3];
Date yourDate = new Date();
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("YYYY-MM-DDTHH:MI:SS");
String date = DATE_FORMAT.format(yourDate);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Manoj for responding back!
Yes I can see error when I execute the scenario.In interface mapping aswell as in SXMB_MONI.
In MONI:
Java mapping base64/Base64encode has thrown a StreamTransformationException.
In Interface mapping:
Start of test
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Evgeniy
I am using JDK 1.4 as my PI version is 7.0.
I see one warning in my JAVA mapping "The type StreamTransformation is deprecated"
But as per this link we can still use StreamTransformation. Please help me ..... This is blocking me to test the scenario.
http://help.sap.com/javadocs/pi/sp3/xpi/com/sap/aii/mapping/api/StreamTransformation.html
Regards
Anitha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Evgeniy for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anitha!
String date=srcStr.substring(0, 9);
String time = srcStr.substring(9);
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Evgeniy
The code you specified works perfectly.Thank you!!
Can you please help me for splitting date and time(20170117153350)using substring() method.
Thanks
Anitha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Evgeniy
I am trying this and will let you know the result.
Regards
Anitha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All
1.Yes I am using File adapter as sender and receiver as SOAP.
2.Using Java mapping to convert entire PDF file to Base64 and pass to one of the field of wsdl.
3.In wsdl I have other fields where we need to pass values from File name
4.No message mapping used to create UDF
5.With Dynamic configuration I can call file name in Java mapping but my problem is how to split the values in file name and send to fields?
Please help me out!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anitha,
If i understand rigth your problem, this is that you need to read the filename and later to use it in some filed of you output XML. These links can help you to read the filename:
https://blogs.sap.com/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter-sp14/
Later you can use the variable with the filename to set it in your output XML.
If I am wrong and you can edit the base64 PDF, i think the solution will be more complicated.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you can achieve this requirement by UDF
you can capture file name using adapter specific attribute in udf and return file name as output of the UDF. Then you can use sub-string standard function and other standard functions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Are you using File Adapter as a sender?
Regards.
Anoop Rai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
9 | |
9 | |
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.