cancel
Showing results for 
Search instead for 
Did you mean: 

Udf for multiple target nodes from one source

former_member452321
Participant
0 Kudos

Here is the source and target structure
udf for Multiple target nodes
source                        Target

e1edkt1   0..99                 Notes 0.1000
   TDID   0..1                      ID   0.1
   E1EDKT2  0..999999               Text  0..1
     TDLINE  0..1
my requiremtn is to create multiple target elements Notes,ID and Text
For each EDKT2>TDLINE> of 30 lines TDLINES, in target has to create separate  Notes and ID  , Text
  I need to concatenate all the 30 lines TDLINE to Text and next 30 lines to next node and corresponding TDID to corresponding
TDID of Notes
I need help udf for edkt1>Notes,TDID>ID,TDLINE>Notes

Thanks for your help

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mahesh

Please do your mapping as below

Notes will be created based on the count of TDLINE. Below is the UDF code. Use all of context option

int count = Integer.parseInt(segcount[0]);

for (int i = 0; i < count; i = i+30)
{
result.addValue("");
}

field mapping

Since the same TDID will be used in both the notes, we have to use the function use one as many

Next we need to write one more UDF for populating text

code :

int count = tdline.length;

String text = "";

int cnt = 0;

int start = 0;

for ( int i = start; i <count; i++)

{

  cnt = cnt + 1;

     text = text + tdline[i];

  if ( cnt % 30 == 0)

  {

  result.addValue(text);

  start = start+ 30;

  }

}

String data = "";

for ( int i = start; i < count ; i++)

  {

   data = data + tdline[i];

  }

result.addValue(data);

field mapping

Output:

I have used 34 TDLINE as input

former_member452321
Participant
0 Kudos

Hi Indrajit

Thank you very much your help. I have two  questions.

1) E1EDKT1
  ST
E1EDKT2
  TDLIINE
E1EDKT2
  TDLIINE
E1EDKT2
  TDLIINE
....
  .... REPEATING 135  This one created Notes and ID 5 times which is expected.
E1EDKT1
  FO1
E1EDKT2
  TDLIINE
E1EDKT2
  TDLIINE
E1EDKT2
  TDLIINE this one only 10 TDLINEs but it has to create notes for this one also.

  This second part Notes and ID  is not created in target

Dont we need to map Notes to EDKT1 so that it will create all instances of Notes .

2) In populate text code , it is concatanting 30 lines but the seconde node also again adding first 30 lines of text + another 30 lines. in the same way 3rd notes text also ..The second node sjhould start from 31 lines and third one should start from 61 line.I set context also as you suggested

Thaniks for your time and I appreciate your help

Thanks for your help

Former Member
0 Kudos

Hi Mahesh

I have tested with two E1EDKT1 segment. First one is having 142 TDLINE and the next one is having 10 TDLINE.

I can see that 6 NOTES have been created. 5 for first case and 1 for second case.

So make sure you have done the following

You have choose the execution of UDF is All value of Context

set the context of TDLINE to e1edkt1.

for Text node, yes there was a small mistake in the code. Here is the correct code

int count = tdline.length;

String text = "";

int cnt = 0;

int start = 0;

for ( int i = start; i <count; i++)

{

  cnt = cnt + 1;

     text = text + tdline[i];

  if ( cnt % 30 == 0)

  {

  result.addValue(text);

  start = start+ 30;

      text = "";

  }

}

String data = "";

for ( int i = start; i < count ; i++)

  {

   data = data + tdline[i];

  }

result.addValue(data);

Please test and let me know if there are any issues.

former_member452321
Participant
0 Kudos

Hi Indrajit,

I used the above code and it is working as expected. Thank you very much

.I am getting the tdid from fixed values

I have small requirement  for TDID

If the TDline>30 and if TDID is F01 ,then Then F01 should be displayed as F01-cont

can we do this with graphical mapping ?

Thanks

Former Member
0 Kudos

Hi Mahesh

Use the below mapping for TDID to ID. This will provide you the desired output

former_member452321
Participant
0 Kudos


Hi Indrajit

Thank you very much. How do I give  the points for the answers. Or it will be automatically given by scn .Sorry I dont know this

Former Member
0 Kudos

Hi Mahesh

Since you have marked my answer as correct and helpful, I already got the points.

Thanks a lot for doing that, this keeps us motivated to help others in the community.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Mahesh,

You can use following UDF to concat 30 source fields.

hope it helps.

Thanks,

Aman

Message was edited by: Aman Mishra Correct code is addded.

gagandeep_batra
Active Contributor
0 Kudos

How you map TDID  to target so you define that TDLINE are corespond to particular TDID

so your strucutre look like

root

     TDID     0..1

     Notes     0..1000

          ID     0..1

               Text     0..1

Plz confirm..

Regrds

Gagan           

former_member452321
Participant
0 Kudos

Hi Gagan

Source and Target structure attached.

I was able to generate the multiple nodes by using the code by Indrajit.

But I am not getting the if more than one EDKT1 segments in the source ,I am always getting only  to the target with multiple nodes for that EDKT1 .

Not getting for second EDKT1 nodes in the Target

Thanks for everyone for the help

EDKT1                                                                                                                      Notes

TDID   =ST                                                                                                                ST

     EDKT2                                                                                                                   Test1Test2Test3

        Test1                                                                                                                                                                                     

EDKT2          

        Test2

EDKT2    

         Test3

EDKT1                                                                                                                  Not getting created Note for this                                                                                                                                                                                                                       

F01                                                                                                                                                                                                                              

                                                                                                                                                                               

EDKT2          

        Test2

EDKT2    

         Test3