on 08-07-2007 8:38 PM
Hi All,
I have scenario, where in the incoming data is put into a file, but if there is no incoming data for any element it should insert spaces equivalent to the lenght of the field. how can this be done?
XIer
Hi ,
No need to use udf when standard funtions are available.
The best thing to is to use ..the standard function call mapbydefault in such cases ..
here inside it you can give spaces equal to fieldlength (when string)
this with existence check will take care of your problem.
source-mapbydefault -
or
source-mapbydefault -
Regards,
Deepak
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use Exists function.
Source --->Exists -
> If ---> Target
In IF Function
Insert Source [True Branch]
Insert Constant[Spaces] [Else Branch]
Best regards,
raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Lets say I have three fields on the source side
field1
field2
field3
and three fields on the target side
field4 (length 3)
field5 (length 4)
field6 (length 5)
so if i pass
field1 = abc
field2 = empty field
field3 = def
I should get
abc def
the empty space equals the lenght of the field...
Pls advice
Xier
Hi ,
I think I got ur reqmt, please refer the link
http://www.flickr.com/photo_zoom.gne?id=1042377965&size=o
Best regards,
raj.
Henrique, this is the XML 'SRC' file get on the target side when I test the mapping,
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_Countresult xmlns:ns0="urn:sce.com:xi:FI:TestProjectStructureUpload"><record><field1>a</field1><field2></field2><field3>b</field3></record></ns0:MT_Countresult>
I passed a for field1 nothing for field2 and b for field3.
why is space not coming between <field2></field2>
I used field2 --> 'MapWith Default' --> field2
XIer
Message was edited by:
XIer
Hi,
When you test in test message mapping you will not see the spaces. If you want to see the spaces whether it is present or not then executie test message mapping and then click on Source of target message. Then copy the whole xml message in an notepad. There you can see the spaces also.
Regards,
---Satish
Xier,
your problem is that the MapWithDefault function will fill only the fields which have no value, for example, if that tag is like <field2/>. When you have <field2></field2>, you have a value, even though this value is an empty string.
To test your scenario properly, change your input xml to:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_Countresult xmlns:ns0="urn:sce.com:xi:FI:TestProjectStructureUpload">
<record>
<field1>a</field1>
<field2/>
<field3>b</field3>
</record>
</ns0:MT_Countresult>
If your requirement is to insert spaces when you have empty string as the input (<field2></field2> case), then you can't use MapWithDefault. In this case, you have to use an if logic: if input = "" (empty string) then output = " " (4 blankspaces), else output = input.
If you don't know how the input will come, best scenario would be to combine the MapWithDefault + If logic, in order to solve both cases (no input or empty string input).
Regards,
Henrique.
Hi ,
No need to use udf when standard funtions are available.
The best thing to is to use ..the standard function call mapbydefault in such cases ..
here inside it you can give spaces equal to fieldlength (when string)
this with existence check will take care of your problem.
source-mapbydefault -
or
source-mapbydefault -
Regards,
Deepak
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.