Need to run .p program from batch file but date range passed as input from batch file

Raj2010

New Member
Hi,

I am using 10.2b, Windows XP V2002 SP3

I need to run a export( .p) program as scheduled tasks(BATCH FILE) from windows.
but i need to run this export file with date range like from last 7 days to till date(TODAY).
I don't no how to pass this date range to Progress Program(.p).

Can anyone aware of Batch File Programming please help me.

Regards,
Raj (new bee)
 

Stefan

Well-Known Member
You cannot pass input parameters directly when starting a prowin32 or _progres executable.

You can pass session parameters using -param on the command line. If your .p expects input parameters then you will need to create a wrapper .p that takes the input from session:parameter and uses these in the call.
 

RealHeavyDude

Well-Known Member
As Stefan mentioned, the only way to pass information to a Progress session at startup is to use the -param paramter. You can pass an arbitary string to which of course the limits of string handling apply.

For example:
prowin32.exe -param "value1=xxx;value2=yyy"

In the Progress session you can retreive the values from the PARAMETER attribute of the SESSION system handle ( SESSION:pARAMETER ).


Heavy Regards, RealHeavyDude.
 

Raj2010

New Member
Sorry to Trouble again.
Here i am facing 2 problems.
1. I am not aware of this batch programming so can anyone help me in this matter, I don't no how to run simple ".p" program from batch file.

2. I need to pass Date range to .p program to run it( I think i got answer for this already).

3. If any one have sample batch file, please share with me so that it will be great help for me.

Currently my prowin32.exe is in C:\dlc\bin\prowin32.exe path
Below is simple .p program which i want to run

/*****************lets assume program name as test1.p*****************/
OUTPUT TO "C:\temp\123.csv".

FOR EACH table1 WHERE table1.from_date > "FROM DATE"
AND table1.to_date < "TO DATE"
NO-LOCK:
EXPORT DELIMITER ","
table1.field1
table1.field2
table1.field3
table1.field4
table1.field5.
END.
OUTPUT CLOSE.

Regards,
Raj,
 

Stefan

Well-Known Member
Please put code inside [ code ] tags - much easier to read.

For testing create a shortcut with:

target: c:\dlc\bin\prowin32.exe -b -T c:\temp -p test1.p -param 2013-01-01,2013-12-31
start in: c:\source

When that works you simply do the same from a batch / cmd file.

Code:
def var dtfrom as date.
def var  dtto as date.
 
function uniso-date returns date private (
   i_ciso-date as char
):
 
   return date( entry( 2, i_ciso-date, "-" ), entry( 3, i_ciso-date, "-" ), entry( 1, i_ciso-date, "-" ) ).
 
end function.
 
assign
   dtfrom = uniso-date( entry( 1, session:parameter ) )
   dtto = uniso-date( entry( 2, session:parameter ) )
   .
 
output to value( substitute( "&1123.csv" ), session:temp-directory ).
for each table1
   where table1.from_date > dtfrom
   and   table1.to_date < dtto
no-lock:
   /* have fun */
end.
 
output close.
 

KMoody

Member
Just as a best practice, you might want to add a function to your .p file that checks for the right number of arguments:

Code:
IF NOT NUM-ENTRIES(SESSION:PARAMETER) = 2 THEN DO:
  OS-COMMAND echo "Wrong number of arguments!".
  /*etc.*/
END.
 

RealHeavyDude

Well-Known Member
Just some thoughts:

Since the Progress executables ( prowin32, _progres or the like on *nix ) lack the functionality to return an exit code to the operating system, IMHO, it is always good practice to roll your own error handling.

Whenever I start a Progress procedure in batch mode from a shell script I create a so-called status file ( on *nix for example with touch ) and pass its name on the -param to the Progress session. When everything went fine, the last thing that the ABL procedure does is to delete that file otherwise it will write an error message to that file. Whenever the file still exists after the Progress session exited - I know that something went wrong.

Furthermore you may want to have a look into the -clientlog startup parameter and the LOG-MANAGER system handle for logging in batch procedures.

Heavy Regards, RealHeavyDude.
 
Top