cancel
Showing results for 
Search instead for 
Did you mean: 

Complex IDOC mapping problem

Former Member
0 Kudos

Hello,

I'm stuck with a complex mapping issue that I can't figure out. I'm trying to pull 0..N Variant Configuration segments from the ORDERS IDOC and map it into a 0..N XML segment.

The inbound ORDERS IDOC is structured like this:

IDOC

...E1EDP01 (Item segment 0..N)

......E1EDP19 (Product data 0..5)

...........Z1EDPIT (Configuration Data 0..N)

.................ATUE1 (Description)

.................ZCODE (Category)

.................RTWTB (Value)

Target XML:

Order

....Item (Item segment 0..N)

.......Product (Product data 0..1)

............VariantConfig (configuration data 0..N)

....................Description

....................Category

.....................Value

I need to create a new VariantConfig segment in my XML for every Z1EDPIT segment for that PO Item. But I need to skip any Z1EDPIT segments when ATUE1 = 'OPTIONS' or when ATUE1 does not exist.

The problem I'm running into is that my mapping is capable of creating the VariantConfig segment under those conditions but the following mappings used to create the Description/Category/Value are unable to skip the Z1EDPIT segments.

For example:

IDOC

...E1EDP01

......E1EDP19

...........Z1EDPIT

.................ZCODE = REQT

.................RTWTB = 5644

...........Z1EDPIT

.................ATUE1 = Finish

.................ZCODE = REQT

.................RTWTB = 7712

The output XML should read:

Order

....Item

.......Product

............VariantConfig

....................Description = Finish

....................Category = REQT

.....................Value = 7712

So I determine to create the VariantConfig segment if ATUE1 exists and does not equal 'OPTIONS'. So my mapping creates one VariantConfig segment because the second Z1EDPIT qualifies. But each element within that node is reverting back to the first Z1EDPIT segment.

I thought the top of the Node (VariantConfig) would determine the context for the following fields. Therefore, when the 2nd Z1EDPIT segment generates the VariantConfig node then the elements should refer to the current context of the root node (VariantConfig).

What tools does PI's mapping provide to resolve a situation like this?

Any suggestions?

Thanks,

Matt

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

Hi Matthew,

You need two elements to make it work as per your requirement:

1. The standard mapWithDefault function for all the fields of the VariantConfig node.

2. Setting the original context for all those fields.

Hope this helps,

Greg

Answers (8)

Answers (8)

Former Member
0 Kudos

I have this working now.

I put the top level node (VariantConfig) at the E1EDP01 context. And each sub element at the Z1EDPIT context. Then used mapWithDefault to replace any missing fields with a space. Then I wrote a UDF to loop through each Z1EDPIT segment and weed them out as needed.

Thanks,

Matt

Former Member
0 Kudos

Ok, I've discovered something today.

mapWithDefault and exists do not create a new value when the input field does not exist.

So with the following input segements my mappings are only returning one value:

IDOC

...E1EDP01

......E1EDP19

...........Z1EDPIT

.................ZCODE = REQT

.................RTWTB = 5644

...........Z1EDPIT

.................ATUE1 = Finish

.................ZCODE = REQT

.................RTWTB = 7712

ATUE1->mapWithDefault [OPTIONS]-->results in one value "Finish"

ATUE1 >exists->If-->Then[ATUE1]>Else[OPTIONS]--->resulsts in one value "Finish"

Why aren't these mappings returning 2 values using Display Queue "OPTIONS" & "Finish"?

Even the UDF I'm building can't work unless I can identify the Z1EDPIT segments that are missing the ATUE1 field...

Any ideas?

Thanks,

Matt

0 Kudos

Matt,

Unfortunately, I do not have access yet to create objects in my current system. But anyways I understand your question.

If you want to see the missing field in the queue, change the context of that field to a higher (ATUE1 or above) level and then use mapswithdefault function, then check the queue again.

On your previous post, you asked me a question u2013 what do I mean by u201Cadd a context change for the fieldsu201D. What I really meant was, include a context change (I think there should be function called u201Csplit by valueu201D under node functions) after each value for the fields.

If you still need help with this, lets try to take it offline and get it done.

Thanks

Job.

Edited by: Job Daniel on Feb 26, 2012 1:30 PM

Former Member
0 Kudos

Job,

Thanks, for the responses!

What do you mean by "add a context change for the fields".

Is there some mapping function to add a context change or is this a UDF I need to write to handle the context changes when ATUE1 is missing or equal to "OPTIONS".

In my example:

VariantConfig:

ATUE1 (E1EDP01) >mapWithDefault [OPTIONS] equatsS [OPTIONS] -


> Not -
>createIf->VariantConfig

