Right Adjust, Zero Fill
 Right Adjust a Text String within a Field
http://www.simotime.com
When technology complements business    Copyright © 1987-2010  SimoTime Enterprises  All Rights Reserved
  Table of Contents Version 10.03.20 
  Introduction
 
  Programming Objectives
  Programming Input and Output
  Programming Requirements
  Programming Overview
  The Call Interface
  Sample CMD Members for Net Express
 
  CMD to Run the Demonstration Program
  CMD to Create a RIGHTADJ Info File
  Sample JCL Members for OS/390 or Mainframe Express
 
  JCL to Run the Demonstration Program
  JCL to Create a RIGHTADJ Info File
  The Demonstration Program
  The Right Adjust Routine
  Summary
 
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Comments or Suggestions
  About SimoTime

Introduction
(Next) (Previous) (Table-of-Contents)

This suite of programs provides an example of a routine that will Right Adjust (or Right Justify) a text string within a numeric field and fill the left-most or high-order bytes with zeroes. The resulting field is also tested for numeric values and a return code (RA12-RESPOND) is set to zero (0) if numeric and eight (8) if not numeric. Two COBOL programs are provided. The first program is a demonstration program that reads a file containing "RIGHTADJ-info" records and calls the second COBOL program that actually does the right-adjust, zero-fill processing.

The objective of the right-adjust, zero-fill routine is to create a numeric field that will contain all digits with leading zeroes in the leftmost positions and be properly aligned to the units position. If the requirement is to right-justify, left-justify or center a text string within a field with the appropriate leading and/or trailing space characters then refer to the text-justification routine .

Both COBOL programs are written using the VS COBOL II dialect and also work with COBOL for MVS and COBOL/370. A JCL member is provided to run the job as an MVS batch job on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) running on a PC with Windows. A Windows Command (.CMD) file is provided to run the job on a PC with Micro Focus Net Express. This program may serve as a tutorial for new programmers and as a reference for experienced programmers. Additional information is provided in the Downloads and Links to Similar Pages section of this document.

Programming Objectives
(Next) (Previous) (Table-of-Contents)

The following is a list of the functions provided in this example.

1. Demonstrate how to Right-Adjust a text string within a field.
2. Do a Zero-Fill for the left-most or high-order bytes.
3. Do an erase to End-Of-Field after the first space.
4. Test the right-adjusted field for all numerics.

The first task performed by the SimoRA12 routine is to erase to the End-Of-Field. This feature will scan the field from left to right and erase (change to a space character) any characters after the first space is encountered. The next task is to right-adjust the non-space characters and zero-fill the leftmost (or high-order) bytes in the field. The final task is to test the results for a numeric value. If the resulting field is numeric the return code (or RA12-RESPOND) is set to zero, If the resulting field is not numeric the return code (or RA12-RESPOND) is set to 0008.

Programming Input and Output
(Next) (Previous) (Table-of-Contents)

The following is an example of the contents of the input or RIGHTADJ-info file (RA12GET1). Notice the 5th statement contains a non-numeric value. The 8th statement contains an embedded space that will cause the erase to End-Of-Field to remove (or erase) any characters after the embedded space character.

RIGHTADJ 1
RIGHTADJ 12
RIGHTADJ 123
RIGHTADJ 1234
RIGHTADJ 1234A
RIGHTADJ 12345
RIGHTADJ 123456
RIGHTADJ 123 56789
RIGHTADJ 1234567
RIGHTADJ 12345678
RIGHTADJ 123456789
RIGHTADJ 1234567890
RIGHTADJ 12345678901
RIGHTADJ 123456789012
RIGHTADJ 3

The following is an example of the output file (RA12PUT1) based on the preceding RIGHTADJ-info file . Notice the 5th statement contains a non-numeric value. The 8th statement contains an embedded space that will cause the erase to End-Of-Field to remove (or erase) any characters after the embedded space character.

