Right Adjust, Zero Fill
Right Adjust a Text String within a Field
  Table of Contents  v-24.01.01 - cblraz01.htm 
  Introduction
  Programming Objectives
  Programming Input and Output
  Programming Requirements
  Programming Overview
  The Call Interface
  Batch Job Scripts
  Windows CMD Files
  Execute the Test Case
  Create the Test Data File
  Mainframe JCL Members
  Execute the Test Case
  Create the Test Data File
  Bash Script Files
  Execute the Test Case
  Create the Test Data File
  COBOL Program Members
  The Mainline Program
  The Right-Adjust Routine
  COBOL Copy Files
  Pass Area for Calling SIMORA12
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Contact or Feedback
  Company Overview
The SimoTime Home Page 

Table of Contents Previous Section Next Section Introduction

This suite of programs provides an example of a routine that will Right Adjust (or Right Justify) a numeric value within a text 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.


We have made a significant effort to ensure the documents and software technologies are correct and accurate. We reserve the right to make changes without notice at any time. The function delivered in this version is based upon the enhancement requests from a specific group of users. The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources.

Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved

Table of Contents Previous Section Next Section Programming Objectives

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 numeric values.
  Program Objectives for the Right-Adjust Programs

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.

Table of Contents Previous Section Next Section Programming Input and Output

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    v07.08.26 http://www.simotime.com
Copyright 1987-2011    SimoTime Enterprises      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 software provided from SimoTime Enterprises
Please send all inquires or suggestions to the helpdesk@simotime.com

Table of Contents Previous Section Next Section Programming Requirements

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

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

Table of Contents Previous Section Next Section Programming Overview

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).

             
Entry Point
ZOS
Entry Point
Linux
Entry Point
Windows
   
   
   
CBLRAZJ1
jcl
cblrazs1
sh
CBLRAZE1
cmd
Start the right-adjust processing example
   
   
   
IEFBR14
Utility
rm
Linux CMD
IF Exist
statement
Delete previously created right-adjust output file
   
   
 
 
   
   
 
 
   
   
RA12GET1
rseq
 
 
CBLRAZC1
cbl
   
   
RA12PUT1
rseq
Read the input file, call the right-adjust routine, write the results to the output file
   
   
   
   
   
   
SIMORA12
cbl
Right-adjust the text string within the field
   
EOJ
End-Of-Job
 
Overview of Right-Adjust for Numeric Fields

