Skip to Content
0

mapping issue in customised idoc

Aug 07, 2017 at 02:05 AM

77

avatar image
Former Member

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.

pi.png (19.7 kB)
pi1.png (29.1 kB)
pi3.png (33.8 kB)
pi4.png (15.0 kB)
pi.png (19.7 kB)
pi1.png (29.1 kB)
pi3.png (33.8 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Evgeniy Kolmakov Aug 07, 2017 at 06:33 AM
1

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.

Share
10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov Aug 08, 2017 at 07:04 AM
1

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.


Share
10 |10000 characters needed characters left characters exceeded
Manoj K Aug 07, 2017 at 05:31 AM
0

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

Show 12 Share
10 |10000 characters needed characters left characters exceeded
Former Member

thanks Manoj, can you help me with the code?

0

Try this :

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

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

Br,

Manoj

0
Former Member

thanks Manoj but I am receiving same result .

I have configured as below:

capture.png (3.9 kB)
capture1.png (8.9 kB)
capture2.png (11.3 kB)
0

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

xml.png (8.8 kB)
0
Former Member

Hi Manoj,

do u mean this :?

let me know wherever I am wrong

11.png (6.9 kB)
12.png (9.7 kB)
1

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

0
Former Member

Manoj, its not working.

pls find txt file

instance.txt

instance.txt (38.2 kB)
0

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),""));
0
Former Member

it didnt help either...same output

0

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

0
Former Member

Hi, Manoj

PFA

instance-2.txt

instance-2.txt (19.5 kB)
0

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

2