cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT code to map IDOC structure into single field

Former Member
0 Kudos

Hi experts

Hi have to map the entire IDOC structure into single field of a file which is a target side by using XSLT code. Please help me out of this

Thank you guys

Accepted Solutions (0)

Answers (2)

Answers (2)

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Yugandhar,

Please check Link1 above, it have solution for this issue using Java Mapping and XSLT.

Regards,

Raghu_Vamsee

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Yugandhar,

If your are using PI7.1, it can be done using graphical mapping.

Please follow these blogs [Link1|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/19719] [original link is broken] [original link is broken] [original link is broken]; [Link2|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/8649] [original link is broken] [original link is broken] [original link is broken];

Else (your are using lesser PI version), it can be done using Java Mapping. Please let me know, if you need help on that.

Regards,

Raghu_Vamsee

Former Member
0 Kudos

Hi Raghu

Yaa in PI 7.1 we had a option in Graphical mapping .but iam using PI7.0 for this we must have to write a code u2026please help me to go out of this

Thank you

former_member181985
Active Contributor
0 Kudos

use this sample and change according to your target message structure

import com.sap.aii.mapping.api.StreamTransformation;
import java.io.*;
import java.util.Map;
 
public class InputPayloadToFieldJM
    implements StreamTransformation
{	
    public InputPayloadToFieldJM()
    {
    } 

	public static void main(String args[])
	{
		try
		{
			FileInputStream fin = new FileInputStream(args[0]);
			FileOutputStream fout = new FileOutputStream(args[1]);
			InputPayloadToFieldJM mapping = new InputPayloadToFieldJM();
			mapping.execute(fin, fout);
		}
		catch (Exception e)
			{
				e.printStackTrace();
			}
	}
    public void setParameter(Map map1)
    {
        map = map1;
    } 
    public void execute(InputStream inputstream, OutputStream outputstream)
    {
        try
        { 
			int len = 0;
			byte[] buffer = new byte[1024*5000];

			outputstream.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TARGET_MT><Field1>".getBytes());
			while ((len = inputstream.read(buffer)) > 0)
			{

					outputstream.write(buffer, 0, len);
			}
			outputstream.write("<Field1></TARGET_MT>".getBytes());
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
 
    private Map map;
}