Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

SAP EWM Help Latest Questions

  • 0
  • 0
DPM125
Beginner

create an XSL (Extensible Stylesheet Language) transformation using the XCO Library in SAP (ABAP)

The XCO Library (ABAP Cloud) — part of SAP’s modern ABAP RESTful programming model — allows you to programmatically create and manipulate repository objects like CDS views, classes, and transformations (including XSLT).

CLASS zcl_create_xsl_demo DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.

PUBLIC SECTION.
METHODS create_xsl.
ENDCLASS.

CLASS zcl_create_xsl_demo IMPLEMENTATION.

METHOD create_xsl.
” Get the package where the object will be created
DATA(lo_package) = xco_cp_abap_repository=>package->for( ‘Z_MY_PACKAGE’ ).

” Define the transformation name
DATA(lo_xsl_name) = xco_cp_abap_repository=>object_name->for( ‘Z_MY_XSLT’ ).

” Define the transformation source code
DATA(lv_xsl_source) = |<?xml version=”1.0″ encoding=”UTF-8″?>| &&
|\n<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”&gt;| &&
|\n <xsl:template match=”/”>| &&
|\n <output>| &&
|\n <xsl:value-of select=”/root/value”/>| &&
|\n </output>| &&
|\n </xsl:template>| &&
|\n</xsl:stylesheet>|.

” Create a new transformation object
DATA(lo_xsl_object) =
xco_cp_abap_repository=>object->transformation->create(
object_name = lo_xsl_name
package = lo_package
).

” Set the source code of the transformation
lo_xsl_object->source->set( lv_xsl_source ).

” Persist (activate) the transformation in the repository
lo_xsl_object->save( xco_cp_abap_repository=>activation_mode->active ).

WRITE: / ‘XSL Transformation Z_MY_XSLT created and activated successfully.’.
ENDMETHOD.

ENDCLASS.

Related Questions

Leave an answer

Leave an answer