Data Extract Customer Master File |
![]() |
The SimoTime Home Page |
This suite of sample programs describes how to extract data from the Customer Master File. The numeric fields will be expanded (Packed or Binary) and the trailing spaces within the text fields will be truncated. A new record will be constructed with the fields being concatenated and separated by a comma. The newly constructed record will be written to a sequential file. The file may now be transferred from the mainframe to a Windows system using the File Transfer Protocol (FTP) and easily imported into a Microsoft Excel spreadsheet, an Access Data Base or other SQL Data Bases.
The extract of data by fields within the record and the reformatting of the output records is actually accomplished with two COBOL programs. The first program does the File I/O of reading the Customer Master File and writing reformatted records to a sequential file. The File I/O program calls the second program to do the record formatting that expands the numeric fields and does blank truncation on the text fields and then places a comma between the fields as the field delimiter. The COBOL programs were generated using SimoTime technology.
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-2016
SimoTime Technologies
All Rights Reserved
When running this job on a Mainframe System the output file will be an EBCDIC-encoded, record-sequential file. The records will be concatenated fields of text strings separated (or delimited) by a comma. This file may be downloaded from the mainframe to a Windows system using FTP in ASCII mode. Since the output file is all text it will be properly converted from EBCDIC to ASCII during the file transfer (FTP) process. It will also be converted from a Record-Sequential file to a Line-Sequential file (Micro Focus terminology for ASCII/Text File). The file is now ready to import into an Excel spreadsheet, an Access Data Base or other SQL Data Bases.
When running the job on a Windows System with Micro Focus and using EBCDIC encoding the output file will be an EBCDIC-encoded, record-sequential file. The records will be concatenated fields of text strings separated (or delimited) by a comma. Since we no longer use the FTP process to transfer the file we no longer have the benefit of the FTP process doing the file-format and record-content conversion. Therefore, we need an alternative method for doing the file format conversion from record-sequential to line-sequential and the record content conversion from EBCDIC to ASCII. Refer to the File-Format and Record-Content Conversion Program for more information.
When running the job on a Windows System with Micro Focus and using ASCII encoding the output file will be an ASCII-encoded, record-sequential file. The records will be concatenated fields of text strings separated (or delimited) by a comma. Since we no longer use the FTP process to transfer the file and we no longer have the benefit of the FTP process doing the file-format conversion (since we are running in an ASCII-encoded configuration the file-content conversion is not a requirement). Therefore, we need an alternative method for doing the file format conversion from record-sequential to line-sequential. Refer to the File-Format Conversion Program for more information.
This document provides a brief oveview of the Micro Focus File Formats available on Linux, UNIX or Windows Systems supported by Micro Focus.
The term Mainframe-Oriented refers to an actual IBM Mainframe, Micro Focus Mainframe Express or Micro Focus Enterprise Server with the Mainframe Transaction Option and the Batch Facility. The following (CUEXTJ01.jcl) is a listing of the JCL member needed to run this job in a Mainframe-Oriented environment.
//CUSEXTJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CUSEXTJ1.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2016 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Read Customer Master File, write to a sequential file //* Author - SimoTime Technologies //* Date - January 01, 1989 //* //* This set of programs will run on a mainframe under MVS or on //* a Personal Computer running Windows and Mainframe Express by //* Micro Focus. //* //* ************ ************ //* * Entry * * Entry * //* * MVS * * Windows * //* ************ ************ //* * * //* ************ ************ //* * CUSEXTJ1 * * CUSEXTE1 * //* ********jcl* ********cmd* //* * * //* ************ * //* * IEFBR14 * * //* ********utl* * //* * * //* ********************************* //* * //* * //* ************ ************ ************ //* * CUSTMAST *----* CUSEXTC1 *----* CUSEXTSV * //* ************ ********cbl* ********dat* //* * * //* * * //* * *---CALL----* //* * * //* * * //* * ************ //* * * CUSEXTR1 * //* * ********cbl* //* * //* ************ //* * EOJ * //* ************ //* //* ******************************************************************* //* Step 1 of 2, This job step will delete a previously created file. //* //DELTSEQ1 EXEC PGM=IEFBR14 //CUSTRCSV DD DSN=SIMOTIME.DATA.CUSTPHON,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=256,DSORG=PS) //* ******************************************************************* //* Step 2 of 2, Execute the Sample program. //* Read the customer file (KSDS) and write a record of //* selected fields to a sequential file. Truncate spaces //* from each field and separate the fields by a comma. //* //CBLEXTS1 EXEC PGM=CUSEXTC1 //STEPLIB DD DSN=MFI01.SIMOPROD.LOADLIB1,DISP=SHR //CUSTMAST DD DSN=SIMOTIME.DATA.CUSTMAST,DISP=SHR //CUSTRCSV DD DSN=SIMOTIME.DATA.CUSTPHON,DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=256,DSORG=PS) //SYSOUT DD SYSOUT=* //*
The Data Extract programs may be executed from a Windows Command line or from Windows Explorer. The programs in this suite of examples will read a Customer Master File that is a VSAM, Key-Sequenced-Data-Set (KSDS) and write to a sequential file that may be a record sequential file with fixed length records and fixed length fields within the records. An example that formats the records in a Comma-Separated-Values (CSV) format is included.
The following (CUSEXTZ1.cmd) is a listing of the CMD member needed to run this job. This job will do a file format conversion from a VSAM, KSDS to a Record Sequential file. The programs will do a record content conversion from fixed-field length with packed data to a CSV format with variable length fields. The packed numeric fields will be converted to text fields.
@echo OFF rem * ******************************************************************* rem * CUSEXTZ1.CMD - a Windows Command File * rem * This program is provided by SimoTime Technologies * rem * (C) Copyright 1987-2016 All Rights Reserved * rem * Web Site URL: http://www.simotime.com * rem * e-mail: helpdesk@simotime.com * rem * ******************************************************************* rem * rem * Text - Read Customer Master, write sequential CSV file. rem * Author - SimoTime Technologies rem * Date - January 24, 1996 rem * rem * The job will read a Customer Master File (KSDS), extract data and rem * write to a record sequential (RSEQ) file that will contain all rem * text data with the fields separated by a comma. rem * The packed and binary numbers will be expanded into text strings. rem * rem * ************ rem * * CUSEXTZ1 * rem * ********cmd* rem * * rem * * rem * ************ rem * * run ***************************** rem * *******mifo* * rem * * * rem * * * rem * * * rem * * ************ ************ ************ rem * * * CUSTMAST ******* CusExtC1 ******* CUSTRCSV * rem * * *******ksds* ********cbl* *******rseq* rem * * * rem * * ************ rem * * * CusExtR1 * rem * * ********cbl* rem * * rem * ************ rem * * EOJ * rem * ************ rem * rem * ******************************************************************* rem * Step 1 of 2, Delete any previously created file... rem * set CmdName=CusExtZ1 call ..\Env1BASE %CmdName% set JobStatus=0000 rem * call SimoNOTE "*******************************************************%CmdName%" call SimoNOTE "Starting JobName %CmdName%, User is %USERNAME%" :DeleteQSAM call SimoNOTE "Identify JobStep DeleteQSAM" set CUSTMAST=%BaseLib1%\DATA\APPL\SIMOTIME.DATA.CUSTMAST.DAT set CUSTRCSV=%BaseLib1%\DATA\Wrk1\SIMOTIME.DATA.CUSTRCSV.DAT if exist %CUSTRCSV% del %CUSTRCSV% rem * rem * ******************************************************************* rem * Step 2 of 2, Extract Customer Info, create a new RSEQ file... rem * :ExecuteExtractRoutine call SimoNOTE "Identify JobStep ExecuteExtractRoutine" call SimoNOTE "DataTake KSA CUSTMAST=%CUSTMAST%" call SimoNOTE "DataMake RSA CUSEXTSV=%CUSTRCSV%" run CUSEXTC1 if not "%ERRORLEVEL%" == "0" set JobStatus=0010 if not "%JobStatus%" == "0000" goto EojNok if not exist %CUSTRCSV% set JobStatus=0020 if not "%JobStatus%" == "0000" goto EojNok rem * rem * ******************************************************************* rem * :EojAok call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus%" goto :End :EojNok call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus%" :End call SimoNOTE "Conclude SysLog is %SYSLOG%" if not "%1" == "nopause" pause
The following (CUSEXTW1.cmd) is a listing of the CMD member needed to run this job. This job will do a file format conversion from a VSAM, KSDS to a Line Sequential or ASCII/Text file and the record content will be converted from fixed-field length with packed data to a CSV format with variable length fields. The packed numeric fields will be converted to text fields.
@echo OFF rem * ******************************************************************* rem * CUSEXTW1.CMD - a Windows Command File * rem * This program is provided by SimoTime Technologies * rem * (C) Copyright 1987-2016 All Rights Reserved * rem * Web Site URL: http://www.simotime.com * rem * e-mail: helpdesk@simotime.com * rem * ******************************************************************* rem * rem * Text - Read Customer Master, write sequential CSV file. rem * Author - SimoTime Technologies rem * Date - January 24, 1996 rem * rem * The job will read a Customer Master File (KSDS), extract data and rem * write to a record sequential (RSEQ) file that will contain all rem * text data with the fields separated by a comma. rem * The packed and binary numbers will be expanded into text strings. rem * The record sequential (RSEQ) file will then be converted to a rem * line sequential (LSEQ) or ASCII/text file. rem * rem * ************ rem * * CUSEXTW1 * rem * ********cmd* rem * * rem * * rem * ************ rem * * run ***************************** rem * *******mifo* * rem * * * rem * * * rem * * * rem * * ************ ************ ************ rem * * * CUSTMAST ******* CusExtC1 ******* CUSTRCSV * rem * * *******ksds* ********cbl* *******rseq* rem * * * rem * * ************ rem * * * CusExtR1 * rem * * ********cbl* rem * * rem * ************ rem * * run ***************************** rem * *******mifo* * rem * * * rem * * * rem * * * rem * * ************ ************ ************ rem * * * DAT256RS ******* R2L256C1 ******* DAT256LS * rem * * *******rseq* ********cbl* *******lseq* rem * * rem * ************ rem * * EOJ * rem * ************ rem * rem * ******************************************************************* rem * Step 1 of 3, Set Environment Variables for File Names, rem * Delete any previously created file... rem * set CmdName=CusExtE1 call ..\Env1BASE %CmdName% set JobStatus=0000 rem * call SimoNOTE "*******************************************************%CmdName%" call SimoNOTE "Starting JobName %CmdName%, User is %USERNAME%" :DeleteQSAM call SimoNOTE "Identify JobStep DeleteQSAM" set CUSTMAST=%BaseLib1%\DATA\APPL\SIMOTIME.DATA.CUSTMAST.DAT set CUSTRCSV=%BaseLib1%\DATA\Wrk1\SIMOTIME.DATA.CUSTRCSV.DAT if exist %CUSTRCSV% del %CUSTRCSV% rem * rem * ******************************************************************* rem * Step 2 of 3, Extract Customer Info, create a new RSEQ file... rem * :ExecuteExtractRoutine call SimoNOTE "Identify JobStep ExecuteExtractRoutine" call SimoNOTE "DataTake KSA CUSTMAST=%CUSTMAST%" call SimoNOTE "DataMake RSA CUSEXTSV=%CUSTRCSV%" run CUSEXTC1 if not "%ERRORLEVEL%" == "0" set JobStatus=0010 if not "%JobStatus%" == "0000" goto EojNok if not exist %CUSTRCSV% set JobStatus=0020 if not "%JobStatus%" == "0000" goto EojNok rem * rem * ******************************************************************* rem * Step 3 of 3, Convert RSEQ file to LSEQ file... rem * :ExecuteRseqToLseqRoutine call SimoNOTE "Identify JobStep ExecuteRseqToLseqRoutine set EXTFH=C:\SimoSAM1\SysLibA1\EXTFHTAB.CFG set DAT256RS=%BaseLib1%\DATA\Wrk1\SIMOTIME.DATA.CUSTRCSV.DAT set DAT256LS=%BaseLib1%\DATA\Wrk1\SIMOTIME.DATA.DAT256LS.CSV if exist %DAT256LS% del %DAT256LS% run R2L256C1 if not exist %CUSTRCSV% set JobStatus=0020 if not "%JobStatus%" == "0000" goto EojNok call SimoNOTE "DataTake RSA DAT256RS=%DAT256RS%" call SimoNOTE "DataMake TXT DAT256LS=%DAT256LS%" rem * rem * ******************************************************************* rem * :EojAok call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus%" goto :End :EojNok call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus%" :End call SimoNOTE "Conclude SysLog is %SYSLOG%" if not "%1" == "nopause" pause
The following describes the COBOL Members included with this suite of programs.
The following (CUSEXTC1.cbl) is the COBOL I/O program that was generated with SimoTime technology. The program was tested using Micro Focus Enterprise Server on Windows/XP. The program was successfully executed in both an EBCDIC and ASCII encoded configuration.
IDENTIFICATION DIVISION. PROGRAM-ID. CUSEXTC1. AUTHOR. SIMOTIME TECHNOLOGIES. ***************************************************************** * This program was generated by SimoZAPS * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * Generation Date: 2011-01-31 Generation Time: 15:47:09:31 * * * * Record Record Key * * Function Name Organization Format Max-Min Pos-Len * * INPUT CUSTMAST INDEXED VARIABLE 00512 00001 * * 00012 00012 * * OUTPUT CUSTRCSV SEQUENTIAL FIXED 00256 * * * * * ***************************************************************** ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT CUSTMAST-FILE ASSIGN TO CUSTMAST ORGANIZATION IS INDEXED ACCESS MODE IS SEQUENTIAL RECORD KEY IS CUSTMAST-PKEY-00001-00012 FILE STATUS IS CUSTMAST-STATUS. SELECT CUSTRCSV-FILE ASSIGN TO CUSTRCSV ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS CUSTRCSV-STATUS. ***************************************************************** DATA DIVISION. FILE SECTION. FD CUSTMAST-FILE DATA RECORD IS CUSTMAST-REC . 01 CUSTMAST-REC. 05 CUSTMAST-PKEY-00001-00012 PIC X(00012). 05 CUSTMAST-DATA-00013-00500 PIC X(00500). FD CUSTRCSV-FILE DATA RECORD IS CUSTRCSV-REC . 01 CUSTRCSV-REC. 05 CUSTRCSV-DATA-01 PIC X(00256). ***************************************************************** * This program was created with the SYSMASK3.TXT file as the * * template for the File I/O. It is intended for use with the * * TransCALL facility that makes a call to a routine that does * * the actual conversion between EBCDIC and ASCII. For more * * information or questions contact SimoTime Technologies. * * * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * The SYSMASK3 provides for the sequential reading of the input * * file and the sequential writing of the output file. * * * * This program mask is used with a callable subroutine that * * will do ASCII/EBCDIC Conversion based on a COBOL Copy File. * * * * If the output file is indexed then the input file must be in * * sequence by the field that will be used to provide the key * * for the output file. * * * * If the key field is not in sequence then refer to SYSMASK4 * * to provide for a random add or update of the indexed file. * ***************************************************************** WORKING-STORAGE SECTION. 01 SIM-TITLE. 05 T1 pic X(11) value '* CUSEXTC1 '. 05 T2 pic X(34) value 'Extract Customer Info to CSV RSEQ '. 05 T3 pic X(10) value ' v10.07.06'. 05 T4 pic X(24) value ' helpdesk@simotime.com'. 01 SIM-COPYRIGHT. 05 C1 pic X(11) value '* CUSEXTC1 '. 05 C2 pic X(32) value 'This Data File Convert Member wa'. 05 C3 pic X(32) value 's generated by SimoTime Technolo'. 05 C4 pic X(04) value 'gies'. 01 CUSTMAST-STATUS. 05 CUSTMAST-STATUS-L pic X. 05 CUSTMAST-STATUS-R pic X. 01 CUSTMAST-EOF pic X value 'N'. 01 CUSTMAST-OPEN-FLAG pic X value 'C'. 01 CUSTRCSV-STATUS. 05 CUSTRCSV-STATUS-L pic X. 05 CUSTRCSV-STATUS-R pic X. 01 CUSTRCSV-EOF pic X value 'N'. 01 CUSTRCSV-OPEN-FLAG pic X value 'C'. 01 CUSTMAST-LRECL pic 9(5) value 00512. 01 CUSTRCSV-LRECL pic 9(5) value 00256. ***************************************************************** * The following buffers are used to create a four-byte status * * code that may be displayed. * ***************************************************************** 01 IO-STATUS. 05 IO-STAT1 pic X. 05 IO-STAT2 pic X. 01 IO-STATUS-04. 05 IO-STATUS-0401 pic 9 value 0. 05 IO-STATUS-0403 pic 999 value 0. 01 TWO-BYTES-BINARY pic 9(4) BINARY. 01 TWO-BYTES-ALPHA redefines TWO-BYTES-BINARY. 05 TWO-BYTES-LEFT pic X. 05 TWO-BYTES-RIGHT pic X. ***************************************************************** * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine. * ***************************************************************** 01 MESSAGE-BUFFER. 05 MESSAGE-HEADER pic X(11) value '* CUSEXTC1 '. 05 MESSAGE-TEXT. 10 MESSAGE-TEXT-1 pic X(68) value SPACES. 10 MESSAGE-TEXT-2 pic X(188) value SPACES. ***************************************************************** 01 PROGRAM-NAME pic X(8) value 'CUSEXTC1'. 01 INFO-STATEMENT. 05 INFO-SHORT. 10 INFO-ID pic X(8) value 'Starting'. 10 filler pic X(2) value ', '. 10 filler pic X(34) value 'Extract Customer Info to CSV RSEQ '. 05 filler pic X(24) value ' http://www.SimoTime.com'. 01 APPL-RESULT pic S9(9) comp. 88 APPL-AOK value 0. 88 APPL-EOF value 16. 01 CUSTMAST-TOTAL. 05 CUSTMAST-RDR pic 9(9) value 0. 05 filler pic X(3) value ' - '. 05 filler pic X(23) value 'Line count for CUSTMAST'. 01 CUSTRCSV-TOTAL. 05 CUSTRCSV-ADD pic 9(9) value 0. 05 filler pic X(3) value ' - '. 05 filler pic X(23) value 'Line count for CUSTRCSV'. ***************************************************************** PROCEDURE DIVISION. move all '*' to MESSAGE-TEXT-1 perform Z-DISPLAY-MESSAGE-TEXT move INFO-STATEMENT to MESSAGE-TEXT-1 perform Z-DISPLAY-MESSAGE-TEXT move all '*' to MESSAGE-TEXT-1 perform Z-DISPLAY-MESSAGE-TEXT perform Z-POST-COPYRIGHT perform CUSTMAST-OPEN perform CUSTRCSV-OPEN perform until CUSTMAST-STATUS not = '00' perform CUSTMAST-READ if CUSTMAST-STATUS = '00' add 1 to CUSTMAST-RDR perform BUILD-OUTPUT-RECORD perform CUSTRCSV-WRITE if CUSTRCSV-STATUS = '00' add 1 to CUSTRCSV-ADD end-if end-if end-perform move CUSTMAST-TOTAL to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move CUSTRCSV-TOTAL to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT if APPL-EOF move 'Complete' to INFO-ID else move 'ABENDING' to INFO-ID end-if move INFO-STATEMENT to MESSAGE-TEXT(1:79) perform Z-DISPLAY-MESSAGE-TEXT perform CUSTRCSV-CLOSE perform CUSTMAST-CLOSE GOBACK. ***************************************************************** BUILD-OUTPUT-RECORD. *> Extract CALL process... call 'CUSEXTR1' using CUSTRCSV-REC CUSTMAST-REC add 00256 to ZERO giving CUSTRCSV-LRECL exit. ***************************************************************** * I/O Routines for the INPUT File... * ***************************************************************** CUSTMAST-CLOSE. add 8 to ZERO giving APPL-RESULT. close CUSTMAST-FILE if CUSTMAST-STATUS = '00' subtract APPL-RESULT from APPL-RESULT else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'CLOSE Failure with CUSTMAST' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move CUSTMAST-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* CUSTMAST-READ. read CUSTMAST-FILE if CUSTMAST-STATUS = '00' subtract APPL-RESULT from APPL-RESULT else if CUSTMAST-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 CUSTMAST-EOF else move 'READ Failure with CUSTMAST' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move CUSTMAST-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if end-if exit. *---------------------------------------------------------------* CUSTMAST-OPEN. add 8 to ZERO giving APPL-RESULT. open input CUSTMAST-FILE if CUSTMAST-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'O' to CUSTMAST-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'OPEN Failure with CUSTMAST' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move CUSTMAST-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. ***************************************************************** * I/O Routines for the OUTPUT File... * ***************************************************************** CUSTRCSV-WRITE. if CUSTRCSV-OPEN-FLAG = 'C' perform CUSTRCSV-OPEN end-if write CUSTRCSV-REC if CUSTRCSV-STATUS = '00' subtract APPL-RESULT from APPL-RESULT else if CUSTRCSV-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 'WRITE Failure with CUSTRCSV' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move CUSTRCSV-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* CUSTRCSV-OPEN. add 8 to ZERO giving APPL-RESULT. open OUTPUT CUSTRCSV-FILE if CUSTRCSV-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'O' to CUSTRCSV-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'OPEN Failure with CUSTRCSV' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move CUSTRCSV-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* CUSTRCSV-CLOSE. add 8 to ZERO giving APPL-RESULT. close CUSTRCSV-FILE if CUSTRCSV-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'C' to CUSTRCSV-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'CLOSE Failure with CUSTRCSV' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move CUSTRCSV-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. ***************************************************************** * The following Z-ROUTINES provide administrative functions * * 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-MESSAGE-TEXT end-if move 'PROGRAM-IS-ABENDING...' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT add 12 to ZERO giving RETURN-CODE STOP RUN. * exit. ***************************************************************** * Display CONSOLE messages... * ***************************************************************** Z-DISPLAY-MESSAGE-TEXT. if MESSAGE-TEXT-2 = SPACES display MESSAGE-BUFFER(1:79) else display MESSAGE-BUFFER end-if move all SPACES to MESSAGE-TEXT exit. ***************************************************************** * Display the file status bytes. This routine will display as * * four digits. If the full two byte file status is numeric it * * will display as 00nn. If the 1st byte is a numeric nine (9) * * the second byte will be treated as a binary number and will * * display as 9nnn. * ***************************************************************** Z-DISPLAY-IO-STATUS. if IO-STATUS not NUMERIC or IO-STAT1 = '9' move IO-STAT1 to IO-STATUS-04(1:1) subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY move IO-STAT2 to TWO-BYTES-RIGHT add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403 move 'File Status is: nnnn' to MESSAGE-TEXT move IO-STATUS-04 to MESSAGE-TEXT(17:4) perform Z-DISPLAY-MESSAGE-TEXT else move '0000' to IO-STATUS-04 move IO-STATUS to IO-STATUS-04(3:2) move 'File Status is: nnnn' to MESSAGE-TEXT move IO-STATUS-04 to MESSAGE-TEXT(17:4) perform Z-DISPLAY-MESSAGE-TEXT end-if exit. ***************************************************************** Z-POST-COPYRIGHT. display SIM-TITLE display SIM-COPYRIGHT exit. ***************************************************************** * This program was generated by SimoZAPS * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * Generation Date: 2011-01-31 Generation Time: 15:47:09:34 * *****************************************************************
The following (CUSEXTR1.cbl) is a COBOL program that extracts the fields of data and expands the numeric fields and truncates the trailing spaces from text fields and builds a comma separated text string of data. The program was tested using Micro Focus Enterprise Server on Windows/XP. The program was successfully executed in both an EBCDIC and ASCII encoded configuration.
IDENTIFICATION DIVISION. PROGRAM-ID. CUSEXTR1. AUTHOR. SIMOTIME TECHNOLOGIES. ***************************************************************** * This routine was generated by SimoREC1 * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * Generation Date: 2011/01/31 Generation Time: 15:47:09:60 * ***************************************************************** DATA DIVISION. WORKING-STORAGE SECTION. 01 NGPU-07-00. 05 NRPU-07-00 pic 9(07). 01 IX-P1 pic 9(9) value 0. 01 IX-P2 pic 9(9) value 0. 01 IX-NP pic 9(5) value 0. 01 IX-L1 pic 9(9) value 0. 01 RA-P1 pic 9(3) value 0. 01 RA-P2 pic 9(3) value 0. 01 COLUMN-NUMBER pic 9(5) value 0. 01 WORK-AREA-X. 05 WORK-AREA-X1 pic X value '"'. 05 WORK-AREA pic X(00288) value SPACES. 01 WORK-AREA-X2 pic X(00256) value SPACES. 01 FRAME-STOP. 05 FRAME-BYTE pic X value '"'. 05 DELIMITER-BYTE pic X value ','. 01 FRAME-FLAG pic X value 'N'. 01 O-FLAG pic X(3) value 'CSV'. 01 BYTE-Y pic X value 'Y'. 01 BYTE-N pic X value 'N'. 01 FRAME-COUNT pic 9(5) value 0. 01 DELIM-COUNT pic 9(5) value 0. 01 FFL-SIZE pic 9(5) value 0. 01 CSV-SIZE pic 9(5) value 0. 01 LAST-NON-SPACE-BYTE pic 9(5) value 0. 01 SIGN-BYTE pic X value SPACE. 01 DIG-POS pic 9(3). 01 DIG-LEN pic 9(3). 01 DIG-CTL pic 9(3). 01 DEC-POS pic 9(3). 01 DEC-LEN pic 9(3). 01 DEC-CTL pic 9(3). 01 DEC-POINT pic 9(3). * ***************************************************************** LINKAGE SECTION. 01 REC1CALL-REC pic X(00256). COPY CUSTCB01. * ***************************************************************** PROCEDURE DIVISION using REC1CALL-REC CUST-RECORD. * add 1 to ZERO giving IX-NP move all SPACES to REC1CALL-REC * * String Move, CUST-NUMBER add 00012 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-NUMBER to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * String Move, CUST-STATUS add 00001 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-STATUS to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * String Move, CUST-LAST-NAME add 00028 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-LAST-NAME to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * String Move, CUST-FIRST-NAME add 00020 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-FIRST-NAME to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * String Move, CUST-MID-NAME add 00020 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-MID-NAME to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * String Move, CUST-ADDRESS-1 add 00048 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-ADDRESS-1 to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * String Move, CUST-ADDRESS-2 add 00048 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-ADDRESS-2 to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * String Move, CUST-CITY add 00028 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-CITY to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * String Move, CUST-STATE add 00028 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-STATE to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * String Move, CUST-POSTAL-CODE add 00012 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-POSTAL-CODE to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * String Move, CUST-PHONE-HOME add 00018 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-PHONE-HOME to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * String Move, CUST-PHONE-WORK add 00018 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-PHONE-WORK to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * String Move, CUST-PHONE-CELL add 00018 to ZERO giving FFL-SIZE move SPACES to WORK-AREA-X2 move CUST-PHONE-CELL to WORK-AREA-X2 perform POST-TEXT-TO-CSV * * Packed-UnSign move, CUST-CREDIT-LIMIT add 00007 to ZERO giving FFL-SIZE if CUST-CREDIT-LIMIT is NUMERIC add CUST-CREDIT-LIMIT to ZERO giving NRPU-07-00 else move ZERO to NRPU-07-00 end-if move SPACES to WORK-AREA-X2 move NGPU-07-00 to WORK-AREA-X2 perform POST-TEXT-TO-CSV GOBACK. * ***************************************************************** POST-TEXT-TO-CSV. * This routine does a left-to-right scan of the content * of a fixed-field. It accumulates counters for the * embedded Frame or Delimiter bytes. * If embedded Frame or Delimiters bytes exist in the * text string within a field then the text string will * be formated as it is moved to the output buffer. * The data in the output buffer will start and end with * a Frame byte * Embedded Frame bytes will be preceded by a Frame byte * and embedded Delimiter bytes will be treated as data * within the output text string. ***************************************************************** add 1 to ZERO giving IX-P1 add 1 to ZERO giving IX-P2 move ZERO to FRAME-COUNT move ZERO to DELIM-COUNT move ZERO to LAST-NON-SPACE-BYTE move SPACES to WORK-AREA perform until IX-P1 > FFL-SIZE move WORK-AREA-X2(IX-P1:1) to WORK-AREA(IX-P2:1) if WORK-AREA-X2(IX-P1:1) = FRAME-BYTE add 1 to IX-P2 add 1 to FRAME-COUNT move FRAME-BYTE to WORK-AREA(IX-P2:1) end-if if WORK-AREA-X2(IX-P1:1) = DELIMITER-BYTE add 1 to DELIM-COUNT end-if if WORK-AREA-X2(IX-P1:1) not = SPACE add IX-P2 to ZERO giving LAST-NON-SPACE-BYTE end-if add 1 to IX-P1 add 1 to IX-P2 end-perform if DELIM-COUNT > 0 or FRAME-COUNT > 0 add 1 to LAST-NON-SPACE-BYTE move FRAME-BYTE to WORK-AREA(LAST-NON-SPACE-BYTE:1) add 1 to IX-P2 add LAST-NON-SPACE-BYTE to 1 giving CSV-SIZE move WORK-AREA-X to REC1CALL-REC(IX-NP:CSV-SIZE) else add LAST-NON-SPACE-BYTE to ZERO giving CSV-SIZE move WORK-AREA to REC1CALL-REC(IX-NP:CSV-SIZE) end-if add CSV-SIZE to IX-NP move DELIMITER-BYTE to REC1CALL-REC(IX-NP:1) add 1 to IX-NP exit. ***************************************************************** * This routine was generated by SimoREC1 * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * Generation Date: 2011/01/31 Generation Time: 15:47:09:60 * *****************************************************************
The following (CUSTCB01.cpy) is the COBOL copy file that is used to define the record structure.
***************************************************************** * CUSTCB01.CPY - a COBOL Copy File * * A Customer Master File used by the Demo programs. * * This is a VSAM Keyed-Sequential-Data-Set or Key-Indexed File. * * Copyright (C) 1987-2016 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 * ***************************************************************** * The length of this data structure is 512 bytes. * 01 CUST-RECORD. 05 CUST-NUMBER PIC X(12). 05 CUST-DATA. 10 CUST-STATUS PIC X. 10 CUST-NAME. 15 CUST-LAST-NAME PIC X(28). 15 CUST-FIRST-NAME PIC X(20). 15 CUST-MID-NAME PIC X(20). 10 CUST-ADDRESS-1 PIC X(48). 10 CUST-ADDRESS-2 PIC X(48). 10 CUST-CITY PIC X(28). 10 CUST-STATE PIC X(28). 10 CUST-POSTAL-CODE PIC X(12). 10 CUST-PHONE-HOME PIC X(18). 10 CUST-PHONE-WORK PIC X(18). 10 CUST-PHONE-CELL PIC X(18). 10 CUST-CREDIT-LIMIT PIC 9(7) COMP-3. 10 CUST-DISCOUNT OCCURS 3 TIMES. 15 CUST-DISCOUNT-CODE PIC S9(3) COMP. 15 CUST-DISCOUNT-RATE PIC S9(2)V999. 15 CUST-DISCOUNT-DATE PIC X(8). 10 CUST-LADATE PIC X(8). 10 CUST-LATIME PIC X(8). 10 CUST-TOKEN PIC 9(3). 10 FILLER PIC X(145). * *** CUSTCB01 - End-of-Copy File - - - - - - - - - - - CUSTCB01 * ***************************************************************** *
The Process Control File will be used to generate the COBOL programs that will extract data from the customer master file and create a record sequential with the fields separated by a comma. The input file (CUSTMAST.dat) is a Micro Focus Key-Sequenced file. The output file may be easily imported into an Excel spread sheet. The following (CUSEXT01.pcf) shows the content of the Process Control File.
*********************************************************************** * CUSEXT01.pcf - a Process Control File * * SimoTime Program Generation Technologies * * (C) Copyright 1987-2016 All Rights Reserved * * Web Site URL: http://www.simotime.com * * e-mail: helpdesk@simotime.com * *********************************************************************** * SYSUT1 is the Customer Master File, Indexed, 512-byte records. * SYSUT2 is a Record Sequential file, 256-byte fixed-length records. *********************************************************************** * This Process Control File will be used to generate a callable COBOL * routine that will extract data from the customer master file and * create a record sequential with the fields separated by a comma. * The input file (CUSTMAST.DAT) is a Micro Focus Key-Sequenced file. * The output file may be easily imported into an Excel spread sheet. * Refer to the utconv01.htm document for additional detail. * * The following group of statements will define the high level * functions and processes to be performed. * &SIMOPREP call ..\Env1BASE &USERPREP call UserCONV &CONFORM IBM ©FILE CUSTCB01.cpy &HTMLFILE custcb01.htm * * The following group of statements will define the behavioral * characteristics and environment variable for the file I/O Program * to be generated. * *HEAD34 ....:....1....:....2....:....3.... &HEAD34 Extract Customer Info to CSV RSEQ &PROGID CUSEXTC1 &SYSUT1 name=CUSTMAST org=Indexed recfm=VARIABLE rmin=12 rmax=512 kpos=1 klen=12 &SYSUT2 name=CUSTRCSV org=Sequential recfm=FIXED rmax=256 * * The following two statements are used when the records in the data * file (input or output) are a Comma-Separated-Values (or CSV) format. * &DELIMITER , &FRAME " * * The following group of statements will define the behavioral * characteristics and environment variables for the record content * conversion program to be generated. * This is for CSV Formatted output records. * &EXTCALL CUSEXTR1 &EXTREC CUST-RECORD &EXTLREC 256 &EXTFMT CSV , &EXTINIT SPACES &EXTHDR YES * * The following group of statements will define the fields to be * extracted from the input file and written to the output file. * This is for CSV Formatted output records. * &EXTRACT CUST-NUMBER &EXTRACT CUST-STATUS &EXTRACT CUST-LAST-NAME &EXTRACT CUST-FIRST-NAME &EXTRACT CUST-MID-NAME &EXTRACT CUST-ADDRESS-1 &EXTRACT CUST-ADDRESS-2 &EXTRACT CUST-CITY &EXTRACT CUST-STATE &EXTRACT CUST-POSTAL-CODE &EXTRACT CUST-PHONE-HOME &EXTRACT CUST-PHONE-WORK &EXTRACT CUST-PHONE-CELL &EXTRACT CUST-CREDIT-LIMIT * &END
The purpose of this program is to provide an example for accessing a VSAM, KSDS and extracting data that is reformatted into a comma separated data string that is written to a sequential file. This document may be used 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 document and the links to other documents are intended to provide a greater awareness of the Data Management and Application Processing alternatives.
The 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 send an e-mail to: helpdesk@simotime.com or call 415 883-6565. We appreciate hearing from you.
Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Enterprises. 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 Enterprises.
SimoTime Enterprises 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 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, documentation or training material.
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.
The following links may be to the current server or to the Internet.
Explore How to Generate a Data File Convert Program using simple specification statements in a Process Control File (PCF). This link to the User Guide includes the information necessary to create a Process Control File and generate the COBOL programs that will do the actual data file conversion. The User Guide contains a list of the PCF statements that are used for the data file convert process.
Explore the capabilities of the SimoZAPS Utility Program. This includes generating a COBOL program that will do the conversion of sequential and VSAM (KSDS) files between EBCDIC and ASCII while maintaining mainframe (or COBOL) numeric formats and integrity. SimoZAPS can also read a sequential file in EBCDIC format and create an ASCII/CRLF file or VSAM KSDS file in ASCII format. The conversion tables may be viewed or modified to meet unique requirements. The Hexcess/2 function provides the capability of viewing, finding or patching the contents of a file in hexadecimal.
Explore the non-Relational Data Connection for more examples of accessing methodologies and coding techniques for Data Files and VSAM Data Sets.
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.
Explore The File Status Return Codes to interpret the results of accessing VSAM data sets and/or QSAM files.
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 via Internet Connect for access to white papers, program examples and product information.
Explore The Micro Focus Web Site via Internet Connect for more information about products and services available from Micro Focus.
Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.
This document was created and is copyrighted and maintained by SimoTime Technologies.
If you have any questions, suggestions, comments or feedback please call or send an e-mail to: helpdesk@simotime.com
We appreciate hearing from you.
Founded in 1987, SimoTime Technologies 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 |
Extract Data from Customer Master File for use by Microsoft Excel or Access |
Copyright © 1987-2016 SimoTime Technologies All Rights Reserved |
When technology complements business |
http://www.simotime.com |