• File Handling Code Examples

    >COBOL Coding for Files Example
    The general format of COBOL input-output coding is shown. 

    >COBOL File Status Code with Text Information
    This COBOL file status example will show how to convert the two byte file status code that may contain binary data to a four byte numeric value that may be displayed. 

    >COBOL File System and Programming
    Here are COBOL file system and programming source code examples. 

    >COBOL Record Format Examples
    COBOL sample code describing record description, determining fixed-length record size, determining fixed-length record size for files with multiple record descriptions, creating variable-length records with the DEPENDING ON Phrase, creating variable-length records with the RECORD VARYING Phrase, and creating variable-length records and using the OCCURS Clause with the DEPENDING ON Phrase. 

    >Comma delimited, QSAM, and COBOL VSAM Files
    Here are several COBOL data access sample programs that cover handling comma delimited, QSAM, and COBOL VSAM files. 

    >Displaying Record-Lock Messages
    This iSeries COBOL subroutine displays record-lock messages. 

    This COBOL program converts EBCDIC-sequential to ASCII-indexed. 

    >Line Sequential File Example
    This COBOL sample demonstrates line sequential file handling. 

    >Read an IFS File
    This is an iSeries Cobol example showing how to read lines from an IFS file. 

    >COBOL VSAM and QSAM COBOL File Status Keys/Error Codes
    This is a COBOL program example of how to determine the COBOL VSAM and QSAM COBOL file status keys/error codes in an IBM Enterprise COBOL environment. 

    >VSAM File Access for COBOL
    If you are interested in writing COBOL programs that utilize VSAM datasets, I hope this documentation has provided you with the information you need to install my routine and get started writing programs on your own.





  • COBOL Future Date Calculation

    Contributed by: Don Stafford, Director of Information Technologies, UAV Entertainment Corporation

    We needed a routine to calculate a date in the future, based on business days, not on calendar days. In searching the internet, no COBOL source could be found.
    However, several routines were found in various other programming languages.
    I took several of those and adapted the code to MicroFocus Cobol. In Working Storage, you need the following variables:       01 CalDays                         PIC 9(3).
          01 BusDays                        PIC 9(3).
          01 DelDay                          PIC 9(3).
          01 DelWks                         PIC 9(3).
          01 WS-DAY-OF-WEEK        PIC 9(2).
          01 DAYS-TO-ADD              PIC 9(3).
          01 DATE-YMD-IN               PIC 9(8).
          01 DATE-YMD-OUT            PIC 9(8).
          01 DATE-DAY                    PIC 9(8). In the Procedure Division, you have 2 paragraphs:       ADD-BUS-DAYS-TO-DATE.          PERFORM GET-DAY-OF-WEEK-FOR-DATE.
             IF WS-DAY-OF-WEEK = 6
                MOVE 5 TO WS-DAY-OF-WEEK
                SUBTRACT 1 FROM DAYS-TO-ADD.          MOVE DAYS-TO-ADD TO CalDays,
                                                            BusDays.          COMPUTE DelDay = WS-DAY-OF-WEEK + DAYS-TO-ADD.          IF DelDay > 5
                COMPUTE BusDays = BusDays - ( 6 - WS-DAY-OF-WEEK )
                COMPUTE CalDays = CalDays + 2
                COMPUTE DelWks = BusDays / 5
             COMPUTE DATE-YMD-OUT = FUNCTION DATE-OF-INTEGER (DATE-DAY). The current (base) date is moved into DATE-YMD-IN.
    The number of (business) days to add is moved into DAYS-TO-ADD.
    You then call  ADD-BUS-DAYS-TO-DATE.
    The resulting date is in DATE-YMD-OUT. Obvious note:  If you call ADD-DAYS-TO-DATE, it simply calculates a date in the future without regards to weekends.
    Not-so-obvious note:  If you make ADD-DAYS-TO-DATE a PIC S9(3), then ADD-DAYS-TO-DATE will add or subtract days.  The ADD-BUS-DAYS-TO-DATE only works with +(positive) numbers.
    Don Stafford, Director of Information Technologies
    UAV Entertainment Corporation
    2200 Carolina Place
    Fort Mill, SC  29708

  • General COBOL Code Examples

    >Micro Focus Acucobol Sample Programs
    This is a collection of sample programs that help illustrate certain concepts integral to developing with ACUCOBOL-85 and ACUCOBOL-GT. 

    >Bubble Sort in COBOL
    This is an example of a COBOL II bubble sort. >COBOL Example Programs
    This is a list of COBOL examples that demonstrate date routines, get free-form number routine, table sorts, and more. 

    >COBOL Example Programs
    These sample programs illustrate date routines, free-form extraction, loan amount calculation, money to text, validate/reverse name, and table sort. 

    >COBOL Example for Beginner's
    This example is for beginner's. 

    >COBOL Programs for Beginner's
    Here is a large number of examples for beginner's. 

    >COBOL Programs for Beginner's
    Here are sample COBOL programs that include hello word, accept number, and sales file processing. 

    >COBOL Programs for Beginner's
    This COBOL example calculates employee payroll information given the tax deduction table for the employee. 

    >COBOL Programs for Beginner's
    Here is collection of sample code for beginner's. 

    >COBOL Reference, Syntax, and Examples
    The COBOL samples here cover COBOL syntax for current-date function, evaluate statement, if and end-iIf statement, initialize statement, in-line perform, inspect statement, and reference modification 

    >COBOL Sample Programs
    These sample programs cover COBOL language elements, two and three files matching, random and sequential files, bubble sort, relative files, screen processing, variable length records, working with dates, object oriented programs, and data structures.

    >Dateout COBOL II Procedure
    This program outputs current date and time as DB2 timestamp to a file. 

    >Editint COBOL Subroutine
    This subroutine determines validity of input unsigned integer number and edits it in its place. 

    >Fujitsu / Alchemy NetCOBOL Sample Programs
    These samples were tested with Version 4 & 5 of the Fujitsu COBOL product set. 

    >How to Write the Syntax of COBOL Programs
    These are notes that have been obtained from various sources on how to write the syntax of COBOL programs. 

    >HP COBOL II/XL Program Example
    This example contains a complete COBOL program listing from the HP COBOL II/XL compiler. 

    >General COBOL Sample Programs
    This is a collection of COBOL examples that show sequential file program, balance sheet printing, calculating yearly depreciation, computing interest, and more 

    >Micro Focus Sample Programs
    Here are examples of integrating operating system functions into Micro Focus Net Express. 

    >Source Entry Utility (SEU) Extensions
    These examples show how to extend the functionality of SEU with your own line commands. 

    >Structured COBOL
    This is the source code from Murach's Structured COBOL book. 

    >Towers of Hanoi
    This program was developed with the Open COBOL compiler. 

    >VS COBOL Code
    This is a typical example of the type of COBOL programs in many mature installations.


  • gnuiconGnuCOBOL (formerly OpenCOBOL)

    GnuCOBOL (formerly OpenCOBOL) is a free COBOL compiler. cobc translates COBOL to executable using intermediate C sources, providing full access to nearly all C libraries.

    OpenCOBOL 1.1 continued on as GNU Cobol 1.1. Officially posted to, also available here.

    GnuCOBOL 2.0 is on its way to a pre-release.

    A superb manual by Gary Cutler, along with a FAQ / How-To, and other documentation is indexed at

    OpenCOBOL 1.1 is

    Copyright (C) 2001-2009 Keisuke Nishida
    Copyright (C) 2007-2012 Roger While

  • Graphical User Interfaces Code Examples

     >Graphical User Interface (GUI) Samples.
    The Micro Focus Acucobol sample programs demonstrate the products GUI features. 

    >GUI ScreenIO
    This Norcom COBOL sample will display and handle user interaction with any type of GUI ScreenIO panel (including a property sheet or a wizard), regardless of the type or number of controls it contains.




    COBOL iSeries (AS400) Code Examples

     >iSeries(AS400) Sample COBOL Programs
    Several sample iseries(as400) COBOL programs.


  • New COBUG Site is developing well.

    Join and help us with your suggestions on what you want adde or deleted fom the site.

     Join New COBUG now.

  • Contributed by: James Lemmon, JWL Software, Johannesburg, South Africa Here is a program that I use for reading from a COM port. This has been used in a few different compilers so hopefully it will work for you without many amendments.

    000550 01 SCA-REC.
                         03 SCA-LINE PIC X(30).
                    01 SCA-REC2.
                         03 SCA-CHAR1 PIC X(01).
                         03 SCA-CHAR2-30 PIC X(29).
                    01 SCA-REC3.
                         03 SCA-KG PIC 9(03).
                         03 SCA-DEC PIC X(01).
                         03 SCA-GRAM PIC 9(03).
                         03 FILLER PIC X(23).
                    01 W02-FILE-IDS.
                         03 W02-SCALES PIC X(04) VALUE "COM2".
    .......This can be any of the com ports.
                    01 SCALE-QUANTITY.
                         03 SCALE-PORT.
                              05 SCALE-NO PIC X(04).
                         03 SCALE-QUANT.
                              05 SCALE-WEIGHT.
                                   07 SCALE-QNT PIC 9(09)V999.
                              05 SCALE-WEIGHT2 REDEFINES SCALE-WEIGHT.
                                   07 SCALE-KG PIC 9(09).
                                   07 SCALE-GR PIC 9(03).
    001220 AA000 SECTION.
    001230 AA00.
                       MOVE ZERO TO SCALE-QNT.
                       MOVE SCALE-NO TO W02-SCALES.
    042140      OPEN I-O SCALES.
    003050      IF NOT (WS-STATUS = "00" OR "41")
                             GO TO AA999.
    001340 AA05.
                       READ SCALES.
                       IF NOT (SCA-CHAR1 = "+" OR "-")
                             MOVE SCA-CHAR2-30 TO SCA-REC
                       IF SCA-REC = SPACES
                             GO TO AA999
                             GO TO AA10.
                       MOVE SCA-CHAR2-30 TO SCA-REC.
                       IF SCA-REC = SPACES
                             GO TO AA999.
                       MOVE SCA-KG TO SCALE-KG.
                       MOVE SCA-GRAM TO SCALE-GR.
    001830           CLOSE SCALES.

  • Support

  • Technical Support

    >Allen Systems Group (ASG)
    ASG offers several different avenues to access support information online.

    >CA Technologies
    Technical support for CA Technologies mainframe environment products is available.

    >Canam Software Labs
    Online technical support provides access to downloads, product knowledge base, FAQs and contact information.

    COBOL-IT technical support offers support for development, production, consulting and monitoring service, training and contact information.

    >Delta Software Technology
    Technical support services are provided under the terms of a maintenance contract that provides access to a range of support services and any necessary patches for reproducible problems.

    >Envyr - ICOBOL
    Envyr provides pre-sales, post-sales and ongoing technical support for ICOBOL.

    In order to receive product technical support for any of the Flexus products, you must have a valid software license and must be currently under maintenance. Flexus offers a discussion forum accessible to all COBOL programmers whether or not you are a customer of Flexus products.

    >Fresche Solutions
    "Ask an Expert" is a free service offered by Fresche Legacy, a leading mainframe modernization solution provider.

    >HP COBOL for OpenVMS
    Contact technical support for any of HP's products.

    >IBM Enterprise COBOL for z/OS
    IBM's technical support resource for all IBM products & services : Fixes & downloads, documentation, report & track problems, news, alerts, training, tools & communities : Enterprise COBOL for z/OS.

    >IRI, The CoSort Company
    Technical support is free during evaluation, and for the first year after product licensing.

    >MarshallSoft Computing
    Technical support includes answering questions about library functions, providing examples of calling library functions, help in running the example programs, and answering questions about how the library can be used.

    >Micro Focus
    Micro Focus supportLine customers can download COBOL related programs, updates, upgrades, etc.

    >NetCOBOL Fujitsu
    The technical support portal provides access to contact information, help, COBOL downloads, documentation, and other support features.

    Norcom provides technical support for all of its software products, including GUI ScreenIO.

    >Ordina Denkart
    Ordina Denkart offers technical product support to all customers. Technical support includes help during product installation and operation, including ViaNova UNISYS which migrates 1100/2200 COBOL mainframe applications to Open Systems with a relational database.

    >Redvers Consulting
    Contact technical support for help with COBOL XML Interface.

    >Relational Language & Database Technology (RLDT SA)
    Contact technical support for help with COBOL Access Plus.

    Contact ScreenJet product support for download of VPlus to ACUCOBOL Migration Demo Video file.

    >Siber Systems
    Data Viewer and Cobol Tools technical support offered by Siber Systems.

    >Software Engineering of America
    Contact technical support for help with Software Engineering Of America mainframe software.

    >Software Mining
    Contact SoftwareMining technical support for help with COBOL To Java and COBOL To C# Converters.

    Syncsort technical support is ready and available to provide customer support, all over the world.

    >The Source Recovery Company
    Contact technical support for help to recover COBOL or Assembler source code from IBM MVS or VSE executable programs.

    TransforMix provides help desk support for entire heterogeneous networks, including systems and applications support.

    >Transoft Limited
    Transoft's technical support provides product knowledgebase, contact support, developer's blog and LinkedIn Group.

    >Visible Systems
    Visible Products Technical Support is available to customers who have purchased a Maintenance Plus. Limited Technical Support is also available to prospective users who have downloaded a demonstration or trial version of any of our products.


This website uses cookies to manage authentication, navigation, and other functions. By using our website, you agree that we can place these types of cookies on your device.

View e-Privacy Directive Documents

You have declined cookies. This decision can be reversed.

You have allowed cookies to be placed on your computer. This decision can be reversed.


Member Login