Executable program requested but PROCEDURE/ENTRY has USING clause

杀马特。学长 韩版系。学妹 提交于 2019-12-24 02:39:16

问题


Does anyone one know what is causing this compilation error? I'm trying to compile a legacy COBOL program using OpenCOBOL. This is the error that I'm getting :

Error: Executable program requested but PROCEDURE/ENTRY has USING clause

This is how my procedure division looks:

procedure division using array-area, m, err, sum1.

And this is the linkage section from my working station:

working-storage section.
77  i    picture s99 usage is computational.
77  prev picture s9(8) usage is computational.
77  d    picture s9(4) usage is computational.
01 error-mess.
    02 filler picture x(22) value ' illegal roman numeral'.
linkage section.
77  m    picture s99 usage is computational.
77  err  picture s9 usage is computational-3.
77  sum1 picture s9(8) usage is computational.
01  array-area.
    02 s picture x(1) occurs 30 times.

回答1:


working-storage section.
77  i    picture s99 usage is computational.
77  prev picture s9(8) usage is computational.
77  d    picture s9(4) usage is computational.
01 error-mess.
    02 filler picture x(22) value ' illegal roman numeral'.
linkage section.
77  m    picture s99 usage is computational.
77  err  picture s9 usage is computational-3.
77  sum1 picture s9(8) usage is computational.
01  array-area.
    02 s picture x(1) occurs 30 times.

Firstly, there is no need for the words usage and is. I use USAGE for INDEX and POINTER. computational does not need to be spelled in full, COMP is sufficient, and that include COMP-3.

Level-77's are well past their sell-by date, and it would be rare to see them in the LINKAGE SECTION. It will not affect the operation of the program if you change them all to 01-levels.

The data-names are terrible, almost without meaning. We have 30 character to play with, so make them meaningful. What are I, D and M? You can only tell by looking, in detail, at the code.

That seems to be the entire WORKING-STORAGE SECTION (which the LINKAGE SECTION is not part of, they are both instead part of the DATA DIVISION). This would indicate that the program does not have much in the PROCEDURE DIVISION, but also that what does have involves a lot of literals. Which is bad. Makes the program more difficult to maintain.

The program seems to be something to do with Roman numerals. To highlight the confusion that the data-names can cause, the numerals D, I and M are nothing to do with the data-names D, I and M respectively, but if you are more unlucky, one or more of the data-names will be associated with a data-name with a single-character name, but a different one.

Can't say more without more code. If you want a review of it, Stack Exchange has a side, Code Review, exactly for that purpose. Working code, how to do it better...


From the code you have now shown, you need to compile that as a loadable module, so use the -m switch instead of -x:

cobx -m ..otherswitches.. yourprogramname

A program which has been called by z/OS would only have one item on the USING of the PROCEDURE DIVISION, and it would be a group-item which would consist of a two-byte binary (likely COMP, perhaps COMP-4, COMP-5 or BINARY, it would not matter) and a PIC X of up to 100 bytes, perhaps defined with an OCCURS but most likely not. Possibly it would have the word PARM in the name.

The code you have shown does not look much like a legacy z/OS COBOL program :-)


First, you may want to consider upgrading to GnuCOBOL, the new name for OpenCOBOL. There is a discussion area here, https://sourceforge.net/p/open-cobol/discussion/?source=navbar, for any problem, large or small.

GnuCOBOL knows that if you have a USING on the PROCEDURE DIVISION or an ENTRY statement, you cannot expect the program to work if it is compiled as an executable, with the -x switch. It would have to be compiled as a loadable module, with -m.

However, as cschneid has pointed out, in IBM Mainframe COBOLs it is common and valid to have a USING in the first program executed, as this is the way to take a parameter value from the JCL which is running the program.

If this is the case, you will need to change the code, to allow for a parameter from the command-line.

So, which do you have? A CALLed program that should be compiled with -m, or a program which expects a parameter from the operating system?

Whether you upgrade or not, you should get yourself a copy of Gary Cutler's Programming Guide for the OpenCOBOL/GnuCOBOL that you will be using. A search with gary cutler cobol programming guide will allow you to locate the correct one.



来源:https://stackoverflow.com/questions/29053234/executable-program-requested-but-procedure-entry-has-using-clause

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!