Right-Adjust, Zero-Fill Example    v04.03.03 http://www.simotime.com
Copyright 1987-2010   SimoTime Enterprises, LLC  All Rights Reserved
********************************************************************
RIGHTADJ 1
Right Adjusted Value......... 000000000001
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 12
Right Adjusted Value......... 000000000012
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 123
Right Adjusted Value......... 000000000123
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 1234
Right Adjusted Value......... 000000001234
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 1234A
Right Adjusted Value......... 00000001234A
RC=0008, Value is NON-Numeric or Request Invalid                    
********************************************************************
RIGHTADJ 12345
Right Adjusted Value......... 000000012345
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 123456
Right Adjusted Value......... 000000123456
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 123 56789
Right Adjusted Value......... 000000000123
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 1234567
Right Adjusted Value......... 000001234567
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 12345678
Right Adjusted Value......... 000012345678
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 123456789
Right Adjusted Value......... 000123456789
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 1234567890
Right Adjusted Value......... 001234567890
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 12345678901
Right Adjusted Value......... 012345678901
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 123456789012
Right Adjusted Value......... 123456789012
RC=0000, Value is Numeric
********************************************************************
RIGHTADJ 3
Right Adjusted Value......... 000000000003
RC=0000, Value is Numeric
RA12GET1 line count is 0000015
is Complete...
Thank you for using this sample by SimoTime Enterprises, LLC
Please send comments or suggestions to helpdesk@simotime.com

Programming Requirements
(Next) (Previous) (Table-of-Contents)

This suite of samples programs will run on the following platforms.

1. Executes on Windows/2000, Windows/NT and Windows/XP using Micro Focus Net Express and the CMD file provided.
2. May be ported to run on the UNIX platforms supported by Micro Focus COBOL.
3. Executes on a mainframe with MVS or Windows/2000, Windows/NT and Windows/XP using Micro Focus Mainframe Express and the JCL file provided.

Programming Overview
(Next) (Previous) (Table-of-Contents)

The following diagram is an overview of how the demonstration program fits into the example. The demonstration program will read the RIGHTADJ info file (RA12GET1), call the right-adjust routine and write the results to the output file (RA12PUT1). The BLUE boxes are unique to the mainframe and Micro Focus Mainframe Express. The RED boxes are unique to the PC with Windows and Micro Focus Net Express. The GREEN boxes are platform independent and will execute on the mainframe or a PC with Windows. Also, the GREEN boxes may be ported to a UNIX platform that is supported by Micro Focus COBOL.

               
Entry Point
OS390 or MFE
     
Entry Point
Net Express
  Entry Points  
 
     
 
     
CBLRAZJ1
jcl
     
CBLRAZE1
cmd
  Start the right-adjust processing example  
 
     
 
     
IEFBR14
cmd
     
If Exist
stmt
  Delete previously created right-adjust output file  
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
RA12GET1
qsam
     
     
     
CBLRAZC1
cobol
     
     
     
RA12OUT1
qsam
  Read the rightadj info file (RA12GET1), call the right-adjust routine and write the results to the output file (RA12PUT1).  
   
 
     
     
     
SIMORA12
cobol
  Right-adjust the text string within the field  
   
EOJ
      End-of-Job  
               

The Call Interface
(Next) (Previous) (Table-of-Contents)

The following is the syntax for calling the right-adjust routine (SIMORA12.CBL).

        call 'SIMORA12' using RA12-PASS-AREA

The callable right-adjust routine will accept a string of numbers up to twelve (12) digits. A data structure for calling the SIMORA12 routine is provided. A copy file (PASSRA12.CPY) is provided with the following fields defined.

      *****************************************************************
      *     Data Structure or Pass Area used for calling SIMORA12.    *
      *****************************************************************
      *         Copyright (C) 1987-2010 SimoTime Enterprises          *
      *                     All Rights Reserved                       *
      *****************************************************************
      *              Provided by SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
       01  RA12-PASS-AREA.
           05  RA12-REQUEST    PIC X(8).
           05  RA12-RESPOND    PIC 9(4).
           05  RA12-BUFFER.
               10  RA12-NUMBER PIC 9(12).
      *!   PASSRA12 - End-of-Copy File...

The following table is an overview of the data strings used in the pass area.

Field Name Description
RA12-REQUEST This is an eight character data string and should contain the following in upper case.
RIGHTADJ This keyword causes the right-adjust routine (SIMORA12) to right-adjust the specified field.
This calling program must provide one of the above as a request. Otherwise, a non-zero return code will be set in the following result field. This data string is not changed by the right-adjust routine.
RA12-RESPOND This is a four byte binary data string and is used by the conversion routine to pass a return code. If the conversion request is successful the value in this data string will be zero.
RA12-BUFFER This is the twelve (12) character field that will be right-adjusted with a zero-fill of the left-most or high-order bytes..
RA12-NUMBER This is a redefinition of the twelve (12) byte field redefined as a numeric field.

Sample CMD File
(Next) (Previous) (Table-of-Contents)

This sample suite of programs has two CMD members. The first CMD member will execute the demonstration program. The second CMD member will create a RIGHTADJ info file.

Sample CMD, Run the Demonstration Program
(Next) (Previous) (Table-of-Contents)

