programming

  • Database Code Examples

    Database Code Examples

    >ADO.NET/ COBOL/Stored Procedures
    This COBOL sample provides an example of how to access a stored procedure to perform a specific task such as create a new table, retrieve data from one or more tables, update one or more tables or perform many other tasks. 

    >COBOL Procedures
    COBOL procedures are to be written in a similar manner as COBOL subprograms. This COBOL example describes handling parameters in a COBOL procedure and exiting a COBOL procedure.

    >DB2 Explain Command
    How to Explain a DB2 SQL Command for a single table. 

    >DB2/SQL/COBOL Samples
    Several IBM COBOL and MicroFocus COBOL samples that include COBOL DB2 API sample programs with no embedded SQL, COBOL DB2 API embedded SQL sample programs, and COBOL SQL sample programs with no DB2 APIs. 

    >DB2/SQL/COBOL for AS/400 Example
    The SQL COBOL example demonstrates how to code SQL statements using iSeries (AS400) COBOL. 

    >Sybase COBOL SQL Samples
    The COBOL sample programs demonstrate features such as how to code a batch of INSERT requests, how to code a DB2 Input Pipe, how to code a transfer request, how to code keyword input, how to embed SQL in COBOL programs, and more. 

    >Tips for Writing an INMOD in COBOL
    Here are tips for writing INMOD routines for Teradata FastLoad in COBOL

     

  • File Handling Code Examples

    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. 

    >EBCDIC to ASCII
    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.

     

     

     

     

  • Future Date Calculation

    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 DAYS-TO-ADD = CalDays + (DelWks * 2).           PERFORM ADD-DAYS-TO-DATE.       ADD-DAYS-TO-DATE.          COMPUTE DATE-DAY = FUNCTION INTEGER-OF-DATE (DATE-YMD-IN).
             ADD DAYS-TO-ADD TO DATE-DAY.
             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

    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.

     

  • GnuCOBOL

    gnuiconGnuCOBOL (formerly OpenCOBOL)

    Description
    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 ftp://ftp.gnu.org/gnu/gnucobol, 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 http://opencobol.add1tocobol.com/guides

    OpenCOBOL 1.1 is

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

  • Graphical User Interfaces Code Examples

    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.

     

     

  • iSeries(AS400) Sample COBOL Programs

     

    COBOL iSeries (AS400) Code Examples

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

     

  • New COBUG Site is developing well

    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.

  • Read COM Port - COBOL Program Example

    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.

    000170 SELECT SCALES ASSIGN W02-SCALES
    000300 ORGANIZATION LINE SEQUENTIAL
    000180 STATUS WS-STATUS
    000310 ACCESS SEQUENTIAL.
    .
    .
    .
    000530 FD SCALES LABEL RECORD OMITTED.
    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).
    .
    .
    .
    001230 PROCEDURE DIVISION USING SCALE-QUANTITY.
    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.
            AA10.
                       IF NOT (SCA-CHAR1 = "+" OR "-")
                             MOVE SCA-CHAR2-30 TO SCA-REC
                       IF SCA-REC = SPACES
                             GO TO AA999
                       ELSE
                             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.
    AA999.
                EXIT-PROGRAM.

  • Support

    Support

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.

Login

Who's Online

Member Login