cancel
Showing results for 
Search instead for 
Did you mean: 

mapping issue in customised idoc

former_member190284
Participant
0 Kudos

Hi experts,

I have facing a mapping issue, so need input.

my scenerio is from idoc(z) to http. This idoc contains an additional segment which contains pdf details and PDF data in base 64. this segment is added under E1EDK01.

Now, I have requirement that I need full Idoc content to be passed to a field in xml, but that content should not contain pdf segement(ZCXTXMLEN).

Though I have made a logic but it's not working. find attached images for reference.

Thanks in advance.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member190293
Active Contributor

Hi Nunu!

To fullfill your requirement I'd suggest using XSL transformation. For example, this template

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <OutputMessage>
            <IDocData>
                <xsl:apply-templates/>
            </IDocData>
        </OutputMessage>
    </xsl:template>
    <xsl:template match="*">
        <xsl:copy>
            <xsl:apply-templates select="(@* | node())[local-name() != 'ZCXTXMLEN']"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="@*">
        <xsl:copy/>
    </xsl:template>
</xsl:stylesheet>

puts contents of your IDoc inside the IDocData element of target message removing unwanted element.

Regards, Evgeniy.

former_member190293
Active Contributor

Hi Nunu!

First, you can't put one xml tree inside the other using standard functions of graphical mapping until it's wrapped with CDATA tags.

If you need to put one XML structure inside the other, you could use approach described in this blog:

https://blogs.sap.com/2012/11/05/message-mapping-play-around-with-target-structure/

Regards, Evgeniy.

manoj_khavatkopp
Active Contributor
0 Kudos

Try using UDF and make it simple :

IDOC(RETURN as XML)--->UDF ( Remove everything from start and end of xml tag <ZCXTXMLEN>)--->Target Node.

Br,

Manoj

former_member190284
Participant
0 Kudos

thanks Manoj, can you help me with the code?

manoj_khavatkopp
Active Contributor
0 Kudos

Try this :

Make sure you pass the source node as IDOC with "Return as XML".

return  (text.replaceAll("<ZCXTXMLEN>[\\s\\S]*?</ZCXTXMLEN>",""));

Br,

Manoj

former_member190284
Participant
0 Kudos

thanks Manoj but I am receiving same result .

I have configured as below:

manoj_khavatkopp
Active Contributor
0 Kudos

Check this embedded in CDATA : This is working for me.

Execute the mapping and copy the target xml and open in browser you can see there.

return "<![CDATA["+(text.replaceAll("<ZCXTXMLEN>[\\s\\S]*?</ZCXTXMLEN>",""))+ "]]>";

Br,

Manoj

former_member190284
Participant

Hi Manoj,

do u mean this :?

let me know wherever I am wrong

manoj_khavatkopp
Active Contributor
0 Kudos

This looks fine, Is it still not working ? Can you attach the output xml file from your MM tab after executing .

former_member190284
Participant
0 Kudos

Manoj, its not working.

pls find txt file

instance.txt

manoj_khavatkopp
Active Contributor
0 Kudos

That's because the node mentioned in UDF and incoming XML dosnt match exactly.

return (text.replaceAll(text.substring(text.indexOf("<ZCXTXMLEN"), text.indexOf("</ZCXTXMLEN>")+12),""));
former_member190284
Participant
0 Kudos

it didnt help either...same output

manoj_khavatkopp
Active Contributor
0 Kudos

Please provide a sample input xml . Not sure why it's not working for you ? It works for me.

former_member190284
Participant
0 Kudos

Hi, Manoj

PFA

instance-2.txt

manoj_khavatkopp
Active Contributor

Nunu,

Better go with XSLT suggested by Eve because in UDF you can't have the dynamic i.e your segment value can be 1 or 2 or anythig . XSLT looks promising .

Br,

Manoj