cancel
Showing results for 
Search instead for 
Did you mean: 

IDOC TDline values udf

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 requirement is to create multiple target elements Notes,ID and Text 

In TDLine we are getting conditions with the following format.Need to concatenate each t&c in one node of text

E1EDKT2

TDLine ..                (1) some text for terms and conditions

E1EDKT2

TDLine                        continutation of (1) text for t&C

E1EDKT2

TDLIne                          continuation (1) text for T&C

E1EDKT2

TDLIne                          continuation (1) text for T&C


E1EDKT2

TDLIne                         (2) some text for terms and conditions

E1EDKT2

TDLIne                          some text for terms and conditions

E1EDKT2

TDLIne                          some text for terms and conditions

E1EDKT2

TDLIne                         (3) some text for terms and conditions


For each T&C We need to created separate Notes ,Id  and Text in target elements


Expected Target

Notes

Id >ID1 >

Text >(1)Sometext for terms and conditions continuation(1) text for t&C Continuation of (1) text for T&C


Notes

Id >ID1 >

Text >(2)Sometext for terms and conditions continuation (2) text for t&C Continuation of (2) text for T&C

Notes

Id >ID1 >

Text >(3)Sometext for terms and conditions continuation (2) text for t&C Continuation of (2) text for T&C

I need your help please

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mahesh

Please provide us the sample data for TDLINE so that we can provide u the necessary mapping.

From the existing data, its impossible to provide the solution.

former_member452321
Participant
0 Kudos

Hi Indrajit

Thanks for your response.Attached sample data I am looking for each T&C in one text node of target(which is concatination couple of tdlines)
we need to split concat tdlines based T&C nos (1) ,(2) we need to contact to target text

Target

Notes

ID ID1

Text (T&C 1)

Notes

ID ID1

Text  (T&C2)

former_member452321
Participant
0 Kudos

Can we concatenate TDLines based on numbers (1),(2) and create target nodes for each (1),(2) etc...

former_member452321
Participant
0 Kudos

Hi Indrajit

Is there any way to solve the above issue ?

former_member452321
Participant
0 Kudos

Hi Indrajit,

Is there any solution for this issue. I will appreciate your help

Thanks

Former Member
0 Kudos

Hi Mahesh

Do the mapping as below

write two udf. One for populating text and one for populating notes. Choose all values of context option in UDF. Also set the context of TDLINE to e1edkt1.

Populate Notes code :


for ( int i = 0; i < tdlines.length; i++)

{

for ( int j = 0; j < tdlines.length; j++)

{

String txt = "("+j+")";

if ( tdlines[i].indexOf(txt) != -1 )

result.addValue(tdid[0]);

}

}

Populate Text:

int count = tdlines.length;

ArrayList list = new ArrayList();

String text = "";

int cnt = 0;

int start = 0;

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

{

for ( int j = 2; j < tdlines.length; j++)

{

String txt = "("+j+")";

if ( tdlines[i].indexOf(txt) != -1 )

{

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

{

text = text + tdlines[k];

}

start = i;

list.add(text);

list.add("CC_");

text = "";

}

}

}

for ( int m = start ; m <  tdlines.length; m++)

{

text = text + tdlines[m];

}

list.add(text);

for(int i = 0;i < list.size();i++){

  if(list.get(i).toString().equals("CC_"))

     result.addContextChange();

  else

    result.addValue(list.get(i).toString());

}

Output:

Let me know if there are any issues.

former_member452321
Participant
0 Kudos

Thank you vey much Indrajit. I appreciate your help. Only one issue is The first TC is combined with initial text as per attached screen shot. I changed the variable J= 0 or 1 and it is coming properly but then last tc is missing . Toal i have 6 +  some intial text before (1). Total I am geting 6 elements not 7 .Attached expected screenshot but in that 6 th TC is not populating

Former Member
0 Kudos

Hi Mahesh

I have written the code based on the assumption that the first TDLINE will have the value of terms.Hence it is not working as expected. I have modified the code now. The new code will handle both the cases

1. First TDLINE has terms ( example (1) some text for terms and conditions  )

2. First TDLINE does not have terms data

Code:

Populate Notes:

String adtext = tdlines[0];

boolean flag = false;

