cancel
Showing results for 
Search instead for 
Did you mean: 

Values are suppress in String

vijender_p
Active Participant
0 Kudos

Hi all.

Am doubting how to build the logic for the mapping of a string function when it is null .

In my scenario what is happening is we are getting field name as usrid in the which i have pass first character of usrid and pass to target field .

And when it is empty it has to pull the first char of usrid _long  and when it is null it should pass null.

So for that i have written a code as below .

But what is happening here is when am passing it  to target field values are been suppress, I think it is due context handling , but both fields are from same segment E1P0105  .

please help me out in these !!!

Best regards,

vijender

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Vijender,

If you add mapWithDefault for the two fields (USRID and USRID_LONG) just before you pass it into your UDF, your mapping should work.

Regards,

Mark

vijender_p
Active Participant
0 Kudos

Hi mark,

I have used map with default in my mapping but, also it is not working !! values are been suppress .

Regards,

Vijender

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Vijender,

Can you post a screenshot wherein you used mapWithDefault?

Regards,

Mark

Former Member
0 Kudos

Hi Vijender,

as Mark wrote a screenshot would be very helpful.

But one question: is the whole node E1P0105 suppressed or just the two fields?

I asume, the node is suppressed because of some other issue.

Have you connected the root-nodes or do you use any condition somewhere?

regards,

Heiko

vijender_p
Active Participant
0 Kudos

Hi Mark ,

Please find the attachment as below and in the which am getting error .

And both the fields are from same segment i.e. E1P0105 and when am handling with map with default it is throwing this error and with out the map with default means values are been suppressed for this two fields .

Best regards,

vijender

azharshaikh
Active Contributor
0 Kudos

Hi Vijender,

Please change the Context in Message Mapping of Both the Source Field Usrid & Usrid_long to 1 level up, instead of default Context and check if it helps

(Assuming both Usrid & Usrid_long are on same level in actual source structure)

Hope it helps

Regards,

Azhar

vijender_p
Active Participant
0 Kudos

Hi Azhar,

i have tried by using your logic also still not working !!!

regards,

Vijender

azharshaikh
Active Contributor
0 Kudos

Hi Vijender,

Pls share Input Q for both Source fields.

I Suggest you to break the code in steps and test with simple / few records in Input

1. First check with 2-3 values of USRID present

2. USRID and UDRID_LONG present

3. One of USRID is absent

so on..

So you will come to know in which case this is failing and you can correct the code accordingly

Regards,

Azhar

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Vijender,

Can you try with the below code in your getSegment udf:

String result="";

if(USRID.length()>=1)

        result=USRID.substring(0,1);

else if(USRID_LONG.length()>=1)

        result=USRID_LONG.substring(0,1);

return result;

Let me know the outcome.

vijender_p
Active Participant
0 Kudos

Hi Vishnu ,

I have used your logic but still there is a error values are been suppress .

Regards,

Vijender

Former Member
0 Kudos

Okay - Suppress comes in - suppress goes out... but the udf is looking fine.

Can you show us the output of your trace when when testing the message?

What is the target field? Is this a variable?

Another thing you can try: add "mapWithDefault" before the udf. At least, that would make sure, that your udf always get a value.

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Vijender,

Use mapwithdefault for both usrid and usrid_long fields before sending as inputs to the udf.

I have checked with sample test cases in my system and it is working fine.

Can you try with this and check the outcome.

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Vijender,

Please find below the sample test case which I have done with the above mentioned code:

validate udf code:

String result="";

if(USRID.length()>=1)

        result=USRID.substring(0,1);

else if(USRID_LONG.length()>=1)

        result=USRID_LONG.substring(0,1);

return result;

Can you check from your end and let me know the screenshots of the issue if you still facing any

Answers (2)

Answers (2)

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Vijender,

code snippet is looking good. Can you please let me know the screenshot of the display queue values of the inputs that you are trying to pass this udf.

Also, are you using any other graphical functions besides this udf, in the population logic of the target field.

Former Member
0 Kudos

Hi Vijender,

your udf looks fine on a quick view. Can't tell why it's not working.

But have you considered to use standard functions instead?

It will be a bit complex-looking, but actually do the same.

I think, it should be solvable with IF, EQUALSS, ISNIL, NOT and SUBSTRING:

Just try this (hope this is understandable):

USERID-------->EQUALSS("")->NOT-->

      -------->ISNIL------->NOT-->AND--->IF   --->targetfield

      --------------->SUBSTRING(0,1)---->then

USERID_LONG---------->SUBSTRING(0,1)---->else


In case USERID_LONG can also be initial, you got to add the IF and comparission there as well.


Hope this helps,

Heiko