Using 'Call' in Method

I am trying to execute a non-windows form cobol program from a windows form cobol program with a method.  My syntax is 'Call "FPACTGN" using PMCALL" .  I have the called program referenced within the calling program project.  When execute the program is not executed and the program just goes to the next line of code.  I have checked the program id and properties of the called program and they seem to be OK.  Suggestions? 

  • So the subprogram is a procedural COBOL program that resides in a different project is that correct?

    Is the project containing the called program a managed code Class Library project or is it a native project?
    Is FPACTGN the name of the Class Library project?
    If not then you might have to load the projects .dll prior to calling the entry point.

    Please take a look at the tutorial here which covers using the CALL statement within in managed code projects in Visual COBOL for Visual Studio.

    Thanks.

  • The programs are in different projects in a single solution. FPACTGN is the class library project.  It's not that I am getting a not found or error, it just executes the call with nothing and goes to the next line.

  • How are you executing the call?

    Are you stepping through the call in the debugger using F11?

    Is any part of the call statement highlighted with an underline in the editor that displays the message about a dynamic call being generated for the method?

    If your solution is self-contained and you can zip it up and e-mail it to me at chris.glazier@microfocus.com I will take a quick look.

  • Yes the calling parameter are underlined and the popup says 'Can not find method  'FPACTGN' with this signature -  will generate dynamic call'.  This is the large solution I have had issues with in the old release.  IT's 101mg zipped.

  • That error message means that the compiler cannot resolve the call as the parameters do not match or the program name cannot be found.

    Are you adding a reference to the Class Library project within the references folder of the calling project?

    If you are adding a reference and you still get this compiler message then something else is not matching up.

    Can you show me what the program-id, linkage section and procedure division header look like for the subprogram?

  • I have a reference to the called program in the calling program project.  I checked the dll is in the bin\debug folder of the calling program.  I remove the calling parameter and still get the same message so I think it's the called program that is not being identified.  Here is the Program-ID, linkage section, and procedure header of the subprogram, I also add the call from the calling program.

          program-id. FPACTGN AS "FPACTGN".

          LOCAL-STORAGE SECTION.

          LINKAGE SECTION.

          01  DPMCall.

              05 DPMCLength                   pic 9(4) comp-5.

              05 DPMCType                     pic 9(4) comp-5.

              05 DPMCReturn                   pic 9(4) comp-5.

              05 DPMCReturnFlag               pic x.

              05 DPMCFileName                 pic x(8).

              05 DPMCDefaultPath              pic x(30).

              05 DPMCLoginRecord              pic x(120).

              05 DPMCSharedData.

                 10 DPMC-PROGRAM              pic X(8).

                 10 DPMC-ACTION               pic X(1).

                 10 FILLER                    pic x(3825).

                 10 DPMC-VEIWRPT              PIC X(256).

              05 DPMTABLENUM                  PIC X(02).

              05 DPMPASS-RECORD                  PIC X(60).

          PROCEDURE DIVISION USING BY REFERENCE DPMCALL.

    Call from main program

              Call "FPACTGN" using PMCALL

    PMCALL and DPMCALL are exactly the same except for naming and we use in all programs to move data from program to program

    Thanks

  • I have a reference to the called program in the calling program project.  I checked the dll is in the bin\debug folder of the calling program.  I remove the calling parameter and still get the same message so I think it's the called program that is not being identified.  Here is the Program-ID, linkage section, and procedure header of the subprogram, I also add the call from the calling program.

          program-id. FPACTGN AS "FPACTGN".

          LOCAL-STORAGE SECTION.

          LINKAGE SECTION.

          01  DPMCall.

              05 DPMCLength                   pic 9(4) comp-5.

              05 DPMCType                     pic 9(4) comp-5.

              05 DPMCReturn                   pic 9(4) comp-5.

              05 DPMCReturnFlag               pic x.

              05 DPMCFileName                 pic x(8).

              05 DPMCDefaultPath              pic x(30).

              05 DPMCLoginRecord              pic x(120).

              05 DPMCSharedData.

                 10 DPMC-PROGRAM              pic X(8).

                 10 DPMC-ACTION               pic X(1).

                 10 FILLER                    pic x(3825).

                 10 DPMC-VEIWRPT              PIC X(256).

              05 DPMTABLENUM                  PIC X(02).

              05 DPMPASS-RECORD                  PIC X(60).

          PROCEDURE DIVISION USING BY REFERENCE DPMCALL.

    Call from main program

              Call "FPACTGN" using PMCALL

    PMCALL and DPMCALL are exactly the same except for naming and we use in all programs to move data from program to program

    Thanks

  • I tested this here and it works fine for me.
    I am using VC 2.2 for VS2012.

    I am attaching my simple demo which has two projects, the main windows form app and then the class library project containing the subprogram.
    When I step through these it calls the subprogram fine and returns.

    Perhaps you can check and see if my demo works for you and to see what the differences might be between your project setup and mine?

    What additional compiler directives are you using and are they the same for both projects?

    TESTCALLMAN.ZIP
  • Your example worked on my system too.  We are using this copybook cblproto.cpy that was provided by you guys, could that cause a problem?  I have check properties and everything I can think of.

  • Using cblproto.cpy should not cause a problem as that only ensures that parameters are correct for the system run-time routines. In fact I just added it to the top of each of the projects in my example and it still runs just fine.

    Your project containing the subprogram is a managed code project correct?

    If you look at the properties page for the project it should have no COBOL Link tab.

    If it were a native project and you were trying to do a P/Invoke then you might see the behavior that you are experiencing.

    Try adding exception handling around the call to see which exception is occurring:

              try

                 Call "FPACTGN" using PMCALL

               catch ex as type Exception

                  display ex::Message

              end-try