cancel
Showing results for 
Search instead for 
Did you mean: 

Diverting image input file to different target folder based on input file length - File 2 File

former_member205101
Participant
0 Kudos

Dear Folks,

Sorry to write lengthy message for this issue.

Scenario: File 2 File - No Mapping or Transformation required

Input file: Image file (.png file ie example: 12344.png)

Req: Just take the file from input folder and place into different target folder based on input file length

If file file length is 11 char...place in Target folder A

Else place file in Target folder B

Created one sender channel

, Receiver channel

Issue:

Interface is correctly taking the file and placing into respective folder but real image data is not getting transmitted at all.

It is just creating file in target folder ie target file size 156KB

Input file size is 538383 KB

If I do not use mapping and give fixed path in receiver file channel, then data is getting transmitted.

Any inputs reg. this issue will be appreciated.

Do i need to go with Java mapping for this?

I have another design option using 2 Business service and 2 receiver channel also before that I want to know to trouble shoot this design issue.

Error message

Some time i get below error message in Moni and if i reprocess the message, then it goes sucessfully but image data is not getting properly

<Trace level="2" type="T">Call method execute of the application Java mapping com.sap.xi.tf._MM_I442_ImageMap_</Trace>

<Trace level="1" type="T">RuntimeException during appliction Java mapping com/sap/xi/tf/_MM_I442_ImageMap_</Trace>

<Trace level="1" type="T">com.sap.aii.utilxi.misc.api.BaseRuntimeException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException: XMLParser: No data allowed here: (hex) 89, 50, 4e(:main:, row:1, col:3) at com.sap.aii.mappingtool.tf3.Transformer.checkParserException(Transformer.java:187) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:174) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:120) at com.sap.aii.ibrun.server.mapping.JavaMapping.executeStep(JavaMapping.java:64) at com.sap.aii.ibrun.server.mapping.Mapping.execute(Mapping.java:92) at com.sap.aii.ibrun.server.mapping.MappingHandler.run(MappingHandler.java:90) at

sender file channel settings:

 

Source directory: FTP path

File Name: *.*

Advanced tab: ASMA: Checked ie Adapater sepecific Message attributes

File name, Directory checked

receiver file channel settings:

Target directory: *

File Name scheme: *.*

Advanced tab: ASMA: Checked

File name, Directory checked

Attached Message Mapping screen shot.

Target record node is not mapped to any thing.

Target Top Node MT_*** is mapped to UDF (This is just to divert the input folder and put into diffferent folder)

UDF:

AbstractTrace trace = container.getTrace();

try {
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey dckFile = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
DynamicConfigurationKey dckDirectory = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
String filename = conf.get(dckFile);
String directory = "";
String SystemID = null;
SystemID = System.getProperty("SAPSYSTEMNAME");

if (filename!=null)
{
if(filename.length() == 11)

{

if (SystemID.equals("DEV"))
directory = "\\\\xxxxx\INTERFACE\FOlderA\\";

if (SystemID.equals("QA"))
  directory = "\\\\xxxxx\INTERFACE\FOlderA\\";

/*****Prod URL***/
if (SystemID.equals("PROD"))
  directory = "\\\\xxxxx\INTERFACE\FOlderA\\";
}
else
{
if (SystemID.equals("DEV"))
directory = "\\\\xxxxx\INTERFACE\FOlderB\\";

if (SystemID.equals("QA"))
  directory = "\\\\xxxxx\INTERFACE\FOlderB\\";

/*****Prod URL***/
if (SystemID.equals("PROD"))
  directory = "\\\\xxxxx\INTERFACE\FOlderB\\";
}
}
conf.put(dckDirectory,directory);


}

catch (Exception e) {
trace.addDebugMessage("SET_FILENAME_FAILED");
}

return "";

..........

Thanks in advance for any help.

Regards,

Praba

Accepted Solutions (0)

Answers (2)

Answers (2)

nabendu_sen
Active Contributor
0 Kudos

