NirajKakodkar
10th January 2011, 08:17
This program is a extension for ttstpconv which will take HTML as argument and insert the logo image in the report. The logo image will be saved on the server and whenever the device is used the program will check if logo exists on client machine and if not available copy the logo to client machine.

The logo will appear on every page.

Some of the enhamcement ideas are listed below.

1) Making the color/font/background/logo image configurable
2) Adding prev/next buttons/links

I have already started writing for the same, will post the next version of the code once complete.

baan_guru
21st March 2011, 05:51
Hi,

Neeraj very useful post.

Do u have any idea about printing logo using BW printer?

Thanks in advance...

NirajKakodkar
21st March 2011, 13:23
http://www.baanboard.com/baanboard/showthread.php?t=27963

check the above link

baan999
19th May 2011, 12:00
Niraj,

I have seen your name appearing in the report.

can you please send device data setup detalis,

our logo is in bmp format. can this be define in device data

please suggest

bdittmar
19th May 2011, 14:00
Niraj,

I have seen your name appearing in the report.

can you please send device data setup detalis,

our logo is in bmp format. can this be define in device data

please suggest

Hello,

read the posts from beginning, please.

The attachment in first post includes the information "logo.jpg" and it's an extension to ttstpconv.

Regards

baan999
20th May 2011, 04:18
can this script be copied & try

do i need to create session/script...etc and copy the script or ??

mark_h
20th May 2011, 15:21
Yes you copy the script into a 3gl program. You then use this script as a device driver on a printer. Lets say you call the 3gl program tuddchtml, then in the device setup under the 4gl program you would put otuddchtml. These are only examples and you can call the device driver name anything you want.

Follow this link http://www.baanboard.com/baanboard/showthread.php?t=513 for sample code on how to setup up your own device driver. It shows a sample of the device setup.

wtf1ftw
5th February 2013, 12:45
Hi Niraj,

Did you extend the functionality by now?

Thank you.

Best regards!

xlcwas0
3rd April 2013, 11:01
hi,
I have this issue.
"(customise.report) [last function:rops] " ????

mark_h
3rd April 2013, 15:32
Check the script and see if you made a typo - rops instead of rpos.

xlcwas0
4th April 2013, 02:41
Check the script and see if you made a typo - rops instead of rpos.
sorry, the same problem.

bhushanchanda
4th April 2013, 08:16
Hi Niraj,

I have attached the settings. The report is processing but it does not give any output.

Please check if the settings are correct as there is no problem with the script.

bhushanchanda
4th April 2013, 08:37
Ok, I put otdbed002 in 4GL program field.
Now it give an error saying,

"Array bound error size -1 not in"

mark_h
4th April 2013, 15:45
Ok, I put otdbed002 in 4GL program field.
Now it give an error saying,

"Array bound error size -1 not in"

Yes - the otdbed002 goes in the 4gl program fields. Now put it in debug mode. My suspicion is that:

while seq.gets(read.str, 2048, input_fp) = 0

if not first_line then
position = rpos(read.str,"<pre>")
ret = seq.puts(read.str(1;position-1) & IMAGE_EMBED & read.str(position;2048), output_fp)

the position -1 is causing the problem. So maybe your report has two blank lines in it or something like that. Then you have to code around that situation. Or maybe <pre> is not getting added when the ttstpconv command is running. What you can do is check the tmp.file right after the ttstpconv - make sure it converts to html first. I am also not sure if the argument should be HTML or html - not sure it makes a difference. But putting it in debug mode and stepping through it should show where the problem starts occurring.

mark_h
4th April 2013, 15:47
sorry, the same problem.

See the all the posts on how to setup device and everything. The question is - is the script compiling for you? Or are you getting this when trying to run a report to html.

bhushanchanda
4th April 2013, 17:08
Hi Mark,

I just put it up in debugger. I have attached the snapshot of what I found. It gives value 0 for position.

Also, I have just changed the position-1 to position-2. But the same error occurs.

I am also attaching the file created on the server. But I did not found any file on client machine.