Sub Element

Category

ATUE1 (E1EDP01) >mapWithDefault [OPTIONS] equatsS [OPTIONS] -


> Not -
>ifWithoutElse>ZCODE->Category

The problem is that this does not keep the ATUE1 and the ZCODE in the same Z1EDPIT segment. So I get the first ZCODE value when I only want the 2nd. Even if I insert a context change I can't say for sure that next time I won't have 5 Z1EDPIT segments missing the ATUE1 segment before I find my first good segment that I need to map.

...confused...

Thanks,

Matt

Former Member
0 Kudos

Job - Thanks for the reply. The problem is there are no unique identifiers in the Z1EDPIT segment. So i can't see how a variable to could accurately refer to a specfic segment.

Arvind - The problem with that solution is that the wrong segment is the 1st segemnt. So when I use createif it skips the 1st segment.

I am now working on a UDF to handle the queues.

Thanks for all the suggestions.

Matt

0 Kudos

Matt,

I understand you are working on a UDF to make it work. But as long as mapping for variantconfig is correct, the same mapping should work for the fields underneath variantconfig segment. I would just add a context change for fields. We can trust the queue and its sequence of values.

just my 2 cents.

Thanks

Job.

Edited by: Job Daniel on Feb 21, 2012 2:54 PM

Former Member
0 Kudos

Iu2019ve tried both proposed solutions and many variations of each. So far I get either no VariantConfig node created or the node is created with the data from the wrong Z1EDPIT segment.

Greg u2013 When the mapping in the top node VariantConfig has ATUE1 set to the original context (Z1EDPIT) the queue looks like this:

Suppress

Context change

[]

So no VariantConfig Node is created.

Ravi u2013 The mapping you describe works fine until the ATUE1 field does not exist in the Z1EDPIT segment. Once that happens the VariantConfig node is created but uses the value from the wrong Z1EDPIT segment.

It seems like this should be a relatively common scenario but it feels like the only solution is to write a UDF to scan through all the Z1EDPIT segments on each line and prevent this mix up when ATUE1 is not present.

Any suggestions?

Thanks,

Matt

0 Kudos

Matt,

The fields under the variantconfig segment do not take the contexts automatically. You will need to use the same condition you used for variantconfig segment to the elements also. If this is a big or complicated condition, create a local variable, assign map (the one you used for variantconfig) to the variable and use that variable for elements below that segment. The only disadvantage in using the local variable would be that you can not test that with test mapping instance, will return a null. But should work at runtime.

Thanks

Job.

Former Member
0 Kudos

using createif shud solve this as it wud create the first Variant config and suppress the second so ur fileds for th esecodn node won't give an error

Former Member
0 Kudos

Thanks, again.

But the problem is that when I try to add this ATUE1 check the contexts don't match up. If I have ATUE1 set to E1EDP01 context then I get the values for the first segment when they appear (category and value). If I have the ATUE1 check set to Z1EDPIT then it. Then I get a blank VariantConfig segment.

Any other suggestions?

Thanks,

Matt

former_member181962
Active Contributor
0 Kudos

Hi Matt,

Try this idea

Set the context of ATUE1 as (E1EDP01)->MapWithDefault->Equals( Othe input "") ->Not -.CreateIf ->VariantConfig node

Then for the fields, just map them as they are.

I have tested with a similar case and tested. It works for me. Let me know if you wnat to show you the screenshot.

Best Regards,

Ravi

Former Member
0 Kudos

Thanks, Ravikanth.

I just tried this process and it produced the same results

I also tried variations of the context of ATUE1. When the context of ATUE1 is E1EDP01 the elements under VariantConfig get only the first values from Z1EDPIT (which should be skipped). When the context of ATUE1 is Z1EDPIT I get no VariantConfig segment.

I guess the question is why the sub-elements of VariantConfig are not using the same Z1EDPIT segment that was used to create the VariantConfig node.

Any ideas of what I am doing wrong?

Thanks,

Matt

former_member181962
Active Contributor
0 Kudos

Hi Matt,

I see your point. The problem arises if there is a subfield that does not exist. that messes up the whole sequence of fields.

What you can probably try is to use a mapWithDefault for all the subfields mapping.

Let me know if that helps.

Best Regards,

Ravikanth Talagana

former_member181962
Active Contributor
0 Kudos

Hi Matt,

This looks doable to me.

Can you consider ATUE1 = space the same as ATUE1 not existing? If yes you can do the following

ATUE1->MapWithDefault(Default value "")->(String function)Equals (Other input "OPTIONS")->Not->IfWithoutElse(pass constant to output node VariantConfig.

Best Regards,

Ravikanth Talagana