Topic
• 15 replies
• Latest Post - ‏2014-02-20T10:18:29Z by Laurent(Satisco)
Jaango
77 Posts

# Pinned topic 2 groups in input and one group in output

‏2013-10-24T09:45:43Z | groups

I have two groups(group1 and group2) in the input typetree, both occurs 0 to 24 times.In the outputtype tree, have just one group(group3) occuring 0 to 24 times. If the group1 occures 24 times, i need the output to have group1, all 24 times filled. Whatever in the group2 should be ignored.

When group1 has items less than 24, then the items from group2 should be filled, till group3 is full. The rest of items in group2 can be ignored.

How do we do such mapping?

• Sidhumohan
34 Posts

#### Re: 2 groups in input and one group in output

‏2013-10-24T16:50:18Z

Call a functinal map in the output group-

put a rule like IF(COUNT(GROUP1)=24,FunctionalMap1(Gropup1),FunctionalMap2(Group2)).

This will process Count the number of occourances of Group 1 and if its 24 it will go to the first fucntional map and map the fields you want.

Else if the numbe rof occourances of Group1 is less than 24 it will call the second functional map. - Becausese the group of the output card is 0-24 it will call only 24 and will ignore the rest.

• Jaango
77 Posts

#### Re: 2 groups in input and one group in output

‏2013-10-25T04:03:12Z

Call a functinal map in the output group-

put a rule like IF(COUNT(GROUP1)=24,FunctionalMap1(Gropup1),FunctionalMap2(Group2)).

This will process Count the number of occourances of Group 1 and if its 24 it will go to the first fucntional map and map the fields you want.

Else if the numbe rof occourances of Group1 is less than 24 it will call the second functional map. - Becausese the group of the output card is 0-24 it will call only 24 and will ignore the rest.

Sorry if my question was not clear. If the count of group1 is less than 24, the output should be first filled with group1, rest should be filled with group2, till the total in output is 24

• vijji_WTX
126 Posts

#### Re: 2 groups in input and one group in output

‏2013-10-28T01:38:58Z
• Jaango
• ‏2013-10-25T04:03:12Z

Sorry if my question was not clear. If the count of group1 is less than 24, the output should be first filled with group1, rest should be filled with group2, till the total in output is 24

Well, same logic applies.

IF(COUNT(GROUP1) <24,FunctionalMap1(Gropup1),FunctionalMap2(Group2)). once you generate the F_maps, u have map accordingly

• Laurent(Satisco)
116 Posts

#### Re: 2 groups in input and one group in output

‏2013-12-04T07:33:55Z
• vijji_WTX
• ‏2013-10-28T01:38:58Z

Well, same logic applies.

IF(COUNT(GROUP1) <24,FunctionalMap1(Gropup1),FunctionalMap2(Group2)). once you generate the F_maps, u have map accordingly

This will not deliver what is needed. You need to call a functional map and pass it the two groups, then decide inside the functional map what data needs to be processed.

The calling rule would look like :

=FMap (CLONE ("A", 24), INDEX(\$), Group1, Group2)

Clone will make the fmap called 24 times, INDEX will tell you where you "stand".

In the FMap, comparing INDEX with COUNT(elements:Group1) will tell you if you want to map element[INDEX]:Group1 or the right element from Group2 (something like element[INDEX - COUNT(Group2)]:Group2 )

• Koml@g
1 Post

#### Re: 2 groups in input and one group in output

‏2013-12-10T09:41:35Z

This will not deliver what is needed. You need to call a functional map and pass it the two groups, then decide inside the functional map what data needs to be processed.

The calling rule would look like :

=FMap (CLONE ("A", 24), INDEX(\$), Group1, Group2)

Clone will make the fmap called 24 times, INDEX will tell you where you "stand".

In the FMap, comparing INDEX with COUNT(elements:Group1) will tell you if you want to map element[INDEX]:Group1 or the right element from Group2 (something like element[INDEX - COUNT(Group2)]:Group2 )

