cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Why sap:external-function is not allowed in the Cloud?

Petr_Plenkov
Active Participant
1,190

Hi,

Just screaming loud  - migrating working code to the Cloud and facing again a problem - function is not supported.

This time  it's sap:external-function in XSLT.

We have some transformations which were XSLT but with some custom hooks via classes. Now we need to rewrite it to sXML code to parse the file and implement the logic which we could just reach with trully simple code as this:

 

 

 

  <xsl:param name="CASE" sap:type="ZIF_ABAP_CASE"/>

  <xsl:template match="@name">
    <xsl:attribute name="name">
      <xsl:value-of select="f:fromAbap($CASE,string(.))"/>
    </xsl:attribute>
  </xsl:template>

  <sap:external-function name="f:fromAbap" method="FROM_ABAP"  kind="instance" >
    <sap:argument param="VALUE" type="csequence"/>
    <sap:result param="RESULT" type="string"/>
  </sap:external-function>

 

 

 

Of course this is just one of examples, but that's still not clear why.. I'd wish this functionality to be available back in the cloud too

Is there anybody from ABAP Cloud team who can explain why it was revoked

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Petr_Plenkov
Active Participant

OK seems like sap:call-external is still allowed. Small adjustment of the code helped to keep transformation almost same, but still required modification

Sandra_Rossi
Active Contributor
0 Likes
Thanks for the feedback. Could you say more about the adjustment needed?
Petr_Plenkov
Active Participant
0 Likes
I mean that mentioned above code doesn't work. It says class is not alllowed. But this works
Petr_Plenkov
Active Participant
<!-- Transform @name attributes using sap:call-external --> <xsl:template match="@name"> <sap:call-external name="CASE" method="FROM_ABAP"> <sap:callvalue param="VALUE" select="string(.)"/> <sap:callvariable param="RESULT" name="convertedName"/> </sap:call-external> <xsl:attribute name="name"> <xsl:value-of select="$convertedName"/> </xsl:attribute> </xsl:template>

Answers (1)

Answers (1)

RemiKaimal
Active Contributor

The cloud environment restricts such direct ABAP calls for security and architectural reasons

Use ABAP Class-Based XSLT Transformation
If you must use XSLT, you can pass additional parameters to the transformation via ABAP.

Another alternative approach
Preprocess Data in ABAP before XSLT
Modify your code to process data before calling XSLT, so you don’t need sap:external-function.

ABAP Code:
DATA:
lt_xml_input TYPE string,
lt_xml_output TYPE string,
lo_transform TYPE REF TO cl_transformation.

DATA(lo_case) = NEW zif_abap_case( ). " your custok class instance
DATA(lv_transformed_value) = lo_case->from_abap( 'OriginalValue' ).

lt_xml_input = `<root name="` && lv_transformed_value && `"></root>`.

" Apply XSLT transformation
CREATE OBJECT lo_transform TYPE ('ZMY_TRANSFORMATION').
lo_transform->call_transformation(
EXPORTING input = lt_xml_input
IMPORTING output = lt_xml_output
).
Processes data before XSLT execution and this works in the Cloud
Hope this helps. Cheers!!

Sandra_Rossi
Active Contributor
0 Likes

Or use

<sap:call-external ...>
  ...
</sap:call-external>

as explained by the post author.

Petr_Plenkov
Active Participant
0 Likes
well - the task behind this question - is to build an effective JSON serializer, parser ( may be even with XML too ). Of course - I can build JSON, load it to sXML model and transform - but that's something I want actually to avoid to do. performance wise transformations work much faster. So this question was not about how to do this - it was mainly a call - that again after hundreds of different reasons we cannot run in a cloud ABAP something which was working for decades.. Personally I do not see a difference between sap:call-external or sap:external-function and changing the code made it working exactly same way. But still - this is the manual action which has to be done to keep transformation working. Additionally as you can see in the shared link - i took it from the official documentation. https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/abenabap_xslt_abap_calls.html. So it means that I want to use something which is documented - but ADT doesn't even allow to compile..