assassinator
18th March 2010, 11:24
When function marked as string, how to converted back function
Now I want to change one Baan default output report to output as txt file in Unix sever.
I meet this trouble. In Statement of Accont Letters, output mode of customer's detail informations had been defined in the header text. Such like: "Customer : $nama","$namb","$namc" etc. Yes, I can hardcode the output data in txt file. But I can't promise whether user would change them. If them been changed, we should modify the report script angain.
So I want to ask. Is there a method I can use like this. When I get the text data, if there is Baan default functions like "$nama", "$cuno", I can obtain the followed results:
customer.name.1 = $nama
customer.name.2 = $namb
output.cuno = $cuno
How can I tell the computer, when it meet string "$nama", automatically execute function $nama, meet string "$cuno" then execute function $cuno?
mark_h
18th March 2010, 15:00
Maybe I do not understand something. To print a baan report as a file all you have to do is define a printer as file. On the UNIX platform I can print to a file using the ASCIF device - you do not have to change the report. Just run the report and send it to a file. So you might need to explain why you need to change the report - I am not understanding that.
bdittmar
18th March 2010, 17:09
When function marked as string, how to converted back function
Now I want to change one Baan default output report to output as txt file in Unix sever.
I meet this trouble. In Statement of Accont Letters, output mode of customer's detail informations had been defined in the header text. Such like: "Customer : $nama","$namb","$namc" etc. Yes, I can hardcode the output data in txt file. But I can't promise whether user would change them. If them been changed, we should modify the report script angain.
So I want to ask. Is there a method I can use like this. When I get the text data, if there is Baan default functions like "$nama", "$cuno", I can obtain the followed results:
customer.name.1 = $nama
customer.name.2 = $namb
output.cuno = $cuno
How can I tell the computer, when it meet string "$nama", automatically execute function $nama, meet string "$cuno" then execute function $cuno?
Hello,
as Mark suggest,
use ASCIIF Device and your Report will be stored at the users homedir.
Regards
Hitesh Shah
18th March 2010, 18:24
If i recollect correctly , while maintaining letter header/footer , baan allows u to zoom to a session where u can select all such variables .
If u want to use the same text in ur program , u need to set the variable lattr.textexpand variable in ur report script to true . That will actually replace these variables in text with actual runtime values of the variables.
mark_h
18th March 2010, 19:09
If i recollect correctly , while maintaining letter header/footer , baan allows u to zoom to a session where u can select all such variables .
If u want to use the same text in ur program , u need to set the variable lattr.textexpand variable in ur report script to true . That will actually replace these variables in text with actual runtime values of the variables.
Now that makes much more sense based off the original post.
assassinator
19th March 2010, 03:07
Maybe I do not understand something. To print a baan report as a file all you have to do is define a printer as file. On the UNIX platform I can print to a file using the ASCIF device - you do not have to change the report. Just run the report and send it to a file. So you might need to explain why you need to change the report - I am not understanding that.
OK, that is my false. I didnot explain why I should do a new report instead of use the Baan default report to output NotePad in detail.
According to Finacial Department's requirement, we should print "Statement of Accounts", output as many different txt files, which are group by costumers. Each file only includes one customer's invoice data and the file's name is named the costumer's code. For example, one file named "MOTO01", and the file only includes the invoice data for "MOTO01". The other one named "SIEM02" and only includes data for "SIEM02". So that we can send(though Email, Louts Note) the statement files to customers base on the matched file's name. Louts would get customers' Email Address according to the files' name. Baan default NotePad output file can not satify our requirement.
In this case, I should add a new report to achieve.
mark_h
22nd March 2010, 02:20
Do you own source code? It would probably be easier with source code. Then you could sort the data going to the report, create an ascii file for each customer, run report to that file for the customer.
Almost like this - we run the print production order by priority report to disk. Then I have another program which pulls out each work center for a user. The program basically reads in the input file, writes the output for a main work center(to a file or printer), then closes. The program works by parsing each line looking for a work center - does not start printing until it hits the selected main work center and stops as soon as it hits the next main work center. Something like you were talking about.
assassinator
22nd March 2010, 03:07
Do you own source code? It would probably be easier with source code. Then you could sort the data going to the report, create an ascii file for each customer, run report to that file for the customer.
Almost like this - we run the print production order by priority report to disk. Then I have another program which pulls out each work center for a user. The program basically reads in the input file, writes the output for a main work center(to a file or printer), then closes. The program works by parsing each line looking for a work center - does not start printing until it hits the selected main work center and stops as soon as it hits the next main work center. Something like you were talking about.
Yse, it is something like you had done. But there are some difference. We set a job to do this, is differ from manual like your discription. We should output files in Unix Sever, then Lotus reads the files, judges the match Email Address by customers' code. Lotus how to achieve Email address, that is not my concern.
And I would like to know is how can I execute function which is marked as a string.
customer.name.1 = "$nama"
Actually execute is:
customer.name.1 = $nama
pconde
22nd March 2010, 11:29
As far as I understand your problem (correct me if I'm false)
you have a report with a text containing some fields $nama, $cuno that need to be replaced with the data from the report.(field nama, cuno)
I suppose that you use the standard report functionnality
This can be achieved by expanding text variable (see manual for report)
You must set the variable lattr.textexpand=TRUE if you want this to happen. Expressions are internally evaluated by the function expr.compile().
see http://www.baanboard.com/programmers_manual_baanerp_help_report_scripts_expanding_text_variables
Regards
Philippe
assassinator
22nd March 2010, 15:30
As far as I understand your problem (correct me if I'm false)
you have a report with a text containing some fields $nama, $cuno that need to be replaced with the data from the report.(field nama, cuno)
I suppose that you use the standard report functionnality
This can be achieved by expanding text variable (see manual for report)
You must set the variable lattr.textexpand=TRUE if you want this to happen. Expressions are internally evaluated by the function expr.compile().
see http://www.baanboard.com/programmers_manual_baanerp_help_report_scripts_expanding_text_variables
Regards
Philippe
Thanks for your reply. But this is what I want is just the opposite. Now the user had defined the variables in the textline. As before, we used the Baan Standard report would be OK. But now, I want to output as many txt files. So I want to know, how to convert the variables which were used in the text to output data.
Examples of what you said, and I met is very similar to.
Hitesh Shah
22nd March 2010, 17:26
u may either run the report in AFS or fix the variable position in letter text and let lotus notes use that fixed positioned information to send the same to right people.
pconde
22nd March 2010, 22:55
Hi,
the first option that I see is printing to a file (device ascif) closing the file after each customer. ==> you need modifying the session script
Second option is to do what the report script does
analyze the text, extracting the variable starting with $ and replace using expr.compile and s.expr
see http://www.baanboard.com/programmers_manual_baanerp_help_functions_expressions_runtime_expr_compile
A lot of programming if you want also suppressing the blank characters;:D
Good luck
Philippe
assassinator
23rd March 2010, 05:48
OK, I have tested the expr.compile(), but it isnot work. And I read a lot of the related posts, most of them were output as Baan standard report. The other were not like as I met. I do not get the "device ascif", is it means to printed as Notepad?
Now my script is lile this:
........
file.name = strip$(store.file.path) & strip$(shiftl$(cuno)) & ".txt"
file.no = seq.open.local(file.name, "w", false)
........
if text.to.buf("htxt", report.language, MAX.TEXT.LINE, text.line) > 0 then
for i = 1 to MAX.TEXT.LINE
tmp.str = strip$(shiftl$(text.line(1,i)))
Then the string array text.line are:
text.line(1,1) = "Customer : $nama Customer A/C : $cuno"
text.line(1,2) = " : $namb"
........
So, how can I get the result to be this:
tmp.str = "Customer : VISTEON KOREA CO.LTD. Customer A/C : CVIS12"
tmp.str = " YESAN PLANT, 2-5 YONGGUNG-RI"
........
Thanks!
rahul.kolhe22
23rd March 2010, 09:12
Hi,
I would like to suggest another option for achieving this:
If the format of text TEXT is going to be fixed like:
text.line(1,1) = "Customer : $nama Customer A/C : $cuno"
text.line(1,2) = " : $namb"
.....
then try modifying this text to
text.line(1,1) = "Customer : %1$s Customer A/C : %2$s"
text.line(1,2) = " : %1$s"
.....
Once you get this text in some string varibale you can substitute the variable value in the string using sprintf$ function. eg:
|* If variable tmp.str = "Customer : %1$s Customer A/C : %2$s" then
tmp.str = sprintf$(tmp.str, nama, cuno)
Hope I understand your problem correctelly and this solution helps you.
Regards,
--Rahul
Hitesh Shah
23rd March 2010, 19:28
U r reading text in array and want to replace the variable values therein . But in fact there is no need whatsoever to do so much effort . U print the text to a report with right input variables and the text in the report will have right values . And re-direct the output to whatever file u want.
Maybe i am missing something . please elaborate so everybody incl me can give right answers in that case.
assassinator
24th March 2010, 05:52
Hi,
I would like to suggest another option for achieving this:
If the format of text TEXT is going to be fixed like:
then try modifying this text to
Once you get this text in some string varibale you can substitute the variable value in the string using sprintf$ function. eg:
|* If variable tmp.str = "Customer : %1$s Customer A/C : %2$s" then
tmp.str = sprintf$(tmp.str, nama, cuno)
Hope I understand your problem correctelly and this solution helps you.
Regards,
--Rahul
Thanks for your reply.
But you had some mistake. Yes your method was work, but the main key point and also is what I wonder to know is that how to know we should use tmp.str = sprintf$(tmp.str, nama, cuno) or use tmp.str = sprintf$(tmp.str, namb) or use tmp.str = sprintf$(tmp.str, cpay) or tmp.str = sprintf$(tmp.str, cdec) . The varibales in the textline was unknow and maybe not static.
rahul.kolhe22
24th March 2010, 07:37
Hi,
For the alternative which I suggested, I have specified a condition:
If the format of text TEXT is going to be fixed
Anyways, I even would like to suggest you one more option.
1. You are getting all the data in the text in an array of a string. (in your case here, you get it in text.line variable). That is fine
2. Then try to concat all the sentences with some an appropriate seperator (sample code: hold.str = text.line(1,1) & "|" & text.line(1,2) & ...). Just take care that concating all the text to form a single string does not exceed the length of your string variable i.e. hold.str
3. Now you can just mention to the person who will maintain the text that where the expect to print "Customer" use %1$s, "Customer A/C" use %2$s
4. Then use sprintf$ function to replace %1$s with value of nama, %2$s with cuno.
5. Here you have to fix the sequence like:
%1$s for Customer
%2$s for Customer A/C
.....
Again please take care that, in text if user types say for example %5$s and you are passing only 4 variables to be substituted in the string then it will give fatal e.g.: sprintf$("Var1 = %1$s, Var2 = %2$s", "abc")
But passing an extra variable will not create any problem. e.g.
sprintf$("Var1 = %1$s, Var2 = %2$s", "abc", "xyz", "ijk")
This option I think will give some flexibility as compared to previous I mention for the person who will maintain the TEXT and will also reduce some chances of error.
Hope I am clear and it helps you.
Regards,
--Rahul
assassinator
24th March 2010, 08:40
U r reading text in array and want to replace the variable values therein . But in fact there is no need whatsoever to do so much effort . U print the text to a report with right input variables and the text in the report will have right values . And re-direct the output to whatever file u want.
Maybe i am missing something . please elaborate so everybody incl me can give right answers in that case.
Thanks for your attention.
text.line(1,1) = "Customer : $nama Customer A/C : $cuno"
text.line(1,2) = " : $namb"
Then write the resturn string to txt files would be like this in the statement header:
Customer : $nama Customer A/C : $cuno
$namb $cpay
This is not I want. I would get the variables return values.
$nama = " VISTEON KOREA CO.LTD."
$cuno = "CVIS12"
$namb = "YESAN PLANT, 2-5 YONGGUNG-RI"
So that the output statement files' header like this:
Customer : VISTEON KOREA CO.LTD. Customer A/C : CVIS12
YESAN PLANT, 2-5 YONGGUNG-RI
And as you said to output the right variables' value to a reprot. I know it would work, but I should output two type reoprts. One is store the right text data, the other are customers' statement files. It is so trouble.
assassinator
24th March 2010, 08:57
Hi,
For the alternative which I suggested, I have specified a condition:
Anyways, I even would like to suggest you one more option.
1. You are getting all the data in the text in an array of a string. (in your case here, you get it in text.line variable). That is fine
2. Then try to concat all the sentences with some an appropriate seperator (sample code: hold.str = text.line(1,1) & "|" & text.line(1,2) & ...). Just take care that concating all the text to form a single string does not exceed the length of your string variable i.e. hold.str
3. Now you can just mention to the person who will maintain the text that where the expect to print "Customer" use %1$s, "Customer A/C" use %2$s
4. Then use sprintf$ function to replace %1$s with value of nama, %2$s with cuno.
5. Here you have to fix the sequence like:
%1$s for Customer
%2$s for Customer A/C
.....
Again please take care that, in text if user types say for example %5$s and you are passing only 4 variables to be substituted in the string then it will give fatal e.g.: sprintf$("Var1 = %1$s, Var2 = %2$s", "abc")
But passing an extra variable will not create any problem. e.g.
sprintf$("Var1 = %1$s, Var2 = %2$s", "abc", "xyz", "ijk")
This option I think will give some flexibility as compared to previous I mention for the person who will maintain the TEXT and will also reduce some chances of error.
Hope I am clear and it helps you.
Regards,
--Rahul
Thank you.
But as you know, this text had been used in so many reports, so we cannot use the method like you suggest. :(
In case we can modify the text, as well I hardcode the statement header to get the fields (like "nama", "namb", "namc") values is better.:D
goooch
25th March 2010, 10:41
Hi
In my opinion, Mark is right
You have already got the standard report, so you can modify it to put data in order you want.
Add special marks (f.e. -----CUNO START HEAR:<CUNO>) in before field layout
And use this information in your parsing script that devides your total report into parts.
It is no mater if there is a job or any user starts this task. The program may be outer or new device script, or AFS, or something else. There are many variants.
But
If you will make a new version of 'r_print_text' function, I ask you to share it with me.
Best regards,
goooch
assassinator
29th March 2010, 11:51
OK, I still did not get your point. How to use Baan standard report output txt files which are divided up by customers' name. Because I had not did this before.
So I had hardcode the information data to each customer.
Thanks for your replies.