cancel
Showing results for 
Search instead for 
Did you mean: 

Context handling while creating IDocs and segments

ramu_g4
Participant
0 Kudos

Hi Experts,

This is regarding File to IDoc[DEBMAS06] where the input structure is external message and need to create multiple IDocs based on occurences on number of occurrences of BusinessPartner node with Address type constant equals to "CA" and E1KNBKM segments should be created under proper IDoc with number of occurrences equal of Banking node which is occuring under BusinessPartner node. Pls find the attached input sample files.

1st input:multiplebnks.txt

2nd input:newfile1.txt

Here 1st input should create 2 IDocs with 2 E1KNBKM segment occurrences under 1st IDoc and 5 E1KNBKM segment occurrences under 2nd IDoc.

Kindly help.

Thanks,

Ramu.

Accepted Solutions (0)

Answers (2)

Answers (2)

xinjiang_li
Active Participant
0 Kudos

Hi Ramu,

You can also use ifWithoutElse function to fulfill your requirement. The point is to change the context of the first parameter to an upper level, which is the same level as the second parameter.

former_member190293
Active Contributor
0 Kudos

Hi Ramu!

I consider XSL transformation to be the most suitable for your requirement.

Here is an example template:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:q1="http://www.abc.com/yellowpages/businesspartner/1_1"
    exclude-result-prefixes="xs q1" version="1.0">
    <xsl:template match="/">
        <DEBMAS06>
            <xsl:apply-templates select="/q1:SyncBusinessPartner/DataArea/BusinessPartner[InternationalVersion/Address/AddressType = 'CA']"/>
        </DEBMAS06>
    </xsl:template>
    <xsl:template match="BusinessPartner">
        <IDOC BEGIN="1">
            <EDI_DC40 SEGMENT="1">
            </EDI_DC40>
            <xsl:apply-templates select="./Banking"/>
        </IDOC>
    </xsl:template>
    <xsl:template match="Banking">
        <E1KNBKM SEGMENT="1">
        </E1KNBKM>
    </xsl:template>
</xsl:stylesheet>

For your first input result looks like:

<?xml version="1.0" encoding="utf-8"?>
<DEBMAS06>
    <IDOC BEGIN="1">
        <EDI_DC40 SEGMENT="1"/>
        <E1KNBKM SEGMENT="1"/>
    </IDOC>
    <IDOC BEGIN="1">
        <EDI_DC40 SEGMENT="1"/>
        <E1KNBKM SEGMENT="1"/>
    </IDOC>
</DEBMAS06>

I guess you could enhance this template furher to build desired IDoc structures.

Regards, Evgeniy.

ramu_g4
Participant
0 Kudos

Hi Evgeniy,

Thanks for your response!

But we are working on PI 7.4 single stack.I have not worked on XSLT before. Also they are several fields Can you help with graphical mapping.

Thanks,

Ramu.