The list of COBOL libraries in the registry.
GnuCOBOL core library with datetime functions
GnuCOBOL 3.x core library with datetime functions
Name | Description |
---|---|
datetime-format | Format the given or current timestamp, replacing the tokens, such as YY Year 18 YYYY Year 2018 M Month of the year (1-12) 7 MM Month of the year (01-12) 07 MMM Month of the year textual Jul D Day of the month (1-31) 9 DD Day of the month (01-31) 09 DDD Day of the year (01-366) 07 WW Week of the year (01-53) 05 U Weekday (1-7) 2 EEE Weekday textual Tue h Hour of the day (0-23) 5 hh Hour of the day (00-23) 05 m Minute of the hour (0-59) 9 mm Minute of the hour (00-59) 09 s Second of the minute (0-59) 4 ss Second of the minute (00-59) 04 z Timezone GMT-08:00 x Timezone ISO 8601 -08:00 |
datetime-format(l-format, l-timestamp)
Format the given or current timestamp, replacing the tokens, such as YY Year 18 YYYY Year 2018 M Month of the year (1-12) 7 MM Month of the year (01-12) 07 MMM Month of the year textual Jul D Day of the month (1-31) 9 DD Day of the month (01-31) 09 DDD Day of the year (01-366) 07 WW Week of the year (01-53) 05 U Weekday (1-7) 2 EEE Weekday textual Tue h Hour of the day (0-23) 5 hh Hour of the day (00-23) 05 m Minute of the hour (0-59) 9 mm Minute of the hour (00-59) 09 s Second of the minute (0-59) 4 ss Second of the minute (00-59) 04 z Timezone GMT-08:00 x Timezone ISO 8601 -08:00
l-format 32-char long string l-timestamp 21-char long current-date or ZERO
Formatted timestamp trailing by spaces, 32-char long
Install and initialize COBOL Package Manager:
$ npm install -g cobolget
$ cobolget init
Add the package to the Manifest
:
$ cobolget add core-datetime
$ cobolget update
Install the package and its dependencies:
$ cobolget install
....
Modules modules.cpy and modules.cbl updated.
Directory modules
contains complete COBOL source-code and modules.cpy
Copybook ready for inclusion into your project.
GnuCOBOL core library with network functions
GnuCOBOL 3.x core library with network functions
Name | Description |
---|---|
receive-udp | Receive UDP requests, a UDP server @param l-host Local host name or IP address @param l-port Local port @param l-limit Limit of requests. 0 - unlimited @param l-callback Program-pointer which handles content |
server-stop | |
receive-tcp | Receive TCP requests, a TCP server @param l-host Local host name or IP address @param l-port Local port @param l-limit Limit of requests. 0 - unlimited @param l-callback Program-pointer which handles content |
server-stop |
Name | Description |
---|---|
send-udp | Send UDP datagram |
syslog | Prepare a message in syslog format. RFC 3164 |
Receive UDP requests, a UDP server @param l-host Local host name or IP address @param l-port Local port @param l-limit Limit of requests. 0 - unlimited @param l-callback Program-pointer which handles content
Receive TCP requests, a TCP server @param l-host Local host name or IP address @param l-port Local port @param l-limit Limit of requests. 0 - unlimited @param l-callback Program-pointer which handles content
send-udp(l-host, l-port, l-message)
Send UDP datagram
l-host Remote host name or IP address l-port Remote port l-message Message
Number of bytes sent
syslog(l-logsource, l-program, l-facility, l-severity, l-message)
Prepare a message in syslog format. RFC 3164
l-logsource Logsource name l-program Program name l-facility Facility code l-severity Severity code l-message String encoded in UTF-8
Syslog message
Install and initialize COBOL Package Manager:
$ npm install -g cobolget
$ cobolget init
Add the package to the Manifest
:
$ cobolget add core-network
$ cobolget update
Install the package and its dependencies:
$ cobolget -t bca12d6c4efed0627c87f2e576b72bdb5ab88e34 install
....
Modules modules.cpy and modules.cbl updated.
Directory modules
contains complete COBOL source-code and modules.cpy
Copybook ready for inclusion into your project.
GnuCOBOL core library with string functions
GnuCOBOL 3.x core library with string functions
Name | Description |
---|---|
substr-pos | Find the position of the first occurrence of a substring in a string. Case-sensitive. |
substr-pos-case | Find the position of the first occurrence of a substring in a string. Case-insensitive. |
byte-to-hex | Convert one byte into hexadecimal representation. |
hex-to-byte | Convert one byte into hexadecimal representation. |
substr-count | Count the number of substring occurrences. Case-sensitive. |
substr-count-case | Count the number of substring occurrences. Case-insensitive. |
sha3-256 | Generate SHA3-256 message digest |
sha3-512 | Generate SHA3-512 message digest |
urlencoded-to-byte | Convert urlencoded symbol into one byte. |
byte-to-urlencoded | Convert one byte into urlencoded symbol. |
csv-ecb-rates | Convert ECB exchange rates in CSV format to the list of currency-rate pairs. https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html |
substr-pos(l-haystack, l-needle)
Find the position of the first occurrence of a substring in a string. Case-sensitive.
l-haystack String to search in l-needle String to search for
Position where the needle exists relative to the beginnning of l-haystack. Returns 0 if not found.
substr-pos-case(l-haystack, l-needle)
Find the position of the first occurrence of a substring in a string. Case-insensitive.
l-haystack String to search in l-needle String to search for
Position where the needle exists relative to the beginnning of l-haystack. Returns 0 if not found.
byte-to-hex(l-byte)
Convert one byte into hexadecimal representation.
l-byte Byte
2 hexadecimal chars
hex-to-byte(l-hex)
Convert one byte into hexadecimal representation.
l-hex 2 hexadecimal chars
Byte
substr-count(l-haystack, l-needle)
Count the number of substring occurrences. Case-sensitive.
l-haystack String to search in l-needle String to search for
Number of occurrences
substr-count-case(l-haystack, l-needle)
Count the number of substring occurrences. Case-insensitive.
l-haystack String to search in l-needle String to search for
Number of occurrences
sha3-256(l-buffer)
Generate SHA3-256 message digest
l-buffer Input bytes
64 hexadecimal chars
sha3-512(l-buffer)
Generate SHA3-512 message digest
l-buffer Input bytes
128 hexadecimal chars
urlencoded-to-byte(l-symbol)
Convert urlencoded symbol into one byte.
l-symbol Urlencoded symbol (3 bytes)
Byte
byte-to-urlencoded(l-byte)
Convert one byte into urlencoded symbol.
l-byte Byte
Urlencoded symbol (3 bytes)
csv-ecb-rates(l-byte)
Convert ECB exchange rates in CSV format to the list of currency-rate pairs. https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html
l-byte CSV string
Urlencoded symbol Pointer to the list of 64 [pic x(3), pic 9(7)V9(8)] elements
Install and initialize COBOL Package Manager:
$ npm install -g cobolget
$ cobolget init
Add the package to the Manifest
:
$ cobolget add core-string
$ cobolget update
Install the package and its dependencies:
$ cobolget install
....
Modules modules.cpy and modules.cbl updated.
Directory modules
contains complete COBOL source-code and modules.cpy
Copybook ready for inclusion into your project.
Simple Unit Testing for GnuCOBOL
GCBLUnit framework
Simple Unit Testing for GnuCOBOL written in GnuCOBOL.
You may choose between local and container execution environment.
GnuCOBOL cobc
2.2+ installed.
GnuCOBOL Docker container up and running. The image includes GnuCOBOL and all required dependencies needed to debug or execute your code.
Simply download gcblunit.cbl file or install by COBOL Package Manager:
$ npm install -g cobolget
$ cobolget init
$ cobolget add --debug gcblunit
$ cobolget update
$ cobolget install
$ cobc -x -debug modules/gcblunit/gcblunit.cbl --job=-h
GCBLUnit 1.22.6 by Olegs Kunicins and contributors.
Usage:
cobc -x -debug gcblunit.cbl first-test.cbl [next-test.cbl] --job='first-test [next-test]'
cobc -x -debug gcblunit.cbl --job=Options
Options:
-h, -help Print this help
-v, --version Print the version
--stop-on-error Stop on the first exception
--stop-on-failure Stop on the first failure
--junit report.xml Report in JUnit XML format
$ cobc -x -debug gcblunit.cbl tests/* --job='equals-test notequals-test'
GCBLUnit 1.22.6 by Olegs Kunicins and contributors.
..............................................................
Time: 00:00:00
OK
Tests: 0000000002, Skipped: 0000000000
Assertions: 0000000062, Failures: 0000000000, Exceptions: 0000000000
Tests are simple COBOL programs that allow futher execution (without stop run
). There is no code-generation tricks nor injections.
The assertions are GnuCOBOL programs and await two values - expected and actual, respectively:
call "assert-equals" using "expected", "actual".
This assertion, once included into the unit-testing, will lead to one failed test. More examples you may find in the tests
directory.
At the moment these assertions are supported:
assert-notequals
GCBLUnit catches exceptions and stops. For instance, the statement compute y = y / 0.
is getting reported this way:
GCBLUnit 1.22.6 by Olegs Kunicins and contributors.
There was an exception: EC-SIZE-OVERFLOW in exception-test; ; 33 on COMPUTE
Time: 00:00:00
EXCEPTIONS!
Tests: 0000000001, Skipped: 0000000000
Assertions: 0000000000, Failures: 0000000000, Exceptions: 0000000001
COBOLUnit returns an exit-code of the execution that is usually enough for CI pipelines.
Additional details you may export to a file in JUnit XML format by using --junit
option.
GCBLUnit primarily focuses on Unit Testing - isolated GnuCOBOL functions and programs with an input and output.
Nonetheless, you may try two alternatives as well:
cobol-unit-test
- a paragraph-level Unit Testing framework, written by Dave Nicolette, hosted on GitHub.COBOLUnit
- a full-featured Unit Testing framework for COBOL, written by Hervé Vaujour, hosted on Google Sites. Not updated since 2010.assert-greater
assert-less
assert-contains
assert-notcontains
Your contribution is always welcome!
Enterprise COBOL library with string functions
Enterprise COBOL library with string functions
Name | Description |
---|---|
strpos | Find the position of the first occurrence of a substring. Case-sensitive. |
stripos | Find the position of the first occurrence of a substring. Case-insensitive. |
CALL "strpos" USING l-haystack, l-h-len, l-needle, l-n-len.
Find the position of the first occurrence of a substring. Case-sensitive.
l-haystack String to search in l-h-len Size of l-haystack in bytes l-needle String to search for l-n-len Size of l-needle in bytes
Position where the needle exists relative to the beginnning of l-haystack. Returns 0 if not found.
CALL "stripos" USING l-haystack, l-h-len, l-needle, l-n-len.
Find the position of the first occurrence of a substring. Case-insensitive.
l-haystack String to search in l-h-len Size of l-haystack in bytes l-needle String to search for l-n-len Size of l-needle in bytes
Position where the needle exists relative to the beginnning of l-haystack. Returns 0 if not found.
Install and initialize COBOL Package Manager:
$ npm install -g cobolget
$ cobolget init
Add the package to the Manifest
:
$ cobolget add main-string
$ cobolget update
Install the package and its dependencies:
$ cobolget install
....
Modules modules.cpy and modules.cbl updated.
Directory modules
contains source-code of the package and modules.cbl
ready for compliation and linking with your project.
ECBLUnit tool
Simple Unit Testing for z/OS written in IBM Enterprise COBOL.
ECBLUEQ
checks binary equality of two 32-byte valuesECBLUNEQ
checks binary inequality of two 32-byte valuesECBLUREQ
checks binary equality of two any-length values represented by pointersObtain an access to a mainframe for training purposes, free of charge. Register at IBM and follow the instructions. You'll receive a registration email with USER ID e.g. Z82698, IP address e.g. 192.86.32.250 and PORT e.g. 10443. For generating the password, you need to login on Open Mainframe Project Slack workspace. After logging in add zih
app via Apps
menu and post zih
a message e.g. Hi. The app will ask your e-mail address and userid that you have received. Post these details one by one and the app will create your PASSWORD for the next step.
Zowe is an open-source framework that allows teams to manage, control, script, and develop on the mainframe, a part of the Open Mainframe Project. Zowe provides a Command-Line Interface that lets you interact with the mainframe from your machine.
$ npm i -g @zowe/cli --ignore-scripts
Create Zowe default ztrial
profile by using your z/OS credentials and setting the --reject-unauthorized flag to false
that bypasses the certificate requirement:
$ zowe profiles create zosmf ztrial --host --port --user --pass --reject-unauthorized false
Profile created successfully!
Verify that your profile can communicate with z/OSMF:
$ zowe zosmf check status
Simply download ecblunit.cbl file or install by COBOL Package Manager:
$ npm install -g cobolget
$ cobolget init
$ cobolget add --debug ecblunit
$ cobolget update
$ cobolget install
Upload the files to the mainframe and submit a JCL job which compiles and links them together. Executable ECBLUNIT
awaits a list of test programs in PARM
parameter, separated by space.
$ zowe zos-files upload file-to-data-set src/ecblunit.cbl .CBL
$ zowe zos-files upload file-to-data-set tests/tests.cbl .CBL
$ zowe jobs submit local-file tests/tests.jcl --view-all-spool-content
...
ECBLUnit 1.64.8 by Olegs Kunicins and contributors.
Time: 00:00:00
OK
Tests: 003, Skipped: 000
Assertions: 050, Failures: 000, Exceptions: 000
Tests are simple COBOL programs that allow further execution (without STOP RUN
). There is no code-generation tricks nor injections.
The assertions are COBOL programs and await two PIC X(32)
values - expected and actual, respectively:
CALL "ECBLUEQ" USING expected actual.
CALL "ECBLUNEQ" USING expected actual.
The record-equality assertion awaits two POINTER
values providing flexible comparison of any data at any position:
CALL "ECBLUREQ" USING
BY CONTENT ADDRESS OF expected
BY CONTENT ADDRESS OF actual
BY CONTENT LENGTH OF expected.
More examples you may find in the tests/tests.cbl
file.
ECBLUnit returns RETURN-CODE
of the execution that is usually enough for CI pipelines. Here's an one-liner which picks the exit code from the output, on Linux:
zowe jobs submit local-file tests/tests.jcl --wait-for-output --rff retcode --rft string | cut -d" " -f 2
ECBLUnit primarily focuses on Unit Testing - isolated COBOL programs and methods with an input and output.
Nonetheless, you may try two alternatives as well:
cobol-unit-test
- a paragraph-level Unit Testing framework, written by Dave Nicolette, hosted on GitHub.zUnit
- a commercial framework on the IBM mainframe platform.Your contribution is always welcome!
Enterprise COBOL library with bitwise functions
Enterprise COBOL library with bitwise functions
Name | Description |
---|---|
BOR | Bitwise OR |
BAND | Bitwise AND |
BXOR | Bitwise XOR |
BNOT | Bitwise NOT |
CALL "BOR" USING l-arg-a, l-arg-b.
Bitwise OR
l-arg-a One byte l-arg-b One byte
One byte
CALL "BAND" USING l-arg-a, l-arg-b.
Bitwise AND
l-arg-a One byte l-arg-b One byte
One byte
CALL "BXOR" USING l-arg-a, l-arg-b.
Bitwise XOR
l-arg-a One byte l-arg-b One byte
One byte
CALL "BNOT" USING l-arg-a, l-arg-b.
Bitwise NOT
l-arg-a One byte l-arg-b One byte
One byte
Install and initialize COBOL Package Manager:
$ npm install -g cobolget
$ cobolget init
Add the package to the Manifest
:
$ cobolget add main-bitwise
$ cobolget update
Install the package and its dependencies:
$ cobolget -t bca12d6c4efed0627c87f2e576b72bdb5ab88e34 install
....
Modules modules.cpy and modules.cbl updated.
Directory modules
contains source-code of the package and modules.cbl
ready for compliation and linking with your project.
See coboldoc documentation.
NetCOBOL library with bitwise functions
NetCOBOL library with bitwise functions
Name | Description |
---|---|
byte-to-hex | Convert one byte into hexadecimal representation. |
hex-to-byte | Convert hexadecimal to binary. |
byte-to-bin | Convert one byte into binary representation. |
bin-or | Bitwise OR |
bin-and | Bitwise AND |
bin-xor | Bitwise XOR |
bin-not | Bitwise NOT |
CALL "byte-to-hex" USING l-byte.
Convert one byte into hexadecimal representation.
l-byte Byte
2 hexadecimal chars
CALL "hex-to-byte" USING l-hex.
Convert hexadecimal to binary.
l-hex 2 hexadecimal chars
Byte
CALL "byte-to-bin" USING l-byte.
Convert one byte into binary representation.
l-byte Byte
8 binary chars
CALL "bin-or" USING l-arg-a, l-arg-b.
Bitwise OR
l-arg-a One byte l-arg-b One byte
One byte
CALL "bin-and" USING l-arg-a, l-arg-b.
Bitwise AND
l-arg-a One byte l-arg-b One byte
One byte
CALL "bin-xor" USING l-arg-a, l-arg-b.
Bitwise XOR
l-arg-a One byte l-arg-b One byte
One byte
CALL "bin-not" USING l-arg-a, l-arg-b.
Bitwise NOT
l-arg-a One byte l-arg-b One byte
One byte
Install and initialize COBOL Package Manager:
$ npm install -g cobolget
$ cobolget init
Add the package to the Manifest
:
$ cobolget add fuji-bitwise
$ cobolget update
Install the package and its dependencies:
$ cobolget install
....
Modules modules.cpy and modules.cbl updated.
Directory modules
contains source-code of the package and modules.cbl
ready for compliation and linking with your project.
My first GnuCOBOL library with banking functions
Calculate IBAN checksum