Within an SAP transformation, either a simple transformation or an XSLT transformation, it is possible to call ABAP class methods and use the result in the transformation.
For an XSLT transformation it is also possible to call the ABAP class method based on an XSLT node set. Then the class method input parameter for the XSLT node set need to be of type IF_IXML_NODE_COLLECTION.
Find below a (part) of a practical case where an XML header field depends on a set of item values. Here a set of material numbers.
Within the header part of the XSLT transformation a class method is called.
The class is ZCL_IDOC. Class method is TRADE.
A class method input paramater is IO_MATNR of type IF_IXML_NODE_COLLECTION. From the XSLT transformation this paramater is populated by XML node set Item/Material.
<sap:call-external class=”ZCL_IDOC” method=”TRADE”>
<sap:callvalue param=”IO_MATNR” select=”Item/Material”/>
<sap:callvariable name=”TRADE” param=”EV_TRADE” type=”boolean”/>
</sap:call-external>
The ABAP class method itself does hold some logic to populate output parameter EV_TRADE based on a set of input material numbers.
* <SIGNATURE>—————————————————————————————+
* | Static Public Method ZCL_IDOC=>TRADE
* +————————————————————————————————-+
* | [—>] IO_MATNR TYPE REF TO IF_IXML_NODE_COLLECTION
* | [<—] EV_TRADE TYPE ABAP_BOOL
* +————————————————————————————–</SIGNATURE>
METHOD trade.
* Material
DO io_matnr->get_length( ) TIMES.
INSERT INITIAL LINE INTO TABLE lt_pre03 REFERENCE INTO lr_pre03.
CALL FUNCTION ‘CONVERSION_EXIT_MATN1_INPUT’
EXPORTING
input = io_matnr->get_item( syst-index – 1 )->get_value( )
IMPORTING
output = lr_pre03->matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
ENDDO.
Within an SAP transformation, either a simple transformation or an XSLT transformation, it is possible to call ABAP class methods and use the result in the transformation.For an XSLT transformation it is also possible to call the ABAP class method based on an XSLT node set. Then the class method input parameter for the XSLT node set need to be of type IF_IXML_NODE_COLLECTION.Find below a (part) of a practical case where an XML header field depends on a set of item values. Here a set of material numbers.Within the header part of the XSLT transformation a class method is called.The class is ZCL_IDOC. Class method is TRADE.A class method input paramater is IO_MATNR of type IF_IXML_NODE_COLLECTION. From the XSLT transformation this paramater is populated by XML node set Item/Material. <sap:call-external class=”ZCL_IDOC” method=”TRADE”>
<sap:callvalue param=”IO_MATNR” select=”Item/Material”/>
<sap:callvariable name=”TRADE” param=”EV_TRADE” type=”boolean”/>
</sap:call-external> The ABAP class method itself does hold some logic to populate output parameter EV_TRADE based on a set of input material numbers. * <SIGNATURE>—————————————————————————————+
* | Static Public Method ZCL_IDOC=>TRADE
* +————————————————————————————————-+
* | [—>] IO_MATNR TYPE REF TO IF_IXML_NODE_COLLECTION
* | [<—] EV_TRADE TYPE ABAP_BOOL
* +————————————————————————————–</SIGNATURE>
METHOD trade.
* Material
DO io_matnr->get_length( ) TIMES.
INSERT INITIAL LINE INTO TABLE lt_pre03 REFERENCE INTO lr_pre03.
CALL FUNCTION ‘CONVERSION_EXIT_MATN1_INPUT’
EXPORTING
input = io_matnr->get_item( syst-index – 1 )->get_value( )
IMPORTING
output = lr_pre03->matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
ENDDO. Read More Technology Blogs by Members articles
#SAP
#SAPTechnologyblog