on 05-31-2012 3:21 PM
Hi ,
I need to write a UDF for the following requirement.
I'm getting a input string of 0-52 characters. but my target filed in IDoc has 13 character limit.If i get 52 characters then i need to divide the text into 4 lines and duplicate the segements 4 times and map.
Can some one help me in writing the UDF for this ?
Thanks.
You can do simple udf for adding empty as Raja pointed and rest you can handle using standard substring function. Create duplicate elements on the target structure.
Example:
UDF for filling remaining spaces to the length upto 52 chars ...
Mapping example for four segments. Assume your source field is remarks and target also remarks
Like that you do for the remaining two segments using substring function
substring for the third ( 26 ,39) start position 26 character count 13
substring for the fourth ( 39, 52) start position 39 character count 13
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are right using UDF is the better solution.
>i may get 0-52 characters like 10,14,22 random numbers,and duplicate segments based on the length
This part is not clear. If you get 22 ,how many duplicate segments you will make 2 or 3? How you can duplicate the segment numbers dynamically? This is not possible.
Solution: You can use duplicate subtree in the target segment only if you know the number of segments in advance. You can always create 4 segments using duplicate subtree in the mapping and send the values accordingly like if you get 52 characters fill all the 4 segments. if the length is less than 52 chars then fill only the required and remaining blank.
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I duplicated the segment thrice so i have 4 segments now in the Idoc structure.I have to map the text in that segments based on the input length.
first 13 characters into first segment, next 13 characters into second segment like that.
I can't use substring because i'm not sure how many characters i get.
You dont need any UDF for this
1)Use lenght standard function to indetify the length of input,if lenghth less then 52 then using substring function map maccoprdingly.
2)Duplice target field 4 times but lengh 52 then only map.(write a logic using standard function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.