NPRao
30th April 2002, 21:32
Hi All,

I am trying to make some new tools to support our process.

I would like to call the standard bdbpre command from my baan 3-gl/4-gl programs and it does not seem to work. I tried to use the run.baan.prog as well as the shell command -

Here is the code of my script which is quite simple -
function main()
{
string code(80)
|code = "-t""|"" -Nttaad200 -C000"
code = " -s -Nttaad200 -C000"
|e = run.baan.prog("bdbpre", code, RP_WAIT)
e = shell("bdbpre" & code, 0)
}
Here is the usage from the BaaN Help manual -
Syntax

long run.baan.prog( const string progname, const string arguments, long mode
)
long run.prog( const string progname, const string arguments, long mode )

Description

The function run.baan.prog() runs a BAAN program.
The function run.prog() runs an operating system command. It is a
system-dependent function. It must not be used in applications that are
distributed across different platforms.

Arguments

progname The name of the program or command to be executed.
run.baan.prog() expands progname to $BSE/bin/progname{release}. If the progname argument in run.prog() does not supply the full path (absolute or relative), the system searches for the command using the standard facilities of the operating system platform (for example, under UNIX, all PATH elements
are searched).The argument can specify a remote host. For example, if progname is "tahoe!sort", the function runs the sort program on the tahoe host. The maximum number of remote programs that can run concurrently depends on available system resources.
arguments The function start the program or command with the parameters specified here.
mode This specifies the execution mode of the program or command. The possible values are:RP_WAIT wait for the program to finish
RP_NOWAIT run as a background program
Note
Output from the program cannot be displayed. If the -q switch is available, use this to output the program results to a file.
Use these functions instead of the shell() function used in previous versions of BAAN.
Return values
0 program executed successfully
<0 program could not be started
>0 program did not execute successfully
Note that the return value cannot be retrieved when the mode argument is set to RP_NOWAIT.
I get the return values as 0 when using the run.baan.prog and 127 for shell commands, but I am not able to get the files in my home directory.

[DEV]/home/nprao
>pwd
/home/nprao
[DEV]/app/common/home/nprao
>ls
afs.log include6.2 np tttams
baanenv include6.2.new ref tzmmig
bin messconv1 store vermig
comp.inf migperm tttadv zmadm
[DEV]/home/nprao
>

BUT when I use the same command, after setting my baan environment, and then calling the bdbpre comand from a shell script (np) I get the files.

[DEV]/home/nprao
>cat np
bdbpre6.2 -t"|" -Nttaad200 -C000
[DEV]/home/nprao
>np
Table RowCount Messages
----------- -------- ----------------------------
ttaad200000 66
[DEV]/home/nprao
>ls
afs.log include6.2 np tttadv zmadm
baanenv include6.2.new ref tttams
bin messconv1 store tzmmig
comp.inf migperm tttaad200000.S vermig
[DEV]/home/nprao
>

[DEV]/home/nprao
>vi *.S

"tttaad200000.S" 68 lines, 13539 characters
1 2002-04-23 15:58:06.797
2 #$!pre-dump!$#00017cv
3 nprao|Prashanth Rao,
Nujett|nprao|1|1||0|2400|2|2||2|6|0|1|b52amlg
d|0|2|zm|adm|00000003|0|1|1|1|1|ISO-8859-1|2||1|1|||1|2|1||||||||BAANADMIN|D
EFAU
LT||||DISPLAY|VIW||1|2|||1|1|2|%s : %S [%c]|1||
4
bsp|bsp|bsp|1|1||0|2400|2|2||2|6|1|1|b52amlgd|0|2|tc|com|00000000|0|1|1|
1|2|ISO-8859-1|2||1|1|||2|2|1||||||||DEFAULT|DEFAULT|||||ULTRAEDIT||1|2|||1|
1|2|
%s : %S [%c]|1||
5
root|root|root|1|1||0|2400|2|2||2|2|1|1|b52a|0|2|tt|tls|0000m000|0|1|1|1
|2|ISO-8859-1|2||1|1|||1|2|1||||||||DEFAULT|DEFAULT|||||||1|2|||1|1|2|%s :
%S [%
c]|1||
6 ibinglis|Ian B.
Inglis|ibinglis|2|1||0|2400|2|2||2|6|0|1|b52amlgd|60|2|t
c|com|00000000|0|1|1|2|2|ISO-8859-1|2||1|1|||1|2|1||MLGDT||||||DEFAULT|DEFAU
LT||
DEFAULT|||ULTRAEDIT|MLGD|2|2|||1|1|2|%s : %S [%c]|1||

Can you please clarify me if I am doing something wrong or there is some
problem with the BaaN Tools ?

Thanks!

NPRao
30th April 2002, 23:39
some updates -

When I use the shell command instead of the run.baan.prog it created the *.S files -


[DEV]/home/nprao
>cat np
bdbpre6.2 -t"|" -Nttaad200 -C000

|e = run.baan.prog("/home/nprao/np", "", RP_WAIT)
e = shell("/home/nprao/np", 0)

$ ls *.S
tttaad200000.S
$

NPRao
10th August 2013, 02:27
Thanks to Bhushan (http://www.baanboard.com/baanboard/member.php?u=22675)'s reference to this thread, I come back a decade later to share the working code :)

comd = "bdbpre"
args = " -t""|"" -N" & tabl & " -o " & path & " -C" & edit$(comp, "999")
|* e = run.prog(comd, args, RP_WAIT, err.file, err.file, err.file)
prog.text = form.text$("zmadms0077") |* Exporting Table - %1$s - %2$s
tbldesc = tt.table.desc(tabl)
prog.text = sprintf$(prog.text, tabl, tbldesc)
e = change.progress.indicator(0, prog.text)
e = run.baan.prog(comd, args, RP_WAIT, err.file, err.file, err.file)
if e <> 0 then
show.file.in.display.browser(err.file, "Table(s) with Error(s):", 1)
else
e = file.rm(err.file)
|display.file(err.file, "Successfully Exported Table(s):", 80, 25, "", "", true)