Application Development 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: 

How to delete blank space in XML tag - Simple Transformation?

Antonio_Lopez
Explorer
0 Kudos

Hi everyone. I new newbie in Sap Abap. I´m working with Simple Transformation. I am trying to generate XML from internal tables, but when I try to get the it through the DEBUG I realized that there´s someting wrong. In some Tags of XML there are some blank spaces but I can´t get where those come from. So I need to delete thoses blank Spaces.

I am newbie in Abap Wolrd. Hope anyone can give a had how to solve it.

The code:

"ABAP CODE:
lv_total_mercancias = lines( ccp_inf_pro ). "Sum records of the IT
mercancias-NumTotalMercancias = lv_total_mercancias

LOOP AT ccp_inf_pro    INTO wa_inf_pro .
  MOVE: wa_inf_pro-zcantrans        TO wa_mercancias_afi-Cantidad,
        wa_inf_pro-zpesokg          TO wa_mercancias_afi-pesoenkg,
        wa_inf_pro-zvalormerc       TO wa_mercancias_afi-ValorMercancia.

 APPEND wa_mercancias_afi 	    TO mercancias-mercancia.
ENDLOOP.

"SIMPLE TRANSFORMATION:
        <Mercancias>
          <tt:attribute name="NumTotalMercancias" value-ref=".MERCANCIAS.NUMTOTALMERCANCIAS"/>
            <tt:loop ref="MERCANCIAS.MERCANCIA">
              <Mercancia>
                <tt:attribute name="Cantidad" 		value-ref="CANTIDAD"/>
                <tt:attribute name="PesoEnKg" 		value-ref="PESOENKG"/>       
                <tt:attribute name="ValorMercancia" 	value-ref="VALORMERCANCIA"/>
              </Mercancia>
            </tt:loop>
	</Mercancias>
1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor

That resembles the place of numeric sign (space for positive number, "-" for negative number).

But in XML transformations, numbers are not represented with place of numeric sign, and without the quotes. So I guess your ABAP components CANTIDAD, PESOENKG, VALORMERCANCIA are all texts, instead of numbers, and you filled them incorrectly. If you turn them into numeric data types, you will get something like that:

<Mercancias NumTotalMercancias=1>
  <Mercancia Cantidad=300 PesoEnKg=5000 ValorMercancia=700000/>
</Mercancias>

If you want to keep these columns as text, you can use String Template to remove the leading space:

wa_mercancias_afi = VALUE #(
Cantidad = |{ wa_inf_pro-zcantrans }|
pesoenkg = |{ wa_inf_pro-zpesokg }|
ValorMercancia = |{ wa_inf_pro-zvalormerc }| ).

NB: MOVE is obsolete.

2 REPLIES 2

Sandra_Rossi
Active Contributor

That resembles the place of numeric sign (space for positive number, "-" for negative number).

But in XML transformations, numbers are not represented with place of numeric sign, and without the quotes. So I guess your ABAP components CANTIDAD, PESOENKG, VALORMERCANCIA are all texts, instead of numbers, and you filled them incorrectly. If you turn them into numeric data types, you will get something like that:

<Mercancias NumTotalMercancias=1>
  <Mercancia Cantidad=300 PesoEnKg=5000 ValorMercancia=700000/>
</Mercancias>

If you want to keep these columns as text, you can use String Template to remove the leading space:

wa_mercancias_afi = VALUE #(
Cantidad = |{ wa_inf_pro-zcantrans }|
pesoenkg = |{ wa_inf_pro-zpesokg }|
ValorMercancia = |{ wa_inf_pro-zvalormerc }| ).

NB: MOVE is obsolete.

Perfect!!! It´s workig. Thank you. I had´t any idea how to solve it. I deleted my table records and insert data again, but that didn´t work until now... gretings!!!