for ( int j = 0; j < tdlines.length; j++)

{

String val = "("+j+")";

if ( adtext.indexOf(val) != -1 )

flag = true;

}

if ( flag == false )

{

result.addValue(tdid[0]);

}

for ( int i = 0; i < tdlines.length; i++)

{

for ( int j = 0; j < tdlines.length; j++)

{

String txt = "("+j+")";

if ( tdlines[i].indexOf(txt) != -1 )

result.addValue(tdid[0]);

}

}

Populate Text:

int count = tdlines.length;

ArrayList list = new ArrayList();

String text = "";

int start = 0;

int firstcount = 0;

String adtext = tdlines[0];

boolean flag = false;

for ( int j = 0; j < tdlines.length; j++)

{

String val = "("+j+")";

if ( adtext.indexOf(val) != -1 )

flag = true;

}

if ( flag == false )

{

firstcount = 1;

}

else

{

firstcount = 2;

}

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

{

for ( int j =  firstcount; j < tdlines.length; j++)

{

String txt = "("+j+")";

if ( tdlines[i].indexOf(txt) != -1 )

{

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

{

text = text + tdlines[k];

}

start = i;

list.add(text);

list.add("CC_");

text = "";

}

}

}

for ( int m = start ; m <  tdlines.length; m++)

{

text = text + tdlines[m];

}

list.add(text);

for(int i = 0;i < list.size();i++){

  if(list.get(i).toString().equals("CC_"))

     result.addContextChange();

  else

    result.addValue(list.get(i).toString());

}

This will give you the desired output.

former_member452321
Participant
0 Kudos

Thank you very much . It is working as expected

former_member452321
Participant
0 Kudos

Hi Indrajit.

I have a small request. It is working perfect and only the issue is the nos of terms and conditions like (1) ,(2) which are coming in the begining of TDlines .But sometimes there are nos (15)  in the middle of text in the terms and conditions. Is there any we can modify it so that it looks only in the begining of tdline and not any where in TDLINE or any other thoughts

example

TDLINE (1)This is for testing This is for testing

TDLiNE (2) This is for testing of (5)scenario and testing of scenario(6).

TDLINE (3)This is for testing This is for testing

In the above case Notes splitting at (5) and (6) which is not correct.

Not sure whether it is possible or not

Thanks for your help

Former Member
0 Kudos

Hi Mahesh

Make a small change in both the UDF's

Replace if ( adtext.indexOf(val) != -1 )  with if (adtext.startsWith(val))

and

if ( tdlines[i].indexOf(txt) != -1 ) with if ( tdlines[i].startsWith(txt))

This should work.

Answers (2)

Answers (2)

former_member452321
Participant
0 Kudos

Currently we have 12 terms and condiitons . I was tying to hardcode no of terms and conditions.I To get the value of substring of tdline = (1)  ,(2),(3) which is each terms and conditions .I need to contactenate all the values of (1),(2),in each different target text node.. I am trying with the following but it is not working.I am able to get the required Notes and IDs in the taget but the TDLine getting exception

Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD

can anyone help .please

String concatText="";
String TCCheckfield = "XXXXXXXXXXXXXXXXX" ;
  
  for(int i=0;i<tdline.length;i++)
                   {
                      // concatText = concatText + "" +  tdline[i]    ;
                       for (int j= 0;j>=17;j++)

                         {
                                 if (tdline[i].substring(0,2).equals(j))
                           trace.addInfo("inside tc  condition" + "" + j );
                                      {
                                      concatText = concatText + " " +  tdline[i]   +"\n" ;
                                        trace.addInfo("inside tdi other  condition" + "" +  tdline[i]);
                                          result.addValue(concatText) ;
                                      result.addContextChange();
          
                                         }
                         }
           // result.addValue(concatText) ;


}


markangelo_dihiansan
Active Contributor
0 Kudos

Hello Mahesh,

Is there any identifier that will let you know that the text has ended for t&c? In your example, it may be possible to group the t&c if there is a number before it e.g (1).

Regards,

Mark

former_member452321
Participant
0 Kudos

Thanks you Mark. There is not spefific identifier in the IDOC . They dont want to add anything in IDOC . For some they did ; for some . etc