Difference between revisions of "SAP ABAP XSLT"
From SapWiki
(Created page with "==Ejemplo 01: XSLT ZHCM_CARGAR_DOCUMENTO (trn. xslt_tool) <?sap.transform simple?> <tt:transform xmlns:tt="http://www.sap.com/transformation-templates"> <tt:root name="RO...") |
|||
| Line 1: | Line 1: | ||
| − | ==Ejemplo 01: XSLT ZHCM_CARGAR_DOCUMENTO (trn. xslt_tool) | + | ==Ejemplo 01: XSLT ZHCM_CARGAR_DOCUMENTO (trn. xslt_tool)== |
| − | <?sap.transform simple?> | + | <nowiki> <?sap.transform simple?> |
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"> | <tt:transform xmlns:tt="http://www.sap.com/transformation-templates"> | ||
<tt:root name="ROOT"/> | <tt:root name="ROOT"/> | ||
| Line 14: | Line 14: | ||
</documento> | </documento> | ||
</tt:template> | </tt:template> | ||
| − | </tt:transform> | + | </tt:transform></nowiki> |
===Generar XML=== | ===Generar XML=== | ||
Revision as of 14:03, 30 March 2020
Ejemplo 01: XSLT ZHCM_CARGAR_DOCUMENTO (trn. xslt_tool)
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:template>
<documento>
<id_documento tt:value-ref=".ROOT.ID_DOCUMENTO"/>
<tt:cond check="not-initial(ROOT.FIRMA)">
<firma tt:value-ref=".ROOT.FIRMA"/>
</tt:cond>
<nombre_documento tt:value-ref=".ROOT.NOMBRE_DOCUMENTO"/>
<tipo_archivo tt:value-ref=".ROOT.TIPO_ARCHIVO"/>
<archivo_b64 tt:value-ref=".ROOT.ARCHIVO_B64"/>
</documento>
</tt:template>
</tt:transform>
Generar XML
types: begin of ty_documento, ID_DOCUMENTO type string, firma type string, NOMBRE_DOCUMENTO type string, TIPO_ARCHIVO type string, ARCHIVO_B64 type string, end of ty_documento. data ls_documento type ty_documento. data l_documento_xml type string.
DATA l_exception_error TYPE REF TO cx_st_error.
DATA l_st_error TYPE string.
TRY.
CALL TRANSFORMATION zhcm_cargar_documento
SOURCE root = ls_documento
RESULT XML l_documento_xml.
CATCH cx_st_error INTO l_exception_error.
l_st_error = l_exception_error->get_text( ).
p_subrc = 1.
p_msg = l_st_error.
RETURN.
ENDTRY.
Leer XML
DATA l_exception_error TYPE REF TO cx_st_error.
DATA l_st_error TYPE string.
TRY.
CALL TRANSFORMATION zhcm_cargar_documento
SOURCE XML l_documento_xml
RESULT root = ls_documento.
CATCH cx_st_error INTO l_exception_error.
l_st_error = l_exception_error->get_text( ).
p_subrc = 1.
p_msg = l_st_error.
RETURN.
ENDTRY.