Hi Laurent,

Could you please elaborate on the above description? Suppose I have 2 group (with 0 to s Occurrence ) in input xml and this needs to be mapped to single group (0 to 24 Occurrence ) in the output xml , Could you please mention the calling rule for it?

I have not worked much on Clone function with functional map .Could you please explain the "A"  in the rule mentioned above?

• Laurent(Satisco)
116 Posts

#### Re: 2 groups in input and one group in output

‏2013-12-10T10:24:44Z
• Koml@g
• ‏2013-12-10T09:41:35Z

Hi Laurent,

Could you please elaborate on the above description? Suppose I have 2 group (with 0 to s Occurrence ) in input xml and this needs to be mapped to single group (0 to 24 Occurrence ) in the output xml , Could you please mention the calling rule for it?

I have not worked much on Clone function with functional map .Could you please explain the "A"  in the rule mentioned above?

Hi,

the "A" for the functional map is just a way to control the number of times the fmap is called. In my rule, the map will be called 24 times (from the second argument to CLONE) with the same "dummy" argument "A" (first CLONE argument)

Then, inside the fmap, you have to use INDEX to determine if you are still in first group, and then you map the INDEX(\$) occurence from group1, otherwise you'll map an occurence frm group2.

The "calling rule"  looks somewhat like

IF (Index < COUNT(Element:Group1),

Element[Index]:Group1,

Element[INDEX - COUNT(Element:Group1)]:Group2 )

• KomalaG
1 Post

#### Re: 2 groups in input and one group in output

‏2013-12-12T02:45:45Z

Hi,

the "A" for the functional map is just a way to control the number of times the fmap is called. In my rule, the map will be called 24 times (from the second argument to CLONE) with the same "dummy" argument "A" (first CLONE argument)

Then, inside the fmap, you have to use INDEX to determine if you are still in first group, and then you map the INDEX(\$) occurence from group1, otherwise you'll map an occurence frm group2.

The "calling rule"  looks somewhat like

IF (Index < COUNT(Element:Group1),

Element[Index]:Group1,

Element[INDEX - COUNT(Element:Group1)]:Group2 )

Hi

The calling rule is not taking the index the way you have mentioned.

• Laurent(Satisco)
116 Posts

#### Re: 2 groups in input and one group in output

‏2013-12-12T08:09:34Z
• KomalaG
• ‏2013-12-12T02:45:45Z

Hi

The calling rule is not taking the index the way you have mentioned.

In the rule, "Index" is the input card that receives the index.

• Ram_A
1 Post

#### Re: 2 groups in input and one group in output

‏2013-12-13T05:08:37Z

In the rule, "Index" is the input card that receives the index.

Hi Laurent,

Is it possible to pass dynamic index object to the element as the way you mentioned?

usually it takes an integer like Element[1]:Group1 or some standard functions like

Element[LAST].Group1

how to to pass an object like Element[index]:group1??

• Laurent(Satisco)
116 Posts

#### Re: 2 groups in input and one group in output

‏2013-12-17T09:34:10Z
• Ram_A
• ‏2013-12-13T05:08:37Z

Hi Laurent,

Is it possible to pass dynamic index object to the element as the way you mentioned?

usually it takes an integer like Element[1]:Group1 or some standard functions like

Element[LAST].Group1

how to to pass an object like Element[index]:group1??

Soory, I've been a bit fast and did cut the corners.

Of course, you need CHOOSE to select the proper piece of data, so the rule reads something like

