- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-31-2021 05:03 AM
Hi,
I want to write this code in expression snaplogic.
I need to map TestID.
<xsl:variable name=âTestIDâ>
<xsl:if test=âexists(node()/IDOC/A1[VW=âFâ]/NO)â>
<xsl:copy-of select=ânode()/IDOC/A1[VW=âFâ]/NOâ>
</xsl:copy-of>
</xsl:if>
<xsl:if test=ânot(exists(node()/IDOC/A1[VW=âFâ]/NO))â>
<xsl:copy-of select=ânode()/IDOC/A1[VW=âFâ]/NPâ>
</xsl:copy-of>
</xsl:if>
</xsl:variable>
How do I do it?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-01-2021 01:22 AM
Hi @Sahil,
Here are two expressions, I was not sure because it is array does always will have only one VW that contains âFâ in the value.
First expression. Finds all NO or NP that contains âFâ in VW field.
$Data.IDOC.A1.filter(e => e.get('VW').contains('F')).map(x => x.get('NO') != null ? x.NO : x.NP)
But I think that the second expression is more correct. This expression finds the first one element in the array that contains âFâ in VW, and returns NO if exist or else NP.
$Data.IDOC.A1.find(e => e.get('VW').contains('F')).get('NO', $Data.IDOC.A1.find(e => e.get('VW').contains('F')).get('NP'))
By default this expression return null, and if you want something else you can add second parameter in the get method for default values.
Ex: .get('NP', "Default")
Regards,
Viktor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-31-2021 06:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-31-2021 07:13 AM
hi Viktor,
I need to translate the whole logic which was done in SAP to snaplogic.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-31-2021 07:26 AM
Iâve misunderstood, I see now what you want to do.
So, I donât have problem with writing expressions, but I am not good at reading xslt schemas.
Some of the syntax I understand, but ânode()/IDOC/A1[VW=âFâ]/NO)â can you explain this to me. Is this a path ?
And what are node() and copy-of ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-31-2021 07:41 AM
Hi
so basically in snaplogic terms it would be:-
$Data.IDOC.A1[VW=âFâ].NO
