on 01-21-2015 9:18 PM
Hi Gurus
Can you please let me know the easiest way to ADD Carriage return or line feed at the end of XML file. Please, review example below in red.
I did come across this article:
However, does this UDF have to added to each field or the root node was unclear to me.
Interface Pattern:
ECC (ABAP Proxy) -> PI (Maps to XSD) -> .xml File placed on FTP server.
Please, let me know the best possible way to implement this.
Also, is there anything which can be done on the Proxy side in ECC itself.
Thank you so much,
Ritu
Example:
<?xml version="1.0" encoding="ISO-8859-1" ?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<note>
<to>Tove</to>
<from>
Jani</from>
<heading>
Reminder</heading>
<body>
Don't forget me this weekend!</body>
</note>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks!! Gagandeep
I did come across wanted to try UDF first - trying your code now.
I am going to copy everything between "+++++++++" to create my .java file as is and then execute your steps detailed on your blog.
I like the option to do without eclipse!!!
Thank you for your quick response will keep you posted,
Ritu
Hi Gagandeep
I received the following error when compiling in command prompt:
"C:\Program Files\Java\jdk1.5.0_11\bin\javac" -cp com.sap.xpi.ib.mapping.lib.jar AddCRorLF.java
"C:\Program Files\Java\jdk1.5.0_11\bin\javac" -cp com.sap.xpi.ib.mapping.lib.jar AddCRorLF.java
Here is the error I am getting: Do I need to just include the above jar files -or-change anything in the code - please advice:
Here is some addl. info on the above error when execute with -Xlint:
com.sap.xpi.ib.mapping.lib.jar AddCRorLF.java -Xlint
AddCRorLF.java:18: warning: [deprecation] com.sap.aii.mapping.api.StreamTransfor
mation in com.sap.aii.mapping.api has been deprecated
import com.sap.aii.mapping.api.StreamTransformation;
^
AddCRorLF.java:22: warning: [deprecation] com.sap.aii.mapping.api.StreamTransfor
mation in com.sap.aii.mapping.api has been deprecated
public class AddCRorLF implements StreamTransformation{
^
2 warnings
Thank you so much for your valuable time & advice,
Ritu
hi Ritu,
the screenshot shows they are warning not errors.
That should not have any problem in executing the program.
And if warning is bothering it is because you must be using execute function which is deprecated and hence you should transform function instead.
the above link can just help you with usage of transform. You can use same structure and change the code accordingly.
hope that helps.
thanks and regards,
Praveen T
Thanks!! Praveen - I will try using the .class . java I have currently - and see if it works.
Also, can you please let me know how to change the command to compile using 3 jar files:
Currently I am using the command:
Thanks your for your timely help!
Ritu
hi Ritu,
there are two ways,
1) copy all the jars in C:\Program Files\Java\jdk1.7.0_17\jre\lib\ext some similar kind of folder in your case and simply compile it without any class path. it should work.
2) java -cp <path>\TOOLS.jar;<path>\jar2.jar;<path>\jar3.jar [javafile-name]
any of the above option should work.
thanks and regards,
Praveen T
Ritu,
Please let us know, what is the need to Indent / PrettyPrint XML?
If target system want an Indent XML: -
Simple solution to Indent XML in SAP PI is XSLT mapping. Please check this.
<xsl:output omit-xml-declaration="yes" indent="yes"/>
If target system user want an Indent XML: -
Please check this wiki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ritu,
The UDF is adding carriage return at each node. If you want to add only to at the end then modify
//write your code here
String res = "";
int flag = 0;
for(int i = 0;i<xmlString.length();i++)
{
if(xmlString.charAt =='Last tag of XML')
{
flag = 0;
res = res +xmlString.charAt + "\n";
}
else
{
res = res +xmlString.charAt ;
}
}
return res;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your quick response!! Harish
Being very week in Java: Can you please tell me wat the input & output parameters would be, and if will apply to single value or all values of queue.
Also, wat would I connect it to
1.If I want it for every tag.
2.If I want it for only last tag (in a record set).
Always very grateful for your prompt response & help!!!
Thanks again,
Ritu
Thanks for your quick response!! Harish, Ramkumar
Can you please help with the syntax error in the code: as the activation change list cancelled with error - saying code has syntax error. The UDF is to add carriage return for all of the code:
String res = "";
int flag = 0;
for(int i = 0;i<xmlString.length();i++)
{
if(xmlString.charAt =='<')
{
flag = 1;
res = res + xmlString.charAt ;
}
else
{
if(xmlString.charAt =='>')
{
flag = 0;
res = res +xmlString.charAt + "\n";
}
else
{
res = res + xmlString.charAt ;
}
}
}
return res;
************
Hi
This is the correct code
String res = "";
int flag = 0;
for(int i = 0;i<xmlString.length();i++)
{
if(xmlString.charAt(i) =='<')
{
flag = 1;
res = res + xmlString.charAt(i) ;
}
else
{
if(xmlString.charAt(i) =='>')
{
flag = 0;
res = res +xmlString.charAt(i) + "\n";
}
else
{
res = res + xmlString.charAt(i) ;
}
}
}
return res;
Thanks,
Indrajit
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.