Color Associations: The  light-green  boxes are unique to SIMOTIME Technologies using an IBM Mainframe System or Micro Focus Enterprise Developer. The  light-red  boxes are unique to the SIMOTIME Technologies using a Linux, UNIX or Windows System and COBOL Technologies such as Micro Focus. The  light-yellow  boxes are SIMOTIME Technologies, Third-party Technologies, decision points or program transitions in the processing logic or program generations. The  light-blue  boxes identify the input/output data structures such as Documents, Spreadsheets, Data Files, VSAM Data Sets, Partitioned Data Set Members (PDSM's) or Relational Tables. The  light-gray  boxes identify a system function or an informational item.

Table of Contents Previous Section Next Section The Call Interface

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-2019 SimoTime Technologies         *
      *                     All Rights Reserved                       *
      *****************************************************************
      *              Provided by SimoTime Technologies                *
      *        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 - - - - - - - - - - - PASSRA12 *
      *****************************************************************
      *

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-REPOND 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.
  An Overview of the Structure of the Pass Area for calling SIMORA12

Table of Contents Previous Section Next Section Batch Job Scripts

This section describes the batch job scripts that are used to create test data files and execute the test cases. A Job Script will identify and allocate resources (data files, memory, work areas, control information, etc.) for the Job or Job Step and execute programs that will process, access or utilize the allocated resources.

Table of Contents Previous Section Next Section Windows CMD Files

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.

Table of Contents Previous Section Next Section Execute the Test Case

The following (CBLRAZE1.cmd) is the CMD that is required to run the demonstration program on a Windows System with Micro Focus Net Express.

@echo OFF
rem  * *******************************************************************
rem  *               CBLRAZE1.cmd - a Windows Command File               *
rem  *       This Job Script is provided by SimoTime Technologies        *
rem  *           (C) Copyright 1987-2020 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Read file of Numeric strings, right-adjust, write output.
rem  * Author - SimoTime Technologies
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  *    *   run    *****************************
rem  *    ************                           *
rem  *         *                                 *
rem  *         *           ************     ************     ************
rem  *         *           * RA12GET1 ******* CblRazC1 ******* RA12PUT1 *
rem  *         *           ********txt*     ********cbl*     ********csv*
rem  *         *                                 *
rem  *         *                            ************
rem  *         *                            * SIMORA12 *
rem  *         *                            ********cbl*
rem  *         *
rem  *    ************
rem  *    *   EOJ    *
rem  *    ************
rem  *
rem  * *******************************************************************
rem  * Step   1   Delete any previously created file...
rem  *
rem  *
     call ..\Env1BASE
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
     set CmdName=CblRazE1
rem  *
     call SimoNOTE "*******************************************************%CmdName%"
     call SimoNOTE "Starting CmdName %CmdName%"
:DeleteQSAM
     call SimoNOTE "Identify JobStep DeleteQSAM"
     set RA12GET1=%BaseLib1%\DATA\Asc1\RA12GET1.DAT
     set RA12PUT1=%BaseLib1%\DATA\Wrk1\RA12PUT1.DAT
     if exist %RA12PUT1% del %RA12PUT1%
rem  *
rem  * *******************************************************************
rem  * Step   2   Edit input, create a new output file...
rem  *
:ExecuteRightAdjustRoutine
     call SimoNOTE "Identify JobStep ExecuteRightAdjustRoutine"
     run CBLRAZC1
     if not ERRORLEVEL = 0 set JobStatus=0001
     if not %JobStatus% == 0000 goto :EojNok
rem  *
     if exist %RA12PUT1% goto :EojAok
     set JobStatus=0002
     goto :EojNok
:EojAok
     call SimoNOTE "Produced DataSet %RA12PUT1%"
     call SimoNOTE "Finished CmdName %CmdName%, Job Status is %JobStatus%"
     goto :End
:EojNok
     call SimoNOTE "ABENDING CmdName %CmdName%, Job Status is %JobStatus%"
:End
     call SimoNOTE "Conclude SysLog is %SYSLOG%"
     if not "%SIMOMODE%" == "BATCH" pause

Table of Contents Previous Section Next Section Create the Test Data File

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

@echo OFF
rem  * *******************************************************************
rem  *               CBLRAZE2.cmd - a Windows Command File               *
rem  *       This Job Script is provided by SimoTime Technologies        *
rem  *           (C) Copyright 1987-2019 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 Echo command.
rem  * Author - SimoTime Technologies
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  *
     call ..\ENV1BASE
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
     set JobName=CblRazE2
rem  *
     call SimoNOTE "*******************************************************%JobName%"
     call SimoNOTE "Starting JobName %JobName%"
     call SimoNOTE "Identify JobStep DeleteQSAM"
     set RA12TXT1=%BaseLib1%\DATA\Txt1\RA12TXT1.TXT
     if exist %RA12TXT1% del %RA12TXT1%
rem  *
rem  * *******************************************************************
rem  * Step   2 of 2  Create and populate a new QSAM file...
rem  *
:CreateLSEQ
     call SimoNOTE "Identify JobStep CreateLSEQ"
rem  * ..1....:....2....:....3....:....4....:....5....:....6....:....7.
echo RIGHTADJ 1             >%RA12TXT1%
echo RIGHTADJ 12           >>%RA12TXT1%
echo RIGHTADJ 123          >>%RA12TXT1%
echo RIGHTADJ 1234         >>%RA12TXT1%
echo RIGHTADJ 1234A        >>%RA12TXT1%
echo RIGHTADJ 12345        >>%RA12TXT1%
echo RIGHTADJ 123456       >>%RA12TXT1%
echo RIGHTADJ 123 56       >>%RA12TXT1%
echo RIGHTADJ 1234567      >>%RA12TXT1%
echo RIGHTADJ 12345678     >>%RA12TXT1%
echo RIGHTADJ 123456789    >>%RA12TXT1%
echo RIGHTADJ 1234567890   >>%RA12TXT1%
echo RIGHTADJ 12345678901  >>%RA12TXT1%
echo RIGHTADJ 123456789012 >>%RA12TXT1%
echo RIGHTADJ 3            >>%RA12TXT1%
     if exist %RA12TXT1% call SimoNOTE "Produced DataSet %RA12TXT1%"
     if not exist %RA12TXT1% set JobStatus=9001
     if not %JobStatus% == 0000 goto :EojNok
:CreateRSEQAsc
     set GETLS080=%BaseLib1%\DATA\TXT1\RA12TXT1.TXT
     set PUTRS080=%BaseLib1%\DATA\Asc1\RA12GET1.DAT
     if exist %PUTRS080% del %PUTRS080%
     run CV80ALAR
     if exist %PUTRS080% call SimoNOTE "Produced DataSet %PUTRS080%"
     if not exist %PUTRS080% set JobStatus=9002
     if not %JobStatus% == 0000 goto :EojNok
:CreateRSEQEbc
     set GETLS080=%BaseLib1%\DATA\TXT1\RA12TXT1.TXT
     set PUTRS080=%BaseLib1%\DATA\Ebc1\RA12GET1.DAT
     if exist %PUTRS080% del %PUTRS080%
     run CV80ALER
     if exist %PUTRS080% call SimoNOTE "Produced DataSet %PUTRS080%"
     if not exist %PUTRS080% set JobStatus=9003
     if not %JobStatus% == 0000 goto :EojNok
rem  *
:EojAok
     call SimoNOTE "Finished JobName %JobName%, Job Status is %JobStatus%"
     goto :End
:EojNok
     call SimoNOTE "NOTE ABENDING JobName %JobName%, Job Status is %JobStatus%"
:End
     call SimoNOTE "Conclude SYSOUT is %SYSOUT%"
     if not "%SIMOMODE%" == "BATCH" pause

Table of Contents Previous Section Next Section Mainframe JCL Members

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.

Table of Contents Previous Section Next Section Execute the Test Case

The following (CBLRAZJ1.jcl) is the JCL member that is required to run the demonstration program on a Mainframe System with ZOS or a Linux, UNIX or Windows System with Micro Focus Enterprise Server.

//CBLRAZJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       CBLRAZJ1.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 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 Technologies
//* 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 right adjust 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 of 2, Delete any previously created file...
//*
//JOBSETUP 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 of 2, Right adjust input, create a new output file...
//*
//RIGHTADJ 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=*
//

Table of Contents Previous Section Next Section Create the Test Data File

The following (CBLRAZJ2.jcl) is the JCL member that may be used to create a RIGHTADJ file to be used for testing.

//CBLRAZJ2 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       CBLRAZJ2.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 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 Technologies
//* 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 of 2, Delete any previously created file...
//*
//JOBSETUP 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 of 2, Create and populate a new QSAM file...
//*
//BUILDNEW 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 123 56789
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)
//