Hi Praba,

Its better if you ask Basis team to move into JDK1.4, so that you can use 'ImageIO'. Otherwise check the API of "java.awt.image" to achieve this functionality.

former_member205101
Participant
0 Kudos

Dear Folks,

I could not attach message mapping screen shot..It is just 58KB Jpeg file

I get error while uploading the file in scn thread " The content type of this attachment is not allowed."

Any way It just have Data type Name and one element Record

Message Mapping : Target Message Type node (Top node mapped to UDF as i mentioned) and below element not yet all mapped.

Thanks

Praba

iaki_vila
Active Contributor
0 Kudos

I get error while uploading the file in scn thread " The content type of this attachment is not allowed."

You could use a program as PrtScr to make a photo, you will have the picture hoving, and later drag an drop to the forum.

XMLParser: No data allowed here: (hex) 89, 50, 4e(:main:, row:1, col:3) at 

Your exception seems a problem with the XML generated by the sender. Have you checked in the error exception cases that the XML is really generated?

Regards.

former_member205101
Participant
0 Kudos

Dear

Here is general error message (last time mentioned error message from Trace)

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

- <!--

 Request Message Mapping 
-->

- <SAP:Error SOAP:mustUnderstand="" xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">

<SAP:Category>Application</SAP:Category>

<SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>

<SAP:P1>com/sap/xi/tf/_MM_I442_ImageMap_</SAP:P1>

<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>

<SAP:P3>Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:P3>

<SAP:P4 />

<SAP:AdditionalText />

<SAP:ApplicationFaultMessage namespace="" />

<SAP:Stack>com.sap.aii.utilxi.misc.api.BaseRuntimeException thrown during application mapping com/sap/xi/tf/_MM_I442_ImageMap_: Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:Stack>

<SAP:Retry>M</SAP:Retry>

</SAP:Error>

I was expecting full image payload but it just have below one.

<?xml version="1.0" encoding="UTF-8" ?>

<ns0:MT_I442_ImageFeed xmlns:ns0=http://yyyyyy/yyy/xyz/namespace />

Thanks

Praba

former_member205101
Participant
0 Kudos

Hello,

I mean to say that I can not see sender payload as XML in Monit bec it is image file.

If i click to see the sender payload and it gives pop up to save the file.

Once i save it as jpeg or png file, I could see the image file thru browser IE.

The same thing I was expecting as payload in receiver..ie Technical routing. But I could see only above

payload in Moni.

There is no mapping transformation involved in this interface for input file.

Thanks in advance

regards,

Praba

former_member205101
Participant
0 Kudos

Folks,

Any input reg. this?

Thanks in advance.

Thanks

Praba

former_member201264
Active Contributor
0 Kudos

Hi Ranga,

You have to use the  following:

1.MessageTransformBean

2.PayloadSwapbean  and respective parameters in the receiver CC.

Make sure send the data using Sender CC with ASMA and the same in the Receiver ASMA.

http://help.sap.com/saphelp_nw04/helpdata/en/57/0b2c4142aef623e10000000a155106/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/2e/bf37423cf7ab04e10000000a1550b0/frameset.htm

Please see this below one for clarity:

Regards,

Sreeni.

former_member205101
Participant
0 Kudos

Hello Srini,

Thanks ..Let me try this payload as attachment in sender and receiver.

But I was thinking it should work with out attachment in normal way.

Created the Java mapping instead of UDF. If i test the same java mapping in different PI 7.1 0r 7.0 server, it is working.

I am testing in PI 7.0 (complete details of the PI version)

PI System: PI 7.0 (SAP EHP 2 for SAP NetWeaver 7.0) ABAP stack/

Software Build information of PSD - REPOSITORY

make.relNW702_06_REL
SP-Number06
jdk.version1.3
latest.change130804

Java Mapping code

package com.test;

import java.util.Map;

import com.sap.aii.mapping.api.MappingTrace;

import com.sap.aii.mapping.api.StreamTransformation;

