cancel
Showing results for 
Search instead for 
Did you mean: 

Context mapping based on a condition

Former Member
0 Kudos

Hi All,

I have the following mapping requirement :

Source Structure : Multiple delivery document with line numbers,batch numbers ,toteid's & Serial numbers.Each row in the table below is a record (0.. many).

One Target Idoc is created for one delivery.

Del#Item#Batch#MaterialSerial#ToteIDQty
123101ABC
81232
123201DEF
81233
1241089ABC
81232
1241090ABC
81244
124201ABC
81233
125101XYZ788101
125101XYZ798101
125101XYZ808101
125101XYZ818101
125201XYZ
8101

Requirement:

I need to create a target segment ZE1DL37 ( 0...many) based on unique ToteId's received and only when the delivery has serial # . In the above scenario

it is deliver # 125 which as  the serial # populated and I need to create 1 ZE1EDL37 based on unique toteid (810) for that delivery.

How to proceed with this..

Any Help greatly appreciated..

Collins V

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Can you try this mapping?

For E1EDL37

The sort parameters that you see is only for the last sort.

For the sum:

The sort for the sum is as is.

Hope this helps,

Mark

Former Member
0 Kudos

Hi Greg and Mark ,

First of all 'Thank You' for both of you in providing the inputs on the mapping requirement.

Greg,

I tried your solution , it was almost there except for one condition , it gave one unique context in the end

with only 1 Z1EDL37 segment created but it was creating for the first delivery # 123 , instead it should create for delivery # 125.Please see the display queue output below.

Mark,

It worked exactly as required . Once again I am going to ask you explain the logic you had above if you don't mind . I guess the key to resolve the logic above is how to group the values for each column and try to see how we can group them based on formatByexample plus the other node functions ( removeContext,splitByValue,collapseContext,sort and sortbyKey), please correct me if I am wrong here.

Thanks again to both of you...

CollinsV

Former Member
0 Kudos

Mark,

There is another segment called ZE1EDL44 under ZE1EDL37 , which has to be created as many times the Line Item No and Serial Number , provided the serial number is not Blank.In the above scenario it will be for Delivery # 125 , I need to have 4 segments populated for ZE1EDL44 ( based on 4 serial numbers 78,79,80,81)

I am trying with the mapping logic below , but it is not working.Any thoughts on were I am doing wrong? I think the issue might be because ZE1EDL44 is under ZE1EDL37  which is not getting created for every Delivery Idoc.

E1EDL20

|_______ZE1EDL37 - 0...many - created for each unique toteid which has Serial number populated and not blank

                  |________ZE1EDL44 - 0....many  - Created as many times under ZE1EDL37 based on line item and serial number , provided serial number not blank

Regards,

Collins V

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

     Yes, you are correct, it all lies with context manipulation. Del is concatenated with ToteID and then sorted because it is not arranged. The sortByKey is used to sort the serial number in the same way as the concatenation of Del and ToteID. ValueChanged is used to group the same Del and ToteID together and then its grouping(according to context) is used to format the grouping of the Serial.

     Serial is sorted before the collapse context so that if ever the context contains a blank and a number, the number will be first. CollapseContext is used to remove duplicates The final splitByValue is used to group the original Del input and then its grouping will be used to format the result of the collapsed serial number.

     The ifWithoutElse is used to pass only the values of the serial in which is not a blank either the output is suppressed or with a value.

Regards,

Mark

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Collins,

I am unsure why it is not working for you. Here is the logic I am using for E1EDL44

The parameters for the last sort is displayed. And here is the test tab:

Hope this helps,

Mark

Former Member
0 Kudos

Hi Mark,

Thanks for your inputs again.

This is ZE1EDL44 segment not the E1EDL44 segment. This ZE1EDL44 segment is created as many times as the occurrence of Serial Number and Line Number for a delivery where the Serial Number field is not Blank.

In the above example it is Del # 125 and ZE1EDL44 will be created 4 times based on 78,79,80,81.

Let me try the mapping again replacing the toteid with Line number which you provided above.

Any thoughts...

Regards,

Collins

Former Member
0 Kudos

Mark,

The reason it is not working for me is ZE1EDL37 is created for each toteid for a delivery and ZE1EDL44 under it is created for each Line & Serial Number for a delivery combination.

And in the above example ZE1EDL37 parent of Z1EDL44 is not created for Del 123 and 124 and it is only created for Del# 125 first time under which we get Z1EDL44 for the first time and it is having the suppress context .

But if I add serial number to delivery 123 , I am getting ZE1EDL44 , since it is also having ZE1EDL37 parent.

How can I make sure when Z1EDL44 creates, it is executed for the right context? .

Please correct me If I am wrong here.

Any thoughts..

Collins

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Collins,

Since this is a

Root - 0..unbounded

Child - 0..unbounded

   Subchild - 0..unbounded scenario,

Context of Root = number of Context Changes of Child

Context of Child = number of Context Changes of Subchild