The following is the CMD required to run the demonstration program on a Personal Computer with Micro Focus Net Express.

@echo OFF
rem  * *******************************************************************
rem  *                   This program is provided by:                    *
rem  *                    SimoTime Enterprises, LLC                      *
rem  *           (C) Copyright 1987-2010 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Read a file of RIGHTADJ inof, right-adjust, write output.
rem  * Author - SimoTime Enterprises
rem  * Date   - January 24, 1996
rem  *
rem  * The job will read an 80-byte file that contains RIGHTADJ
rem  * information. The job will also write a file containing the results
rem  * of the right-adjust functions..
rem  *
rem  * This set of programs will run on a mainframe under MVS or on a
rem  * Personal Computer with Windows and Micro Focus Net Express.
rem  *
rem  *    ************
rem  *    * CblRazE1 *
rem  *    ********cmd*
rem  *         *
rem  *         *
rem  *    ************     ************     ************
rem  *    * SimoEXEC ******* SIMOLOGS ******* CONSOLE  *
rem  *    ********cbl*  *  ********cbl*  *  ************
rem  *         *        *                *
rem  *         *        *                *  ************
rem  *         *        *                ****  SYSLOG  *
rem  *         *        *                   ********txt*
rem  *         *        *
rem  *         *        **************************
rem  *         *                                 *
rem  *         *           ************     ************     ************
rem  *         *           * RA12GET1 ******* CblRazC1 ******* RA12PUT1 *
rem  *         *           ********txt*     ********cbl*     ********csv*
rem  *         *                                 *
rem  *         *                            ************
rem  *         *                            * SIMORA12 *
rem  *         *                            ********txt*
rem  *         *
rem  *    ************
rem  *    *   EOJ    *
rem  *    ************
rem  *
rem  *
rem  * *******************************************************************
rem  * Step   1   Delete any previously created file...
rem  *
     set syslog=d:\simoNXE4\AN01\datawrk1\SYSLOGT1.TXT
rem  *
     SimoEXEC NOTE *******************************************************CblRazE1
     SimoEXEC NOTE Starting JobName CblRazE1
:DeleteQSAM
     SimoEXEC NOTE Identify JobStep DeleteQSAM
     set RA12GET1=d:\SimoNXE4\AN01\DataAsc1\RA12GET1.TXT
     set RA12PUT1=d:\SimoNXE4\AN01\DataWrk1\RA12PUT1.TXT
     if exist %RA12PUT1% del %RA12PUT1%
rem  *
rem  * *******************************************************************
rem  * Step   2   Edit input, create a new output file...
rem  *
:ExecuteRightAdjustRoutine
     SimoEXEC NOTE Identify JobStep ExecuteRightAdjustRoutine
     SimoEXEC EXEC CBLRAZC1
     if exist %SYSUT2% SimoEXEC NOTE Produced DataSet %SYSUT2%
     SimoEXEC NOTE Finished JobName CblRazE1
     if not "%1" == "nopause" pause

Sample CMD, Create a RIGHTADJ Info File
(Next) (Previous) (Table-of-Contents)

The following is the CMD that may be used to create a RIGHTADJ-info file.

@echo OFF
rem  * *******************************************************************
rem  *                   This program is provided by:                    *
rem  *                    SimoTime Enterprises, LLC                      *
rem  *           (C) Copyright 1987-2010 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Create a Sequential Data Set on disk using IEBGENER.
rem  * Author - SimoTime Enterprises
rem  * Date   = January 24, 1996
rem  *
rem  * The first job step (DeleteQSAM) will delete any previously created
rem  * file. The second job step (CreateQSAM) will create a new file.
rem  *
rem  * This set of programs will run on a Personal Computer with Windows
rem  * and Micro Focus Net Express.
rem  *
     set syslog=d:\simoNXE4\AN01\datawrk1\SYSLOGT1.TXT
rem  *
     SimoEXEC NOTE  *******************************************************CblRazE2
     SimoEXEC NOTE  Starting JobName CblRazE2
     SimoEXEC NOTE  Identify JobStep DeleteQSAM
     set RA12GET1=d:\SimoNXE4\AN01\DataAsc1\RA12GET1.TXT
     if exist %RA12GET1% del %RA12GET1%
rem  *
rem  * *******************************************************************
rem  * Step   2 of 2  Create and populate a new QSAM file...
rem  *
:CreateQSAM
     SimoEXEC NOTE  Identify JobStep CreateQSAM
