cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Introduction

itabhishek9
Participant
0 Kudos

Hi SDNites, 

I have used certain UDF in the past from the google repository . Also I do understand the flow of the code but would like your suggestions in how to,

1. Write a new one.

2. How can I test it standalone.

3. How to debug it in case of error.

4. How to know which standard class / methods can be used to meet my requirement.

Any pointers in this direction would be of great help.

Regards,

Abhi

Accepted Solutions (0)

Answers (3)

Answers (3)

itabhishek9
Participant
0 Kudos

Thanks for the above inputs.

When sending a file containing special characters to receiver, all the special charcters are transformed,

1. " - Changed to "

2. ' - Changed to '

Also I tried writing an UDF which converts the input value to a string but still it dosen't help.

Small UDF written for testing :

String a = "My ' testing";  (Here apostophe special character has been passed in string)

return a;

Regards,

Abhi

former_member184720
Active Contributor
0 Kudos

They are illegal char's in xml.

However your receiver system should be able to handle this right? what is the issue that you are facing?

If you want them as is then you must enclose them within cdata so that they'll be ignored by parser.

http://www.w3schools.com/xml/xml_cdata.asp

Please do not merge multiple questions into one discussion.

http://scn.sap.com/docs/DOC-18590

nabendu_sen
Active Contributor
0 Kudos

Hi Abhishek,

If you also use UDF, you have to implement that for individual fields from which you want to remove special characters. Actually you don't need UDF.

try these as mentioned by

Input ------->

            Constant(')-->  replaceString() -----> target

            Constant()--->

Regards,

Nabendu.

itabhishek9
Participant
0 Kudos

Thanks Nabendu - As suggested above, it is working for normal characters but not for special characters. Below are the results,

Try 1 :

___________

ABC'-----

'       --------> replaceString() -----> ABC'

""     -----

Try 2 :

___________

ABC'-----

' --------> replaceString() -----> ABC'

""     -----

Here ' can be seen in inbound XML.

@Hareesh - When sending special charcters like ' my output xml has ' into it.

Regards,

Abhi

Harish
Active Contributor
0 Kudos

Hi Abhi,

The below doc will help

former_member184720
Active Contributor
0 Kudos

>>> When sending special charcters like ' my output xml has ' into it.


That is how it behaves.. do you want to remove them? if so replace string function third parameter should be blank.


>>>Try 1 :

___________

ABC'-----

'       --------> replaceString() -----> ABC'

""     -----

Try 2 :

___________

ABC'-----

' --------> replaceString() -----> ABC'

""     -----

Here again you are trying to replace it with another illegal char. did you check the w3 school link that i shared in my previous reply?

itabhishek9
Participant
0 Kudos

Hi SDNites,

Thanks for your responses on the query.

I have resolved the same.

Resolution - Receiver file name should be .XML. Earlier it was mentioned as .TXT due to which output generated file contains the source code and " is populated as "

Regards,

Abhi

former_member184720
Active Contributor
0 Kudos

Issues is completely different from the question you asked.

May be you can close the discussion now.

nabendu_sen
Active Contributor
0 Kudos

Hi Abhishek,

Left side of Message Mapping you will find the option to create UDF.

You will have these 3 options to manage your Return values from the Function.

You will like below after creation.

To check the code for any error or typo, run "Check" option.

If you want to test / run locally, use Display Queue option. Before this 'Test' tab (Next to 'Definition') should be filled with proper Source side xml.

Regards,

Nabendu.

former_member184720
Active Contributor
0 Kudos
itabhishek9
Participant
0 Kudos

Hi Hareesh,

Above links are of real help.

Request you to please pen down some of your experience which will show me a ray in the dark specially for point 4 (How to know which standard class / methods can be used to meet my requirement.)

Regards,

Abhi

nabendu_sen
Active Contributor
0 Kudos

Hi Abhishek,

You don't need to include / import any package because most of them are included under com.sap.aii.mapping.api.*

Regards,

Nabendu.

former_member184720
Active Contributor
0 Kudos

Like any other java program, it's based on your requirement.

You should go through java documentation to find out the classes/methods that you need to suffice your custom transformation needs.