import com.sap.aii.mapping.api.StreamTransformationConstants;

import com.sap.aii.mapping.api.StreamTransformationException;

import java.awt.image.BufferedImage;

import java.io.*;

import java.util.Map;

import java.util.HashMap;

import javax.imageio.ImageIO;

import com.sap.aii.mapping.api.DynamicConfiguration;

import com.sap.aii.mapping.api.DynamicConfigurationKey;

//Start of class

public class DivertImage  implements StreamTransformation

      {

                private Map param =null;

                private MappingTrace trace;

                        public void setParameter(Map param)

                         {

                          this.param = param;

                          if (param == null)

                            {

                                 this.param = new HashMap();

                              }

                if (param != null)

                  {

                    Object o = param.get(StreamTransformationConstants.MAPPING_TRACE);

                    if (o != null && o instanceof MappingTrace)

                     {

                    trace = (MappingTrace) o;

                       }

                    }

                  }

                        public void execute(InputStream in, OutputStream out)throws StreamTransformationException  

                        {

                                    try

                                       {

                                               

                                                DynamicConfiguration conf = (DynamicConfiguration)param.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

                                                DynamicConfigurationKey dckFile = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

                                                DynamicConfigurationKey dckDirectory = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");

                                                String filename = conf.get(dckFile);

                                                String directory = "";

                                                String SystemID = null;

                                                SystemID = System.getProperty("SAPSYSTEMNAME");

                                                if (filename!=null)

                                                 {

                                                if(filename.length() == 11)

                                                {

if (SystemID.equals("DEV"))
directory = "\\\\xxxxx\INTERFACE\FOlderA\\";

if (SystemID.equals("QA"))
  directory = "\\\\xxxxx\INTERFACE\FOlderA\\";

/*****Prod URL***/
if (SystemID.equals("PROD"))
  directory = "\\\\xxxxx\INTERFACE\FOlderA\\";
}                                             

                                                else

                                                 {

                                                if (SystemID.equals("DEV"))
directory = "\\\\xxxxx\INTERFACE\FOlderB\\";

if (SystemID.equals("QA"))
  directory = "\\\\xxxxx\INTERFACE\FOlderB\\";

/*****Prod URL***/
if (SystemID.equals("PROD"))
  directory = "\\\\xxxxx\INTERFACE\FOlderB\\";

                                                }

                                                }

                                                conf.put(dckDirectory,directory);

                                                BufferedImage img;

                                        img = ImageIO.read(in);

                                        ImageIO.write(img, "PNG",out);

                                         }//End Of Try

                                       catch(Throwable th)

                                        {

                                        th.printStackTrace();

                                       }//End of Catch      

                          }//End of Method

}//End of class

Issue

  • It produces 0KB output file in correct target folder with correct file name
  • No data in output file

Thanks

Praba

sugata_bagchi2
Active Contributor
0 Kudos

Hi Praba,
MTB and payloadswapbean module will not be that useful..

Prabaharan you can not use MTB as it is not a Plain2XML or XML2Plain conversion, the incoming file is a Image.

you can also not use the PayloadSwapBean  as your incoming message contain only one main document (the main payload as image) no attachment is there so that you can swap the payload and attachment with each other. And more over you can not use this module as your scenario is a file to file not mail in the receiver side.
you can try by using the additional files feature of file adapter

now the best option would be to use custom adapter module if everything fails...

have you refreshed the CPA cache?

sugata_bagchi2
Active Contributor
0 Kudos

Hi Praba,

According to the code for java mapping .,  it will not work if you are in JDK 1.3 , as it does not support ImageIO.
You need to handle using byte stream or create binary stream.

Thanks

Sugata

sugata_bagchi2
Active Contributor
0 Kudos

Hi Praba,
If it is not possible to change the JDK, you can try with common IO by apache . It is a seperate external Jar you can read / write by using the static IOUtills.
read the inputstream and convert it to byte array then write it to outputstream.

Thanks

Sugata B Majumder