IF (Index < COUNT(Element:Group1),

CHOOSE(  Element:Group1, INDEX),

CHOOSE( Element:Group2, INDEX - COUNT(Element:Group1))

There could be other issues (this is not an actual rule) but I hope you get the idea.

• prap
7 Posts

#### Re: 2 groups in input and one group in output

‏2013-12-19T20:26:58Z

if you are not modifying the data while mapping and if it just an append of the Group1 & Group2 based on their record Count, then it can be acheived as below,

IF(COUNT(GROUP1)=24,FunctionalMap1(PACKAGE(Gropup1), PACKAGE(Group2)),

FunctionalMap1(PACKAGE(Gropup2), PACKAGE(Group1))

Inside the Functional map treat the Input1 & Input2 as text Items and output card with 2 text elements and the Map the first element with first Input Card and second element with Second card.. If the terminators are causing any issue..then you can design the output card with Multilpe Blob fileds within Multiple Blob fields..Hope this will work.

• Jaango
77 Posts

#### Re: 2 groups in input and one group in output

‏2013-12-23T16:34:03Z
• prap
• ‏2013-12-19T20:26:58Z

if you are not modifying the data while mapping and if it just an append of the Group1 & Group2 based on their record Count, then it can be acheived as below,

IF(COUNT(GROUP1)=24,FunctionalMap1(PACKAGE(Gropup1), PACKAGE(Group2)),

FunctionalMap1(PACKAGE(Gropup2), PACKAGE(Group1))

Inside the Functional map treat the Input1 & Input2 as text Items and output card with 2 text elements and the Map the first element with first Input Card and second element with Second card.. If the terminators are causing any issue..then you can design the output card with Multilpe Blob fileds within Multiple Blob fields..Hope this will work.

Why cant we simply use

IF(INDEX(\$)<=(COUNT(GROUP1),FunctionalMap1(Gropup1),FunctionalMap2(Group2)).

Whenever is index of the output group is greater than groups1s count, group will be called.

• prap
7 Posts

#### Re: 2 groups in input and one group in output

‏2013-12-24T01:45:36Z
• Jaango
• ‏2013-12-23T16:34:03Z

Why cant we simply use

IF(INDEX(\$)<=(COUNT(GROUP1),FunctionalMap1(Gropup1),FunctionalMap2(Group2)).

Whenever is index of the output group is greater than groups1s count, group will be called.

Hi,

I am so sorry, I misunderstood the query. i thought, if grp1 count <24 then grp2 data should be mapped first & there is no max rec limit for grp3..:)..I do agree with with what "Laurent(Satisco)" has R8ly suggested.

- And, I also tried the below and it worked for me..you can also try. as the max occurrences (24) is fixed in type tree..you can directly try this ..
EITHER (REC:GRP1,
REC:GRP2)

.....assuming..the input grp1, grp2, are with same structure & hierarchy.. the above should work other wise you will get an error message saying "Output argument of rule does not match output item sub-class"

Note: I tried it by passing the data as text blob (Package of GRP1) & Package of GRP2 & using the Either function..it gave results as expected..:)

• PranavShankar
3 Posts

#### Re: 2 groups in input and one group in output

‏2014-02-19T16:40:00Z

you can use the below rule

=If (COUNT(GROUP1)<24, F_Create_1(Group1,Group2),IF(COUNT(GROUP1)=24,F_Create_2(Group1),IF(COUNT(GROUP1)>24,F_Create_3(Group1))))

as the output repetition is fixed to 24, this should work.

• Laurent(Satisco)
116 Posts

#### Re: 2 groups in input and one group in output

‏2014-02-20T10:18:29Z

you can use the below rule

=If (COUNT(GROUP1)<24, F_Create_1(Group1,Group2),IF(COUNT(GROUP1)=24,F_Create_2(Group1),IF(COUNT(GROUP1)>24,F_Create_3(Group1))))

as the output repetition is fixed to 24, this should work.

Don't know if this is still a current topic, as I hope Jaango has finally implemented what he needed originally, but there are two remarks on your suggestion (at least for me, of course):

1) there is only one test needed, and it's IF (COUNT(GROUP1)<24 as in this case there is a need to call a specific functional map. But if count is equal or greater than 24, F_Create_2 can be used and will not be called more than 24 times, as the output range is 24.

2) F_Create_1 will be called with both groups, but it will need to "loop" as many times as needed (24), and for each "loop", to select what item to extract, so you need another functional map that's called similarly to what I wrote earlier.