Suppose, we have to fetch Opportunities which start with Opportunity Name like ‘Test’ and write it in to a file. So our first task is to write one batch file which will have SQL statement with spooling option to fetch opportunities and next step, call batch file from siebel browser script.
Write all sql statements into a file, including the query “SELECT A.ROW_ID, A.NAME FROM SIEBEL.S_OPTY A WHERE A.NAME LIKE ‘Test%’; ” and save the file with .sql extension. We have saved it as opty.sql. The SELECT SQL statement will fetch all opportinities where name starts with ‘Test’ and spool it in opty.txt. Our opty.sql file looks like below.
Set heading off
Set echo off
Set feedback off
Set pagesize 0
Set inlinesize 256
Set serveroutput off
SELECT A.ROW_ID, A.NAME FROM SIEBEL.S_OPTY A WHERE A.NAME LIKE ‘Test%’;
As we can not call SQL statement directly from Siebel script, we will put it in one batch file. So we have created one batch file opty.bat which will be used in script. Batch file should look like below:
Absolute path of Sqlplus.exe [email protected] @absolute path of the sql file
Now write one client side business service which will call opty.bat. Go to Administration – Business Service and create a new BS ‘Generate Report’ with method name as ‘Generate Report’.
In PreInvokeMethod, use Clib function to call the bat file.
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
Clib.system(“D:\Runsql\opty.bat”); //give the absolute path of the file location.
Now verify the bisuness service, go to Administration – Business Service > Simulator and create a record with Service name and Method name and click on Run. It will create an output file ‘opty.txt’ with opportunity details where Opportunity name starts with ‘Test’.
If you have any doubt or question, feel free to comment here. To get more updates on recent activities, follow ‘TechOneStop‘ on Facebook/Twitter/LinkedIn or join our website as followers.