mark_h
4th April 2013, 17:13
AHH - change it from <pre> to <PRE>. See if that works.

so position = rpos(read.str, "<pre>") then becomes position = rpos(read.str, "<PRE>"). The PRE is upper case in your file.

bhushanchanda
4th April 2013, 17:25
Hi,

I just read in the documentation, it says :

If return value of file.stat is:-

0 File exists.
<>0 Operating system error code.

So, it means, the drive does not have permission to write. But, I just checked and everything is ok.

mark_h
4th April 2013, 17:59
Right - if file.stat returns 0 then the file DEFAULT in this example exists. If <>0 then Operating system error code - which could be anything. So I am assuming you are talking about this piece of code:


logo_fp = file.stat(DEFAULT,file_size)

if logo_fp < 0 then
ret = server2client(HEADER, DEFAULT, 0)
if ret < 0 then
message("Logo not available")
endif
endif


So if everything is okay - what is the question? I mean if it works why worry what logo_fp is. If you are not finding the log on the client machine then move the default somewhere you know you can right. On my win7 machine I cannot access "c:\windows\temp\" - so if I used this I would put it to c:\temp where I know I can write.

bhushanchanda
4th April 2013, 18:45
Hi Mark,

I changed all the tags to uppercase i.e. <PRE>, </PRE>,</BODY>,</HTML>

Also I changed this line

position = rpos(read.str,"<SPAN>")

I gave the permissions to the temp file. Placed the logo at right position.

Now, when after the final statement in 3GL script the output file opens. But has no data.

My Server file shows this:-

<HTML><BODY BGCOLOR="#FFFFFF"><img src='c:\windows\temp\logo.jpg'><hr><br><PRE></TD></TR></TABLE><A NAME=LAST_PAGE></BODY></HTML>
</PRE></BODY></HTML>
And yes, the address bar shows this http://temp.html/
I tried in other device and data comes up. What might be the problem now?

mark_h
4th April 2013, 18:54
Make sure this statement is working - ret = server2client(tmp.file2, dest, false). The very last line launches the file, but if the file does not get copied down to the client it will be empty. So when you run your report if the spool.fileout put a directory like c:\temp\test.html. Make sure you can write to the location. This will be the variable dest in the server2client command. I am not sure where it writes to if you just enter test.html. Also keep in mind baan has issues if you use directories with spaces in the path - at least my 4c4 does.

bhushanchanda
4th April 2013, 19:09
Hi Mark,

I tried writing

C:\windows\temp\test.html in my path and now it creates the file in the folder and displays the logo as the logo was already present in the folder as it was not able to move the logo file from server to client machine.

But I cant see any report data.

And yes, ret return 0 it means its going good.

mark_h
4th April 2013, 19:43
It reads from the temp file created by the reporting session - this is the input_fp file. As it reads it, it then writes to output_fp which is tmp.file2. The only thing I can suggest is make sure that these two files get closed:
ret = seq.close(input_fp)
ret = seq.close(output_fp)
So in debug mode stop it on the server to client. Now with input_fp and output_fp close you can go and look at them on your baan server. Make sure input fp has data in it from the original report you ran. If there is not data in it then maybe the original report was empty.

Next as this program reads thru input_fp - it writes to output_fp. Make sure the reading and writing is taking place correctly. Make sure each line is read in and then written back out into the new tmp file or output_fp. If both of those work then the temp file should have your logo and report data.

Then right after the server2client command is executed, go to the desktop and edit the html file that is out there in the dest location. If everything then lines up. Just double click the test html file and see how it comes up. Maybe the original conversion to html is wrong - but I do not know and if it is there is not much I can do about that. ANother thing is there could be something wrong with the logo image your are using - can't say, but it could be.

Your just going to have to keep debugging it to see where the issue it is going wrong and adapt to it. All this is basically doing is taking a baan report in a temp file, converting it to html, then adding a line with the logo.

bhushanchanda
4th April 2013, 20:33
Hi Mark,

Yes, as you said I found something unusual happening in there at Server side. The function

