Baanboard.com

Baanboard.com (http://www.baanboard.com/baanboard/index.php)
-   Code & Utilities (http://www.baanboard.com/baanboard/forumdisplay.php?f=33)
-   -   CODE: Creating your own ttstpconv Sample (http://www.baanboard.com/baanboard/showthread.php?t=513)

mark_h 30th November 2001 17:47

Creating your own ttstpconv Sample
 
1 Attachment(s)
Below is a sample of device driver which could be used in replace of ttstpconv. The original source was posted by Kevin Brock. I modified it for my use on our system. This is just a sample of what you could do. I have another version that uses a table and tells which macro to launch for excel.
See the attached zip file for a copy of the device data.

Code:

|***************************************************************************
|* tuddcconv2  0  VRC B40C c3 dev
|***************************************************************************
|* Title                : tuddcconv2 - Download file, start excel, clean up
|* Description:        : This program removes downloads a report, starts excel,
|*                        and cleans up after itself.
|* Original Author      : Kevin Brock
|* Modified by          : Mark Holland
|* Date                : 11/29/01
|***************************************************************************
|* Category            : Utility
|* Platform            : UNIX
|*
|* License for tuddcconv2
|*
|* Copyright 2001 by Mark Holland
|*
|* All Rights Reserved
|*
|* Permission to use, copy, modify, and distribute this software and its
|* documentation for any purpose and without fee is hereby granted,
|* provided that the above copyright notice appear in all copies and that
|* both that copyright notice and this permission notice appear in
|* supporting documentation.
|*
|* Mark Holland and Baanboard.com DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|* AND FITNESS, IN NO EVENT SHALL <author> nor Baanboard.com BE LIABLE FOR ANY
|* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|* OR PERFORMANCE OF THIS SOFTWARE.
|***************************************************************************
|                                                                               
|*************************** DECLARATION SECTION ***************************
        #pragma nowarnings
        #include <bic_tt>        |include tools functions
       
function main()
{
| This session will run the standard program conversion session
|  ttstpconv using a temporary output file and the arguments
|  passed in 3+ verbatim.
| Arguments are passed from Baan spooler as follows:
|    1 = Name of input (temporary) file contain dev independent report
|    2 = Name of output file
|    3 = Additional arguments (from Device data)
|    4 = Specilar parm for ttstpconv (unknown reason)

        string        tmp.file(1024)                | Temporary file name.
        string        local.path(1024)        | Location on client for report.
        long        rc                        | Return code.
        string        appl(132)                | Application to start.
        long        app_id                        | Application id.
        string        start(1024)                | Parameter for the app_start
                                        | function which has application
                                        | and file to use.

| Convert the report file into the temp file.
        tmp.file = creat.tmp.file$( bse.tmp.dir$() )
        wait.and.activate("ttstpconv", argv$(1), tmp.file, argv$(3),argv$(4))
       
| Set the path on the client's pc and send the file down. Let the user
| enter the path and filename to be downloaded.
        local.path = strip$(spool.fileout)
       
| Copy file to the client.
        send.report.to.client(tmp.file, strip$(local.path))
       
| Start the file.       
        appl = "C:\program files\microsoft office\office\excel.exe"
        start= appl&" "&local.path
       
| Start the apllication       
        app_id = app_start(start,"","","","")
       
|Check status of Application.       
        rc = app_status(app_id)
        if(rc = 0) then
                message("Application start failed.")
        endif

| Remove our work file
        seq.unlink(tmp.file)

}

function send.report.to.client(const string src(), const string dest())
{
        long err

        err = server2client(src, dest, 1)
        if (err) then
            message("Error %d copying file to PC (may not have permission)",
                err)
        endif
}


Thomas 22nd February 2002 14:19

Conversion problem
 
Hi Mark,

I'd tried to install your program, but the error status isn't cleared (I used compile flag -b ottdllbw) :
When script type = 4:
tuddcconv20:
std_gen6.1 -b ottdllbw -s ptuddcconv20 -pacc B40CUS03 -qe /baanprog/bse/tmp/tmp059325143
bic6.1 -Pvariant=0 -b ottdllbw ptuddcconv2g -u -d ottstpstandard -o otuddcconv2
-f /baanprog/bse/tmp/tmp059325142 -pacc B40CUS03 -qe /baanprog/bse/tmp/tmp05932
5144

So no error message is shown, but it doesn't work. What 's wrong ?

Now we are using a device "EXCELIT" using as 4GL-program: ttstpconv and argument: ASCII:excel. This works good, but it is annoying that always a new excel application starts, also when excel is already running. Is this resolved with your script, and/or are there other advantages ?

Thanks

Thomas

mark_h 22nd February 2002 15:42

Compile Option
 
I use the -d ottdllbw option on the compile. I am sorry to say that it will not solve the problem of launching multiple copies of excel. I have never really thought about that. I am not really sure how you stop that. Now that I think about the way that I use it I would prefer it to start multiple copies of excel. Usually (not always) when I down load to excel I kick off a macro. This way I can run the same report(different parameters) multiple times and have multiple macros running at once. See below.

This program was mainly just a sample of what you could do on your own. The way we use it hear at this site actually involves a couple of tables. One to hold the application to start and one to hold the macro that gets kicked off at the start of the app.

Examples:

table 1
report name(key) : rtisfc960001000
site (key) : lou
download filename: c:\baan\tmp\somefile.txt
macro name : somemacro.xls
macro location : f:\common\macro

table 2
site(key) : lou
appl : c:\somedir\excel.exe

I designed this for excel, but others discovered you could set up other applications. To get this to work the user selects the device PCEXCEL and puts the site key in the output file. Not elegant , but it is functional.


Mark

tjbyfield 15th June 2002 10:03

Can you please tell where function server2client() can be found
or give me some idea of what is required.

(We use baan4c4)

Your help will be appreciated

Terry

alejandro 15th June 2002 13:35

server2client
 
It is located in ttdllbw.

you can see many threads related with its use in the forum.

Include this line in your code and then use it.
#pragma used dll ottdllbw

If you want more infromation use (in Unix), bic_info6.1 ottdllbw -eu, or use session "Print Objects by Program Script / Libraries" (ttadv2439m000)

Hope this helps.

tjbyfield 15th June 2002 16:01

Re: server2client
 
Quote:

Originally posted by alejandro
It is located in ttdllbw.

you can see many threads related with its use in the forum.

Include this line in your code and then use it.
#pragma used dll ottdllbw

If you want more infromation use (in Unix), bic_info6.1 ottdllbw -eu, or use session "Print Objects by Program Script / Libraries" (ttadv2439m000)

Hope this helps.


tjbyfield 15th June 2002 16:22

Thank you I will try it right away.

I didn't know about bic_info

Regards

Terry

tjbyfield 15th June 2002 16:38

Thank you I will try it right away.

I didn't know about bic_info

Regards

Terry

gentercz 11th December 2002 10:48

start excel with a macro
 
Hi mark,

i read your post on how you use excel together with a macro.

we plan to do the same, but until now i could not find the way to start excel with a special macro.

can you please tell me the syntax how to start excel with a specific file AND launch a macro after opening this file.

Thanx,
jochen

mark_h 11th December 2002 15:26

Launch Excel with a Macro
 
To launch excel with a macro just do:

excel somepath\macrofile.xls

Please note that Excel must be in your path or you have to include the path with excel. The way I do this is the macrofile.xls contains the macro code. It uses the auto_open() subroutine to start processing. This macro knows where the data file is located and pulls it in to process it.

So I have a table that has report name and download file location and macro. My ttstpconv program looks up the report name and gets the download location. It the uses server2client to download the file to that location. Next my ttstpconv launches Excel with the macro from the table.


Mark

mclime 28th August 2003 17:43

How can ttstpconv (or replacemnt) know the reportname?
 
Hi Mark!

How can Your ttstpconv replacement know about the report that it was called by?

Is there a magic variable to import?
Or do You just parse the report data for a heading (which is the least best I'd like)

I'd be interested in the technical report name, same as in Your "table 1" mentioned earlier in this thread, because in my ttstpconv replacement (or wrapper actually) I want to do some processing dependig on the report name

Thanks a lot

mclime 29th August 2003 21:42

string spool.report(20)
 
Hrmm, hrrm,

very embarrassing! That one was a clean RTFM!

There are predefinde variables for this:
(it's even in the online-manual)

Code:

DESCRIPTION
The following predefined variables are used within the spooler functions:


  long spool.date                  date to print
  long spool.fontnumber            number of font, 1=LARGE, 2=SMALL,
                                  3=MIDDLE
  long spool.id                    identification of spooler
  long spool.left.mrg              left margin
  long spool.pr.copies            number of copies
  long spool.pg.length            length of page
  long spool.pg.width              width of page, incl left margin
  long spool.time                  time to print
  long spool.view.rtl              report in bidirectional language,
                                  true = yes, false = no
  string spool.device(14)          name of spooler device
  string spool.fileout(100)        path name of spooler output file
  string spool.paper.type(6)      type of paper
  string spool.pr.line(300)        line to print
  string spool.report(20)          report to be printed

Those varables are available to ttstpconv or a replacement program

Thanks anyway

Pilekes 14th November 2003 14:17

I'm trying to make the clientfile read-only, but haven't succeeded sofar....
I am able to make the file in the Unix dir read-only, but what I am trying to achieve is not letting server2client overwrite the file on clientside...
Any ideas?

Greetz

mclime 14th November 2003 14:48

Change Attrib of a file at client side
 
Hi Pilekes,

assume You have a bwclient, just got this idea (untested):

string dest(1024) | Temporary file name holds full client-side file path (i.e. C:\temp\foo.txt)

| do the server2client(src, dest, 0) stuff here
...
| now set dest to r/o on BW Client
app_start("ATTRIB +R " & dest ,"","","","")

Of course, errorchecking should be done on app_start, but this shoud work.

bye

mclime 14th November 2003 15:20

Wait a minute,
what are You trying to achieve?
With the piece of code I just posted, the next server2client() will run on an error if the destination file is write-protected (as it does if it's currently opened, btw)

What You'd need additionally is probably a code that checks the returncode of server2client() and then changes the filename (or lets the user do it).

Or You should probably generate a unique filename in the form of prefix+timestamp or something in the firstplace.

bye


All times are GMT +2. The time now is 04:06.


vB.Sponsors
©2001-2017 - Baanboard.com - Baanforums.com