Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone
This's my story:
I have a table, VFACTURA, with a date field. On the other hand, there's another table, VRENG_CO where I want to "map" the date field mentioned.
So far, no problem... but, in the data, not all the registries of VRENG_CO have a coincidence in VFACTURA. I'm not sure but, when that happens shouldn´t the map return null?
Anyway, my problem is that when I list the values of the date field already mapped (in VRENG_CO) I got as a result, dates of 1980 and even 2045. Debugging, when I list the result of the map table (taking off the mapping statement, just for test) there's any problem with dates.
The only explanation that I've so far is because of the not-coincidence, but i'm not sure.
In case that's the reason, is it a way of condition the data that I wanna map? explaining myself better, can I ask: if there's a coincidence then map the date field, if not, map it with null or just dont map it?
Well, hope u can help me! Thxs in advance
PS: I dont think there's a problem with the code itself, but if u consider it necesary to analize this issue, let me know, and I'll publish it.
By default, when a field value being mapped isn't in your mapping table, the mapping returns the field value, not null. You can get more control over the mapping by using the applymap() function instead of just saying MAP MyDate USING VRENG_CO. That will also allow you to specify an expression for the default value, such as null(), if you don't want it to just use the field value as a default. You can also then conditionally map. Something like this:
if(condition,applymap('VRENG_CO',MyDate,null()),MyDate) as MyMappedDate,
Hi John
Thxs for your answer!
I'd forgotten completly the default option of the applymap statement!. I implemented it, with null() ,and now there's no problem with the dates.
Thxs.
Thanks John
Your post on Null() applymap has REALLY helped me out
Anne