tmp.file = creat.tmp.file$(bse.tmp.dir$())

creates a temp.file of my report file on the server as the script says. But, what I observed is :-

<HTML><BODY BGCOLOR="#FFFFFF"><PRE></TD></TR></TABLE><A NAME=LAST_PAGE></BODY></HTML>

This is what I get into that temp.file. And hence it reads only one line which is this and so nothing gets printed in my final HTML report.

When I select other device, it gives me data.

Does this function has a proper syntax? It is not crearting the temp.file as expected.

bhushanchanda
4th April 2013, 20:37
And yes,

The temp.file I want has some different name. But yes it is being created there too.

mark_h
4th April 2013, 20:44
All that does is create an empty file. That is the correct syntax for it. Right after that is the command wait.and.activate("ttstpconv", argv$(1), tmp.file, argv$(3), argv$(4)). So in debug mode right after the wait and activate for ttstpconv has occurred. Go check the tmp.file. Make sure it has the data in it. Also check the file in argv$(1) it should also have the data in it. What ttstpconv does is convert the data in file argv$(1) into the tmp.file just created. You may also want to try lower case html in your device - I am not sure which is correct. I use lower case on my devices.

If all of that is correct step thru reading the tmp.file and writing to the tmp.file2.

bhushanchanda
4th April 2013, 22:17
I started my print session and check the tmp folder.

Pass 1. on opening ttstpopen, a new temp file created say temp1 which was blank.
Pass 2. after processing my report, a new temp file created which has my data within it, say temp2
Pass 3. after creat.tmp.file$(bse.tmp.dir$()) a new temp file created which was blankm say it temp3.
Pass 4. after wait.and.activate("ttstpconv", argv$(1), tmp.file, argv$(3), argv$(4)) a new temp file created, which does not have my data say temp4.

temp4 has :-
<HTML><BODY BGCOLOR="#FFFFFF"><PRE></TD></TR></TABLE><A NAME=LAST_PAGE></BODY></HTML>

Pass 5. after 2nd creat.tmp.file$(bse.tmp.dir$()), a enw temp file created say temp5, which is not having my data as well.

temp5 has :-
<HTML><BODY BGCOLOR="#FFFFFF"><img src='C:\Windows\Temp\logo.jpg'><hr><br><PRE></TD></TR></TABLE><A NAME=LAST_PAGE></BODY></HTML>
</PRE></BODY></HTML>

And that's it. I don't get anything in the html window.

Are these steps going fine?

mark_h
4th April 2013, 22:47
Pass 2 is where I will start. When you run your report program and pick the HTML device. Here is what happens:

Pass 2: Your report file will create a temp file - as you say temp2 and from above it has your data.
pass 3: This creates the new tmp file. temp3 as you say above.

pass 4: wait.and.activate("ttstpconv", argv$(1), tmp.file, argv$(3), argv$(4)) now this takes temp2 (which is in argv$(1)) and converts it to html into tmp.file(this is temp3 created in pass 3). This is not a new file - there is no temp4 file name. Now argv$(3) contains the addition parameters from the device. You must get this working first or the rest does not matter.

When you run the report in debug mode what is in argv$(1), argv$(3), argv$(4). Argv$(1) should contain the temp file from pass 2 with the data - include snapshot of the file. Argv$(3) is should contain html - once again I am not sure uppercase HTML will work. So what is in argv$(3)? argv$(4) should be empty and should not be used. Now the tmp.file is from pass 3 include a snapshot of it after the wait.and.activate, but before it is opened for reading.

bhushanchanda
4th April 2013, 22:56
Hi Marks,

Thanks very much for being patient. Problem was no where but the device setup. I never created any devices before so was new to this subject.
But with all your help, I got the output.

What I understood is, when wait.and.activate("ttstpconv", argv$(1), tmp.file, argv$(3), argv$(4))

is executed, the 4 arguments are the one we find in device data session.

What I was doing, I was writing a driver name as ttstpopen, ttbed002 , etc.