In the original example, there are only three unique del item. So its Child should contain at most 3 context changes. It is only on the last context change that (81) E1EDL37 will be created. Now, for its subchild, you may notice that there are 4 contexts in the logic for E1EDL37, three are suppressed and only one has a value. The output logic for E1EDL44 should be at most 4 context changes because each Suppressed from E1EDL37 corresponds to ONE context change in E1EDL44.

So even if I add a serial number to del 123

The output would be 1 E1EDL44 on the first E1EDL37, no output for the next two context change and 4 outputs on the last context change (for 81).

Hope this helps,

Mark

Former Member
0 Kudos

Mark,

I agree to your point above . But I am confused why it is not working for me. Can you try creating E1EDL37 only from the 3rd delivery and see what happens for E1EDL44 then.


I forgot to mention  , I am creating one Idoc for each delivery . So when I get multiple records with multiple delivery and their line item,batch details multiple Idocs are created for each delivery.

How segments should  be created

IDOC  ( 1...9999) 1 delivery per Idoc

|

E1EDL20 ( 1...9999) ONLY 1 segment per Idoc

|_______E1EDL18

|_______E1EDT13

|_______E1EDL24 (0...9999) multiple segments per line item for a delivery

|                    |_______E1EDL11 (for serialize items only)

|                   |_______E1EDL19

|_______E1EDL37 (0...9999) multiple segments created for each tote

|                  |_______E1EDL44 (0...9999) multiple segments created for each line item under each tote

|_______ZE1EDL37 (for serialized items only)  (0...9999) multiple segments created for each tote

                   |_______ZE1EDL44 (for serialized items only)  (0...9999) multiple segments created for each line item under each tote

Everything works above except for ZE1EDL44 segment below...

Regards,

Collins

Former Member
0 Kudos

Mark,

I was trying the above 'formatByExample' based on the below logic below till now

Serial --->

                    formatByExample

Del

+     ----->

LineItem

+

Serial

I changed mine as yours and it is working now.

How do you decide to try the formatByExample based on Serial# and Del+ToteId combination instead of mine above.

The reason I did above is since the requirement was " create as many segments for each line item and serial# combination based on serial# not blank

Thanks Again,

Collins

Former Member
0 Kudos

Mark,

I need your help again . The above mapping for E1EDL44 segment is created based on a condition .

What if I need to create the segment without a condition ? E1EDL44 segment needs to be created under each E1EDL37 based on number of line items for each tote.

The output based on above source would be

IDOC

     |E1EDL20

          |E1EDL37 = 8123

               |E1EDL44=10

               |E1EDL44=20

IDOC

     |E1EDL20

          |E1EDL37 = 8123

               |E1EDL44=10

               |E1EDL44=20

          |E1EDL37 = 8124

               |E1EDL44=10

IDOC

     |E1EDL20

          |E1EDL37 = 810

               |E1EDL44=10

               |E1EDL44=20

Thanks,

Collins V

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You just need to adjust your logic , for E1EDL37, the mapping should now look like this:

For E1EDL44, it looks like this:

The output is:

Hope this helps,

Mark

Former Member
0 Kudos

Mark,

Thank you again . How did you decide that you need to change the logic for E1EDL37 to get the mapping output for E1EDL44 ?

I have another field HIPO which is not working properly ...

IDOC  ( 1...9999) 1 delivery per Idoc

|

E1EDL20 ( 1...9999) ONLY 1 segment per Idoc

|_______E1EDL24 (0...9999) multiple segments per line item and batch# combination for a delivery

                     |

                HIPO --- If there are more than one Batch # for a lineItem# then populate this field with lineitem# else Blank.

The output should be as follows for a delivery Idoc

IDOC (Del#124)

|

E1EDL20

|_______E1ED24

                    |____HIPO = 10

|_______E1ED24

                    |____HIPO = 10

|_______E1ED24

                    |____HIPO = <Blank>

can you help me over here..

I have the same question in another thread http://scn.sap.com/thread/3202668

Thanks,

C

Former Member
0 Kudos

Mark,

Any suggestion on the above mapping requirement.

I am trying with the below mapping and it is not working.

Thanks,

Collins

Answers (1)

Answers (1)

former_member184681
Active Contributor
0 Kudos

Hi,

So if I got it right, you want ZE1EDL37 to be created for each unique combination of Del# and ToteID, that has non-empty Serial#, is that correct? If so, here is how I would do that:

Serial -> mapWithDefault("") -> equalsS(constant("")) ->

                                  ifWithoutElse -> splitByValue(Value Change) -> collapseContexts -> ZE1EDL37

concat(Del, ToteID, separator ":") ->

Regards,

Greg

Former Member
0 Kudos

Yes Greg , your understanding is correct, but it is not creating the desired result.

Any other thoughts..

Regards,

Collins

Former Member
0 Kudos

Hi All,

Any thoughts on the mapping requirement above ?

Regards,

Collins

former_member184681
Active Contributor
0 Kudos

Hi,

I just had a quick review of the mapping and here is what it was missing:

- in the condition check for "ifWithoutElse", the negation was missine

- also, I forgot to mention that the context of the source fields should be switched to the header (delivery) level.

See the complete mapping now, I have already tested it on your example data and it works fine:

Regards,

Greg