Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SPACE problem in parsed XML Data

Former Member
0 Likes
898

Hi All,

I am using an ABAP Mapping in XI to convert XML data to flat file where I have parsed the input XML Data and am working with it to pass each string into internal table.

Here I have an issue where a STRING starts with a SPACE which is lost at the output.I mean the leading spaces in a string are getting Truncated.

Can anyone please help in resolving this ASAP?

I tried all the possible ways like concatenating SPACE, ' ' etc.Any help in this regard will be very much helpul.

Thanks & Regards,

Harish.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
779

use this UDF in XI mapping :

Name the function as spacesuppress and take the cache as value and take one argument input. Then put the code below:

//write your code here

String output = input.replaceFirst("^ +","");

return output;

This removes all the leading spaces.

Sandeep

4 REPLIES 4
Read only

Former Member
0 Likes
780

use this UDF in XI mapping :

Name the function as spacesuppress and take the cache as value and take one argument input. Then put the code below:

//write your code here

String output = input.replaceFirst("^ +","");

return output;

This removes all the leading spaces.

Sandeep

Read only

Former Member
0 Likes
779

Hi Sandeep,

May be I am not clear.I want to retain the leading spaces of the string.

Also to give you a clear picture , I am using Graphical mapping to convert Idoc-XML to XML and then this XML data should be mapped into a flat file using the abap mapping.

Thanks & Regards,

Harish.

Read only

0 Likes
779

In graphical mapping, you have an option to create User Defined functions,

you have to use this code to create that user defined function there.

Now use that UDF in your graphical mapping

if your field is mapped as

a--> a

now map the same as :

a --> UDF --> a

Sandeep

Read only

Former Member
0 Likes
779

Hi Sandeep,

The output from the Graphical mapping still has the leading space but the output from this graphical mapping is passed to the abap mapping as input and the output from this abap mapping doesn't contain the leading white space.

BR,

Harish.