You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

SQR in Report mode and Process Mode

1 reply [Last post]
Guest's picture
Guest

Hello ,

I have to write a SQR in such a way that it needs to execut either in report mode or in process mode. I have to put a process flag on runcontrol page to choose the mode. If it is Process Mode it just needs to insert a row in JOB, BAS_ACTIVITY table based on some logic. If it is report mode it needs to generate CSV file. Please let me know is there any delivered sqr to look into or guide me how to achieve this task.
Thanks in Advance!

Guest's picture
Guest (not verified)
Re: SQR in Report mode and Process Mode

There are several ways you can accomplish this.

First of all you probably want the "Process Mode" checkbox value on the run control page to always initiate to off (Page Activate PeopleCode).

Next a couple of your options are lisited:

Use an if statement to see if this should insert or write file

example A:

if $process_mode = 'Y' then
begin-sql
insert into ps_xxxxxxx
values
(
...
,...
,...
)
end-sql
else
write file
end-if

Or (my preference) always write the file - maybe including the process_mode value. Go ahead and execute the insert but before the process actually ends execute a rollback as the last statement in the program.

Example B: rough - but I think you can see the logic

begin-program
do Get-Run-Control-Parameters ! to get $process_mode checkbox value
do Write-File
do Insert-Values
if $process_mode = 'N' then
rollback
end-if
end-program