This tutorial walks you through the process of invoking a native COBOL program using JCL, calling a SQL Server SQL CLR stored
procedure passing group structured host variables, and returning a group variable back to the calling COBOL native program.
The SQL CLR stored procedure used in this tutorial was generated using the Generate SPD File tool.
Requirements
Complete the tutorials specified in the
Prerequisites topic.
Start
Enterprise Developer as an Administrator
Because you need to make changes to files in your SQL Server installation area, which requires administrator privileges, you
must start
Enterprise Developer as an administrator. See
To start
Enterprise Developer as an administrator for details.
Open the SQLCLRTutorialSPGroupCall Solution
- In
Enterprise Developer, click
File > Open > Project/Solution.
- Browse to the
%PUBLIC%\Documents\Micro Focus\Enterprise Developer\Samples\Mainframe\SQL\hcoss\JCLCallingSP\SPDGroupDemo directory.
- Double-click
SQLCLRTutorialSPGroupCall.sln.
Set Project Properties
- In the Solution Explorer, right-click the
SPCall project; then select
Properties from the context menu.
- On the
Debug tab (located on the left sidebar), using the drop-down list, set
Active Settings to
JCL.
- In the Solution Explorer, double-click the
Properties entry under the
SQLCLRTutorial.Publish project.
- On the
Project Settings tab (located on the left sidebar), using the drop-down list, set
Target platform to your version of SQL Server.
- Click
(Save All).
Build the Solution
- In the Solution Explorer, right-click the solution; then select
Build Solution from the context menu.
Publish the Stored Procedure
- In the Solution Explorer, right-click the
SQLCLRTutorial.Publish project; then select
Publish from the context menu.
- On the Publish Database dialog box, click
Edit.
- In the
Server name field, type
. (dot) to represent your local server.
- In the
Select or enter database name field, select
SQLCLR_Test from the drop-down list; then click
OK.
- On the Publish Database dialog box, click
Publish.
When the publishing process is complete, the Data Tools Operations window shows a status of "Publish Completed Successfully."
Associate the JCLSPG Region with the SPCall Project
- In Server Explorer, expand
Micro Focus Servers > localhost.
- Right-click
JCLSPG; then select
Associate With Project > SPCall from the context menu.
Start the JCLSPG Region
- On the Server Explorer list, right-click
JCLSPG; then select
Start from the context menu.
- If you are using SQL Server authentication, check
Server is secured; then provide your
Username and
Password. (If you are using Windows authentication, skip this step.)
- Click
OK.
Configure SQL Server Debug Properties
- In
Enterprise Developer, click
View > SQL Server Object Explorer.
- Expand
SQL Server.
- In the list of SQL Server instances, expand your SQL Server instance.
Note: If your SQL Server instance is not listed:
- On the SQL Server Object Explorer, right-click
SQL Server; then select
Add SQL Server from the context menu.
- On the Connect to Server dialog box, type
. (dot) into the
Server name field; then click
Connect.
- Repeat this step.
- Expand
Databases; then check the resulting list to ensure that
SQLCLR_Test is listed.
- Right-click your SQL Server instance; then select
Application Debugging to turn it on. When Application Debugging is on, a check mark () appears to its left.
- Right-click your SQL Server instance again; then select
Allow SQL/CLR Debugging to turn it on.
- If prompted, click
Yes.
Debug the Program and Stored Procedure
In this section, you use
Enterprise Developer to debug the native COBOL program and the SQL CLR stored procedure.
- In the Solution Explorer, double-click
SPCall.cbl to open in the COBOL editor.
- In the COBOL Editor, scroll to:
exec sql
call "GETHIRE" (:EMP-PARM, :SQLXCODE)
end-exec
- In the leftmost column on the
exec sql line, click to set a breakpoint.
- From the Solution Explorer, open
GETHIRE.cbl.
- Scroll to:
MOVE IN-EMP-TXT TO DCLEMP
and set a breakpoint.
- Click
DEBUG > Start Debugging. This builds the project and puts the debugger in a wait state.
- In Solution Explorer, right-click the
SPCall.jcl file; then select
Submit JCL from the context menu.
The JCL script calls the SPCall program and stops at the beginning of the program. Press
F5 to continue execution up to the breakpoint you set in the
SPCall.cbl file.
- Click
DEBUG > Attach to Process.
- On the Attach to Process dialog box, click
Select.
- On the Select Code Type dialog box, click
Debug these code types; then check the following boxes:
- Managed (v4.6, v4.5, v4.0)
- T-SQL
- Click
OK.
- On the Attach to Process dialog box, check
Show processes from all users.
- On the
Available Processes list, select the
sqlservr.exe entry that has the
NT Service\MSSQLServer User Name.
- Click
Attach.
Note: If a prompt appears, click
Attach to clear it.
- Click
DEBUG > Step Into.
The debugger steps into the managed SQL CLR stored procedure code. This demonstrates debugging in a mixed native/managed environment.
- To continue debugging, press
F10; when the debugger reaches another breakpoint, press
F10 again.
- Press
F5 to run the program to its completion.
- Click
Stop Debugging
to stop the Debugger.
View JCL Execution Results
- In the
Enterprise Developer Output window, select
Enterprise Server from the
Show output from drop-down list.
- CTRL-click the job output link.
This opens the
JCLSPG tab, showing the
Enterprise Server Job Output window.
- Click
SYSOUT.
This shows the output from the SQL CLR Stored Procedure.
- Close the
JCLSPG tab.
Stop the JCLSPG Enterprise Server Region
- On the Server Explorer, right-click
JCLSPG; then select
Stop from the context menu.