on 01-15-2023 12:00 PM
Hi expert.
I have a requirement for value update via specific xml element on MAG as below screenshot.
I wanna change value 9->92 when D_3035 is populated value SU on MAG or XSLT code.
Would you be able to provide xslt code or MAG mapping tools ? I haven't found how can i do handle on MAG area.
1. XML schema
<G_SG2>
<S_NAD>
<D_3035>SU</D_3035>
<C_C082>
<D_3039>MYCARRIER</D_3039>
<D_3055>9</D_3055> ------------------> <D_3055>92</D_3055>
</C_C082>
</S_NAD>
</G_SG2>
2.Below is the MAG Mapping screenshot
Hi Young Soo
You need to set field PARNTER_Q as qualifier for node E1ADRM1 in the MIG first. Then, in the MAG you can qualify the source node with SU and create your mapping with constant value 92 in target field 3055.
After that, you duplicate the source node for each of the other qualifiers that you need (ST, UD etc.).
Look at this blog post for more info: https://blogs.sap.com/2019/12/09/integration-advisor-the-precision-of-semantics-use-of-qualifiers
Philippe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Young- I recommend you go with graphical mapping to change the value for the EDI message. However, I have added the XSLT code here.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" indent="yes"/><xsl:template match="@* | node()"><xsl:copy><xsl:apply-templates select="@* | node()"/></xsl:copy></xsl:template><xsl:template match="/"><xsl:apply-templates /></xsl:template><xsl:template match = "/Node/G_SG2/S_NAD/D_3035[text() = 'ST' ]"><xsl:variable name="position" select="position()"/><D_3055><xsl:if test="//Node/G_SG2[$position]//D_3055/text() = '9'" ><xsl:value-of select= "92"/></xsl:if></D_3055><D_3035><xsl:value-of select='.'/></D_3035></xsl:template></xsl:stylesheet>
Note: Value has updated but the position has changed in the output XML. Regards,Karthik ArjunSAP CPI | Fiori Senior Specialist
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karthik ,
Thanks for reply and providing other option.
But value has not been updated when su value populated using above code in xslt.
I am providing outcome xml.
Would you be able to solution for that?
I would like to express big thanks for your effort
<G_SG2>
<S_NAD>
<D_3035>BY</D_3035>
<C_C082>
<D_3039>0000152055</D_3039>
<D_3055>9</D_3055>
</C_C082>
</S_NAD>
</G_SG2>
<G_SG2>
<S_NAD>
<D_3035>ST</D_3035>
<C_C082>
<D_3039>0000152055</D_3039>
<D_3055>9</D_3055>
</C_C082>
</S_NAD>
</G_SG2>
<G_SG2>
<S_NAD>
<D_3035>SU</D_3035>
<C_C082>
<D_3039>3000</D_3039>
<D_3055>9</D_3055>
</C_C082>
</S_NAD>
</G_SG2>
All the best
Young
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Can you give it a try with for loop? Sample code has attached here (requires additional effort to make it o=work)
Option 1:
Split the record -> use XSLT -> Manipulate the record with condition -> Gather
Option 2:
<xsl:template name="D_3055">
<xsl:for-each select = "G_SG2">
<xsl:variable name="level1Count" select="position() - 1"/>
<xsl:variable name="varD_3035" select="//D_3035[$level1Count]" />
<xsl:variable name="varD_3055" select="//D_3055[$level1Count]" />
<D_3055>
<xsl:value-of select= "if( $varD_3035 = 'SU' ) then '92' else $varD_3055 "/>
</D_3055>
</xsl:for-each>
</xsl:template>
Regards,
Karthik Arjun
SAP CPI | FIORI Senior Specialist
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karthik
Thanks for reply my question for xslt.
1. below is the outcome using your xslt code.
I wanna only populate 92 on D_3055 field when SU value on D_3035 field.But other BY/ST value on D_3035 was updated as well 92 from 9.
Would you be able to provide only xslt logic for 92 on D_3055 with SU on D_3035 ?
<G_SG2>
<S_NAD>
<D_3035>BY</D_3035>
<C_C082>
<D_3039>0000152055</D_3039>
<D_3055>92</D_3055>
</C_C082>
</S_NAD>
</G_SG2>
<G_SG2>
<S_NAD>
<D_3035>ST</D_3035>
<C_C082>
<D_3039>0000152055</D_3039>
<D_3055>92</D_3055>
</C_C082>
</S_NAD>
</G_SG2>
<G_SG2>
<S_NAD>
<D_3035>SU</D_3035>
<C_C082>
<D_3039>3000</D_3039>
<D_3055>92</D_3055>
</C_C082>
</S_NAD>
</G_SG2>
2.Below is my current xslt + your code.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes" omit-xml-declaration="no"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="S_DTM[C_C507/D_2005!='137' and (C_C507/D_2005!='11')]"/>
<xsl:template match="G_SG2[S_NAD/D_3035!='BY' and (S_NAD/D_3035!='ST') and (S_NAD/D_3035!='SU') and (S_NAD/D_3035!='UD')]"/>
<xsl:variable name="varD_3035" select="//D_3035"/>
<xsl:variable name="varD_3055" select="//D_3055"/>
<xsl:template match="D_3055">
<D_3055>
<xsl:value-of select= "if( $varD_3035 = 'SU' ) then '92' else $varD_3055 "/>
</D_3055>
</xsl:template>
<xsl:template match="G_SG1">
<G_SG2>
<S_NAD>
<D_3035>CA</D_3035>
<C_C082>
<D_3039>MYCARRIER</D_3039>
<D_3055>92</D_3055>
</C_C082>
</S_NAD>
</G_SG2>
</xsl:template>
<xsl:template match="S_CPS">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<S_CPS>
<D_7164>1</D_7164>
<D_7166></D_7166>
<D_7075>IE</D_7075>
</S_CPS>
</xsl:template>
<xsl:template match="S_PAC">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<S_PAC>
<D_7224>1</D_7224>
<C_C202>
<D_7065>PK</D_7065>
</C_C202>
</S_PAC>
</xsl:template>
<xsl:template match="S_PAC">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<S_PAC>
<D_7224>1</D_7224>
<C_C202>
<D_7065>PK</D_7065>
</C_C202>
</S_PAC>
</xsl:template>
</xsl:stylesheet>
Thank you so much
All the Best
Young
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi youngsookim - Would you mind using the below code to use in your case?
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:variable name="varD_3035" select="//D_3035"/>
<xsl:variable name="varD_3055" select="//D_3055"/>
<xsl:template match="D_3055">
<D_3055>
<xsl:value-of select= "if( $varD_3035 = 'SU' ) then '92' else $varD_3055 "/>
</D_3055>
</xsl:template>
</xsl:stylesheet>
Regards,
Karthik Arjun
SAP CPI | Fiori Senior Specialist
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
73 | |
8 | |
8 | |
8 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.