Skip to content

Instantly share code, notes, and snippets.

@quxiaowei
Last active July 14, 2016 05:41
Show Gist options
  • Save quxiaowei/9fda97ccd8099dbabdf968452a3d93e8 to your computer and use it in GitHub Desktop.
Save quxiaowei/9fda97ccd8099dbabdf968452a3d93e8 to your computer and use it in GitHub Desktop.
[abap] transformation from json to abap
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<!--
json: example:
[{"result":-3.585595,"errorCode":"0","errorMessage":" "},
{"result":-3.585595,"errorCode":"0","errorMessage":" "}]
abap type:
TYPES: BEGIN OF ty_result,
result TYPE string,
errorcode TYPE string,
errormessage TYPE string,
END OF ty_result.
CALL TRANSFORMATION ztransform SOURCE XML v_text RESULT result = it_result.
-->
<tt:root name="RESULT"/>
<tt:template>
<array>
<tt:loop ref=".RESULT">
<object>
<num name="result">
<tt:value ref="$ref.RESULT"/>
</num>
<str name="errorCode">
<tt:value ref="$ref.ERRORCODE"/>
</str>
<str name="errorMessage">
<tt:value ref="$ref.ERRORMESSAGE"/>
</str>
</object>
</tt:loop>
</array>
</tt:template>
</tt:transform>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment