Intrinsic function
A ready-made COBOL function, written FUNCTION followed by a name, that returns a value such as today's date.
Also written FUNCTION, CURRENT-DATE, NUMVAL, INTEGER-OF-DATE, UPPER-CASE
Intrinsic functions are built into COBOL. You write the word FUNCTION, the function's name and any arguments, and use the result like a field: MOVE FUNCTION CURRENT-DATE TO WS-NOW.
Some are used all the time. CURRENT-DATE returns the date, the time and the difference from UTC as one 21-character value, starting with the year, month and day. UPPER-CASE and LOWER-CASE change the case of text. LENGTH returns the length of a field. NUMVAL turns text such as '1,234.50' into a number that can be used in arithmetic. MAX, MIN and MOD do what their names say.
Date arithmetic is a common use. INTEGER-OF-DATE turns a date into a day number, and DATE-OF-INTEGER turns a day number back into a date. To add 30 days to a date, convert it, add 30, and convert it back. That avoids writing your own rules for month lengths and leap years.
Older programs often do these jobs by hand, because the functions were added to COBOL later. When you change such code, the functions can make it shorter and safer.
Where can I learn this hands-on?
Right here, at ZedBank. You take a junior job at a simulated bank and learn each part of the work by doing it, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- COMPUTEThe COBOL statement that calculates a formula and stores the result, such as COMPUTE TOTAL = PRICE * QUANTITY.
- MOVEThe COBOL statement that copies a value into a field, converting it to fit the receiving field's format.
- COBOLThe programming language most business logic on the mainframe is written in. Verbose by design, and still running the world's payments.
- PROCEDURE DIVISIONThe part of a COBOL program that contains the actual logic, the statements that run.
- INSPECTA COBOL statement that counts, replaces or converts characters inside a field.