cancel
Showing results for 
Search instead for 
Did you mean: 

Need help in writing UDF?

Former Member
0 Kudos

Hello All,

I dont have knowledge in java code, so iam posting this Q.

I have one requirement.

i have 50 line of data in any of the line contain key word say as DOCTYPE then i need to remove the line and send space to the target side.

iam using file adater at sender side and grahical mapping.

how to achive this. Please send the java code.

Thanks n Regards,

Chinna

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Chinna

Could you please elaborate a bit on your requirement.

Do you have a flat-file in source with 50 lines in it?

If so no need to use UDF for this. Just use ifWithoutElse to the target node in graphical mapping.

Source field-> If(DOCTYPE) then (blank contant) -> target NODE

Incase there's no DOCTYPE teh node would be suppressed for that instance automatically.

Regards

Soumen...

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi chinna,

i have 50 line of data in any of the line contain key word say as DOCTYPE then i need to remove the line and send space to the target side.

Step1: map the source element to the udf.

step2:UDF

All value of conext

input:records,result,container

output:void

udf code:

-


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

{

if(records<i>.contais("DOCTYPE"))

result.addValue(" ");// u can specify the number of spaces if u want more to be in target. If u want only.

result.addValue(records<i>); // This is default else condition adding the contents tio target.

}

-


Please change the context of source to parent.

I hope this will solve ur prblm

Babu

former_member200962
Active Contributor
0 Kudos
i have 50 line of data in any of the line contain key word say as DOCTYPE then i need to remove the line and send space to 
the target side.

DOCTYPE will be in some node of the DT that you define in IR.

Node -->
                 -->equalS --> IfWithoutElse (Then --> Constant_with_SPACE as parameter) --> Target
Constant(DOCTYPE)-->

UDF will be required if you are not sure about the position of DOCTYPE in the node....i.e. if DOCTYPE has some characters before/ after it.

In the above logc you will have to take care of Context if the node will be repeating.

Regards,

Abhishek.

former_member208856
Active Contributor
0 Kudos

Use IF without Else for the line & send Constant Space, if the condition is True.