rem  * ..1....:....2....:....3....:....4....:....5....:....6....:....7.
echo RIGHTADJ 1             >%RA12GET1%
echo RIGHTADJ 12           >>%RA12GET1%
echo RIGHTADJ 123          >>%RA12GET1%
echo RIGHTADJ 1234         >>%RA12GET1%
echo RIGHTADJ 1234A        >>%RA12GET1%
echo RIGHTADJ 12345        >>%RA12GET1%
echo RIGHTADJ 123456       >>%RA12GET1%
echo RIGHTADJ 1234567      >>%RA12GET1%
echo RIGHTADJ 12345678     >>%RA12GET1%
echo RIGHTADJ 123456789    >>%RA12GET1%
echo RIGHTADJ 1234567890   >>%RA12GET1%
echo RIGHTADJ 12345678901  >>%RA12GET1%
echo RIGHTADJ 123456789012 >>%RA12GET1%
echo RIGHTADJ 3            >>%RA12GET1%
     if exist %RA12GET1% SimoEXEC NOTE Produced DataSet %RA12GET1%
     SimoEXEC NOTE  Finished JobName CblRazE2
     if not "%1" == "nopause" pause

Sample JCL
(Next) (Previous) (Table-of-Contents)

This sample suite of programs has two JCL members. The first JCL member will execute the demonstration program. The second JCL member will create a RIGHTADJ info file.

Sample JCL, Run the Demonstration Program
(Next) (Previous) (Table-of-Contents)

The following is the JCL required to run the demonstration program on the mainframe or with Micro Focus Mainframe Express.

//CBLRAZJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2010 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Read a file of RIGHTADJ Info, right adjust, write output.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* The job will read an 80-byte file that contains RIGHT-ADJUST
//* information. The job will also write a file containing the results
//* of the date edit functions..
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//*                     ************
//*                     * CBLRAZJ1 *
//*                     ********jcl*
//*                          *
//*                     ************
//*                     * IEFBR14  *
//*                     ********utl*
//*                          *
//*    ************     ************     ************
//*    * RA12GET1 *-----* CBLRAZC1 *-----* RA12PUT1 *
//*    ********dat*     ********cbl*     ********dat*
//*                          *   *
//*                          *   *       ************
//*                          *   *-call--* SIMORA12 *
//*                          *           ********cbl*
//*                          *
//*                     ************
//*                     *   EOJ    *
//*                     ************
//*
//* *******************************************************************
//* Step   1   Delete any previously created file...
//*
//QSAMDELT EXEC PGM=IEFBR14
//RA12PUT1 DD  DSN=SIMOTIME.DATA.RA12PUT1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   2   Right adjust input, create a new output file...
//*
//EXECDAT1 EXEC PGM=CBLRAZC1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//RA12GET1 DD  DSN=SIMOTIME.DATA.RA12GET1,DISP=SHR
//RA12PUT1 DD  DSN=SIMOTIME.DATA.RA12PUT1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//

Sample JCL, Create a RightAdj Info File
(Next) (Previous) (Table-of-Contents)

The following is the JCL that may be used to create a RIGHTADJ file.

//CBLRAZJ2 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2010 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create a Sequential Data Set on disk using IEBGENER.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* The first job step (QSAMDELT) will delete any previously created
//* file. The second job step (QCRTDIN1) will create a new file.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//* *******************************************************************
//* Step   1   Delete any previously created file...
//*
//QSAMDELT EXEC PGM=IEFBR14
//SYSUT2   DD  DSN=SIMOTIME.DATA.RA12GET1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   2   Create and populate a new QSAM file...
//*
//QCRTDIN1 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
RIGHTADJ 1
RIGHTADJ 12
RIGHTADJ 123
RIGHTADJ 1234
RIGHTADJ 1234A
RIGHTADJ 12345
RIGHTADJ 123456
RIGHTADJ 1234567
RIGHTADJ 12345678
RIGHTADJ 123456789
RIGHTADJ 1234567890
RIGHTADJ 12345678901
RIGHTADJ 123456789012
RIGHTADJ 3
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.RA12GET1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//

The Demonstration Program
(Next) (Previous) (Table-of-Contents)