But what I found is that, if we write a specific driver there, it creates a temp file before the execution of tmp.file = creat.tmp.file$( bse.tmp.dir$() ).

The problem was, it was not taking the temp file obtained from the report but the other one.

I am attaching 2 screen shots with the script again for the further reference of those who are still stuck here.

Thanks again. :)

mark_h
4th April 2013, 23:01
Glad you figured it out. I was starting to run out of ideas.

mark_h
5th April 2013, 00:36
As per your PM about the log:

You can put the logo on the baan server where ever you want it to be. Then just make sure you set the right path in your driver file(the script uses HEADER). What I am not sure of is if the program actually explodes the ${BSE} - I think it does, but am not sure. Then if you use the script as it is it would download it to DEFAULT. Again default can be any path you can write the logo jpg into on the client. Then you would change the IMAGE_EMBED to the path of DEFAULT.

The issue I have is that I thought file.stat only looked on the BaaN server - not the local client. That could be different depending on your setup - not 100% sure. Here is how I check on 4c4 if a file exists on the client. If input file is less than 0 then it does not exist.

inputfile = seq.open.local(input.file,"r",0)
if(inputfile<0) then

So what you could try is this:

logo_fp = seq.open.local(DEFAULT,"r",0)
if logo_fp < 0 then
ret = server2client(HEADER, DEFAULT, 0)

if logo_fp is <0 you know the logo does not exist and then download it. Or if you want just always download the logo so you know it is the correct and current logo. In that case just remove the if statement for file.stat or seq.open.local - which ever you use. Just make it do this every time it runs. Notice I just commented out the checks.

| logo_fp = seq.open.local(DEFAULT,"r",0))
| if logo_fp < 0 then
ret = server2client(HEADER, DEFAULT, 0)
if ret < 0 then
message("Logo not available")
endif
| endif

bhushanchanda
6th April 2013, 17:24
Hi Mark,

Attaching a new file with everything working fine now. I observed that, the extension of the image file was causing a problem as well as the following code lines:-


logo_fp = seq.open.local(DEFAULT,"r",0))
if logo_fp < 0 then
ret = server2client(HEADER, DEFAULT, 0)
if ret < 0 then
message("Logo not available")
endif
endif

I changed it to as you suggested. I commented the lines as you said.

| logo_fp = seq.open.local(DEFAULT,"r",0))
| if logo_fp < 0 then
ret = server2client(HEADER, DEFAULT, 0)
if ret < 0 then
message("Logo not available")
endif
| endif

And now it worked. The return value for logo_fp was causing the problem.

xlcwas0
7th April 2013, 04:06
See the all the posts on how to setup device and everything. The question is - is the script compiling for you? Or are you getting this when trying to run a report to html.

hi, the script compiling no any errors, it's only display with run a report to html. [last function :rpos]
thanks.

bhushanchanda
7th April 2013, 08:52
Hi xlcwas0,

Can you specify what the problem is? Also refer to the snapshots posted in the thread.

xlcwas0
7th April 2013, 10:21
Hi xlcwas0,

Can you specify what the problem is? Also refer to the snapshots posted in the thread.

hi, bhushanchanda

fyi.

bhushanchanda
7th April 2013, 11:53
Same problem!!

Well, I will suggest you to go through the posts in the thread.
Check if the temp files are created on the server. Also, check if your local path has proper write permissions.

I have already attached the snapshots. Attaching them again.

The problem I think is in your device setup as the src file is blank.

Please do the device settings as mentioned and try again.

Also, post your device snapshots to verify if everything is correct.

xlcwas0
8th April 2013, 06:29
Same problem!!

Well, I will suggest you to go through the posts in the thread.
Check if the temp files are created on the server. Also, check if your local path has proper write permissions.

I have already attached the snapshots. Attaching them again.

The problem I think is in your device setup as the src file is blank.

Please do the device settings as mentioned and try again.

Also, post your device snapshots to verify if everything is correct.

hi, bhushanchanda and mark h

thank you very much,it's working!!

bhushanchanda
8th April 2013, 06:59
Well done!! :)