Re: COBOL calling C functions, run program under ispf and z/OS UNIX
Interesting code. I don't know that I like using C functions to OPEN and READ the file in COBOL. It seems to bypass some of the normal COBOL functionality that COBOL programmers would want. I'd likely use environment variable facility in the ASSIGN clause as documented: http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR50/4.2.3.1 You could prompt the programmer for the dataset/file name the same way. I don't know if that is easier than just doing a CALL of BPX1RED. Use LE's CEEENV routine to set the environment variable (which is equivalent to what we think of as the DD name): http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CEEA31B0/2.2.5.34 == I don't know exactly what the OP wanted either. But the question did raise one in my mind. Suppose that I have a batch program. In TSO, I can run the program by doing some ALLOCATE commands to allocate my files and then invoke my program using the CALL command. Without changing the program in any way (do to dynamic allocation or anything else), how can I run this same program from a UNIX shell prompt? For a pure COBOL program, I think the above can be done by replacing the ALLOCATE commands with export commands to define the environment variables (DD names) with the proper dataset names. If you need something like SYSIN or SYSPRINT to point to the UNIX shell input / output, I think you could do: export SYSIN='/dev/fd/0' export SYSPRINT='/dev/fd/1' The do your method with the chmod 1755 to a filename in the current directory which is the same as the program name in the PDS and export the name of the PDS in STEPLIB. But this wouldn't work in general, like for HLASM programs. -- John McKown -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html
Re: COBOL calling C functions, run program under ispf and z/OS UNIX
On 3/21/2011 1:21 PM, John McKown wrote: Interesting code. I don't know that I like using C functions to OPEN and READ the file in COBOL. It seems to bypass some of the normal COBOL functionality that COBOL programmers would want. Huh? What sort of functionality can't be used here? I'd likely use environment variable facility in the ASSIGN clause as documented: http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR50/4.2.3.1 Yes, I know about using CEEENV or even 'putenv' to dynamically allocate data sets. I have versions of this code that just use 'display' and 'accept' and then use either putenv or ceeenv to set up an environment variable. But I like this example _because_ it uses C functions and works with either MVS files or HFS files with a minimum of fuss in the code and runs equally simply under ISPF and zOS UNIX. You could prompt the programmer for the dataset/file name the same way.I don't know if that is easier than just doing a CALL of BPX1RED. Use LE's CEEENV routine to set the environment variable (which is equivalent to what we think of as the DD name): http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CEEA31B0/2.2.5.34 Actually, you need to use a little different syntax if you are using COBOL's dynamic allocation, checking if you have been passed an MVS name or an HFS file name; I find it a bit cumbersome. All my work with BPX1RED in COBOL has been with CGIs. == I don't know exactly what the OP wanted either. But the question did raise one in my mind. Suppose that I have a batch program. In TSO, I can run the program by doing some ALLOCATE commands to allocate my files and then invoke my program using the CALL command. Without changing the program in any way (do to dynamic allocation or anything else), how can I run this same program from a UNIX shell prompt? Well, you can use the techniques included in the original post to have the shell look in STEPLIB, so under OMVS (or telnet if you prefer): === touch app2co3 === chmod 1755 app2co3 (you only need to do this once) then when you run have a shell script that issues tso allocate commands, exports STEPLIB to include the library where the program is, then simply run the program by naming it. (You need to ensure _BPX_SHAREAS is set to YES, also). For a pure COBOL program, I think the above can be done by replacing the ALLOCATE commands with export commands to define the environment variables (DD names) with the proper dataset names. If you need something like SYSIN or SYSPRINT to point to the UNIX shell input / output, I think you could do: export SYSIN='/dev/fd/0' export SYSPRINT='/dev/fd/1' The do your method with the chmod 1755 to a filename in the current directory which is the same as the program name in the PDS and export the name of the PDS in STEPLIB. But this wouldn't work in general, like for HLASM programs. COBOL programs can interact with the terminal user by: * DISPLAY and ACCEPT - under ISPF and the shell PL/I programs can interact with the terminal user by: * PUT and GET - under ISPF and the shell All LE-enabled programs can interact with the terminal user by: * printf and scanf - under ISPF and the shell All programs, LE-enabled or not, can interact with the terminal user by: * bpx1red and bpx1wrt, using fd0 for stdin and fd1 for stdout, but it doesn't work under ISPF I have examples of these scattered about many courses. -- John McKown -- Kind regards, -Steve Comstock The Trainer's Friend, Inc. 303-393-8716 http://www.trainersfriend.com * To get a good Return on your Investment, first make an investment! + Training your people is an excellent investment * Try our new tool for calculating your Return On Investment for training dollars at http://www.trainersfriend.com/ROI/roi.html -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html
Re: Cobol calling C function
That was the problem, overrode the EDCC procedure with a //LKED Sam: That was the problem, overrode the EDCC procedure with a //LKED.SYSIN DD * with an entry and name and it worked like a champ, thank you so much for the help. Regards, Scott J Ford From: Sam Siegel s...@pscsi.net To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 4:13:19 PM Subject: Re: Cobol calling C function On Thu, Sep 16, 2010 at 12:43 PM, Scott Ford scott_j_f...@yahoo.com wrote: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) IN Sam: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(IGZEBST) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSMOD(xxx) - I think this should be the C module ENTRY TS04B - C module NAME THRALLC(R) - name for the cobol routine Hi Scott, My error, I should have been more clear. Use the entry TS04B when you compile/bind TS04B. Do not use it for your cobol program. sorry about that. Sam Yields a S0C1 ... SYSTEM COMPLETION CODE=0C1 REASON CODE=0001 TIME=15.38.39 SEQ=00058 CPU= ASID=001A PSW AT TIME OF ERROR 078D 91A01718 ILC 2 INTC 01 ACTIVE LOAD MODULE ADDRESS=11A00A28 OFFSET=0CF0 NAME=THRALLC DATA AT PSW 11A01712 - F34407FF 11A0 1A20 GR 0: FD08 1: 6FF8 2: 0040 3: 008D79D4 4: 008D79B0 5: 008FF350 6: 008C6FE0 7: FD00 8: 91A017E0 9: 008CFCC8 A: B: 11A01680 C: D: 6F60 E: 91A0168A F: 11A01A20 Regards, Scott J Ford From: Sam Siegel s...@pscsi.net To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 3:33:49 PM Subject: Re: Cobol calling C function On Thu, Sep 16, 2010 at 12:26 PM, Scott Ford scott_j_f...@yahoo.com wrote: Good point, but that compiled C module is in that library but i Sam: Good point, but that compiled C module is in that library but it brings a good point. According the the LE/C manuals the binder should look like this: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(IGZEBST) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSMOD(xxx) - I think this should be the C module ENTRY CBLRTN - cobol routine NAME (R) - name for the cobol routine The CSECT for C was wrong in the linkage output , here is the line from the Binder... z/OS V1 R10 BINDER 12:52:13 THURSDAY SEPTEMBER 16, 2010 BATCH EMULATOR JOB(ADCDMETA) STEP(LKED ) PGM= HEWL IEW2278I B352 INVOCATION PARAMETERS - AMODE=31,MAP IEW2650I 5102 MODULE ENTRY NOT PROVIDED. ENTRY DEFAULTS TO SECTION $PRIV10. Maybe its me, but this looks wrong That message occurs when your 'c' function does not have a 'main' in it and no ENTRY control card is specified for the binder. Try ENTRY TS04B in your binder and see if it goes away. Sam Scott J Ford From: Sam Siegel s...@pscsi.net To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 2:38:31 PM Subject: Re: Cobol calling C function On Thu, Sep 16, 2010 at 11:27 AM, Scott Ford scott_j_f...@yahoo.com wrote: START OF TS04A CEE3207S The system detected a data exception ( zMan: START OF TS04A CEE3207S The system detected a data exception (System Completion Code=0C7). From compile unit THRALLC at entry point THRALLC at compile unit offset at address 11A00E4E. Looks like I have something wrong in C. I am not a C heavy...So any help is super great ! Thanks I'm not sure if this is related but you appear to be dynamically calling a function that you have statically linked. Are you sure that you are picking up the correct version of TSO4B? Sam Scott J Ford From: zMan zedgarhoo...@gmail.com To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 1:58:43 PM Subject: Re: Cobol calling C function What is the failure you're seeing? On Thu, Sep 16, 2010 at 1:38 PM, Scott Ford scott_j_f...@yahoo.com wrote: I have seen several 'bit and piece' posts on LE Cobol calling C All: I have seen several 'bit and piece' posts on LE Cobol calling C. I have written a sample C call and here is the source and have included the C source and JCL , Cobol source and JCL, I dont understand what I have missed, I have been through the LE Books and C-C++ books and I am confused and the execution is receiving a S0C7 : JCL for 'C' compile: -- //ADCDMETA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=0M // EXEC EDCCL, // INFILE=SFORD.JCLLIB.CNTL(TESTC)', // OUTFILE='SFORD.CLINKLIB(TS04B),DISP=SHR' 'C' Source
Re: Cobol calling C function
On Fri, Sep 17, 2010 at 6:13 AM, Scott Ford scott_j_f...@yahoo.com wrote: That was the problem, overrode the EDCC procedure with a //LKED Sam: That was the problem, overrode the EDCC procedure with a //LKED.SYSIN DD * with an entry and name and it worked like a champ, thank you so much for the help. You're welcome. Cheers, Sam Regards, Scott J Ford From: Sam Siegel s...@pscsi.net To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 4:13:19 PM Subject: Re: Cobol calling C function On Thu, Sep 16, 2010 at 12:43 PM, Scott Ford scott_j_f...@yahoo.com wrote: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) IN Sam: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(IGZEBST) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSMOD(xxx)- I think this should be the C module ENTRY TS04B- C module NAME THRALLC(R)- name for the cobol routine Hi Scott, My error, I should have been more clear. Use the entry TS04B when you compile/bind TS04B. Do not use it for your cobol program. sorry about that. Sam Yields a S0C1 ... SYSTEM COMPLETION CODE=0C1 REASON CODE=0001 TIME=15.38.39 SEQ=00058 CPU= ASID=001A PSW AT TIME OF ERROR 078D 91A01718 ILC 2 INTC 01 ACTIVE LOAD MODULE ADDRESS=11A00A28 OFFSET=0CF0 NAME=THRALLC DATA AT PSW 11A01712 - F34407FF 11A0 1A20 GR 0: FD08 1: 6FF8 2: 0040 3: 008D79D4 4: 008D79B0 5: 008FF350 6: 008C6FE0 7: FD00 8: 91A017E0 9: 008CFCC8 A: B: 11A01680 C: D: 6F60 E: 91A0168A F: 11A01A20 Regards, Scott J Ford From: Sam Siegel s...@pscsi.net To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 3:33:49 PM Subject: Re: Cobol calling C function On Thu, Sep 16, 2010 at 12:26 PM, Scott Ford scott_j_f...@yahoo.com wrote: Good point, but that compiled C module is in that library but i Sam: Good point, but that compiled C module is in that library but it brings a good point. According the the LE/C manuals the binder should look like this: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(IGZEBST) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSMOD(xxx)- I think this should be the C module ENTRY CBLRTN- cobol routine NAME (R)- name for the cobol routine The CSECT for C was wrong in the linkage output , here is the line from the Binder... z/OS V1 R10 BINDER12:52:13 THURSDAY SEPTEMBER 16, 2010 BATCH EMULATOR JOB(ADCDMETA) STEP(LKED) PGM= HEWL IEW2278I B352 INVOCATION PARAMETERS - AMODE=31,MAP IEW2650I 5102 MODULE ENTRY NOT PROVIDED. ENTRY DEFAULTS TO SECTION $PRIV10. Maybe its me, but this looks wrong That message occurs when your 'c' function does not have a 'main' in it and no ENTRY control card is specified for the binder. Try ENTRY TS04B in your binder and see if it goes away. Sam Scott J Ford From: Sam Siegel s...@pscsi.net To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 2:38:31 PM Subject: Re: Cobol calling C function On Thu, Sep 16, 2010 at 11:27 AM, Scott Ford scott_j_f...@yahoo.com wrote: START OF TS04A CEE3207S The system detected a data exception ( zMan: START OF TS04A CEE3207S The system detected a data exception (System Completion Code=0C7). From compile unit THRALLC at entry point THRALLC at compile unit offset at address 11A00E4E. Looks like I have something wrong in C. I am not a C heavy...So any help is super great ! Thanks I'm not sure if this is related but you appear to be dynamically calling a function that you have statically linked. Are you sure that you are picking up the correct version of TSO4B? Sam Scott J Ford From: zMan zedgarhoo...@gmail.com To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 1:58:43 PM Subject: Re: Cobol calling C function What is the failure you're seeing? On Thu, Sep 16, 2010 at 1:38 PM, Scott Ford scott_j_f...@yahoo.com wrote: I have seen several 'bit and piece' posts on LE Cobol calling C All: I have seen several 'bit and piece' posts on LE Cobol calling C. I have written a sample C call and here is the source and have included the C source and JCL , Cobol source and JCL, I dont understand what I have missed, I have been through the LE Books and C-C++ books and I am confused and the execution is receiving a S0C7 : JCL for 'C' compile
Re: Cobol calling C function
What is the failure you're seeing? On Thu, Sep 16, 2010 at 1:38 PM, Scott Ford scott_j_f...@yahoo.com wrote: I have seen several 'bit and piece' posts on LE Cobol calling C All: I have seen several 'bit and piece' posts on LE Cobol calling C. I have written a sample C call and here is the source and have included the C source and JCL , Cobol source and JCL, I dont understand what I have missed, I have been through the LE Books and C-C++ books and I am confused and the execution is receiving a S0C7 : JCL for 'C' compile: -- //ADCDMETA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=0M // EXEC EDCCL, // INFILE=SFORD.JCLLIB.CNTL(TESTC)', // OUTFILE='SFORD.CLINKLIB(TS04B),DISP=SHR' 'C' Source: --- #include stdio.h #include string.h #pragma linkage(TS04B,COBOL) void TS04B( char *pBuffer ) { strcpy( pBuffer, OK ); fprintf(stderr,ok trans\n); } LE Cobol V4r1 JCL: -- //ADCDTHRA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=4096K //* //COB EXEC PGM=IGYCRCTL, // PARM=('NOC(E)','FLAG(W)','DATA(31)',NODYN,RES,RENT,OPT, // MAP,NOSSR,NOZWB,NUM,NOTERM,NOVBREF,X,APOST,LIB,LIST), // REGION=1024K //STEPLIB DD DISP=SHR,DSN=IGY410.SIGYCOMP //SYSLIB DD DISP=SHR,DSN=CEE.ACEESRC1 // DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSPRINT DD SYSOUT=X //SYSUT1 DD UNIT=VIO //SYSUT2 DD UNIT=VIO //SYSUT3 DD UNIT=VIO //SYSUT4 DD UNIT=VIO //SYSUT5 DD UNIT=VIO //SYSUT6 DD UNIT=VIO //SYSUT7 DD UNIT=VIO //SYSLIN DD DISP=(,PASS),DSN=LOADSET, // UNIT=VIO, // DCB=BLKSIZE=3200 //SYSIN DD DISP=SHR,DSN=SFORD.COBOL.SOURCE(THRALLC) //* //LNK EXEC PGM=IEWL, // COND=(4,LT,COB), // PARM='LIST,XREF', // REGION=4096K //SYSLIB DD DISP=SHR,DSN=SFORD.CLINKLIB // DD DISP=SHR,DSN=CEE.SCEELKED // DD DISP=SHR,DSN=SYS1.CSSLIB // DD DISP=SHR,DSN=TCPIP.SEZATCP //SYSLMOD DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSUT1 DD UNIT=SYSDA, // DCB=BLKSIZE=1024, // SPACE=(1024,(200,20)) //SYSPRINT DD SYSOUT=X //SYSLOUT DD SYSOUT=X //SYSLIN DD DISP=(OLD,DELETE),DSN=LOADSET // DD DDNAME=SYSIN //SYSIN DD * MODE AMODE(31),RMODE(ANY) INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSLMOD(TS04B) ENTRY THRALLC NAME THRALLC(R) /* // LE Cobol Source: - IDENTIFICATION DIVISION. PROGRAM-ID. THRALLC. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. DATA DIVISION. FILE SECTION. WORKING-STORAGE SECTION. 01 TS04B PIC X(8) VALUE 'TS04B'. 01 TESTIT PIC X(10) VALUE 'SCOTT'. PROCEDURE DIVISION. DISPLAY 'START OF TS04A'. CALL TS04B USING TESTIT. DISPLAY TESTIT. GOBACK. Sorry for the long post, but I think one has to see all the pieces. Please tell me am I blind in my old age or what... Thanks in advance. Scott J Ford -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html -- zMan -- I've got a mainframe and I'm not afraid to use it -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html
Re: Cobol calling C function
START OF TS04A CEE3207S The system detected a data exception ( zMan: START OF TS04A CEE3207S The system detected a data exception (System Completion Code=0C7). From compile unit THRALLC at entry point THRALLC at compile unit offset at address 11A00E4E. Looks like I have something wrong in C. I am not a C heavy...So any help is super great ! Thanks Scott J Ford From: zMan zedgarhoo...@gmail.com To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 1:58:43 PM Subject: Re: Cobol calling C function What is the failure you're seeing? On Thu, Sep 16, 2010 at 1:38 PM, Scott Ford scott_j_f...@yahoo.com wrote: I have seen several 'bit and piece' posts on LE Cobol calling C All: I have seen several 'bit and piece' posts on LE Cobol calling C. I have written a sample C call and here is the source and have included the C source and JCL , Cobol source and JCL, I dont understand what I have missed, I have been through the LE Books and C-C++ books and I am confused and the execution is receiving a S0C7 : JCL for 'C' compile: -- //ADCDMETA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=0M // EXEC EDCCL, // INFILE=SFORD.JCLLIB.CNTL(TESTC)', // OUTFILE='SFORD.CLINKLIB(TS04B),DISP=SHR' 'C' Source: --- #include stdio.h #include string.h #pragma linkage(TS04B,COBOL) void TS04B( char *pBuffer ) { strcpy( pBuffer, OK ); fprintf(stderr,ok trans\n); } LE Cobol V4r1 JCL: -- //ADCDTHRA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=4096K //* //COB EXEC PGM=IGYCRCTL, // PARM=('NOC(E)','FLAG(W)','DATA(31)',NODYN,RES,RENT,OPT, // MAP,NOSSR,NOZWB,NUM,NOTERM,NOVBREF,X,APOST,LIB,LIST), // REGION=1024K //STEPLIB DD DISP=SHR,DSN=IGY410.SIGYCOMP //SYSLIB DD DISP=SHR,DSN=CEE.ACEESRC1 // DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSPRINT DD SYSOUT=X //SYSUT1 DD UNIT=VIO //SYSUT2 DD UNIT=VIO //SYSUT3 DD UNIT=VIO //SYSUT4 DD UNIT=VIO //SYSUT5 DD UNIT=VIO //SYSUT6 DD UNIT=VIO //SYSUT7 DD UNIT=VIO //SYSLIN DD DISP=(,PASS),DSN=LOADSET, // UNIT=VIO, // DCB=BLKSIZE=3200 //SYSIN DD DISP=SHR,DSN=SFORD.COBOL.SOURCE(THRALLC) //* //LNK EXEC PGM=IEWL, // COND=(4,LT,COB), // PARM='LIST,XREF', // REGION=4096K //SYSLIB DD DISP=SHR,DSN=SFORD.CLINKLIB // DD DISP=SHR,DSN=CEE.SCEELKED // DD DISP=SHR,DSN=SYS1.CSSLIB // DD DISP=SHR,DSN=TCPIP.SEZATCP //SYSLMOD DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSUT1 DD UNIT=SYSDA, // DCB=BLKSIZE=1024, // SPACE=(1024,(200,20)) //SYSPRINT DD SYSOUT=X //SYSLOUT DD SYSOUT=X //SYSLIN DD DISP=(OLD,DELETE),DSN=LOADSET // DD DDNAME=SYSIN //SYSIN DD * MODE AMODE(31),RMODE(ANY) INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSLMOD(TS04B) ENTRY THRALLC NAME THRALLC(R) /* // LE Cobol Source: - IDENTIFICATION DIVISION. PROGRAM-ID. THRALLC. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. DATA DIVISION. FILE SECTION. WORKING-STORAGE SECTION. 01 TS04B PIC X(8) VALUE 'TS04B'. 01 TESTIT PIC X(10) VALUE 'SCOTT'. PROCEDURE DIVISION. DISPLAY 'START OF TS04A'. CALL TS04B USING TESTIT. DISPLAY TESTIT. GOBACK. Sorry for the long post, but I think one has to see all the pieces. Please tell me am I blind in my old age or what... Thanks in advance. Scott J Ford -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html -- zMan -- I've got a mainframe and I'm not afraid to use it -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html
Re: Cobol calling C function
INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) IN Sam: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(IGZEBST) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSMOD(xxx) - I think this should be the C module ENTRY TS04B - C module NAME THRALLC(R) - name for the cobol routine Yields a S0C1 ... SYSTEM COMPLETION CODE=0C1 REASON CODE=0001 TIME=15.38.39 SEQ=00058 CPU= ASID=001A PSW AT TIME OF ERROR 078D 91A01718 ILC 2 INTC 01 ACTIVE LOAD MODULE ADDRESS=11A00A28 OFFSET=0CF0 NAME=THRALLC DATA AT PSW 11A01712 - F34407FF 11A0 1A20 GR 0: FD08 1: 6FF8 2: 0040 3: 008D79D4 4: 008D79B0 5: 008FF350 6: 008C6FE0 7: FD00 8: 91A017E0 9: 008CFCC8 A: B: 11A01680 C: D: 6F60 E: 91A0168A F: 11A01A20 Regards, Scott J Ford From: Sam Siegel s...@pscsi.net To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 3:33:49 PM Subject: Re: Cobol calling C function On Thu, Sep 16, 2010 at 12:26 PM, Scott Ford scott_j_f...@yahoo.com wrote: Good point, but that compiled C module is in that library but i Sam: Good point, but that compiled C module is in that library but it brings a good point. According the the LE/C manuals the binder should look like this: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(IGZEBST) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSMOD(xxx) - I think this should be the C module ENTRY CBLRTN - cobol routine NAME (R) - name for the cobol routine The CSECT for C was wrong in the linkage output , here is the line from the Binder... z/OS V1 R10 BINDER 12:52:13 THURSDAY SEPTEMBER 16, 2010 BATCH EMULATOR JOB(ADCDMETA) STEP(LKED ) PGM= HEWL IEW2278I B352 INVOCATION PARAMETERS - AMODE=31,MAP IEW2650I 5102 MODULE ENTRY NOT PROVIDED. ENTRY DEFAULTS TO SECTION $PRIV10. Maybe its me, but this looks wrong That message occurs when your 'c' function does not have a 'main' in it and no ENTRY control card is specified for the binder. Try ENTRY TS04B in your binder and see if it goes away. Sam Scott J Ford From: Sam Siegel s...@pscsi.net To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 2:38:31 PM Subject: Re: Cobol calling C function On Thu, Sep 16, 2010 at 11:27 AM, Scott Ford scott_j_f...@yahoo.com wrote: START OF TS04A CEE3207S The system detected a data exception ( zMan: START OF TS04A CEE3207S The system detected a data exception (System Completion Code=0C7). From compile unit THRALLC at entry point THRALLC at compile unit offset at address 11A00E4E. Looks like I have something wrong in C. I am not a C heavy...So any help is super great ! Thanks I'm not sure if this is related but you appear to be dynamically calling a function that you have statically linked. Are you sure that you are picking up the correct version of TSO4B? Sam Scott J Ford From: zMan zedgarhoo...@gmail.com To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 1:58:43 PM Subject: Re: Cobol calling C function What is the failure you're seeing? On Thu, Sep 16, 2010 at 1:38 PM, Scott Ford scott_j_f...@yahoo.com wrote: I have seen several 'bit and piece' posts on LE Cobol calling C All: I have seen several 'bit and piece' posts on LE Cobol calling C. I have written a sample C call and here is the source and have included the C source and JCL , Cobol source and JCL, I dont understand what I have missed, I have been through the LE Books and C-C++ books and I am confused and the execution is receiving a S0C7 : JCL for 'C' compile: -- //ADCDMETA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=0M // EXEC EDCCL, // INFILE=SFORD.JCLLIB.CNTL(TESTC)', // OUTFILE='SFORD.CLINKLIB(TS04B),DISP=SHR' 'C' Source: --- #include stdio.h #include string.h #pragma linkage(TS04B,COBOL) void TS04B( char *pBuffer ) { strcpy( pBuffer, OK ); fprintf(stderr,ok trans\n); } LE Cobol V4r1 JCL: -- //ADCDTHRA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=4096K //* //COB EXEC PGM=IGYCRCTL, // PARM=('NOC(E)','FLAG(W)','DATA(31)',NODYN,RES,RENT,OPT, // MAP,NOSSR,NOZWB,NUM,NOTERM,NOVBREF,X,APOST,LIB,LIST), // REGION=1024K //STEPLIB DD DISP=SHR,DSN=IGY410.SIGYCOMP //SYSLIB DD DISP=SHR,DSN=CEE.ACEESRC1 // DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSPRINT DD SYSOUT=X //SYSUT1 DD UNIT=VIO
Re: Cobol calling C function
On Thu, Sep 16, 2010 at 11:27 AM, Scott Ford scott_j_f...@yahoo.com wrote: START OF TS04A CEE3207S The system detected a data exception ( zMan: START OF TS04A CEE3207S The system detected a data exception (System Completion Code=0C7). From compile unit THRALLC at entry point THRALLC at compile unit offset at address 11A00E4E. Looks like I have something wrong in C. I am not a C heavy...So any help is super great ! Thanks I'm not sure if this is related but you appear to be dynamically calling a function that you have statically linked. Are you sure that you are picking up the correct version of TSO4B? Sam Scott J Ford From: zMan zedgarhoo...@gmail.com To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 1:58:43 PM Subject: Re: Cobol calling C function What is the failure you're seeing? On Thu, Sep 16, 2010 at 1:38 PM, Scott Ford scott_j_f...@yahoo.com wrote: I have seen several 'bit and piece' posts on LE Cobol calling C All: I have seen several 'bit and piece' posts on LE Cobol calling C. I have written a sample C call and here is the source and have included the C source and JCL , Cobol source and JCL, I dont understand what I have missed, I have been through the LE Books and C-C++ books and I am confused and the execution is receiving a S0C7 : JCL for 'C' compile: -- //ADCDMETA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=0M // EXEC EDCCL, // INFILE=SFORD.JCLLIB.CNTL(TESTC)', // OUTFILE='SFORD.CLINKLIB(TS04B),DISP=SHR' 'C' Source: --- #include stdio.h #include string.h #pragma linkage(TS04B,COBOL) void TS04B( char *pBuffer ) { strcpy( pBuffer, OK ); fprintf(stderr,ok trans\n); } LE Cobol V4r1 JCL: -- //ADCDTHRA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=4096K //* //COB EXEC PGM=IGYCRCTL, // PARM=('NOC(E)','FLAG(W)','DATA(31)',NODYN,RES,RENT,OPT, // MAP,NOSSR,NOZWB,NUM,NOTERM,NOVBREF,X,APOST,LIB,LIST), // REGION=1024K //STEPLIB DD DISP=SHR,DSN=IGY410.SIGYCOMP //SYSLIBDD DISP=SHR,DSN=CEE.ACEESRC1 // DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSPRINT DD SYSOUT=X //SYSUT1DD UNIT=VIO //SYSUT2DD UNIT=VIO //SYSUT3DD UNIT=VIO //SYSUT4DD UNIT=VIO //SYSUT5DD UNIT=VIO //SYSUT6DD UNIT=VIO //SYSUT7DD UNIT=VIO //SYSLINDD DISP=(,PASS),DSN=LOADSET, // UNIT=VIO, // DCB=BLKSIZE=3200 //SYSIN DD DISP=SHR,DSN=SFORD.COBOL.SOURCE(THRALLC) //* //LNK EXEC PGM=IEWL, // COND=(4,LT,COB), // PARM='LIST,XREF', // REGION=4096K //SYSLIBDD DISP=SHR,DSN=SFORD.CLINKLIB // DD DISP=SHR,DSN=CEE.SCEELKED // DD DISP=SHR,DSN=SYS1.CSSLIB // DD DISP=SHR,DSN=TCPIP.SEZATCP //SYSLMOD DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSUT1DD UNIT=SYSDA, // DCB=BLKSIZE=1024, // SPACE=(1024,(200,20)) //SYSPRINT DD SYSOUT=X //SYSLOUT DD SYSOUT=X //SYSLINDD DISP=(OLD,DELETE),DSN=LOADSET // DD DDNAME=SYSIN //SYSIN DD * MODE AMODE(31),RMODE(ANY) INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSLMOD(TS04B) ENTRY THRALLC NAME THRALLC(R) /* // LE Cobol Source: - IDENTIFICATION DIVISION. PROGRAM-ID. THRALLC. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. DATA DIVISION. FILE SECTION. WORKING-STORAGE SECTION. 01 TS04BPIC X(8) VALUE 'TS04B'. 01 TESTIT PIC X(10) VALUE 'SCOTT'. PROCEDURE DIVISION. DISPLAY 'START OF TS04A'. CALL TS04B USING TESTIT. DISPLAY TESTIT. GOBACK. Sorry for the long post, but I think one has to see all the pieces. Please tell me am I blind in my old age or what... Thanks in advance. Scott J Ford -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html -- zMan -- I've got a mainframe and I'm not afraid to use it -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html
Re: Cobol calling C function
On Thu, Sep 16, 2010 at 12:26 PM, Scott Ford scott_j_f...@yahoo.com wrote: Good point, but that compiled C module is in that library but i Sam: Good point, but that compiled C module is in that library but it brings a good point. According the the LE/C manuals the binder should look like this: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(IGZEBST) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSMOD(xxx)- I think this should be the C module ENTRY CBLRTN - cobol routine NAME (R)- name for the cobol routine The CSECT for C was wrong in the linkage output , here is the line from the Binder... z/OS V1 R10 BINDER 12:52:13 THURSDAY SEPTEMBER 16, 2010 BATCH EMULATOR JOB(ADCDMETA) STEP(LKED) PGM= HEWL IEW2278I B352 INVOCATION PARAMETERS - AMODE=31,MAP IEW2650I 5102 MODULE ENTRY NOT PROVIDED. ENTRY DEFAULTS TO SECTION $PRIV10. Maybe its me, but this looks wrong That message occurs when your 'c' function does not have a 'main' in it and no ENTRY control card is specified for the binder. Try ENTRY TS04B in your binder and see if it goes away. Sam Scott J Ford From: Sam Siegel s...@pscsi.net To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 2:38:31 PM Subject: Re: Cobol calling C function On Thu, Sep 16, 2010 at 11:27 AM, Scott Ford scott_j_f...@yahoo.com wrote: START OF TS04A CEE3207S The system detected a data exception ( zMan: START OF TS04A CEE3207S The system detected a data exception (System Completion Code=0C7). From compile unit THRALLC at entry point THRALLC at compile unit offset at address 11A00E4E. Looks like I have something wrong in C. I am not a C heavy...So any help is super great ! Thanks I'm not sure if this is related but you appear to be dynamically calling a function that you have statically linked. Are you sure that you are picking up the correct version of TSO4B? Sam Scott J Ford From: zMan zedgarhoo...@gmail.com To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 1:58:43 PM Subject: Re: Cobol calling C function What is the failure you're seeing? On Thu, Sep 16, 2010 at 1:38 PM, Scott Ford scott_j_f...@yahoo.com wrote: I have seen several 'bit and piece' posts on LE Cobol calling C All: I have seen several 'bit and piece' posts on LE Cobol calling C. I have written a sample C call and here is the source and have included the C source and JCL , Cobol source and JCL, I dont understand what I have missed, I have been through the LE Books and C-C++ books and I am confused and the execution is receiving a S0C7 : JCL for 'C' compile: -- //ADCDMETA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, //NOTIFY=SYSUID,REGION=0M //EXEC EDCCL, // INFILE=SFORD.JCLLIB.CNTL(TESTC)', // OUTFILE='SFORD.CLINKLIB(TS04B),DISP=SHR' 'C' Source: --- #include stdio.h #include string.h #pragma linkage(TS04B,COBOL) void TS04B( char *pBuffer ) { strcpy( pBuffer, OK ); fprintf(stderr,ok trans\n); } LE Cobol V4r1 JCL: -- //ADCDTHRA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, //NOTIFY=SYSUID,REGION=4096K //* //COBEXEC PGM=IGYCRCTL, //PARM=('NOC(E)','FLAG(W)','DATA(31)',NODYN,RES,RENT,OPT, //MAP,NOSSR,NOZWB,NUM,NOTERM,NOVBREF,X,APOST,LIB,LIST), //REGION=1024K //STEPLIB DD DISP=SHR,DSN=IGY410.SIGYCOMP //SYSLIBDD DISP=SHR,DSN=CEE.ACEESRC1 // DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSPRINT DD SYSOUT=X //SYSUT1DD UNIT=VIO //SYSUT2DD UNIT=VIO //SYSUT3DD UNIT=VIO //SYSUT4DD UNIT=VIO //SYSUT5DD UNIT=VIO //SYSUT6DD UNIT=VIO //SYSUT7DD UNIT=VIO //SYSLINDD DISP=(,PASS),DSN=LOADSET, //UNIT=VIO, //DCB=BLKSIZE=3200 //SYSINDD DISP=SHR,DSN=SFORD.COBOL.SOURCE(THRALLC) //* //LNKEXEC PGM=IEWL, //COND=(4,LT,COB), //PARM='LIST,XREF', //REGION=4096K //SYSLIBDD DISP=SHR,DSN=SFORD.CLINKLIB // DD DISP=SHR,DSN=CEE.SCEELKED // DD DISP=SHR,DSN=SYS1.CSSLIB // DD DISP=SHR,DSN=TCPIP.SEZATCP //SYSLMOD DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSUT1DD UNIT=SYSDA, //DCB=BLKSIZE=1024, //SPACE=(1024,(200,20)) //SYSPRINT DD SYSOUT=X //SYSLOUT DD SYSOUT=X //SYSLINDD DISP=(OLD,DELETE),DSN=LOADSET // DD DDNAME=SYSIN //SYSINDD * MODE AMODE(31),RMODE(ANY) INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSLMOD(TS04B) ENTRY THRALLC
Re: Cobol calling C function
Good point, but that compiled C module is in that library but i Sam: Good point, but that compiled C module is in that library but it brings a good point. According the the LE/C manuals the binder should look like this: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(IGZEBST) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSMOD(xxx) - I think this should be the C module ENTRY CBLRTN - cobol routine NAME (R) - name for the cobol routine The CSECT for C was wrong in the linkage output , here is the line from the Binder... z/OS V1 R10 BINDER 12:52:13 THURSDAY SEPTEMBER 16, 2010 BATCH EMULATOR JOB(ADCDMETA) STEP(LKED ) PGM= HEWL IEW2278I B352 INVOCATION PARAMETERS - AMODE=31,MAP IEW2650I 5102 MODULE ENTRY NOT PROVIDED. ENTRY DEFAULTS TO SECTION $PRIV10. Maybe its me, but this looks wrong Scott J Ford From: Sam Siegel s...@pscsi.net To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 2:38:31 PM Subject: Re: Cobol calling C function On Thu, Sep 16, 2010 at 11:27 AM, Scott Ford scott_j_f...@yahoo.com wrote: START OF TS04A CEE3207S The system detected a data exception ( zMan: START OF TS04A CEE3207S The system detected a data exception (System Completion Code=0C7). From compile unit THRALLC at entry point THRALLC at compile unit offset at address 11A00E4E. Looks like I have something wrong in C. I am not a C heavy...So any help is super great ! Thanks I'm not sure if this is related but you appear to be dynamically calling a function that you have statically linked. Are you sure that you are picking up the correct version of TSO4B? Sam Scott J Ford From: zMan zedgarhoo...@gmail.com To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 1:58:43 PM Subject: Re: Cobol calling C function What is the failure you're seeing? On Thu, Sep 16, 2010 at 1:38 PM, Scott Ford scott_j_f...@yahoo.com wrote: I have seen several 'bit and piece' posts on LE Cobol calling C All: I have seen several 'bit and piece' posts on LE Cobol calling C. I have written a sample C call and here is the source and have included the C source and JCL , Cobol source and JCL, I dont understand what I have missed, I have been through the LE Books and C-C++ books and I am confused and the execution is receiving a S0C7 : JCL for 'C' compile: -- //ADCDMETA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=0M // EXEC EDCCL, // INFILE=SFORD.JCLLIB.CNTL(TESTC)', // OUTFILE='SFORD.CLINKLIB(TS04B),DISP=SHR' 'C' Source: --- #include stdio.h #include string.h #pragma linkage(TS04B,COBOL) void TS04B( char *pBuffer ) { strcpy( pBuffer, OK ); fprintf(stderr,ok trans\n); } LE Cobol V4r1 JCL: -- //ADCDTHRA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=4096K //* //COB EXEC PGM=IGYCRCTL, // PARM=('NOC(E)','FLAG(W)','DATA(31)',NODYN,RES,RENT,OPT, // MAP,NOSSR,NOZWB,NUM,NOTERM,NOVBREF,X,APOST,LIB,LIST), // REGION=1024K //STEPLIB DD DISP=SHR,DSN=IGY410.SIGYCOMP //SYSLIB DD DISP=SHR,DSN=CEE.ACEESRC1 // DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSPRINT DD SYSOUT=X //SYSUT1 DD UNIT=VIO //SYSUT2 DD UNIT=VIO //SYSUT3 DD UNIT=VIO //SYSUT4 DD UNIT=VIO //SYSUT5 DD UNIT=VIO //SYSUT6 DD UNIT=VIO //SYSUT7 DD UNIT=VIO //SYSLIN DD DISP=(,PASS),DSN=LOADSET, // UNIT=VIO, // DCB=BLKSIZE=3200 //SYSIN DD DISP=SHR,DSN=SFORD.COBOL.SOURCE(THRALLC) //* //LNK EXEC PGM=IEWL, // COND=(4,LT,COB), // PARM='LIST,XREF', // REGION=4096K //SYSLIB DD DISP=SHR,DSN=SFORD.CLINKLIB // DD DISP=SHR,DSN=CEE.SCEELKED // DD DISP=SHR,DSN=SYS1.CSSLIB // DD DISP=SHR,DSN=TCPIP.SEZATCP //SYSLMOD DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSUT1 DD UNIT=SYSDA, // DCB=BLKSIZE=1024, // SPACE=(1024,(200,20)) //SYSPRINT DD SYSOUT=X //SYSLOUT DD SYSOUT=X //SYSLIN DD DISP=(OLD,DELETE),DSN=LOADSET // DD DDNAME=SYSIN //SYSIN DD * MODE AMODE(31),RMODE(ANY) INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSLMOD(TS04B) ENTRY THRALLC NAME THRALLC(R) /* // LE Cobol Source: - IDENTIFICATION DIVISION. PROGRAM-ID. THRALLC. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. DATA DIVISION. FILE SECTION. WORKING-STORAGE SECTION. 01 TS04B PIC X(8) VALUE 'TS04B'. 01 TESTIT PIC X(10) VALUE 'SCOTT
Re: Cobol calling C function
On Thu, Sep 16, 2010 at 12:43 PM, Scott Ford scott_j_f...@yahoo.com wrote: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) IN Sam: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(IGZEBST) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSMOD(xxx)- I think this should be the C module ENTRY TS04B - C module NAME THRALLC(R)- name for the cobol routine Hi Scott, My error, I should have been more clear. Use the entry TS04B when you compile/bind TS04B. Do not use it for your cobol program. sorry about that. Sam Yields a S0C1 ... SYSTEM COMPLETION CODE=0C1 REASON CODE=0001 TIME=15.38.39 SEQ=00058 CPU= ASID=001A PSW AT TIME OF ERROR 078D 91A01718 ILC 2 INTC 01 ACTIVE LOAD MODULE ADDRESS=11A00A28 OFFSET=0CF0 NAME=THRALLC DATA AT PSW 11A01712 - F34407FF 11A0 1A20 GR 0: FD08 1: 6FF8 2: 0040 3: 008D79D4 4: 008D79B0 5: 008FF350 6: 008C6FE0 7: FD00 8: 91A017E0 9: 008CFCC8 A: B: 11A01680 C: D: 6F60 E: 91A0168A F: 11A01A20 Regards, Scott J Ford From: Sam Siegel s...@pscsi.net To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 3:33:49 PM Subject: Re: Cobol calling C function On Thu, Sep 16, 2010 at 12:26 PM, Scott Ford scott_j_f...@yahoo.com wrote: Good point, but that compiled C module is in that library but i Sam: Good point, but that compiled C module is in that library but it brings a good point. According the the LE/C manuals the binder should look like this: INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(IGZEBST) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSMOD(xxx)- I think this should be the C module ENTRY CBLRTN- cobol routine NAME (R)- name for the cobol routine The CSECT for C was wrong in the linkage output , here is the line from the Binder... z/OS V1 R10 BINDER12:52:13 THURSDAY SEPTEMBER 16, 2010 BATCH EMULATOR JOB(ADCDMETA) STEP(LKED) PGM= HEWL IEW2278I B352 INVOCATION PARAMETERS - AMODE=31,MAP IEW2650I 5102 MODULE ENTRY NOT PROVIDED. ENTRY DEFAULTS TO SECTION $PRIV10. Maybe its me, but this looks wrong That message occurs when your 'c' function does not have a 'main' in it and no ENTRY control card is specified for the binder. Try ENTRY TS04B in your binder and see if it goes away. Sam Scott J Ford From: Sam Siegel s...@pscsi.net To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 2:38:31 PM Subject: Re: Cobol calling C function On Thu, Sep 16, 2010 at 11:27 AM, Scott Ford scott_j_f...@yahoo.com wrote: START OF TS04A CEE3207S The system detected a data exception ( zMan: START OF TS04A CEE3207S The system detected a data exception (System Completion Code=0C7). From compile unit THRALLC at entry point THRALLC at compile unit offset at address 11A00E4E. Looks like I have something wrong in C. I am not a C heavy...So any help is super great ! Thanks I'm not sure if this is related but you appear to be dynamically calling a function that you have statically linked. Are you sure that you are picking up the correct version of TSO4B? Sam Scott J Ford From: zMan zedgarhoo...@gmail.com To: IBM-MAIN@bama.ua.edu Sent: Thu, September 16, 2010 1:58:43 PM Subject: Re: Cobol calling C function What is the failure you're seeing? On Thu, Sep 16, 2010 at 1:38 PM, Scott Ford scott_j_f...@yahoo.com wrote: I have seen several 'bit and piece' posts on LE Cobol calling C All: I have seen several 'bit and piece' posts on LE Cobol calling C. I have written a sample C call and here is the source and have included the C source and JCL , Cobol source and JCL, I dont understand what I have missed, I have been through the LE Books and C-C++ books and I am confused and the execution is receiving a S0C7 : JCL for 'C' compile: -- //ADCDMETA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, //NOTIFY=SYSUID,REGION=0M //EXEC EDCCL, // INFILE=SFORD.JCLLIB.CNTL(TESTC)', // OUTFILE='SFORD.CLINKLIB(TS04B),DISP=SHR' 'C' Source: --- #include stdio.h #include string.h #pragma linkage(TS04B,COBOL) void TS04B( char *pBuffer ) { strcpy( pBuffer, OK ); fprintf(stderr,ok trans\n); } LE Cobol V4r1 JCL: -- //ADCDTHRA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, //NOTIFY=SYSUID,REGION=4096K
Re: Cobol calling C function
On 9/16/2010 11:38 AM, Scott Ford wrote: I have seen several 'bit and piece' posts on LE Cobol calling C All: I have seen several 'bit and piece' posts on LE Cobol calling C. I have written a sample C call and here is the source and have included the C source and JCL , Cobol source and JCL, I dont understand what I have missed, I have been through the LE Books and C-C++ books and I am confused and the execution is receiving a S0C7 : JCL for 'C' compile: -- //ADCDMETA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=0M // EXEC EDCCL, // INFILE=SFORD.JCLLIB.CNTL(TESTC)', // OUTFILE='SFORD.CLINKLIB(TS04B),DISP=SHR' 'C' Source: --- #includestdio.h #includestring.h #pragma linkage(TS04B,COBOL) void TS04B( char *pBuffer ) { strcpy( pBuffer, OK ); fprintf(stderr,ok trans\n); } LE Cobol V4r1 JCL: -- //ADCDTHRA JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8, // NOTIFY=SYSUID,REGION=4096K //* //COB EXEC PGM=IGYCRCTL, // PARM=('NOC(E)','FLAG(W)','DATA(31)',NODYN,RES,RENT,OPT, // MAP,NOSSR,NOZWB,NUM,NOTERM,NOVBREF,X,APOST,LIB,LIST), // REGION=1024K //STEPLIB DD DISP=SHR,DSN=IGY410.SIGYCOMP //SYSLIBDD DISP=SHR,DSN=CEE.ACEESRC1 // DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSPRINT DD SYSOUT=X //SYSUT1DD UNIT=VIO //SYSUT2DD UNIT=VIO //SYSUT3DD UNIT=VIO //SYSUT4DD UNIT=VIO //SYSUT5DD UNIT=VIO //SYSUT6DD UNIT=VIO //SYSUT7DD UNIT=VIO //SYSLINDD DISP=(,PASS),DSN=LOADSET, // UNIT=VIO, // DCB=BLKSIZE=3200 //SYSIN DD DISP=SHR,DSN=SFORD.COBOL.SOURCE(THRALLC) //* //LNK EXEC PGM=IEWL, // COND=(4,LT,COB), // PARM='LIST,XREF', // REGION=4096K //SYSLIBDD DISP=SHR,DSN=SFORD.CLINKLIB // DD DISP=SHR,DSN=CEE.SCEELKED // DD DISP=SHR,DSN=SYS1.CSSLIB // DD DISP=SHR,DSN=TCPIP.SEZATCP //SYSLMOD DD DISP=SHR,DSN=SFORD.CLINKLIB //SYSUT1DD UNIT=SYSDA, // DCB=BLKSIZE=1024, // SPACE=(1024,(200,20)) //SYSPRINT DD SYSOUT=X //SYSLOUT DD SYSOUT=X //SYSLINDD DISP=(OLD,DELETE),DSN=LOADSET // DD DDNAME=SYSIN //SYSIN DD * MODE AMODE(31),RMODE(ANY) INCLUDE SYSLIB(EDCSTART) INCLUDE SYSLIB(CEEROOTB) INCLUDE SYSLIB(@@CBL2C) INCLUDE SYSLMOD(TS04B) ENTRY THRALLC NAME THRALLC(R) /* // LE Cobol Source: - IDENTIFICATION DIVISION. PROGRAM-ID. THRALLC. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. DATA DIVISION. FILE SECTION. WORKING-STORAGE SECTION. 01 TS04BPIC X(8) VALUE 'TS04B'. 01 TESTIT PIC X(10) VALUE 'SCOTT'. PROCEDURE DIVISION. DISPLAY 'START OF TS04A'. CALL TS04B USING TESTIT. DISPLAY TESTIT. GOBACK. Sorry for the long post, but I think one has to see all the pieces. Please tell me am I blind in my old age or what... Thanks in advance. Scott J Ford I think there's a bunch of issues here, so I'll try and address them all. 1. It seems to me you unnecessarily complicate things by calling your C source member TESTC and then binding it under the name TSO4B; why do that? life is simpler if you can use source member names the same as load module names; so I reverted to that 2. You don't really need the #pragma linkage(TS04B,COBOL) or, in my case, #pragma linkage(TESTC,COBOL) statement; (we'll see the tradeoffs shortly) 3. When you pass an array (in this case, a character string) to a C subroutine, C expects to be passed a pointer to the string; C also does not handle the end-of-list bit flag that COBOL generates; there are three ways (at least) to handle this: * code the #pragma linkage(TESTC,COBOL) statement - don't like to limit a subroutine to a single programming language * in your calling program, pass an extra parm, so that the first parm is the true string you want to pass and the second parm is just a place for COBOL to set on the end-of-list flag, which C will not even notice, since it is only expecting one parameter - a simple example, that works, is to name the parameter twice, such as: call testc using testit, testit (this works) * in your calling program, set up pointer to your last (and only, in this case) argument, and pass the pointer BY VALUE; for example: IDENTIFICATION DIVISION. PROGRAM-ID. THRALLC. DATA DIVISION. WORKING-STORAGE SECTION. 01 TS04BPIC X(8) VALUE 'TESTC'. 01 TESTIT PIC X(10) VALUE 'SCOTT'. 01 TESTIT-PTR POINTER. PROCEDURE DIVISION. DISPLAY 'START OF THRALL.' SET TESTIT-PTR TO ADDRESS OF TESTIT
Re: COBOL and C
You can find info on calling between COBOL and C (as well as between other languages) in the Language Environment Writing ILC Applications book at http://publibz.boulder.ibm.com/cgi- bin/bookmgr_OS390/BOOKS/CEEA4140/CCONTENTS?SHELF=CEE2BK61DN=SA22-7563- 04DT=20050804124136 Rick Arellanes IBM COBOL and PL/I Development On Thu, 9 Nov 2006 22:31:05 +0530, Chithra Nayar [EMAIL PROTECTED] wrote: Hi, Thanks to Mr Comstock.I tried the changes you suggested and it worked!!! How can i change the static call to a dynamic call?I tried by changing the first line PROCESS NODYNAM MAP LIST to PROCESS DYNAM MAP LIST and left the remaining unchanged. Compiled and linked the C code. MODULE ENTRY NOT PROVIDED. ENTRY DEFAULTS TO SECTION @ST1. is a message i got when the link of c code was done.I did not use #pragma. I got a SOC7 while executing this. WORKING-STORAGE SECTION. 01 ONEARG PIC X(10) VALUE SUDHEER123. 01 B1 PIC X(30). PROCEDURE DIVISION. MAIN. DISPLAY ONEARG IS ONEARG. CALL PADWPD1 USING BY REFERENCE B1, ONEARG. DISPLAY PADDED STRING B1. DISPLAY PADWPD1'S RC IS RETURN-CODE. I have no access to edit the link JCL to specify the entry point. Is there an alternate method to do this? Also can you please suggest some good book to learn about COBOL dynamically calling C routine? Thanks in Advance. Chithra -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html = -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html
Re: COBOL and C
Chithra Nayar wrote: Hi, Thanks to Mr Comstock.I tried the changes you suggested and it worked!!! How can i change the static call to a dynamic call?I tried by changing the first line PROCESS NODYNAM MAP LIST to PROCESS DYNAM MAP LIST and left the remaining unchanged. Compiled and linked the C code. Huh? You changed the COBOL program and compiled and linked the C code? You need to recompile and bind the COBOL program. MODULE ENTRY NOT PROVIDED. ENTRY DEFAULTS TO SECTION @ST1. is a message i got when the link of c code was done.I did not use #pragma. Sounds like your bind (link edit) step for the C program needs one of the following: //LKED.SYSLMOD DD DISP=SHR,DSN=load_lib(PADWPD1) or, in your binder control statements include NAME PADWPD1(R) I got a SOC7 while executing this. WORKING-STORAGE SECTION. 01 ONEARG PIC X(10) VALUE SUDHEER123. 01 B1 PIC X(30). PROCEDURE DIVISION. MAIN. DISPLAY ONEARG IS ONEARG. CALL PADWPD1 USING BY REFERENCE B1, ONEARG. DISPLAY PADDED STRING B1. DISPLAY PADWPD1'S RC IS RETURN-CODE. I have no access to edit the link JCL to specify the entry point. Really? Why not? Is there an alternate method to do this? Build your own link JCL? Also can you please suggest some good book to learn about COBOL dynamically calling C routine? No, but I've got a course ... Kind regards, -Steve Comstock The Trainer's Friend, Inc. http://www.trainersfriend.com Thanks in Advance. Chithra -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html