IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Convert Packed data in a file


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
usharaniA

New User


Joined: 22 Jan 2008
Posts: 85
Location: India

PostPosted: Mon May 25, 2009 5:40 pm
Reply with quote

Hi,
Is it possible to convert all the packed data (Comp datas) in a flat file in one stretch using REXX.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Mon May 25, 2009 5:45 pm
Reply with quote

You asked for a YES/NO answer and that' s what You are getting
yes/no depending on the meaning of one stretch ??

did You care to search the forums with ( for example ) "REXX PACK" checking search for all terms ??
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon May 25, 2009 8:32 pm
Reply with quote

since this is the cobol forum,

no, you can't do it in COBOL using REXX.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon May 25, 2009 8:52 pm
Reply with quote

COMP data is not packed data!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon May 25, 2009 11:33 pm
Reply with quote

Hello,

Quote:
Is it possible to convert all the packed data (Comp datas) in a flat file in one stretch using REXX.
Now that you've received a beatin', someone may have a suggestion if you better explain what you want to do.

Showing some sample input (use hex on and the "Code" tag) and the output you want from that input will help.
Back to top
View user's profile Send private message
usharaniA

New User


Joined: 22 Jan 2008
Posts: 85
Location: India

PostPosted: Tue May 26, 2009 9:20 am
Reply with quote

Actually there are some invisible datas(Packed data) in the Production file.
I want to convert the whole production file data to be visible one .

If suppose i convert the data ,line by line should i check for the data whethere they are normal or packed data, or simply i can use the X2D built in function to convert the data.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue May 26, 2009 9:24 am
Reply with quote

Hello,

The first thing you need to do is map the input so that you will know which positions (start-end) contain a packed-decimal value. There may be multiple packed-decimal fields next to each other. You will need to know the start and end positon of each one.

Once you know the layout, you can convert the records so that everything is unpacked.

Packed-decimal fields often are negative, so you need to consider how you want a negative sign represented in your output.

Lastly, what about decimal places?

You may want to consider using your sort product instead of rexx. . .
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue May 26, 2009 9:25 am
Reply with quote

look at the record layout and convert field by field accordingly
( binary and packed need different processing )

for a large number of records sort ( any make ) would be a better alternative
Back to top
View user's profile Send private message
usharaniA

New User


Joined: 22 Jan 2008
Posts: 85
Location: India

PostPosted: Tue May 26, 2009 9:46 am
Reply with quote

I have the Copybook layout to present the production file in the readable format.

Is there any Rexx routine to pick the data according to the variable name.

for Example
Code:
variable  len type  value
 Name      10  A    Alexdra


I have all the variable names in the ISPF tables , so when i get each variable from the ISPF tables , can i get the value of the variable using any rexx module
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue May 26, 2009 9:50 am
Reply with quote

Quote:
Is there any Rexx routine to pick the data according to the variable name.


no, but You can write Your own
REXX is a programming language, not a file tool,
the facility You ask for might be present in fileaid or filemanager
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue May 26, 2009 9:51 am
Reply with quote

Hello,

If you already have a cobol copybook of the existing file, it sould be a simiple matter to clone that copybook to match the desired new layout. Just make the field names in the new file one charcter different.

Read the old file and simply move the fields to the new definitions and write the new output records.

For this exercise, it may be quicker to do this in cobol than rexx or sort.
Back to top
View user's profile Send private message
usharaniA

New User


Joined: 22 Jan 2008
Posts: 85
Location: India

PostPosted: Tue May 26, 2009 9:56 am
Reply with quote

ok dick. thanks for your suggestion . ill try and let you about it.
Back to top
View user's profile Send private message
usharaniA

New User


Joined: 22 Jan 2008
Posts: 85
Location: India

PostPosted: Thu May 28, 2009 2:58 pm
Reply with quote

Hi,
I tried a cobol program to move the records from flat file to the copy book structure and write it into another flat file so this will solve the issue of Packed data and field format conditions.

But now i want to know how to move the data from flat file to the copybook which contains various group.

