I cannot get a GNUCOBOL subroutine invoked successfully using Fujitsu Cobol for Windows or from IBM PL/I. The calling module is a .EXE. The GNUCOBOL subroutine was compiled with -fimplicit-init - When calling a GNUCOBOL subroutine the error handler return to the system - no diagnostic as to what failed or why.
I then decided to invoke cob_init with standard Win API's - this also failed. Can some advise as to the method by which to call a GNUCOBOL subroutine from another Windows based high level language - Not "C" or its derivatives.
:::cobol@OPTIONSBINARY(BYTE)@OPTIONSNOALPHAL*@OPTIONSMAIN(MAIN)*cob_init(argc,**argv)*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**ThisprogramisapreloadedprogramusedbymyCICSemulator*TheCICSmainistheonly.EXEtobeexecutedduringCICS*CICSisenhancedtextonly-thereareno.NET/C++components*Applicationprograms(CICSTransactions)arecalledas.DLL's*MyCICSmainisaFujitsuCobolforWindows.EXE*Thissubroutinetriestoinvokecob_init*Thiswasanattempttocircumvent-fimplicit-initnotworking*FurthertestingusingaPL/Imainalsofails*AnyGNUCOBOLmodulecalledbyCICSfails*ThefailureterminatestheCICS.EXE-Noindicationastowhy*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*IDENTIFICATIONDIVISION.PROGRAM-ID.ZOSGNU.ENVIRONMENTDIVISION.CONFIGURATIONSECTION.SOURCE-COMPUTER.IBM-PC.OBJECT-COMPUTER.IBM-PC.SPECIAL-NAMES.ARGUMENT-NUMBERISCOMMAND-LINE-NUMBERARGUMENT-VALUEISCOMMAND-LINE-VALUEENVIRONMENT-NAMEISENVIRONMENT-NAMEENVIRONMENT-VALUEISENVIRONMENT-VALUESYMBOLICCONSTANTVAL-FALSEIS0VAL-TRUEIS1VAL-STARTUP-FAILEDIS0VAL-STARTUP-OKIS1VAL-READ-ONLYIS1VAL-WRITE-ONLYIS2VAL-READ-WRITEIS3VAL-PROTECT-FROM-WRITESIS1VAL-PROTECT-FROM-READSIS2VAL-NORMAL-I-OIS0VAL-READ-FILE-SIZEIS128VAL-I-O-OKIS'00'VAL-END-OF-FILEIS'10'VAL-MEMORY-IS-NON-SHAREABLEIS0VAL-MEMORY-IS-SHAREABLEIS1.INPUT-OUTPUTSECTION.FILE-CONTROL.DATADIVISION.FILESECTION.WORKING-STORAGESECTION.77GNU-ZEROPIC9(04)COMP-5VALUEZERO.77GNU-NADAPICX(01)VALUESPACES.77GNU-NULLUSAGEPOINTER.77GNU-NULL-9REDEFINESGNU-NULLPIC9(08)COMP-5.77DLL-ZEROPIC9(08)COMP-5VALUEZERO.77ERROR-PAUSEPICX(01).77DLL-BUFFER-LENPIC9(08)COMP-5VALUE200.77DLL-HANDLEPIC9(08)COMP-5.77NULL-BYTEAPICX(01)VALUELOW-VALUES.77LOADLIBRARYPICX(24)VALUE'LoadLibrary '.77GETDLLPICX(24)VALUE'GetProcAddress '.77GNURELPICX(08)VALUE'GNUREL'.77GNUCOMMPICX(07)VALUE'GNUCOMM'.77NULL-BYTE0PICX(01)VALUELOW-VALUES.77GNUAPIPICX(08)VALUE'libcob-4'.77NULL-BYTE1PICX(01)VALUELOW-VALUES.77GNUOPENPICX(08)VALUE'GNUOPEN'.77NULL-BYTE2PICX(01)VALUELOW-VALUES.77GNUINITPICX(08)VALUE'cob_init'.77NULL-BYTE2-1PICX(01)VALUELOW-VALUES.77GNUCMDPICX(08)VALUE'GNUCMD'.77NULL-BYTE3PICX(01)VALUELOW-VALUES.77ZOSPD171PICX(08)VALUE'ZOSPD171'.77NULL-BYTE3PICX(01)VALUELOW-VALUES.77LOAD-ERROR-BUFFERPICX(100).77LOAD-ERROR-BUFFER-SIZEPIC9(08)COMP-5VALUE100.77IPIC9(04)COMP-4.77NOGOPIC9(04)COMP-5.01PROGRAM-FIELDS.05DLL-NAME.10DNAMEOCCURS8TIMESPICX(01).05DLL-LOWPICX(01)VALUELOW-VALUES.05DLL-API-PTRUSAGEPROCEDURE-POINTER.05DLL-API-PTR-XREDEFINESDLL-API-PTRPICX(04).05GNUOPEN-PTRUSAGEPROCEDURE-POINTER.05GNUINIT-PTRUSAGEPROCEDURE-POINTER.05GNUCMD-PTRUSAGEPROCEDURE-POINTER.05DLL-PTRUSAGEPOINTER.05LINK-ENTRY-NAMEPICX(08).05LINK-DLL-NAME.10LNAMEOCCURS8TIMESPICX(01).LINKAGESECTION.PROCEDUREDIVISION.*-*-*Set**argvtoNULLSETGNU-NULLTONULL.*-*-*Loadthe.DLLthatcontainsentrypoint"cob_init"MOVE'libcob-4'TOLINK-DLL-NAME.MOVELINK-DLL-NAMETODLL-NAME.MOVELOW-VALUESTODLL-API-PTR-X.CALL'LoadLibraryA'WITHSTDCALLLINKAGEUSINGBYREFERENCEGNUAPIRETURNINGDLL-HANDLEIFDLL-HANDLE=0DISPLAY'MODULE NOT FOUND='LINK-DLL-NAMEDISPLAY'RETURN CODE QUERY MODULE='RETURN-CODEMOVE12TORETURN-CODEGOBACKEND-IF.*-*-*DLLloadedsuccessfully-FindProcAddressof"cob_init"CALL'GetProcAddress'WITHSTDCALLLINKAGEUSINGBYVALUEDLL-HANDLEBYREFERENCEGNUINITRETURNINGDLL-API-PTR.IFDLL-API-PTR-X=LOW-VALUESDISPLAY'PROC ADDR NOT FOUND='LINK-DLL-NAMEDISPLAY'RETURN CODE QUERY MODULE='RETURN-CODEMOVE16TORETURN-CODEGOBACKEND-IF.*-*-*Entrypoint"cob_init"found-Begintotrycallingcob_initMOVE0TOGNU-NULL-9SETGNU-NULLTONULL*-*-*Callprocedurepointer"cob_init"withnumerouslinkagesCALLDLL-API-PTRMOVERETURN-CODETONOGOIFNOGO=0GOBACKEND-IF*-*-*Theabovefailed-tryagaindifferentparametersSETGNU-NULLTONULLCALLDLL-API-PTRUSINGBYVALUE0BYREFERENCEGNU-NADAMOVERETURN-CODETONOGOIFNOGO=0GOBACKEND-IF*-*-*Theabovefailed-tryagaindifferentparametersMOVE0TOGNU-NULL-9SETGNU-NULLTONULLCALLDLL-API-PTRWITHSTDCALLLINKAGEUSINGBYVALUE0BYREFERENCEGNU-NADAMOVERETURN-CODETONOGOIFNOGO=0GOBACKEND-IF*-*-*Theabovefailed-tryagaindifferentparametersMOVERETURN-CODETONOGOMOVE0TOGNU-NULL-9SETGNU-NULLTONULLCALLDLL-API-PTRWITHCLINKAGEUSINGBYVALUE0BYREFERENCEGNU-NADAMOVERETURN-CODETONOGOIFNOGO=0GOBACKEND-IF*-*-*Theabovefailed-tryagaindifferentparametersSETGNU-NULLTONULLCALLDLL-API-PTRUSINGGNU-ZEROBYREFERENCEGNU-NADAMOVERETURN-CODETONOGOIFNOGO=0GOBACKEND-IF*-*-*Theabovefailed-tryagaindifferentparametersMOVE0TOGNU-NULL-9SETGNU-NULLTONULLCALLDLL-API-PTRWITHSTDCALLLINKAGEUSINGGNU-ZEROBYREFERENCEGNU-NADAMOVERETURN-CODETONOGOIFNOGO=0GOBACKEND-IF*-*-*Theabovefailed-tryagaindifferentparametersMOVERETURN-CODETONOGOMOVE0TOGNU-NULL-9SETGNU-NULLTONULLCALLDLL-API-PTRWITHCLINKAGEUSINGGNU-ZEROBYREFERENCEGNU-NADAMOVERETURN-CODETONOGOIFNOGO=0GOBACKEND-IF*-*-*cob_initfailswithalloftheaboveparametersGOBACK.
Last edit: Edward Hart 2016-10-04
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You try to call cob_init() which is a void function. You cannot get any RETURNC-CODE from this. GnuCOBOL supports the extension CALL 'voidfunc' USING stuff RETURNING NULL, I don't know if Fujitsu has something similar. If not I'd try to use CALL-CONVENTION if this is supported by Fujitsu using the flags "doesn't change RETURN-CODE" (bit number two) and, if possible "static linking" (this would lead to the fujitsu COBOL caller to be always linked against libcob).
The correct parameters are an int (BINARY-LONG) and a char ** (USAGE POINTER).
Despite that (I'd like you to get this working) I'd suggest to call the COBOL module directly. For calling the module you'd need to compile it with -fimplicit-init and call it from fujitsu COBOL with the correct case and parameter. Please post the sample you already seem to have and we can check this.
The likely easiest solution is to compile the COBOL main programs via GnuCOBOL as main (-x) and do something like CALL 'SYSTEM' USING 'yourcobmain.exe param1 "param numer 2" from Fujitsu COBOL.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I cannot get a GNUCOBOL subroutine invoked successfully using Fujitsu Cobol for Windows or from IBM PL/I. The calling module is a .EXE. The GNUCOBOL subroutine was compiled with -fimplicit-init - When calling a GNUCOBOL subroutine the error handler return to the system - no diagnostic as to what failed or why.
I then decided to invoke cob_init with standard Win API's - this also failed. Can some advise as to the method by which to call a GNUCOBOL subroutine from another Windows based high level language - Not "C" or its derivatives.
Last edit: Edward Hart 2016-10-04
You try to call
cob_init()which is avoidfunction. You cannot get anyRETURNC-CODEfrom this. GnuCOBOL supports the extensionCALL 'voidfunc' USING stuff RETURNING NULL, I don't know if Fujitsu has something similar. If not I'd try to useCALL-CONVENTIONif this is supported by Fujitsu using the flags "doesn't change RETURN-CODE" (bit number two) and, if possible "static linking" (this would lead to the fujitsu COBOL caller to be always linked against libcob).The correct parameters are an
int(BINARY-LONG) and achar **(USAGE POINTER).Despite that (I'd like you to get this working) I'd suggest to call the COBOL module directly. For calling the module you'd need to compile it with
-fimplicit-initand call it from fujitsu COBOL with the correct case and parameter. Please post the sample you already seem to have and we can check this.The likely easiest solution is to compile the COBOL main programs via GnuCOBOL as main (
-x) and do something likeCALL 'SYSTEM' USING 'yourcobmain.exe param1 "param numer 2"from Fujitsu COBOL.@Bruce: Did the post help you to solve the issue?