I'm trying to figure out the best way to convert numbers into currency using Informatica. For example, I want to convert 4000 to $4,000.00. I think the Java tx is the way to go but I have never used it and I'm unable to find examples of how to code it properly so that it works. Any help you can provide would be greatly appreciated.
Thank you,
Gary
Here is a solution in Expression Transformation without using Java. Of course, this is kind of static, but you can always code it for maximum possible amount.
v_AMT_STR := TO_CHAR(TO_DECIMAL(TO_CHAR(inp_AMT),2))
v_LEN := LENGTH(v_AMT_STR)
v_THSND_SEP := DECODE(TRUE,
IN(v_LEN,7,8,9), SUBSTR(v_AMT_STR,0,v_LEN-6)||','||SUBSTR(v_AMT_STR,-6),
IN(v_LEN,10,11,12), SUBSTR(v_AMT_STR,0,v_LEN-9)||','||SUBSTR(v_AMT_STR,-9,3)||','||SUBSTR(v_AMT_STR,-6),
IN(v_LEN,13,14,15), SUBSTR(v_AMT_STR,0,v_LEN-12)||','||SUBSTR(v_AMT_STR,-12,3)||','||SUBSTR(v_AMT_STR,-9,3)||','||SUBSTR(v_AMT_STR,-6),
v_AMT_STR)
o_CURRENCY := '$'||v_THSND_SEP
inp_AMT is decimal input port
v_ and o_ are variable and output ports respectively
It supports up to $999,999,999,999.99. You can add more lines in the DECODE above to go beyond that.
Related
I have a Delphi 10.1 Berlin application that is using a kbmMemTable 7.82 table. It is indexed on two fields: lastname and firstname.
My problem is that the order is wrong when an apostrophe is encountered. It may also happen with other characters, but I haven't tested it extensively.
Does anyone have an idea what might be wrong? Any help would be appreciated.
I've tried it on both Delphi 7 and Delphi 10.1 Berlin and get the same results. I've tried having the index be case-sensitive and case-insensitive. In all four cases, I get the same results. I've also tried creating the index programmatically and through the object inspector.
Here is the generic form of how I created the index programatically:
Table.Open;
IndexDef := Table.IndexDefs.AddIndexDef;
IndexDef.Name := IndexByName;
IndexDef.Fields := 'lastname;firstname';
IndexDef.Options := [ixCaseInsensitive];
Table.Indexes.Add(IndexDef);
Table.IndexName := IndexByName;
Table.IndexFieldNames := 'lastname;firstname';
Table.CreateIndexes;
Table.EnableIndexes := True;
Table.First;
The index puts O'HARA after OLSON, instead of before. This works the same with and without case sensitivity.
Its because the locale settings defines the order.
Try to set mtifoIgnoreLocale in the index definition, alternatively setup a locale that provides the correct sort order.
Then it will do a simple sort.
best regards
Kim/C4D
I see requests to socket.io containing parameter t to be like LZywzeV, LZz5lk7 and similar.
All examples that i found so far used second- or millisecond-based UNIX timestamps.
Has anyone ever seen a timestamp format like this? (It is not base64-encoded).
I started looking a site that uses Socket.io today, and got the same problem, trying to look for the protocol definition was useless.
I figured this format is something called yeast
TBH, really don't know why people invent this sort of things instead of use
base64(timestamp.getBytes())
pseudocode instead.
A yeast decode algorithm in Python is as follow:
from datetime import datetime
a='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'
b={a[i]: i for i in range(len(a))}
c=0
for d in "LZywzeV":
c=c*64+b[d]
print(c)
print(datetime.fromtimestamp(c/1000))
The output of that code is:
1481712065055
2016-12-14 07:41:05
to #jeremoquai:
It is easy, is matter of invert the algorithm:
def yeast(d):
r=""
while d!=0:
r='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'[d&63]+r
d>>=6
return r
so, if you run
yeast(1481712065055)
it returns LZywzeV
I am trying to create a data field using Mockaroo and they say they have Ruby support but I know nothing about Ruby so I am trying to find out how to do a field that will randomly choose between the 3 options.
now() or
now()+days(-1) or
now()+days(-2) or
now()+days(-3)
Idea 1
I was initially thinking something using random like now()+days(this.rand(-3))
Idea 2
I also thought of using or logic like now() or now()+days(-3) or etc...
This answer may end up being different than a typical ruby solution since Mockaroo has their own little API to use too... Appreciate any help that can be given.
Turns out I had to use the random function first and pass in min and max date parameters.
random(now()+days(2), now()+days(-3))
I am converting a character variable to a numeric variable. I am using a bestw.d format. I also tried just best. as the format in the input statement and this worked fine. I cant find any mention of just using best. instead of bestw. in SAS help, though I know from SAS help that the d can be omitted. I have been playing around with using just the best.and I am wondering if there is a default w assigned when just using best..
All formats have a default w. It is not generally good practice to use best. (or <format>.) in most cases, as you should know and plan for the specific width needed, but it always exists.
Also, informat and format have different defaults in many cases where there are identically named informat and format.
In the case of bestw., the default length is 12. See this documentation page for details.
I always find it's worth using a worked example, this shows the different outcomes when using lengths on the BEST. format:
data _NULL_;
a=1031564321300.302;
put '==================================';
put 'Different "BEST" formats';
put '==================================';
put 'BEST8. - ' a best8.;
put 'BEST12. - ' a best12.;
put 'BEST13. - ' a best13.;
put '==================================';
put 'BEST. - ' a best.;
put '==================================';
run;
You can run this in your environment and check the outcome. On my machine it looks like this:
==================================
Different "BEST" formats
==================================
BEST8. - 1.032E12
BEST12. - 1.0315643E12
BEST13. - 1031564321300
==================================
BEST. - 1.0315643E12
==================================
i.e. It looks like BEST12. is the matching format when no width is specified.
I have a list of the following codes and their corresponding codes in format code_128. I want to given a string, be able to generate the corresponging code in CODE_128 format. Based on this list, how could I generate a code_128 number to the string A4Y9387VY34, for example?
code code in code_128
A4Y9387VY34 ????
ADN38Y644YT7 9611019020018632869509
AXCW99QYTD34 9622019021500078083444
A9YQC44W9J3K 9611083009710754539701
AT8V7T3G3874 9622083021255845940154
A7K444N4FKB8 9622083033510467186874
AYCHFW448HTQ 9611005019246067403120
AY63CWBMTDCC 9622005028182439033426
ANY7TF46NGQ3 9622005031345848081170
AYY48TBVQ3FH 9611200003793988696055
AT8Q4CF4DQ9Q 9611200021606968867090
A764WYQFJWTT 9622200022706968919275
AC649ND7N8B6 9622148007265209832185
A4VDPTJ99YN4 9611148013412173923039
AHDYK498BD6T 9622148021309216149530
A4YYYNY7C3DJ 9611017021934363499071
AYG6XWVCCQ89 9622017031009914238743
A68YJHGQKCCM 9622017031138587166053
APMB7XG9XQC9 9611021011608391750002
AGP8C44Y8VYK 9622021021608111646113
A7C68B9T69XB 9622021021958603678086
AJYYWKR6BDGN 9611010022528724015883
AKMNVXDT9PYN 9622010027475034102229
AXPXMK9QMDFD 9622010031475028243694
I read a lot about it, but I didn't come to any solution. Thanks in advance!!
Well, this is a pretty open question, I will give you my suggestions:
If it is a finite list, you can use a Hash or a Dictionary, where
the keys are the Codes and map them to the corresponding value, in
your case, Code_128
Some scanners have software installed that allow you to change what
has been read to a new value, format it, etc.
If you need a bigger insight please, give us more detail about the environment you are using.
Hope that helps,
I decided to create a new answer because now I get your point. Well, if you are talking about a GS1-128 Code (please see www.gs1.org) please do not start without visiting Wikipedia info about it. as you can see, there is a thorough explanation about how to work with that type of code. That code is composed by several application identifiers followed by their corresponding values. There is a better way of encoding them by using special characters as parenthesis. Here is other info that may help you.
Hope it helps,