Table of Contents Previous Section Next Section Bash Script Files

This set of job scripts for a Linux or UNIX System has two Bash Scripts. The first Bash Script will execute the demonstration program. The second Bash Script will create the test files used by the first Bash Script as input.

Table of Contents Previous Section Next Section Execute the Test Case

The following (cblrazs1.sh) is the Bash Script File that is required to run this test case on a Linux System with GnuCOBOL.

#!/bin/bash
   JOBNAME=cblrazs1
#  * *******************************************************************
#  *       Bash Script File - provided by SimoTime Technologies        *
#  *           (C) Copyright 1987-2018 All Rights Reserved             *
#  *             Web Site URL:   http://www.simotime.com               *
#  *                   e-mail:   helpdesk@simotime.com                 *
#  * *******************************************************************
#  *
#  * Text    - Right-Justify, Zero-Fill Numeric String within a Field
#  * Author  - SimoTime Technologies
#  * Date    - November 11, 2003
#  * Version - 06.07.16
#  *
#  * Prepare the environment by mapping the file names.
#  * Execute the 80/80 copy file program.
#  *
#  * ********************************************************************
#  * Step 1 of 3, Prepare the System Environment.
#  *
   JOBSTATUS=0
   for textstring in $(cat ENV4SYS1.txt);
   do