The following is the source code listing for the demonstration program.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLRAZC1.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2010 SimoTime Enterprises, LLC.            *
      *                                                               *
      * All rights reserved.  Unpublished, all rights reserved under  *
      * copyright law and international treaty.  Use of a copyright   *
      * notice is precautionary only and does not imply publication   *
      * or disclosure.                                                *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any non-commercial purpose and without fee is hereby      *
      * granted, provided the SimoTime copyright notice appear on all *
      * copies of the software. The SimoTime name or Logo may not be  *
      * used in any advertising or publicity pertaining to the use    *
      * of the software without the written permission of SimoTime    *
      * Enterprises.                                                  *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Enterprises. Once the fee is received by SimoTime    *
      * the latest version of the software will be delivered and a    *
      * license will be granted for use within an enterprise,         *
      * provided the SimoTime copyright notice appear on all copies   *
      * of the software. The SimoTime name or Logo may not be used    *
      * in any advertising or publicity pertaining to the use of the  *
      * software without the written permission of SimoTime           *
      * Enterprises.                                                  *
      *                                                               *
      * SimoTime Enterprises makes no warranty or representations     *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any express or implied warranty,     *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Enterprises shall not be liable for any direct, indirect,     *
      * special or consequential damages resulting from the loss of   *
      * use, data or projects, whether in an action of contract or    *
      * tort, arising out of or in connection with the use or         *
      * performance of this software                                  *
      *                                                               *
      * SimoTime Enterprises                                          *
      * 15 Carnoustie Drive                                           *
      * Novato, CA 94949-5849                                         *
      * 415.883.6565                                                  *
      *                                                               *
      * RESTRICTED RIGHTS LEGEND                                      *
      * Use, duplication, or disclosure by the Government is subject  *
      * to restrictions as set forth in subparagraph (c)(1)(ii) of    *
      * the Rights in Technical Data and Computer Software clause at  *
      * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of          *
      * Commercial  Computer Software - Restricted Rights  at 48      *
      * CFR 52.227-19, as applicable.  Contact SimoTime Enterprises,  *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      * Source Member: CBLRAZC1.CBL
      * Copy Files:    PASSRA12.CPY
      * Calls to:      SIMORA12
      *****************************************************************
      *
      *                   ************
      *                   * CBLRAZJ1 *
      *                   ********jcl*
      *                        *
      *                   ************
      *                   * IEFBR14  *
      *                   ********utl*
      *                        *
      *  ************     ************     ************
      *  * RA12GET1 *-----* CBLRAZC1 *-----* RA12PUT1 *
      *  ********dat*     ********cbl*     ********dat*
      *                        *   *
      *                        *   *       ************
      *                        *   *-call--* SIMORA12 *
      *                        *           ********cbl*
      *                        *
      *                   ************
      *                   *   EOJ    *
      *                   ************
      *
      *****************************************************************
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT RA12GET1-FILE  ASSIGN to     RA12GET1
                  ORGANIZATION is SEQUENTIAL
                  ACCESS MODE  is SEQUENTIAL
                  FILE STATUS  is RA12GET1-STATUS.
           SELECT RA12PUT1-FILE  ASSIGN to     RA12PUT1
                  ORGANIZATION is SEQUENTIAL
                  ACCESS MODE  is SEQUENTIAL
                  FILE STATUS  is RA12PUT1-STATUS.

      *****************************************************************
       DATA DIVISION.
       FILE SECTION.
       FD  RA12GET1-FILE
           BLOCK CONTAINS 00800 CHARACTERS
           DATA RECORD    is RA12GET1-RECORD
           .
       01  RA12GET1-RECORD.
           05  RA12GET1-DATA-01.
               10  RA12GET1-KEYWORD  pic X(0008).
               10  RA12GET1-BLANK    pic X.
               10  RA12GET1-INFO     pic X(71).

       FD  RA12PUT1-FILE
           BLOCK CONTAINS 00800 CHARACTERS
           DATA RECORD    is RA12PUT1-RECORD
           .
       01  RA12PUT1-RECORD.
           05  RA12PUT1-DATA-01  pic X(00080).

       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CBLRAZC1 '.
           05  T2 pic X(34) value 'Right-Adjust, Zero-Fill Example   '.
           05  T3 pic X(10) value ' v04.03.03'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLRAZC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2010 '.
           05  C3 pic X(28) value '  SimoTime Enterprises, LLC '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* CBLRAZC1 '.
           05  C2 pic X(32) value 'Thank you for using this sample '.
           05  C3 pic X(32) value 'by SimoTime Enterprises, LLC    '.
           05  C4 pic X(04) value '    '.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* CBLRAZC1 '.
           05  C2 pic X(32) value 'Please send comments or suggesti'.
           05  C3 pic X(32) value 'ons to helpdesk@simotime.com    '.
           05  C4 pic X(04) value '    '.

       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CBLRAZC1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

       01  RA12GET1-STATUS.
           05  RA12GET1-STATUS-L     pic X.
           05  RA12GET1-STATUS-R     pic X.
       01  RA12GET1-EOF              pic X       value 'N'.
       01  RA12GET1-OPEN-FLAG        pic X       value 'C'.

       01  RA12PUT1-STATUS.
           05  RA12PUT1-STATUS-L     pic X.
           05  RA12PUT1-STATUS-R     pic X.
       01  RA12PUT1-EOF              pic X       value 'N'.
       01  RA12PUT1-OPEN-FLAG        pic X       value 'C'.

       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.
       01  TWO-BYTES.
           05  TWO-BYTES-LEFT      pic X.
           05  TWO-BYTES-RIGHT     pic X.
       01  TWO-BYTES-BINARY        redefines TWO-BYTES pic 9(4) comp.

       01  APPL-RESULT             pic S9(9)   comp.
           88  APPL-AOK            value 0.
           88  APPL-EOF            value 16.

       01  RA12GET1-TOTAL.
           05  filler      pic X(23)  value 'RA12GET1 line count is '.
           05  RA12GET1-LOC  pic 9(7) value 0.

      *****************************************************************
      * The following copy file of the pass area for calling SIMODATE,
      * the date editing routine.
      *****************************************************************
      *
       COPY PASSRA12.
      *
      *****************************************************************
       PROCEDURE DIVISION.
           perform Z-POST-COPYRIGHT
           perform RA12GET1-OPEN
           perform RA12PUT1-OPEN

           perform until RA12GET1-STATUS not = '00'
               perform RA12GET1-READ
               if  RA12GET1-STATUS = '00'
                   add 1 to RA12GET1-LOC
                   perform RIGHT-ADJUST-FUNCTION-DOIT
                   perform RIGHT-ADJUST-FUNCTION-DISPLAY
               end-if
           end-perform

           move RA12GET1-TOTAL to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE

           if  APPL-EOF
               move 'is Complete...' to MESSAGE-TEXT
           else
               move 'is ABENDING...' to MESSAGE-TEXT
           end-if
           perform Z-DISPLAY-CONSOLE-MESSAGE

           perform RA12PUT1-CLOSE
           perform RA12GET1-CLOSE
           perform Z-THANK-YOU.
           GOBACK.

      *****************************************************************
      * The following routines are in alphabetical sequence..         *
      *****************************************************************

       RIGHT-ADJUST-FUNCTION-DISPLAY.
           move 'Right Adjusted Value......... ' to MESSAGE-TEXT
           move RA12-BUFFER                      to MESSAGE-TEXT(31:12)
           move MESSAGE-TEXT                     to RA12PUT1-DATA-01
           perform Z-DISPLAY-CONSOLE-MESSAGE
           perform RA12PUT1-WRITE

           if  RA12-RESPOND = ZERO
               move 'RC=nnnn, Value is Numeric' to MESSAGE-TEXT
           else
               move 'RC=nnnn, Value is NON-Numeric or Request Invalid'
                 to MESSAGE-TEXT
           end-if
           move RA12-RESPOND to MESSAGE-TEXT(4:4)
           move MESSAGE-TEXT                     to RA12PUT1-DATA-01
           perform Z-DISPLAY-CONSOLE-MESSAGE
           perform RA12PUT1-WRITE
           exit.
      *
      *****************************************************************
       RIGHT-ADJUST-FUNCTION-DOIT.
           move all '*' to MESSAGE-TEXT-1
           perform Z-DISPLAY-CONSOLE-MESSAGE
           move all '*' to RA12PUT1-DATA-01
           perform RA12PUT1-WRITE

           move RA12GET1-DATA-01 to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE
           move RA12GET1-DATA-01 to RA12PUT1-DATA-01
           perform RA12PUT1-WRITE

           move 'RIGHTADJ'       to RA12-REQUEST
           move RA12GET1-INFO    to RA12-BUFFER
           call 'SIMORA12'    using RA12-PASS-AREA

           exit.

      *****************************************************************
      * I/O ROUTINES FOR RA12GET1...                                  *
      *****************************************************************
       RA12GET1-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close RA12GET1-FILE
           if  RA12GET1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'RA12GET1-Failure-CLOSE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move RA12GET1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       RA12GET1-READ.
           read RA12GET1-FILE
           if  RA12GET1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  RA12GET1-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to RA12GET1-EOF
               else
                   move 'RA12GET1-Failure-GET...' to MESSAGE-TEXT
                   perform Z-DISPLAY-CONSOLE-MESSAGE
                   move RA12GET1-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       RA12GET1-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open input RA12GET1-FILE
           if  RA12GET1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to RA12GET1-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'RA12GET1-Failure-OPEN...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move RA12GET1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * I/O ROUTINES FOR RA12PUT1...                                  *
      *****************************************************************
       RA12PUT1-WRITE.
           if  RA12PUT1-OPEN-FLAG = 'C'
               perform RA12PUT1-OPEN
           end-if
           write RA12PUT1-RECORD
           if  RA12PUT1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  RA12PUT1-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if.
           if  APPL-AOK
               CONTINUE
           else
               move 'RA12PUT1-Failure-WRITE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move RA12PUT1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       RA12PUT1-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open output RA12PUT1-FILE
           if  RA12PUT1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to RA12PUT1-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'RA12PUT1-Failure-OPEN...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move RA12PUT1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       RA12PUT1-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close RA12PUT1-FILE
           if  RA12PUT1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'C' to RA12PUT1-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'RA12PUT1-Failure-CLOSE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move RA12PUT1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative tasks         *
      * for this program.                                             *
      *****************************************************************
      * ABEND the program, post a message to the console and issue    *
      * a STOP RUN.                                                   *
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  MESSAGE-TEXT not = SPACES
               perform Z-DISPLAY-CONSOLE-MESSAGE
           end-if
           move 'PROGRAM-IS-ABENDING...'  to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE
           add 12 to ZERO giving RETURN-CODE
           STOP RUN
           exit.

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-CONSOLE-MESSAGE.
           if MESSAGE-TEXT-2 = SPACES
               display MESSAGE-BUFFER(1:79) upon console
           else
               display MESSAGE-BUFFER upon console
           end-if
           move all SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
      * Display the file status bytes. This routine will display as   *
      * two digits if the full two byte file status is numeric. If    *
      * second byte is non-numeric then it will be treated as a       *
      * binary number.                                                *
      *****************************************************************
       Z-DISPLAY-IO-STATUS.
           if  IO-STATUS not NUMERIC
           or  IO-STAT1    = '9'
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               display '* CBLRAZC1 File-Status-' IO-STAT1 '/'
                       TWO-BYTES-BINARY upon console
           else
               display '* CBLRAZC1 File-Status-' IO-STATUS upon console
           end-if
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE     upon console
           display SIM-COPYRIGHT upon console
           exit.

      *****************************************************************
       Z-THANK-YOU.
           display SIM-THANKS-01 upon console
           display SIM-THANKS-02 upon console
           exit.
      *****************************************************************
      *      This example is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

