To perform count:
integer count_LIN;
count_LIN=count($GROUP_12[1][*]);//Group_12 is in the Group_1 So we have two indexes.
* for calulating count.
ntoa(count_LIN,$INPUT.#TEMP_mdTxLineCount);//converting integer to string
Concate two string(one is in date format YYYYMMDD another is in time format HHMMSS) and converting string format into date format:
mdate=#CREDAT+#CRETIM;
$INPUT.#TEMP_mdExtractDate = date("%Y%m%d%H%M%S",mdate);
NOTE: Be cautious with date format If you give data format incorrect it will give redundant results.
Compare first few characters with some string
STRING[20] temp_variable;
temp_variable=left($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,2);//
temp_variable=left($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,2);//
it store first two characters in temp_variable
CERROR(100,temp_variable);
CERROR(100,temp_variable);
LEFT:
The left
function extracts a specified number of characters from the left side of a
string variable or field and returns the result as a string.
STRING[20] temp_variable;
temp_variable=left($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,2); //first 2 characters stored in temp_variable
temp_variable=left($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,2); //first 2 characters stored in temp_variable
RIGHT:
The
right function extracts a specified number of characters from the right side of
a string variable or field.
$INPUT.#temp_costHandling=right($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,dec_pos);
//stores the characters after * position
1)IF $GROUP_7[1][group_7_cnt].#TDID:2="0003" & temp_variable="ED" THEN
BEGIN
2)dec_pos = strstr($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,"*");
3)i=len($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2);
ntoa(dec_pos,v_s_cerror);
//cerror(1001,v_s_cerror);
//var_datePromised=right($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,dec_pos+1);
4)var_datePromised= mid($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,dec_pos+1,i-dec_pos);
$INPUT.#temp_datePromised=date("%Y%m%d",var_datePromised);
cerror(100,"sample",var_datePromised);
END
For example we are getting ED*20110701 as input in step2 we can find the position of * i.e 2 because strstr is zero based function.
Third step returns length of the input i.e 10.
In 4th step it returns the characters from 3 to 8(10-2) i.e "20110701"
MID:
The mid character extracts the specified characters from the specified position in the string,either to the end of the string or up to the characters we specified.1)IF $GROUP_7[1][group_7_cnt].#TDID:2="0003" & temp_variable="ED" THEN
BEGIN
2)dec_pos = strstr($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,"*");
3)i=len($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2);
ntoa(dec_pos,v_s_cerror);
//cerror(1001,v_s_cerror);
//var_datePromised=right($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,dec_pos+1);
4)var_datePromised= mid($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,dec_pos+1,i-dec_pos);
$INPUT.#temp_datePromised=date("%Y%m%d",var_datePromised);
cerror(100,"sample",var_datePromised);
END
For example we are getting ED*20110701 as input in step2 we can find the position of * i.e 2 because strstr is zero based function.
Third step returns length of the input i.e 10.
In 4th step it returns the characters from 3 to 8(10-2) i.e "20110701"
STRSTR:
IF #TDID:2="0003" THEN
IF temp_variable="FC" THEN
BEGIN
dec_pos = strstr($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,"*"); // finds * position
IF temp_variable="FC" THEN
BEGIN
dec_pos = strstr($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,"*"); // finds * position
END
Your Blog is Really useful and helpful. Great Work
ReplyDeletecan you show how to do for strdate function
ReplyDelete