Highlighted
Absent Member.
Absent Member.
10792 views

Using 'Call' in Method

Jump to solution

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? 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: Using 'Call' in Method

Jump to solution

It was managed code.  If I put the sub program in the same project as the calling program ,it works fine.  I will use that for now until I have more time to explore.

Thanks for all of the help.

View solution in original post

0 Likes
20 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Using 'Call' in Method

Jump to solution

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.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Using 'Call' in Method

Jump to solution

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.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Using 'Call' in Method

Jump to solution

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.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Using 'Call' in Method

Jump to solution

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.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Using 'Call' in Method

Jump to solution

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?

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Using 'Call' in Method

Jump to solution

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

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Using 'Call' in Method

Jump to solution

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?

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Using 'Call' in Method

Jump to solution

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.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Using 'Call' in Method

Jump to solution

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

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Using 'Call' in Method

Jump to solution

It was managed code.  If I put the sub program in the same project as the calling program ,it works fine.  I will use that for now until I have more time to explore.

Thanks for all of the help.

View solution in original post

0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

RE: Using 'Call' in Method

Jump to solution

Hi Chris,

I am a little confused with this. We have one Winform project for a Menu that should call different Winform projects for every Menu option, and I can not make the call work, I allways receive an error. I really do not want to have a hole solution with all the projects inside. Is that needed or is there a way to call a managed winform solution from another managed winform solution in Visual COBOL? And I need to pass some parameters too. If you have a sample of this situation passing some parameters would be very welcome.

Regards

Juan Manuel Urraburu
Director of Technology @ ProRM & Axtrio
Micro Focus Knowledge Partner
LinkedIn

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.