This is an old revision of the document!
Table of Contents
COBOL
~~META: status = active ~~
On May 28 and 29 of 1959 (exactly one year after the Zürich ALGOL 58 meeting), a meeting was held at the Pentagon to discuss the creation of a common programming language for business. It was attended by 41 people and was chaired by Phillips.The Department of Defense was concerned about whether it could run the same data processing programs on different computers. FORTRAN, the only mainstream language at the time, lacked the features needed to write such programs. COmmon Business Oriented Language (COBOL) is a programming language that resembles English. As its name suggests, COBOL is especially efficient for processing business problems. It emphasizes describing and handling data items and input/output records; thus, COBOL is well adapted for managing large files of data.
COBOL Nowadays
Cobol is said to be dead.
IBM COBOL, ILE COBOL
IBM Cobol is for AS400 machine and for ZOS mainframe.
Example in ILE COBOL and call FUNCTION API which return current date.
01 WS-CURRENT-DATE-DATA. 05 WS-CURRENT-DATE. 10 WS-CURRENT-YEAR PIC 9(04). 10 WS-CURRENT-MONTH PIC 9(02). 10 WS-CURRENT-DAY PIC 9(02). 05 WS-CURRENT-TIME. 10 WS-CURRENT-HOURS PIC 9(02). 10 WS-CURRENT-MINUTE PIC 9(02). 10 WS-CURRENT-SECOND PIC 9(02). 10 WS-CURRENT-MILLISECONDS PIC 9(02). PROCEDURE DIVISION. MAIN-LINE SECTION. MOVE FUNCTION CURRENT-DATE to WS-CURRENT-DATE-DATA DISPLAY WS-CURRENT-DATE-DATA
This is example code with call AS400 API for dump memmory in ILE COBOL.
PROCESS OPTIONS NOMONOPRC NOSTDTRUNC. CONFIGURATION SECTION. WORKING-STORAGE SECTION. COPY DUMP_FULL. 77 BOOL-1 PIC 1 INDICATOR 61 VALUE B"0" USAGE IS DISPLAY. 01 BOOL-ARRAY. 08 BOOL-2 OCCURS 10 PIC 1 VALUE B"1". PROCEDURE DIVISION. PAR. MOVE B"1" TO BOOL-1 MOVE B"0" TO BOOL-2(2) CALL LINKAGE IS PROCEDURE "QlnDumpCobol" USING OMITTED, OMITTED, OMITTED, PROGRAM-TYPE, DUMP-TYPE, ERROR-CODE
IBM CL, ILE CL
Programming control language CL is like script language on AS400. Programs in language CL call for processing programs in COBOL on AS400.
PGM /* Begin program */ /* Set flag to true */ DCL &True *lgl ('1') /* Declaration variables */ /* Loop control ( index loop ) with lenght 1 */ DCL &LoopCtl *int len(4) DCL &LoopLml *int len(4) value(5) DCL &LoopNo *char len(1) DCL &List *lgl value('1') /* If value True will 0, loop will end */ DoWhile Cond(&True) SndPgmMsg Msg('Value is true' ) TopGmq(*PRV) Chgvar &True ('0') EndDo DoFor Var(&LoopCtl) From(1) To(&LoopLml) By(1) Chgvar &LoopNo &LoopCtl SndPgmMsg Msg('Loop = ' *BCAT &LoopNo) TopGmq(*PRV) EndDo Top: DoWhile cond(&List) SndMsg Msg('Hello World1') ToUsr(*REQUESTER) Middle: DoUntil Cond(*Not &List) SndMsg Msg('Hello World2') ToUsr(*REQUESTER) Inner: DoWhile Cond(&List) Leave cmdlbl(Top) EndDo /* End loop , Inner */ EndDo /* End loop, Middle */ EndDo /* End loop, Top */ ENDPGM /* End program */
More information on :
https://en.wikipedia.org/wiki/IBM_i_Control_Language
https://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c415721506.htm
OpenCOBOL (GNUCOBOL)
Open source variant and crossplatform cobol for PC. This is example in OpenCOBOL on PC. Program shows date and time.
****************************************************************** * Author: Maxfx * Date: 13/10/2016 ****************************************************************** IDENTIFICATION DIVISION. PROGRAM-ID. DATE-AND-TIME. DATA DIVISION. FILE SECTION. WORKING-STORAGE SECTION. 01 W-T PIC S9(8). 01 W-D PIC S9(8). 01 W-BATCH-COMPLET PIC X(16). 01 W-BATCH-TEST PIC X(16). 01 W-BATCH. 03 W-DATE PIC X(8). 03 W-TIME PIC X(8). PROCEDURE DIVISION. MAIN-PROCEDURE. ACCEPT W-TIME OF W-BATCH FROM TIME. ACCEPT W-DATE OF W-BATCH FROM DATE YYYYMMDD. DISPLAY W-TIME OF W-BATCH. DISPLAY W-DATE OF W-BATCH. DISPLAY "STRUCT : " W-BATCH. STRING W-DATE OF W-BATCH DELIMITED BY SPACE W-TIME OF W-BATCH DELIMITED BY SPACE INTO W-BATCH-COMPLET END-STRING. MOVE W-BATCH TO W-BATCH-TEST. DISPLAY "COMPLET : " W-BATCH-COMPLET. DISPLAY "TEST : " W-BATCH-TEST STOP RUN. END PROGRAM DATE-AND-TIME.
IDE OpenCOBOL (GNUCOBOL)
More Examples
More code examples for https://github.com/Martinfx/Cobol
Slides from our actions https://brmlab.cz/event/as400clcobol