How to convert packed decimal values to numeric values via File Master using COBOL copybooks
search cancel

How to convert packed decimal values to numeric values via File Master using COBOL copybooks

book

Article ID: 142191

calendar_today

Updated On:

Products

File Master Plus for IMS File Master Plus for DB2 for z/OS

Issue/Introduction

The only method to get this done is to use a File Master Reformat data set, aka. REFFILE.
Such a REFFILE will be created via File Master ISPF 3.11 menu
("11  REFORMAT       Convert file from one record layout to another").

Resolution

How to convert packed decimal values to numeric values via File Master using COBOL copybooks

This document describes how packed decimal values (Computational-3) can be converted to numeric values via File Master using COBOL copybooks.

The only method to get this done is to use a File Master Reformat data set, aka. REFFILE.
Such a REFFILE will be created via File Master ISPF 3.11 menu
("
11  REFORMAT       Convert file from one record layout to another").

You need two COBOL data structures, aka. copybooks. One copybook for the source data structure and one for the new data structure.
For example:
...
       01  DATAREC1OLD.                              
           02  FIELD1-PCK     PIC  9(08)V99  COMP-3.
           02  FILLER         PIC  X(72).           
...
       01  DATAREC1NEW.                     
           02  FIELD1-NUM     PIC  9(06)V99.
           02  FILLER         PIC  X(72).   
...

That is a File Master 3.11 Reformat example:

------------------  CA File Master Plus -- Dataset Reformat  ------------------
OPTION ===>                                                                  
                                                                              
   BLANK - Update Reformat Control Parms      E - Execute Reformat            
                                                                              
Reformat "FROM":                                                              
   Dataset name  ===> 'your.CONVERT.INPUT'                         
   Member name   ===>                                                         
   Layout DSN    ===> 'your.CONVERT.LIB'                           
   Layout member ===> CPYBK#O1                                                 
                                                                              
Reformat "TO":                                                                
   Dataset name  ===> 'your.CONVERT.OUTPUT'                         
   Member name   ===>                                                         
   Layout DSN    ===> 'your.CONVERT.LIB'                           
   Layout member ===> CPYBK#N1                                                
   Replace Keys  ===> N        ('Y' to replace duplicate keys in KSDS)        
                                                                              
Reformat Control Parm:                                                        
   Dataset name  ===> 'your.CONVERT.LIB'                           
   Member name   ===> REFORMAT                                                
                                                                              
Execution mode   ===> E        O = Online   S = Submit JCL   E = Edit JCL     

After pressing enter you have to assign the "FROM" fields to the "TO" fields. Enter 2 and 3 in the TO section of the panel, for example:

CA File Master Plus -- Reformat your.CONVERT.LIB(REFORMAT)         
 COMMAND ===>                                                 SCROLL ===> CSR
                                                                              
FROM Record ------------ CPYBK#O1 of your.CONVERT.LIB --------------
Num Field Name                    Pos    Format                      Row 1 of 3
   1 DATAREC1OLD                      1       78                              
   2   FIELD1-PCK                     1 P    8.2                              
   3   FILLER                         7 C     72                               
*************************** Bottom of Record Layout ***************************
                                                                              
                                                                               
                                                         
                                                                               
TO Record   ------------ CPYBK#N1 of your.CONVERT.LIB --------------
Num Field Name                    Pos    Format  Reformat            Row 1 of 3
   1 DATAREC1NEW                      1       80                               
   2   FIELD1-NUM                     1 N    6.2 2                   
   3   FILLER                         9 C     72 3                      
*************************** Bottom of Record Layout ***************************

After pressing enter the numbers will be automatically translated to the field names.
Press PF3 and type E now.
You will see the JCL now. For example:
...
//your_job_card...
//REFMT   EXEC PGM=CAWABATC,REGION=4M            
//STEPLIB   DD DSN=your.FM110.CDBILOAD,         
//             DISP=SHR                          
//SYSPRINT  DD SYSOUT=*                           
//SYSUDUMP  DD SYSOUT=*                          
//SYSUT1    DD DSN=your.CONVERT.INPUT,
//             DISP=SHR                          
//SYSUT1O   DD DSN=your.CONVERT.OUTPUT,
//             DISP=SHR                           
//SYSIN     DD *                                 
COPY ,                                           
  INFILE(SYSUT1),                                
  OUTFILE(SYSUT1O),                              
  REFFILE(your.CONVERT.LIB(REFORMAT)),
  REPLACEKEY(N)                                  
/*                                               
...

Now, when running the job and using the following three records input file:
...
------------------------------------------------------------------------------
....î@record#01-----------------------------------------------------------------
0013579889987FF66666666666666666666666666666666666666666666666666666666666666666
00246C953694B0100000000000000000000000000000000000000000000000000000000000000000
 ------------------------------------------------------------------------------
......record#02-----------------------------------------------------------------
0022229889987FF66666666666666666666666666666666666666666666666666666666666666666
00222C953694B0200000000000000000000000000000000000000000000000000000000000000000
 ------------------------------------------------------------------------------
......record#03-----------------------------------------------------------------
0033339889987FF66666666666666666666666666666666666666666666666666666666666666666
00333C953694B0300000000000000000000000000000000000000000000000000000000000000000
 ------------------------------------------------------------------------------
...

The OUTPUT will contain the numeric data:

BROWSE    your.CONVERT.OUTPUT                       Line 0000000000 Col 001 080
 Command ===>                                                  Scroll ===> CSR
********************************* Top of Data **********************************
01234567record#01---------------------------------------------------------------
02222222record#02---------------------------------------------------------------
03333333record#03---------------------------------------------------------------
******************************** Bottom of Data ********************************


Additional Information