cancel
Showing results for 
Search instead for 
Did you mean: 

Counter

Former Member
0 Kudos

Hi All,

In my IDOC there are three item segments E1J3AIT, E1J3AIS, E1TXTH9.They are linked to three different structures SI1, SI2, SI3. I am creating a flat file.

In the target structure there is one common field counter. Now if my first segment has 3 items, 2nd segment has two items and if my 3rd segment has 3items my counter field in my output should start from 0 and end with 8. How can I achieve this? Your help will be highly appreciated.

korobee

Accepted Solutions (1)

Accepted Solutions (1)

claus_wallacher
Active Participant
0 Kudos

Hi Korobee,

I checked your issue one more time and found a problem with the first mapping. Youi should use the following mapping for your counter in I3INT1:

      <i>MAKTX</i> 
              equalS --> creatIf --> indexUDF --> SplitByValue --> counter
Constant[Y] /

The function indexUDF is a user defined function with the following code (use cahe = Context):

 int cnt = 1;

   for (int j = 0; j < a.length; j++){
     if (a[j].equals(ResultList.SUPPRESS )) {
        result.addSuppress();
     }
     else {
        result.addValue(Integer.toString(cnt));
        cnt++;
     }
  }

This should solve your problem.

Regards,

Claus

Former Member
0 Kudos

Thanks Claus. It works with a boom. Thanks for your continous support claus.

korobee

Answers (3)

Answers (3)

claus_wallacher
Active Participant
0 Kudos

Hi Korobee,

just to complete your scenario. If you have a condition in your first structure (coming from E1J3AIT) just replace E1J3AIT with the following logic in all three of the mappings I decribed above.

      <i>MAKTX</i> 
              equalS ----
Constant[Y] /               ifWithoutElse -->
              Constant[] /

You need to change the context of <i>MAKTX</i> to one level higher.

Regards,

Claus

claus_wallacher
Active Participant
0 Kudos

Hi Korobee,

I think I understood your problem. I can give you a solution for the case where you map all segments E1J3AIT. With your IF condition it becomes a little more complex, but I think you can adjust my suggestion yourself to get the complete solution.

You need to create 3 mappings, one for each of the segments I3INT1, I3INT2, I3INT3.

The first mapping simply looks like:

E1J3AIT --> index --> splitByValue --> COUNT (of I3INT1)

The second mapping looks like:

E1J3AIT --> count 
                    add --> splitByValue --> COUNT (of I3INT2)
E1J3AIX --> index /

The third mapping looks like:

E1J3AIT --> count 
                    add ---------------- 
E1J3AIX --> count /                       add --> splitByValue --> COUNT (of I3INT3)
                      E1TXTH9 --> index /

Regards,

Claus

claus_wallacher
Active Participant
0 Kudos

Hi Korobee,

can you please provide me with a sample input file and the output you like to see? If I understand you correct, you have one segment in your target node that needs to be filled from three different IDOC segments. Is that correct?

Then your main challenge would be to get the mapping for this node working. Once this is done, the counter is an easy exercise using the function index.

Regards,

Claus

Former Member
0 Kudos

Claus,

I have three segements from IDOC and needs to be mapped with three structures. Basically my structure is same for all the three. So I have made one structure and made an duplicate subtree for the other two. My mapping is working fine. In my target there is a counter which needs to be incremented for every item.

Also I have a conditon for my first structure in my target. I am checking a condition for one field and if it is true then I am mapping in the target else I am not mapping. Here my mapping is working fine except the counter. So can you please help me out in resolving the issue?

My input has three segements E1J3AIT, E1J3AIX, E1TXTXH9. My E1J3AIT has a field MAKTX. If it has the value "Y" then only I am mapping it to my target else I am not mapping the node at all.

E1J3AIT

ZPKT

MAKTX

E1J3AIS

E1TXTXH9

My target is:

I3INT1

I3INT2

I3INT3

So I have mapped:

MAKTX ---> RemoveContexts

= IF -> Then ZPKT-> RemoveContexts --->I3INT1

Constant"Y"

E1J3AIS ---> RemoveContexts --->I3INT2

E1TXTXH9 ---> RemoveContexts --->I3INT3

In my Input I have 3ZPKT and if one fails then I have to map the rest two and my counter should have 1 and 2. And if my E1J3AIS has 2 records then my counter should be added with my previous ZPKT and it should show 3 & 4 and if my E1TXTXH9 has 2 records then my counter should have 4 & 5.

I hope we both are at the same level. IF you find some difficulty in understanding my requirement let me know.

korobee