2009 Mar 26 12:48 PM
I's is possible to create a XML files with XLST Transformations using nested internal tables?
I want do create a XML file that represents the structure of a Sales Order (Header + Items):
TYPES: BEGIN OF s_order,
vbak TYPE vbak,
vbap TYPE vbap OCCURS 0,
END OF s_order.
DATA: gs_vbap TYPE vbap,
gt_vbap TYPE STANDARD TABLE OF vbap.
DATA: gs_order TYPE s_order,
gt_order TYPE STANDARD TABLE OF s_order.
gs_vbap-vbeln = 100.
gs_vbap-posnr = 10.
gs_vbap-matnr = 'MAT1'.
APPEND gs_vbap TO gt_vbap.
gs_vbap-posnr = 20.
gs_vbap-matnr = 'MAT2'.
APPEND gs_vbap TO gt_vbap.
gs_order-vbap = gt_vbap.
APPEND gs_order TO gt_order.
GET REFERENCE OF gt_order INTO gs_source_wa-value.
gs_source_wa-name = 'ORDER'.
APPEND gs_source_wa TO gt_source_itab.
TRY.
CALL TRANSFORMATION z_abap_to_xml
SOURCE (gt_source_itab)
RESULT XML gt_itab.
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
The XML result should be something like this:
<ORDER>
<VBELN>100</VBELN>
--- vvv ---
<VBAP>
<POSNR>10</POSNR>
<MATNR>MAT1</MATNR>
</VBAP>
<VBAP>
<POSNR>20</POSNR>
<MATNR>MAT2</MATNR>
</VBAP>
--- ^^^ ---
<ORDER>
The area between --- vvv --- and --- ^^^ --- should be dynamic, according with the number of entries of the nested internal table. I'm using the instruction "for-each" in the XSLT transformation, however that doesn't seems to work with internal tables
Any help?
Thanks in advance,
Nuno
2009 Mar 27 5:44 AM
I's is possible to create a XML files with XLST Transformations using nested internal tables?
I want do create a XML file that represents the structure of a Sales Order (Header + Items):
TYPES: BEGIN OF s_order,
vbak TYPE vbak,
vbap TYPE vbap OCCURS 0,
END OF s_order.
DATA: gs_vbap TYPE vbap,
gt_vbap TYPE STANDARD TABLE OF vbap.
DATA: gs_order TYPE s_order,
gt_order TYPE STANDARD TABLE OF s_order.
gs_vbap-vbeln = 100.
gs_vbap-posnr = 10.
gs_vbap-matnr = 'MAT1'.
APPEND gs_vbap TO gt_vbap.
gs_vbap-posnr = 20.
gs_vbap-matnr = 'MAT2'.
APPEND gs_vbap TO gt_vbap.
gs_order-vbap = gt_vbap.
APPEND gs_order TO gt_order.
GET REFERENCE OF gt_order INTO gs_source_wa-value.
gs_source_wa-name = 'ORDER'.
APPEND gs_source_wa TO gt_source_itab.
TRY.
CALL TRANSFORMATION z_abap_to_xml
SOURCE (gt_source_itab)
RESULT XML gt_itab.
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
The XML result should be something like this:
<ORDER>
<VBELN>100</VBELN>
--- vvv ---
<VBAP>
<POSNR>10</POSNR>
<MATNR>MAT1</MATNR>
</VBAP>
<VBAP>
<POSNR>20</POSNR>
<MATNR>MAT2</MATNR>
</VBAP>
--- ^^^ ---
<ORDER>
The area between --- vvv --- and --- ^^^ --- should be dynamic, according with the number of entries of the nested internal table. I'm using the instruction "for-each" in the XSLT transformation, however that doesn't seems to work with internal tables
Any help?
Thanks in advance,
Nuno
2009 Mar 27 5:44 AM
2009 Apr 15 11:30 AM
Dear Nuno,
You can perform XSLT transformations only on tables of flat structure.
You'll need to hand over both tables VBAP and VBAK to the stylesheet and create the nested XML structure within the XSLT.
Best wishes,
Jan