cancel
Showing results for 
Search instead for 
Did you mean: 

Context challenge in graphical mapping

0 Kudos

I often have the challenge to deal with context differences in mappings if something has to repeat in the target that was on a higher level in the source. So far I have been able to solve most of it using use-one-as-many and latest since PI 7.1 and 7.3 I have been so happy to use mapping variables since this approach is much simpler, but now I have a new challenge that would normally push me to use a stylesheet mapping instead, but I really would like to find out if it is possible to do this with the graphical mapping:

My source looks somwthing like this (marked the interesting part with red😞

<Style>

    <Header>

        <Flags>

            <Flag>

                <Code/>

                <Reason/>

            </Flag>

            <Flag>

                <Code/>

                <Reason/>

            </Flag>

            <Flag>

                <Code/>

                <Reason/>

            </Flag>

        </Flags>

    </Header>

    <Details>

        <Detail>

            <BarCode/>

        </Detail>

        <Detail>

            <BarCode/>

        </Detail>

    </Details>

</Style>

My target should then look like this (again marked the interesting part with red😞

<Skus>

    <Sku>

        <BarCode/>

        <Flags>

            <Flag>

                <Code/>

                <Reason/>

            </Flag>

            <Flag>

                <Code/>

                <Reason/>

            </Flag>

            <Flag>

                <Code/>

                <Reason/>

            </Flag>

        </Flags>

    </Sku>

    <Sku>

        <BarCode/>

        <Flags>

            <Flag>

                <Code/>

                <Reason/>

            </Flag>

            <Flag>

                <Code/>

                <Reason/>

            </Flag>

            <Flag>

                <Code/>

                <Reason/>

            </Flag>

        </Flags>

    </Sku>

</Skus>

As you can see, this time I need a whole structure to repeat at a lower level.

For each 'Sku' the whole flags part has to repeat because the target application does not have a header level, only Sku level.

Has anyone come across something like this and did you manage to solve it using a graphical mapping ?

We are currently on PI 7.3 (dual stack) and there are quite a lot of new features since our 7.0.

Best regards Soren

Accepted Solutions (1)

Accepted Solutions (1)

ambrish_mishra
Active Contributor
0 Kudos

Hi Soren,

The requirement below seems more about how to link the Flag to the Detail. Is Flag-> Code and Detail-> Barcode same ?

More than the technical solution, I think the question should be how is header and detail related. Once you provide that input, technical solution can follow

Ambrish

0 Kudos

Hi Ambrish,

Yes I know it is a bit unclear.

The message is a product (style) with belonging details (sku variations).

For the product there are header fields that apply to all the product skus and then there are a number of skus (detail) with information that applies to the individual skus (in real life more than in the example).

One of the header informations is a list of flags for the style, and this list contains pairs of a flag code and the belonging reason text. Problem is that it is not fixed, there could be 2, 3, 10 whatever flags (0..unbound). But in the receiving system they do not operate with the term 'product' as we do, they only have skus. So I need to replicate the list of flags down at sku level (corresponding to my source 'detail' level) and repeat it for each sku.

It is not to complicated with stylesheet but I was currious if graphical mapping can also do this.

For single values I either use use-one-as-many or a mapping variable. But for a whole structure I am a bit lost 😉

Soren

ambrish_mishra
Active Contributor
0 Kudos

Hi Soren,

Can you provide some sample data from source(just an example with dummy but logical values) and expected target data.

Logic is required both for XSLT or graphical mapping. I am sure we will figure out a solution with graphical.

cheers,

Ambrish

Former Member
0 Kudos

Hello,

I think "use one as many" function will not be of much help, but having said that "return as xml" +  declaring variable functionality could actually help u in getting close to your desired structure .

Mapping Result

Thanks

Amit Srivastava

0 Kudos

Hi Amit,

That's a very clever solution and it does really work 😉

Well spottet to combine the new 'return as xml' with the new mapping variable.

Thanks a lot for the input.

Br Soren

Answers (1)

Answers (1)

former_member184681
Active Contributor
0 Kudos

Hi Soren,

This can be simply achieved with the useOneAsMany function, check more about it here:

http://help.sap.com/saphelp_nw04/helpdata/en/ef/df564b6aa24fc9ab0d685460747de5/content.htm

http://wiki.sdn.sap.com/wiki/display/XI/Explain+node+functions

Regards,

Greg

0 Kudos

Hi Grzegorz,

Thanks for the fast reply.

I know the use-one-as-many but I do not think it can do this specific mapping or if, at least, I do not know how to.

Maybe I was not specific enough but in the normal cases you are mapping single values from the header to be repeated in the lower level, that's fine. But here I have a repeating section (0..onbound) containing pairs of fields. The whole section of repeating pairs should be copied for each and every Sku that is also (0..unbound).

How do you use use-one-as-many with a first argument node that itself is

a repeting (0..unbound) node ?

Sounds more like a use-many-as-many...