09-07-2021 11:31 PM
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>
09-08-2021 5:03 AM
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.
09-08-2021 5:03 AM
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.
09-08-2021 2:52 PM
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!!!