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

Problem reading XML file - Leading space truncation

Former Member
0 Likes
911

Hi Friends,

We are reading a XML file for AP Posting in FB01.

XML file has two elements called - Name1 and Name2 which goes directly into Name1 and Name2 fields for onetime customer during posting.

Name1- 35char

Name2- 35 char.

Problem.

When ever there is a space in 1st position in Name2 of source data, while reading it from xml to string, leading spaces are ignored, which is causing problem.

code in brief: (not the complete code)


DATA: wa_xmltab          TYPE xstring,
          g_selementvalue  TYPE string,
          g_selementname TYPE string,
          g_childnode         TYPE REF TO if_ixml_node,

*l_file is xml file name.
READ DATASET l_file INTO wa_xmltab.
*get element name
g_selementname = g_childnode->get_name( ).
*get value stored in this node.
g_selementvalue = g_childnode->get_value( ).

if name2 = ' ABCDEFGH' ( 3 leading spaces in name2)

it is being read as 'ABCDEFGH' which is causing the problem.

Same is the case if there are trailing spaces.

Appreciate if someone could suggest me an alternative approach of reading the XML data so that leading or trailing spaces are not ignored and retained.

Regards,

Simha

Edited by: Simha on Nov 6, 2008 11:10 AM

Hi Friends,

We are reading a XML file for AP Posting in FB01.

XML file has two elements called - Name1 and Name2 which goes directly into Name1 and Name2 fields for onetime customer during posting.

Name1- 35char

Name2- 35 char.

Problem.

When ever there is a space in 1st position in Name2 of source data, while reading it from xml to string, leading spaces are ignored, which is causing problem.

code in brief: (not the complete code)


DATA: wa_xmltab          TYPE xstring,
          g_selementvalue  TYPE string,
          g_selementname TYPE string,
          g_childnode         TYPE REF TO if_ixml_node,

*l_file is xml file name.
READ DATASET l_file INTO wa_xmltab.
*get element name
g_selementname = g_childnode->get_name( ).
*get value stored in this node.
g_selementvalue = g_childnode->get_value( ).

if name2 = ' ABCDEFGH' ( 3 leading spaces in name2)

it is being read as 'ABCDEFGH' which is causing the problem.

Same is the case if there are trailing spaces.

Appreciate if someone could suggest me an alternative approach of reading the XML data so that leading or trailing spaces are not ignored and retained.

Regards,

Simha

Edited by: Simha on Nov 6, 2008 11:10 AM

2 REPLIES 2
Read only

Former Member
0 Likes
565

read this blog .. will be of great help

Read only

0 Likes
565

Hi Renu Gusain,

Thanks for your inputs.

Could you please be more specific towards the problem.

I read the blog and could not relate how to solve the space problem. Thanks

Simha.

Edited by: Simha on Nov 12, 2008 3:57 AM