Project and Portfolio Management Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Help with ksc_local_exec

Highlighted
Chuck Crowell
Occasional Advisor

Help with ksc_local_exec

Hi,
I have the following simple code in a command
ksc_local_exec c:/PPMCustomCode/PPMTest.exe [REQ.REQUEST_ID]
ksc_local_exec c:/PPMCustomCode/test.bat "[REQ.REQUEST_ID]" "[EXEC.EXIT_CODE]" "[EXEC.OUTPUT]"

My problem is that if PPMTest.exe has a return code other than 0, the second step is not executed. So how does one report an error code?

Thanks in advance for any help you can provide.
4 REPLIES
Jason Nichols K
Honored Contributor

Re: Help with ksc_local_exec

Chuck,

Many years ago, I had an application that I needed to automate and it's successful return codes were non-zero. I wrapped the script in a Perl script to capture the output of the commands. Then the Perl script could handle any error conditions and then the Perl script would exit with a 0 exit code so that PPM (at the time, this was still Kintana) would continue successfully.

Jason
Bobby M
Super Collector

Re: Help with ksc_local_exec

Hi Chuck,

We used shell script and the shell script will exit with value as '0' always but 'echo' the value 0,1,2 as the desired output.
Then use the sql statement to process the echo value to traverse to next steps.

For eg:
Call the shell script using ksc_local_exe
In the shell script it will be something like
/***************/
echo "ERROR - Running SQLPLUS revoke script!"
err=2
echo $err
exit 0
/***************/

Processing thru SQL
/************/
ksc_run_sql QUERY_STRING="select decode('[EXEC.OUTPUT]','0','SUCCESS','1','FAILURE', '2', 'EXCEPTION', '[EXEC.OUTPUT]') from dual" ENV_NAME="[SOURCE_ENV.ENVIRONMENT_NAME]"
/**************/
ksc_set_exit_value "[SQL_OUTPUT]"

Thanks
Bobby
Chuck Crowell
Occasional Advisor

Re: Help with ksc_local_exec

Thanks for the replies. I was afraid that I would need to work around the situation. Now I question what value does EXEC.EXIT_CODE have if the only time you coould possibly get a value is when it is 0?
Jason Nichols K
Honored Contributor

Re: Help with ksc_local_exec

Chuck,

I know it's been while since you posed your last question, but the ksc_set_exit_value allows you to set more than just '0'. The problem you were seeing was the return codes of the individual executions. PPM checks the return codes for each execution to make sure they were successfull, i.e. 0, and uses that information to determine if the rest of the command steps should be executed. When you use ksc_set_exit_value, you set the value that is used by the transition step. That's why the example showed using the SQL_OUTPUT. The thought being that the value from the SQL Query would direct how the exection step would route coming out of that step. I just recently step a Bypass function step for a client where they had certain criteria that would send requests to review board or skip that review board. The logic for processing that is more complicated that can be done with a single select statement, so I wrote simple little program to process the logic and then output the result. The workflow then routes based on that result by using the ksc_set_exit_value command.
//Add this to "OnDomLoad" event