cancel
Showing results for 
Search instead for 
Did you mean: 

Map File name to some of the fields in WSDL

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member190293
Active Contributor
0 Kudos

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.

Answers (13)

Answers (13)

former_member190293
Active Contributor

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.

Former Member
0 Kudos

Closing this thread as I opened new thread for warning error.

0 Kudos

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

0 Kudos

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

  • Call method execute of the application Java mapping base64.Base64encode
  • Java mapping base64/Base64encode has thrown a StreamTransformationException.
  • com.sap.aii.mapping.api.StreamTransformationException: java.lang.NullPointerException: while trying to invoke the method java.lang.String.split(java.lang.String) of a null object loaded from local variable 'fileName'
    at base64.Base64encode.execute(Base64encode.java:59)
0 Kudos

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

manoj_khavatkopp
Active Contributor
0 Kudos

This I just a warning you can ignore that .are you getting any error while running that? I have many java mappings with strantransformation in our 7.0 system currently running.

Former Member
0 Kudos

Thank you Evgeniy for your help.

former_member190293
Active Contributor
0 Kudos

Hi Anitha!

String date=srcStr.substring(0, 9);

String time = srcStr.substring(9);

Regards, Evgeniy.

Former Member
0 Kudos

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

Former Member
0 Kudos

Thank you Evgeniy

I am trying this and will let you know the result.

Regards

Anitha

Former Member
0 Kudos

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!!

iaki_vila
Active Contributor
0 Kudos

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/

https://wiki.scn.sap.com/wiki/display/XI/Sample+Code+-+Dynamic+Configuration+in+Java+and+ABAP+Mappin...

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.

0 Kudos

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.

former_member207703
Active Participant
0 Kudos

Hi,

Are you using File Adapter as a sender?

Regards.

Anoop Rai