The Right-Adjust Routine
(Next) (Previous) (Table-of-Contents)

The following is the source code listing for the right-adjust routine.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    SIMORA12.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2010 SimoTime Enterprises, LLC.            *
      *                                                               *
      * All rights reserved.  Unpublished, all rights reserved under  *
      * copyright law and international treaty.  Use of a copyright   *
      * notice is precautionary only and does not imply publication   *
      * or disclosure.                                                *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any non-commercial purpose and without fee is hereby      *
      * granted, provided the SimoTime copyright notice appear on all *
      * copies of the software. The SimoTime name or Logo may not be  *
      * used in any advertising or publicity pertaining to the use    *
      * of the software without the written permission of SimoTime    *
      * Enterprises.                                                  *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Enterprises. Once the fee is received by SimoTime    *
      * the latest version of the software will be delivered and a    *
      * license will be granted for use within an enterprise,         *
      * provided the SimoTime copyright notice appear on all copies   *
      * of the software. The SimoTime name or Logo may not be used    *
      * in any advertising or publicity pertaining to the use of the  *
      * software without the written permission of SimoTime           *
      * Enterprises.                                                  *
      *                                                               *
      * SimoTime Enterprises makes no warranty or representations     *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any express or implied warranty,     *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Enterprises shall not be liable for any direct, indirect,     *
      * special or consequential damages resulting from the loss of   *
      * use, data or projects, whether in an action of contract or    *
      * tort, arising out of or in connection with the use or         *
      * performance of this software                                  *
      *                                                               *
      * SimoTime Enterprises                                          *
      * 15 Carnoustie Drive                                           *
      * Novato, CA 94949-5849                                         *
      * 415.883.6565                                                  *
      *                                                               *
      * RESTRICTED RIGHTS LEGEND                                      *
      * Use, duplication, or disclosure by the Government is subject  *
      * to restrictions as set forth in subparagraph (c)(1)(ii) of    *
      * the Rights in Technical Data and Computer Software clause at  *
      * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of          *
      * Commercial  Computer Software - Restricted Rights  at 48      *
      * CFR 52.227-19, as applicable.  Contact SimoTime Enterprises,  *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *****************************************************************
      *
      *****************************************************************
      * Source Member: SIMORA12.CBL
      * Copy Files:    PASSRA12.CPY
      *****************************************************************
      *
      * SIMORA12 - Erase to End=Of-Field (EOF) after first space and
      * then do a Right-Adjust, Zero-Fill for a 12 byte field.
      *
      * EXECUTION or CALLING PROTOCOL
      * -----------------------------
      * CALL 'SIMORA12' USING RA12-PASS-AREA.
      *
      *****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1997/02/27 Simmons, Created program.
      * 1997/02/27 Simmons, No changes to date.
      *
      *****************************************************************
      *
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Z-X12                   pic 9(3)    value 0.

       LINKAGE SECTION.
       COPY PASSRA12.

      *****************************************************************
       PROCEDURE DIVISION using RA12-PASS-AREA.
           add 16 to ZERO giving RA12-RESPOND
      *    The following INSPECT statement will erase to end-of-field
      *    any characters after the first space character.
           inspect RA12-BUFFER
                   replacing CHARACTERS by ' ' after initial ' '

      *    The following IF logic is for performance. It quickly
      *    reduces the number of loops for the PERFORM logic.
           if  RA12-BUFFER(7:6) = SPACES
               if  RA12-BUFFER(4:3) = SPACES
                   move RA12-BUFFER(1:3) to RA12-BUFFER(10:3)
                   move all ZEROES     to RA12-BUFFER(1:9)
               else
                   move RA12-BUFFER(1:6) to RA12-BUFFER(7:6)
                   move all ZEROES     to RA12-BUFFER(1:6)
               end-if
           else
               if  RA12-BUFFER(10:3) = SPACES
      *            The following three MOVE statements are used to
      *            avoid a potential problem with an overlapping MOVE.
                   move RA12-BUFFER(7:3) to RA12-BUFFER(10:3)
                   move RA12-BUFFER(4:3) to RA12-BUFFER(7:3)
                   move RA12-BUFFER(1:3) to RA12-BUFFER(4:3)
                   move all ZEROES     to RA12-BUFFER(1:3)
               end-if
           end-if

           perform until RA12-BUFFER(12:1) not = SPACE
               if  RA12-BUFFER(12:1) = SPACE
                   add 11 to ZERO giving Z-X12
                   perform 11 times
                     move RA12-BUFFER(Z-X12:1) to RA12-BUFFER
                     (Z-X12 + 1:1)
                     subtract 1 from Z-X12
                   end-perform
                   move ZERO to RA12-BUFFER(1:1)
               end-if
           end-perform

           if  RA12-BUFFER NUMERIC
               move ZERO to RA12-RESPOND
           else
               add 8 to ZERO giving RA12-RESPOND
           end-if

           GOBACK.
      *****************************************************************
      *      This example is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Summary
