cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help For this logic

Former Member
0 Kudos

Hi frnds,

i have to map to fields

Source: Target:

Texto(256 max length) -


> Txt_Line(132 max length) with occurance 0:6

If the Texto field from source side contains more than 132 chars length text then it has to create another Txt_line field on target side..

Ex: if a text of 256 chars comes it has to create two Txt_line fields on Target of 132 and 124 size resp..

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

This is possible via UDF.

Texto(256 max length) -


> Txt_Line(132 max length) with occurance 0:6

Here is the mapping:


Textto --> UDF --> splitByValue:eachValue --> Txt_Line

UDF is of context type

Argument: input


	StringBuffer sb = new StringBuffer(input[0]);
		double cnt = Math.ceil((double)input[0].length()/132);
		for(double b=0;b<cnt;b++){
			if(sb.length()<132)
				result.addValue(sb.toString());
			else
			{
				result.addValue(sb.substring(0,132).toString());
				sb= new StringBuffer(sb.substring(132,sb.length()));
			}
		}

Hope this helps,

Mark

Former Member
0 Kudos

Hi Mark your UDF worked thanks for that. But there was an updation in requirement now

The present reqrmnt is

the TXT_line occurance is changed to 0:1

and the node in which it comes on the output has to repeated ..

ex: If the no.of chars are greater than 132 then output should be like

>Text(Node in which the element exist)

--Txt_line(first 132 chars)

>Text

--Txt_line(Chars greater than 132 should be there)

Kindly Help me on this..

RKothari
Contributor
0 Kudos

Hello,

For your new requirement use the below logic with the use of UDF provided by Mark:

On Node Text:
Textto --> UDF --> Text

On Text line element:
Textto --> UDF --> splitByValue:eachValue --> Txt_Line

-Rahul

Former Member
0 Kudos

Thanks Mark and Rahul

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Use UDF : Advance Type

Steps to perform in UDF is :

Find length of String ,

Substring it aftet every 124 Characters .

Then using addValue add it into ResultList Type result Element , One by One ..

So Now ur result of UDF Contains all Substring element in different Index.

Simply Pass it to Target Side , There is no need to Use SplitByValue .. Because SplitBy value is used Only When you want to change the Index.

Do You want UDF also for this ... ??

Regards

Prabhat Sharma.

former_member191435
Contributor
0 Kudos

Hi King Kiran,

Can you please follow the below Mapping for ur condition.

First duplicate the target field which u want.

Now here is the maping.

Sourcefield--->length

less(text function) if without else----


> Target Field1

Constant 132 source field

for duplicated i.e the output for more than 132 fields u have to follow below mapping

Sourcefield--->length

greater(text function) if without else----


> Target Field2

Constant 132 source field

Thanks,

Enivass

Former Member
0 Kudos

Hi,

Check the length of the string (text_to) if it is greater than 132 then use substring(0,132) and map to target1..

and substring (132,..) remaining to the another target field..

I am not sure whether lenght function is there or not ..if not UDFcan be used..

HTH

Rajesh

Former Member
0 Kudos

Hi Rajesh ,

There are not 2 diff fields on target side. one field has to be produced twice if lenght is >132

Former Member
0 Kudos

Hi,

generate the duplicate element on the target side and use createIf function...and the condition should be as mentioned above..i.e create if length is greater than 132 and pass the substring value to target...

no need to use UDF also..

HTH

Rajesh