I'm writing a COBOL program with NETEXPRESS.
I wrote $ZZZZ9.99 in detail line and it works when I use school desktop but I get an error "PICTURE string has illegal character " if I compile it with my laptop.
05 DL-WAGE PIC $ZZZZ9.99 VALUE ZERO.
Can anyone help me resolve this issue?? I used the same version of NEXEXPRESS in both places.
Related
I started to learn Cobol a few days ago and I'm wathcing a video about the basics. The problem that I have is that i'm calling a rountine from another file and when I compile the program I get the error libcob: module 'GETSUM' not found.
I'm using a virtual machine with wsl2 wIth ubuntu 20.04.4 LTS on windows 10. And as compiler I am using GnuCobol 2.2.0
Code of main file :
IDENTIFICATION DIVISION.
PROGRAM-ID. COBOL-TUTORIAL5.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Num1 PIC 9 VALUE 5.
01 Num2 PIC 9 VALUE 4.
01 Sum1 PIC 99.
PROCEDURE DIVISION.
CALL 'GETSUM' USING Num1, Num2, Sum1.
DISPLAY Num1 " + " Num2 " = " Sum1.
STOP RUN.
Get sum file:
IDENTIFICATION DIVISION.
PROGRAM-ID. GETSUM.
DATA DIVISION.
LINKAGE SECTION.
01 LNum1 PIC 9 VALUE 5.
01 LNum2 PIC 9 VALUE 4.
01 LSum PIC 99.
PROCEDURE DIVISION USING LNum1, LNum2, LSum,.
ADD LNum1 TO LNum2 GIVING LSum.
EXIT PROGRAM.
when I compile the program I get the error libcob: module 'GETSUM' not found
That can't be the case, because this is the COBOL runtime telling you the module is missing, so this only happens when executing, not when compiling.
You have two general options:
cobc -x COBOL-TUTORIAL5.cob GETSUM.cob
--> compile everything at once, creating one big binary. In this case you may want to add -static for both faster runtime and for making sure that you indeed include everything necessary (if not you'd get a linker error, commonly a message like "symbol 'GETSUM' not found").
Compile at least GETSUM.cob as module (cobc GETSUM.cob) and have it either in the current directory when COBOL-TUTORIAL5, or use COB_LIBRARY_PATH to point to the place where the modules are located.
For more details see the GnuCOBOL manual using Multiple source.
I am looking for an example using Cobol either mf cobol or gnucobol. I would like an alternate of VB or C. Old time coboller since Cobol 61. I have looked at the Java and python examples but they are not clear to me.
Parameter sizes, contents, and order are what I am looking for as well as the translation routine or module name.
Vb or c example will do as I have worked with those languages as well.
A cobol example with results expected:
Id division.
Program-Id. Somename.
Environment division.
Data division.
Working-storage section.
01 Some-existing-text pic x(32000) value
"The quick brown fox jumped over the silver moon".
01 input-text-type pic x(20) value "english".
01 resulting-text pic x(32000) value
"Der schnelle braune Fuchs sprang über den silbernen Mond ".
01 destination-text-type pic x(20) value "German".
Procedure division.
Start-here.
Call "translation-routine" using Some-existing-text,
input-text-type,
Resulting-text,
Destination-text-type.
Stop-here.
Stop run.
Take a look at this, i tried it in linux and its working absolutely fine.
First Install Translate Shell:-
Translate Shell is available in the official repositories of popular Linux operating systems.
Use below command to install.
$ sudo apt-get install translate-shell
Now find the cobol code that takes user input and translates from your preferred language to English and vice versa.
ID DIVISION.
PROGRAM-ID. SOMENAME.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 SOME-SAMLPLE-TEXT PIC X(30) VALUE "नमस्ते". /*THIS WORD IS "HI" IN HINDI*/
PROCEDURE DIVISION.
START-HERE.
STRING "TRANS"
" "
SOME-SAMLPLE-TEXT
DELIMITED BY SPACES INTO LINUX-COMMAND.
CALL "SYSTEM" USING LINUX-COMMAND
RETURNING CONVERTED-TEXT.
DISPLAY CONVERTED-TEXT.
STOP RUN.
Output will be "HI"
Below program translates Hindi to Tamil, you can use an variable and make the language code dynamic.
For more language codes goto:https:language codes
ID DIVISION.
PROGRAM-ID. SOMENAME.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 SOME-SAMPLE-TEXT PIC X(30) VALUE "नमस्ते". /*THIS WORD IS "HI" IN HINDI*/
PROCEDURE DIVISION.
START-HERE.
STRING "TRANS"
" "
":"
"te" /*code to convert text to tamil*/
" "
SOME-SAMPLE-TEXT
DELIMITED BY SPACES INTO LINUX-COMMAND.
CALL "SYSTEM" USING LINUX-COMMAND
RETURNING CONVERTED-TEXT.
DISPLAY CONVERTED-TEXT.
STOP RUN.
Output will be "வணக்கம்"
For information on installing google translate in linux please refer :this link
Happy coding........
I have file defined
select bankd-file assign to f-bankd-file
file status is wx-fstat
organization line sequential.
fd bankd-file.
****************
01 bankd-rec pic x(80).
And I am writing to this file line by line, just simple with write command. And on one line I need also write form-feed character. This character I have defined as
01 w-ff pic x value x'0C'.
But in output file, I have before form-feed char NUL char. Please how can I get rid of this NUL char? Other chars are written without any problems.
The question does not specify the used COBOL compiler therefore we can only guess. Different compilers include a x'00' before "non-text-data" to make sure it can be read in correctly (this is mainly done if someone tries to write a COMP item which may contain line breaks and/or form feeds).
This may not be possible with your compiler but normally you would do:
WRITE bankd-rec FROM SPACES BEFORE ADVANCING PAGE
(no need for the FROM SPACES when you do this BEFORE/AFTER the record you actually want to have the form-feed in)
For Micro Focus COBOL, you can turn off x"00" before non-test-data by using the INSERTNULL=OFF in the extfh.cfg
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.
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.
I've recently started a COBOL course and, because of my computer configuration (Windows 7 64 Bits and GNU/Linux 64Bits) I have to use Dosbox to compile and execute programs.
Everything is going well but, I'n finding some troubles when I try to open an Indexed file, either I-O or Ouput mode. I can compile and link but at execution time, dosbox get frozen.
My compiler version is MS-COBOL 5.0 and DosBox is 0.74 (last version).
Does anybody have had this issue? Can someone tell how to fix it.
My code is this one.
Thanks in advance.
IDENTIFICATION DIVISION.
PROGRAM-ID. AGENDA.
AUTHOR. JOSE MARIA RAMIREZ MIRA.
DATE-WRITTEN. 06/05/2014.
DATE-COMPILED. 06/05/2014.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-PC.
OBJECT-COMPUTER. IBM-PC.
SPECIAL-NAMES.
DECIMAL-POINT IS COMMA.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT AGENDA ASSIGN TO DISK "AGENDA.DAT"
ORGANIZATION IS INDEXED
ACCESS IS RANDOM
RECORD KEY IS AG-NICK
FILE STATUS IS AG-STATUS.
DATA DIVISION.
FILE SECTION.
FD AGENDA
RECORD CONTAINS 112 CHARACTERS
LABEL RECORD IS STANDARD
DATA RECORD IS AG-PERSONA.
01 AG-PERSONA.
03 AG-NICK PIC X(25).
03 AG-NOMBRE PIC X(25).
03 AG-APELLIDOS PIC X(50).
03 AG-TELEFONO PIC X(12).
WORKING-STORAGE SECTION.
77 AG-STATUS PIC 99.
88 EXITO VALUE 00.
88 CLAVE-DUPLICADA VALUE 22.
88 CLAVE-NO-ENCONTRADA VALUE 23.
88 SIN-ESPACIO-EN-DISCO VALUE 34.
88 FICHERO-NO-EXISTE VALUE 35.
88 EOF VALUE 10.
PROCEDURE DIVISION.
MAIN-PROCEDURE.
DISPLAY "PROCEDO A ABRIR EL ARCHIVO".
OPEN I-O AGENDA.
IF EXITO THEN
DISPLAY "EL ARCHIVO SE HA ABIERTO"
ELSE
EVALUATE TRUE
WHEN FICHERO-NO-EXISTE
DISPLAY "EL ARCHIVO NO EXISTE"
END-EVALUATE
END-IF.
CLOSE AGENDA.
STOP RUN.
END PROGRAM AGENDA.
Have you tried selecting the file using the OPTIONAL phrase. For example,
SELECT OPTIONAL AGENDA ASSIGN TO DISK "AGENDA.DAT"
ORGANIZATION IS INDEXED
ACCESS IS RANDOM
RECORD KEY IS AG-NICK
FILE STATUS IS AG-STATUS.
The OPTIONAL phrase must be specified for files opened for INPUT, I-O, or EXTEND that need not be present when the program runs.
Against this being the problem is your statement that the problem also occurs with OPEN OUTPUT and the program should in any case be producing some output but as others have remarked the version of COBOL is not well known.
By the way I plugged your program into the online COBOL at http://www.compileonline.com/compile_cobol_online.php
and it worked fine triggering the FICHERO-NO-EXISTE condition name.
But this does raise another point. In my Microfocus manual the file status code of 35 is given as being returned when an OPEN INPUT, I-O or EXTEND is attempted on a NON-OPTIONAL file that does not exist. A file status of 05 is returned if you have used the OPTIONAL phrase and the file does not exist at the time the OPEN is executed.
What is the absolute path to AGENDA.DAT?
Sometimes with legacy DOS programs you can't read/write files inside folders with spaces on its name. Say, if your current folder is C:\ms cobol\ , rename it to C:\mscobol\.
It's worth a try, if this is your case.
DOSBox was designed for gaming.
The problem could be DOSBox missing file and record locking.
DOSBox has more issues like internal file caching, a time bomb with multi-user enabled programs.
You could try vDos: http://sourceforge.net/projects/vdos/.
It is Windows only, but integrates better with it.