This is my cobol program,
Code:
 IDENTIFICATION DIVISION.                           
 PROGRAM-ID. WRITEFIL.                               
 ENVIRONMENT DIVISION.                               
 INPUT-OUTPUT SECTION.                               
 FILE-CONTROL.                                       
      SELECT INFILE ASSIGN TO DD1.                   
      SELECT OUTFILE ASSIGN TO DD2.                 
 DATA DIVISION. 
                                   
 FILE SECTION.                                       
 FD INFILE.                                         
 01 IN-RECORDS                 PIC X(80). 
         
 FD OUTFILE.                                         
 01 OUT-RECORDS                 PIC X(80).   
       
 WORKING-STORAGE SECTION.                           
  COPY DFHAID.                                       
  77  EOF                       PIC 9 VALUE IS 0. 
 
 PROCEDURE DIVISION.                                 
 0000-MAIN-PARA.                                     
      OPEN INPUT INFILE                             
           OUTPUT OUTFILE.                           
      DISPLAY 'FILES ARE OPENED SUCCESSFULLY'.       
      DISPLAY OUT-RECORDS                           
      PERFORM READ-PARA THRU READ-EXIT UNTIL EOF = 1.
      PERFORM CLOSE-PARA THRU CLOSE-EXIT.           
      STOP RUN.                                     
 READ-PARA.                                         
      DISPLAY 'READ PARA'                                 
      READ INFILE AT END MOVE 1 TO EOF.                   
      IF EOF = 1                                           
         DISPLAY 'ALL RECORDS ARE READ'                   
      ELSE                                                 
        MOVE IN-RECORDS TO MAP1I                     
       PERFORM WRITE-PARA THRU WRITE-EXIT                 
      END-IF.                                             
 READ-EXIT.                                               
      EXIT.                                               
 WRITE-PARA.                                               
      MOVE MAP1I      TO OUT-RECORDS                       
      WRITE OUT-RECORDS.                                   
 WRITE-EXIT.                                               
      EXIT.                                               
 CLOSE-PARA.                                               
      CLOSE INFILE                                         
            OUTFILE.                                       
      DISPLAY 'FILE IS CLOSED SUCCESSFULLY'.               
 CLOSE-EXIT.                                               
      EXIT.                                               



and my copybook is
Code:

01  MAP1I.                       
    02  FILLER PIC X(12).         
    02  NUML    COMP  PIC  S9(4).
    02  NUMF    PICTURE X.       
    02  FILLER REDEFINES NUMF.   
      03 NUMA    PICTURE X.       
    02  NUMI  PIC X(3).           
    02  NAMEL    COMP  PIC  S9(4).
    02  NAMEF    PICTURE X.       
    02  FILLER REDEFINES NAMEF.   
01  MAP1O REDEFINES MAP1I.       
    02  FILLER PIC X(12).         
    02  FILLER PICTURE X(3).     
    02  NUMO  PIC X(3).           
    02  FILLER PICTURE X(3).     
    02  NAMEO  PIC X(16).         
    02  FILLER PICTURE X(3).     
    02  MARKO  PIC X(3).         
    02  FILLER PICTURE X(3).     
    02  MSGFLDO  PIC X(16).       
01  MAP2I.                       
    02  FILLER PIC X(12).         
    02  NAME1L    COMP  PIC  S9(4)
    02  NAME1F    PICTURE X.     
    02  FILLER REDEFINES NAME1F. 
      03 NAME1A    PICTURE X.     
    02  NAME1I  PIC X(16).       
    02  MARK1L    COMP  PIC  S9(4)
    02  MARK1F    PICTURE X.     
    02  FILLER REDEFINES MARK1F. 



I want to read the data from flat file and want to move to the copybook.
In the cobol program i have specified MOVE IN-RECORDS TO MAP1I ,

how to move it to the other groups dynamically without specifying MAP1I or MAP10.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu May 28, 2009 3:15 pm
Reply with quote

that is a bms copybook definition of a map.

why not make a duplicate of the copybook that defines the input file
rename the duplicate (new member name)
change the first char of each reference name,
remove the COMP, COMP-3, BINARY, PACKED-DECIMAL usage clauses.

then:
  1. use READ with workarea option populate the original Copybook in working-storage
  2. use MOVE instructions to populate the new copybook
  3. use WRITE with workarea option to output the newly formatted record
Back to top
View user's profile Send private message
usharaniA

New User


Joined: 22 Jan 2008
Posts: 85
Location: India

PostPosted: Thu May 28, 2009 3:34 pm
Reply with quote

Quote:
use READ with workarea option populate the original Copybook in working-storage



im know only the basic of cobol, can you please show me some examples.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu May 28, 2009 3:42 pm
Reply with quote

This Link lists COBOL manuals for all the different Versions. Pick the version used at your site.

By the way, READ/WRITE on a fixed-length file with workarea option is the same for all vsns of COBOL.

Reading and learning from the manuals
is a better way to increase your skill level
than to use someone else's code.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top