#      # * The following statement will replace all occurences
#      # * of DL_BASESYS1 with the value of the BASESYS1
#      # * environment variable.
       textstring=${textstring//DL_BASESYS1/$BASESYS1}
#      # * The following statement will replace all occurences
#      # * of BASHUSER_JOBNAME with the value of the JOBNAME
#      # * environment variable.
       textstring=${textstring/DL_JOBNAME/$JOBNAME}
       export $textstring
       rc=$?
       if [ $rc != 0 ]
       then
          simonote.sh "#  $textstring - Return Code is $rc"
          JOBSTATUS=$rc
       fi
   done
#  *
   simonote.sh "************************************************************$JOBNAME"
   simonote.sh "# Starting Job Name $JOBNAME"
   simonote.sh "# SIMOSYS1........... $BASESYS1"
   simonote.sh "# SIMONOTE........... $SIMONOTE"
   simonote.sh "# COB_LIBS........... $COB_LIBS"
   simonote.sh "# COB_LIBRARY_PATH... $COB_LIBRARY_PATH"
#  *
#  * Prepare the environment, map the file names...
   export RA12GET1=$BASESYS1/SIMOSAM1/DEVL/DATA/APPL/SIMOTIME.DATA.RA12RS80.dat
   export RA12PUT1=$BASESYS1/SIMOSAM1/DEVL/DATA/APPL/SIMOTIME.DATA.RA12PUT1.dat
   simonote.sh "# DATATAKE is $RA12GET1"
   simonote.sh "# DATAMAKE is $RA12PUT1"
#  *
#  * ********************************************************************
#  * Step 2 of 3, Run the program.
#  *
   if [ -f "$RA12PUT1" ]
   then
      rm $RA12PUT1
   fi
   cobcrun CBLRAZC1 | tee $BASESYS1/SIMOSAM1/DEVL/LOGS/SYSOUT_USERPROG_CBLRAZC1.txt
   rc=$?
   if [ $rc != 0 ]
   then
      simonote.sh "# ABENDING $name - Return Code is $rc"
      JOBSTATUS=$rc
   else
      ((AOK_Count++))
   fi
#  *
#  * ********************************************************************
#  * Step 3 of 3, End of Job Processing.
#  *
     if [ "$JOBSTATUS" = "0" ]
     then
        simonote.sh "# Finished Job Name $JOBNAME"
     else
        simonote.sh "# ABENDING Job Name $JOBNAME"
     fi


Table of Contents Previous Section Next Section Create the Test Data File

The following (cblrazs2.sh) is the Bash Script File that may be used to create a RIGHTADJ file to be used for testing.

#!/bin/bash
   JOBNAME=cblrazs2
#  *********************************************************************
#  *       Bash Script File - provided by SimoTime Technologies        *
#  *           (C) Copyright 1987-2018 All Rights Reserved             *
#  *             Web Site URL:   http://www.simotime.com               *
#  *                   e-mail:   helpdesk@simotime.com                 *
#  *********************************************************************
#  *
#  * Text   - Create Test Files.
#  * Author - SimoTime Technologies
#  * Date   = January 24, 1996
#  *
#  * The 1ST step will delete a previously created file and then
#  * create a new ASCII/Text file.
#  * The 2ND step will convert the Line Sequential file to a Record
#  * Sequential file and keep the ASCII encoding.
#  * The 3RD step will convert the Line Sequential file to a Record
#  * Sequential file and convert the record content from ASCII to EBCDIC
#  *
#  * This set of programs will run on a Linux System with GnuCOBOL.
#  *
#  * ********************************************************************
#  * Step 1 of 3, Prepare the System Environment.
#  *
   JOBSTATUS=0
   for textstring in $(cat ENV4SYS1.txt);
   do
#      # * The following statement will replace all occurences
#      # * of DL_BASESYS1 with the value of the BASESYS1
#      # * environment variable.
       textstring=${textstring//DL_BASESYS1/$BASESYS1}
#      # * The following statement will replace all occurences
#      # * of BASHUSER_JOBNAME with the value of the JOBNAME
#      # * environment variable.
       textstring=${textstring/DL_JOBNAME/$JOBNAME}
       export $textstring
       rc=$?
       if [ $rc != 0 ]
       then
          simonote.sh "#  $textstring - Return Code is $rc"
          JOBSTATUS=$rc
       fi
   done
#  *
   simonote.sh "************************************************************$JOBNAME"
   echo "# SIMOSYS1........... $BASESYS1"
   echo "# SIMONOTE........... $SIMONOTE"
   echo "# COB_LIBS........... $COB_LIBS"
   echo "# COB_LIBRARY_PATH... $COB_LIBRARY_PATH"
   simonote.sh "StepInfo Delete previously created files"
   export RA12TXT1=$BASESYS1/SIMOSAM1/DEVL/DATA/TXT1/RA12TXT1.txt
#  *
#  * *******************************************************************
#  * Step   1 of 3  Create and populate a new ASCII/TEXT file...
#  *
   simonote.sh "StepInfo Create an ASCII/Text File"
   if [ -f "$RA12TXT1" ]
   then
      rm $RA12TXT1
   fi
#  *  ....:....1....:....2....:....3....:....4....:....5....:....6....:....7.
echo "RIGHTADJ 1            ">$RA12TXT1
echo "RIGHTADJ 12           ">>$RA12TXT1
echo "RIGHTADJ 123          ">>$RA12TXT1
echo "RIGHTADJ 1234         ">>$RA12TXT1
echo "RIGHTADJ 1234A        ">>$RA12TXT1
echo "RIGHTADJ 12345        ">>$RA12TXT1
echo "RIGHTADJ 123456       ">>$RA12TXT1
echo "RIGHTADJ 123 56       ">>$RA12TXT1
echo "RIGHTADJ 1234567      ">>$RA12TXT1
echo "RIGHTADJ 12345678     ">>$RA12TXT1
echo "RIGHTADJ 123456789    ">>$RA12TXT1
echo "RIGHTADJ 1234567890   ">>$RA12TXT1
echo "RIGHTADJ 12345678901  ">>$RA12TXT1
echo "RIGHTADJ 123456789012 ">>$RA12TXT1
echo "RIGHTADJ 3            ">>$RA12TXT1
#  *
   if [ -f "$RA12TXT1" ]
   then
     simonote.sh "RA12TXT1 is $RA12TXT1"
   else
     simonote.sh "ABENDING File not created, $RA12TXT1"
     exit 9001
   fi
#  *
#  * *******************************************************************
#  * Step 2 of 3, Convert ASCII/TEXT file to ASCII RSEQ File...
#  *
   simonote.sh "StepInfo Convert Line Sequential to ASC Record Sequential"
   export GETLS080=$RA12TXT1
   export PUTRS080=$BASESYS1/SIMOSAM1/DEVL/DATA/APPL/SIMOTIME.DATA.RA12RS80.dat
   if [ -f "$PUTRS080" ]
   then
      rm $PUTRS080
   fi
   cobcrun CV80ALAR
   rc=$?
   if [ $rc != 0 ]
   then
      simonote.sh "+ $name - Return Code is $rc"
      JOBSTATUS=$rc
      simonote.sh "ABENDING Job Name is  $JOBNAME, Job Status is $JOBSTATUS"
      exit $JOBSTATUS
   else
      simonote.sh "DataTake $GETLS080"
      simonote.sh "DataMake $PUTRS080"
   fi
#  *
#  * *******************************************************************
#  * Step   3 of 3  Convert ASCII/TEXT file to EBCDIC RSEQ File...
#  *
   simonote.sh "StepInfo Convert Line Sequential to EBC Record Sequential"
   export GETLS080=$RA12TXT1
   export PUTRS080=$BASESYS1/SIMOSAM1/DEVL/DATA/EBC1/SIMOTIME.DATA.RA12RS80.dat
   if [ -f "$PUTRS080" ]
   then
      rm $PUTRS080
   fi
   cobcrun CV80ALER
   rc=$?
   if [ $rc != 0 ]
   then
      simonote.sh "+ $name - Return Code is $rc"
      JOBSTATUS=$rc
      simonote.sh "ABENDING Job Name is  $JOBNAME, Job Status is $JOBSTATUS"
      exit $JOBSTATUS
   else
      simonote.sh "DataTake $GETLS080"
      simonote.sh "DataMake $PUTRS080"
   fi
#  *
     if [ "$JOBSTATUS" = "0" ]
     then
        simonote.sh "Finished Job Name $JOBNAME"
     else
        simonote.sh "ABENDING Job Name $JOBNAME"
     fi


Table of Contents Previous Section Next Section COBOL Program Members

This section describes the COBOL Members that are are included in this test case.

Table of Contents Previous Section Next Section The Mainline Program

The following (CBLRAZC1.cbl) is the COBOL source code for the demonstration program.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLRAZC1.
      *AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2019 SimoTime Technologies.                *
      *                                                               *
      * 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 commercial purpose requires a fee to be paid to       *
      * SimoTime Technologies. 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           *
      * Technologies.                                                 *
      *                                                               *
      * Permission to use, copy and modify 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           *
      * Technologies.                                                 *
      *                                                               *
      * SimoTime Technologies makes no warranty or representations    *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any expressed or implied warranty,   *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Technologies 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 Technologies                                         *
      * 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 Technologies, *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Technologies        *
      *        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
           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
           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 ' v07.08.26'.
           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-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           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 program'.
           05  C3 pic X(32) value ' provided from SimoTime Technolo'.
           05  C4 pic X(04) value 'gies'.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* CBLRAZC1 '.
           05  C2 pic X(32) value 'Please send all inquires or sugg'.
           05  C3 pic X(32) value 'estions to the helpdesk@simotime'.
           05  C4 pic X(04) value '.com'.

       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 SimoRA12,
      * 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  RA12GET1-EOF = 'Y'
               move 'is Finished...' 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 Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section The Right-Adjust Routine

The following (SIMORA12.cbl) is the COBOL source code for the demonstration program.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    SIMORA12.
       AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2019 SimoTime Technologies.                *
      *                                                               *
      * 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 commercial purpose requires a fee to be paid to       *
      * SimoTime Technologies. 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           *
      * Technologies.                                                 *
      *                                                               *
      * Permission to use, copy and modify 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           *
      * Technologies.                                                 *
      *                                                               *
      * SimoTime Technologies makes no warranty or representations    *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any expressed or implied warranty,   *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Technologies 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 Technologies                                         *
      * 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 Technologies, *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Technologies        *
      *        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 Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section COBOL Copy Files

This section describes the COBOL Copy Files that are used in this suite of COBOL programs.

Table of Contents Previous Section Next Section Pass Area for Calling SIMORA12

The following (PASSRA12.cbl) is the COBOL source code for the demonstration program.

      *****************************************************************
      *     Data Structure or Pass Area used for calling SIMORA12.    *
      *****************************************************************
      *         Copyright (C) 1987-2019 SimoTime Technologies         *
      *                     All Rights Reserved                       *
      *****************************************************************
      *              Provided by SimoTime Technologies                *
      *        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 - - - - - - - - - - - PASSRA12 *
      *****************************************************************
      *

Table of Contents Previous Section Next Section Summary

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. This document may be used to assist as a tutorial for new programmers or as a quick reference for experienced programmers.

In the world of programming there are many ways to solve a problem. This documentation and software were developed and tested on systems that are configured for a SIMOTIME environment based on the hardware, operating systems, user requirements and security requirements. Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration.

SIMOTIME Services has experience in moving or sharing data or application processing across a variety of systems. For additional information about SIMOTIME Services or Technologies please contact us using the information in the  Contact or Feedback  section of this document.

Table of Contents Previous Section Next Section Software Agreement and Disclaimer

Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Technologies. Once the fee is received by SimoTime the latest version of the software, documentation or training material 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 Technologies.

SimoTime Technologies makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose. It is provided "AS IS" without any expressed or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Technologies 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, documentation or training material.

Table of Contents Previous Section Next Section Downloads and Links

This section includes links to documents with additional information that are beyond the scope and purpose of this document. The first group of documents may be available from a local system or via an internet connection, the second group of documents will require an internet connection.

Note: A SimoTime License is required for the items to be made available on a local system or server.

Table of Contents Previous Section Next Section Current Server or Internet Access

The following links may be to the current server or to the Internet.

Note: The latest versions of the SimoTime Documents and Program Suites are available on the Internet and may be accessed using the Link to Internet icon. If a user has a SimoTime Enterprise License the Documents and Program Suites may be available on a local server and accessed using the Link to Server icon.

Link to Internet   Link to Server   Explore How to Center, Left or Right Justify a text string within a field using a COBOL program. This suite of programs includes Job Scripts to create test data and execute the COBOL programs. The Job Scripts include JCL Members for an IBM Mainframe System, CMD Files for a Windows System and Bash Script Files for a Linux or UNIX System.

Link to Internet   Link to Server   Explore the JCL Connection for more examples of JCL functionality with programming techniques and sample code.

Link to Internet   Link to Server   Explore the COBOL Connection for more examples of COBOL programming techniques and sample code.

Link to Internet   Link to Server   Explore An Enterprise System Model that describes and demonstrates how Applications that were running on a Mainframe System and non-relational data that was located on the Mainframe System were copied and deployed in a Microsoft Windows environment with Micro Focus Enterprise Server.

Link to Internet   Link to Server   Explore The ASCII and EBCDIC Translation Tables. These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats.

Link to Internet   Link to Server   Explore The File Status Return Codes that are used to interpret the results of accessing VSAM data sets and/or QSAM files.

Table of Contents Previous Section Next Section Internet Access Required

The following links will require an internet connect.

This suite of programs and documentation is available to download for review and evaluation purposes. Other uses will require a SimoTime Software License. Link to an Evaluation zPAK Option that includes the program members, documentation and control files.

A good place to start is The SimoTime Home Page for access to white papers, program examples and product information. This link requires an Internet Connection

Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection.

Explore the GnuCOBOL Technologies available from SourceForge. SourceForge is an Open Source community resource dedicated to helping open source projects be as successful as possible. GnuCOBOL (formerly OpenCOBOL) is a COBOL compiler with run time support. The compiler (cobc) translates COBOL source to executable using intermediate C, designated C compiler and linker. This link will require an Internet Connection.

Table of Contents Previous Section Next Section Glossary of Terms

Link to Internet   Link to Server   Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.

Table of Contents Previous Section Next Section Contact or Feedback

This document was created and is maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please use the following contact information.

1. Send an e-mail to our helpdesk.
1.1. helpdesk@simotime.com.
2. Our telephone numbers are as follows.
2.1. 1 415 763-9430 office-helpdesk
2.2. 1 415 827-7045 mobile

 

We appreciate hearing from you.

Table of Contents Previous Section Next Section Company Overview

SimoTime Technologies was founded in 1987 and 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. Our customers include small businesses using Internet technologies to corporations using very large mainframe systems.

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. We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms.

Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform. The data will need to be transferred between the systems and may need to be converted and validated at various stages within the process. SimoTime has the technology, services and experience to assist in the application and data management tasks involved with doing business in a multi-system environment.

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
Right Adjust, Zero Fill with Erase to End-of-Field Feature
Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com