(Next) (Previous) (Table-of-Contents)

The purpose of this document is to assist as a tutorial for new programmers or as a quick reference for experienced programmers. This suite of programs provides an example of a routine that right-adjusts a text string within a field.

Software Agreement and Disclaimer
(Next) (Previous) (Table-of-Contents)

Permission to use, copy, modify and distribute this software for any non-commercial purpose and without fee is hereby granted, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.

Permission to use, copy, modify and distribute this software for any commercial purpose requires a fee to be paid to SimoTIme Enterprises. Once the fee is received by SimoTime the latest version of the software will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.

SimoTime Enterprises makes no warranty or representations about the suitability of the software for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software.

If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com

Downloads and Links to Similar Pages
(Next) (Previous) (Table-of-Contents)

You may download this example at http://www.simotime.com/sim4dzip.htm#COBOLZipRightAdjust or view the complete list of SimoTime Examples at http://www.simotime.com/sim4dzip.htm .

Note: You must be attached to the Internet to download a Z-Pack or view the list.

Check out   Justify Text (Center, Right or Left) to position a text string within a field.

Check out   The COBOL Connection  in the SimoTime Library for more examples of mainframe COBOL techniques and sample code.

Check out   The JCL Connection  in the SimoTime Library for more mainframe JCL examples.

Check out   The SimoTime Library   for a wide range of topics for Programmers, Project Managers and Software Developers.

To review all the information available on the SimoTIme Web Site start at   http://www.SimoTime.com  .

For more information about Micro Focus Mainframe Express refer to   http://www.microfocus.com  .

Comments or Suggestions
(Next) (Previous) (Table-of-Contents)

If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com

About SimoTime Enterprises
(Next) (Previous) (Table-of-Contents)

Founded in 1987, SimoTime Enterprises is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com


Return-to-Top
Copyright © 1987-2010  SimoTime Enterprises  All Rights Reserved
When technology complements business
http://www.simotime.com