MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to sort this file with File-Aid?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
nguyenh
Beginner


Joined: 09 Mar 2004
Posts: 52
Topics: 6

PostPosted: Mon Oct 25, 2004 3:18 pm    Post subject: How to sort this file with File-Aid? Reply with quote

Hi all experts,
I am re-written a program from COBOL to C, there is sort step in the skeleton that calls a COBOL program to perform the sort. I am wondering if I can use File-aid or other utilities to sort this without writing a C program. If so could anyone please show me the way. I am very low in main frame skill!

The input file needs to be sorted based on 6 keys, sort key values can be different depends the conditions. Here is the example:

if colums 33-38 contains "member"
key#1 = blank
key#2 = column 77-78, which contains AA,AB,CA,CC....
key#3 = some particular column
key#4 = column 79-80, which contains blank, 01, 02
key#5 = order of the orginal records

if column 77-78 contain "TT"
key#1 = some particular column
key#2 = some particular column
key#3 = some particular column
key#4 = some particular column
key#5 = some particular column

if column 69-70 contain "DL"
key#1 = some particular column
key#2 = some particular column
key#3 = some particular column
key#4 = some particular column
key#5 = some particular column

and so on...

I am wondering if the is a way that I can achieve this goal?
the input file looks like this:
Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************MEMBERBFS     **********************************
********************************MEMBERFILEHDR **********************************

TSS.1R.HZD.CMDS...003133.TSS.1R.....                                        AB
  PCSDLST   092      040595M. WILLIS       7134831040       NSTS18411SM2    AA
TSS.1R.PCS.SUPPORT003133.TSS.1R.....                                        AB
  UMP.UMP3  004      080295SONJA SUMMERS   7134834217       NSTS21249SM2    AA
USMP.3............003407.USMP.3.....                                        AB
********************************MEMBERFILE01  **********************************
  PEMP      033      090195K.B. THOMAS     7134831380       NSTS21286SM2    AA
                                                                           1CA
                     PF01  102S    OUT        1501                          CB01
P03K6097J 04EVENT   DEPL HEATERS PWR ON (K2)          O                     CC
P03K6097J L  O            ON      02  PF01SIO101501      SS               32CD
P03K6097J P03K6097E           P33M9001J                                     CE
P03K6097J               D555000002008073                                    CL01
P03K6097JA                  DISP=213, ITEM=18                               CF
P03K6098J 04EVENT   DEPL HEATERS PWR OFF (K2)         O                     CC
P03K6098J L  O           OFF      02  PF01SIO101501      SS               32CD
********************************MEMBERFILE14  **********************************
                                                                           2CA
P13K0800L 07EVENT   MAIN ISO. V. OPEN                                       CC
P13K0800L L      S      OPEN      01                     QQ X  S     L      CD
P13K0800L A01K001J                                                          CE


The output will look simmilar to this:
Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+-
P03K6097J 04EVENT   DEPL HEATERS PWR ON (K2)          O                     CC  FILE01
P03K6097J L  O            ON      02  PF01SIO101501      SS               32CD  FILE01
P03K6097J P03K6097E           P33M9001J                                     CE  FILE01
P03K6097J               D555000002008073                                    CL01FILE01
P03K6097JA                  DISP=213, ITEM=18                               CF  FILE01
905 53FFAFC30  F0001       U0000004         1                              TB   FILE28
914 53      O                       1.00BIPL08100000400100  10032000.000000TA   FILE28
914 53FFAFC30  F0001       U0000004         1                              TB   FILE28


*Note that the output records is 86 characters long because the COBOL program puts member names at the end of each of records so that it can sort by file names

I am very appreciate all of you who trying to help me on this assignment.
Thank you!
Back to top
View user's profile Send private message
nguyenh
Beginner


Joined: 09 Mar 2004
Posts: 52
Topics: 6

PostPosted: Mon Oct 25, 2004 3:24 pm    Post subject: Reply with quote

Additional information

Here is the skeleton:
Temp1 is 80 characaters file that contains data that combining from a set of members. OldList is an 86 characters long.

Code:

//SORTPDT  EXEC PGM=SORTPDT,REGION=512K
)IM STEPOLTS
//IPFILE   DD  DSNAME=&USERID..TEMP1,DISP=SHR
//OPFILE   DD DSN=&USERID..OLDLIST,DISP=(OLD,KEEP),UNIT=SYSDA
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  *
//SORTWK01 DD UNIT=DISK,SPACE=(CYL,5,,CONTIG)
//SORTWK02 DD UNIT=DISK,SPACE=(CYL,5,,CONTIG)
//SORTWK03 DD UNIT=DISK,SPACE=(CYL,5,,CONTIG)
//SORTWK04 DD UNIT=DISK,SPACE=(CYL,5,,CONTIG)
//SORTWK05 DD UNIT=DISK,SPACE=(CYL,5,,CONTIG)
//SYSDBOUT DD  SYSOUT=*,DCB=(RECFM=FBA,LRECL=121,BLKSIZE=12100)
//SYSOUT   DD  SYSOUT=*,DCB=(RECFM=FBA,LRECL=131,BLKSIZE=13100)
/*
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Mon Oct 25, 2004 3:31 pm    Post subject: Reply with quote

nguyenh,

If I understand correctly you are sort fields vary depending upon the contents of the file.
Code:

if colums 33-38 contains "member"
then sort fields=(k1,k2,k3,k4,k5,k6)

if column 77-78 contain "TT"
then sort fields=(k7,k8,k9,k10,k11,k12)

if column 69-70 contain "DL"
then sort fields=(k13,k14,k15,k16,k17,k118)

Can the input file have records which match more than 1 condition? i.e one of the record in the input file has "member" at pos 33 and 'tt' in pos 77 and "DL" in pos 69

How do you intend to sort such records?

Also post the position , format for the key values k1 thru k18.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nguyenh
Beginner


Joined: 09 Mar 2004
Posts: 52
Topics: 6

PostPosted: Tue Oct 26, 2004 11:22 am    Post subject: Reply with quote

Hi Kolusu,
First Thank you for your helps,
It's kind wording to explain. here is the actual original COBOL code that I want to replace with File-Aid step. Hope that it helps to explain what I am trying to say. You may delete the code if you think it is too long for this post. Sorry I am not trying to get you do my work, but if you can help me with some hints. I am very appreciated.
Quote:

If I understand correctly you are sort fields vary depending upon the contents of the file.

The answer to this one is yes you are correct.
Quote:

Can the input file have records which match more than 1 condition? i.e one of the record in the input file has "member" at pos 33 and 'tt' in pos 77 and "DL" in pos 69

Not like the one that you provided, because "MEMBER" only appears in these lines:
Code:

********************************MEMBERBFS     **********************************
********************************MEMBERFILEHDR **********************************
********************************MEMBERFILE01  **********************************
********************************MEMBERFILE02  **********************************
********************************MEMBERFILE03  **********************************
and so on...


but yes I think it could have something like
"DL" in 69-70 and "TT" in 77-78, and so on

Code:

 FD  WRK
           RECORD CONTAINS 080 CHARACTERS
           BLOCK CONTAINS 0 RECORDS
           LABEL RECORDS ARE OMITTED
           DATA RECORD IS WORK.
       01  WORK                                PIC X(080).
       FD  OUTT
           RECORD CONTAINS 086 CHARACTERS
           BLOCK  CONTAINS 0 RECORDS
           LABEL RECORDS ARE OMITTED
           DATA RECORD IS OP.
       01  OP                                  PIC X(086).
       SD  SORTE
           RECORD CONTAINS 108 CHARACTERS
           DATA RECORD IS SORRT.
       01  SORRT.
           05  S-SORT                              PIC X(80).
           05  K0                                  PIC X(06).
           05  K1.
               10 K-BLK                            PIC X(1).
               10 K-FST                            PIC X(3).
               10 K-LST                            PIC X(6).
           05  K2                                  PIC X(2).
           05  K3                                  PIC X(4).
           05  K4                                  PIC X(2).
           05  K5                                  PIC 9(7) COMP-3.
       WORKING-STORAGE SECTION.
       01  IP-REC      VALUE 0                 PIC 9(10).
       01  OP-REC      VALUE 0                 PIC 9(10).
       01  FL-CNT      VALUE 0                 PIC 9(02).
       01  SW-MEM      VALUE 0                 PIC 9(02).
       01  WS-K5       VALUE 0                 PIC 9(07)    COMP-3.
       01  BLANK80     VALUE SPACES            PIC X(80).
       01  SAVE-KEY    VALUE SPACES            PIC X(06).
       01  SAVE-REC    VALUE SPACES            PIC X(80).
       01  OLD-MSID                            PIC X(10).
       01  OLD-KEY.
           05  O-NUM                           PIC X(4).
           05  O-MSID                          PIC X(10).
       01  NEW-KEY.
           05  N-NUM                           PIC X(4).
           05  N-MSID                          PIC X(10).

       01  TA-KEY.
           05  T-NUM                           PIC X(4).
           05  T-FILR   VALUE SPACES           PIC X(6).

       01  OLD-IP.
           05  O-RECORD.
               10  O-NO.
                   20  O-LET                       PIC X(01).              1-1
                   20  O-FST                       PIC X(03).              2-4
                   20  O-LST                       PIC X(06).              5-10
               10  O-FMT                           PIC X(04).             11-14
               10  O-KEY6                          PIC X(01).             15-15
               10  FILLER                          PIC X(17).             16-32
               10  O-MEM                           PIC X(06).             33-38
               10  FILLER                          PIC X(06).             39-44
               10  O-FILE                          PIC X(02).             45-46
               10  FILLER                          PIC X(07).             47-53
               10  O-KEY5                          PIC X(04).             54-57
               10  O-KEY11                         PIC X(04).             58-61
               10  O-KEY4                          PIC X(04).             62-65
               10  O-KEY1                          PIC X(03).             66-68
               10  O-KEY2                          PIC X(02).             69-70
               10  O-KEY3                          PIC X(02).             71-72
               10  O-PREFIX                        PIC X(04).             73-76
               10  O-CT.                                                  77-80
                   20  O-TYP                       PIC X(02).             77-78
                   20  O-SEQ                       PIC X(02).             79-80
               10  O-KEY                           PIC X(06).             81-85
       01  INN-IP.
           05  I-RECORD.                                                   1-10
               10  I-NO.
                   20  I-LET                       PIC X(01).              1-1
                   20  I-FST                       PIC X(03).              2-4
                   20  I-LST                       PIC X(06).              5-10
               10  R-NO REDEFINES I-NO.
                   20  R-FST                       PIC X(04).              1-1
                   20  R-LST                       PIC X(06).              5-10
               10  T-NO REDEFINES I-NO.
                   20  T-FST                       PIC X(01).              1-1
                   20  T-FMT                       PIC X(04).              5-10
                   20  T-LST                       PIC X(05).              5-10
               10  I-FMT                           PIC X(04).             11-14
               10  I-KEY6                          PIC X(01).             15-15
               10  FILLER                          PIC X(17).             16-32
               10  I-MEM                           PIC X(06).             33-38
               10  I-FILE                          PIC X(06).             39-44
               10  FILLER                          PIC X(09).             45-53
               10  I-KEY5                          PIC X(04).             54-57
               10  I-KEY11                         PIC X(04).             58-61
               10  I-KEY4                          PIC X(04).             62-65
               10  I-KEY1                          PIC X(03).             66-68
               10  I-KEY2                          PIC X(02).             69-70
               10  I-KEY3                          PIC X(02).             71-72
               10  I-PREFIX                        PIC X(04).             73-76
               10  I-CT.                                                  77-80
                   20  I-TYP                       PIC X(02).             77-78
                   20  I-SEQ                       PIC X(02).             79-80

       PROCEDURE DIVISION.
       CALL-HEADER.
           OPEN INPUT WRK.
           OPEN OUTPUT OUTT.
           PERFORM 3001-FRM-WORD-SORT
           CLOSE WRK.
           CLOSE OUTT.
           DISPLAY IP-REC.
           STOP RUN.
       3001-FRM-WORD-SORT.
           SORT SORTE ON ASCENDING KEY K0 K1 K2 K3 K4 K5
               INPUT  PROCEDURE IS 3010-READ THRU 3020-SORT
               OUTPUT PROCEDURE IS 3040-RETURN-RECORD THRU 3999-CLOSE.
       3010-READ                SECTION.
           MOVE SPACE TO SORRT.
           MOVE SPACE TO K1.
           MOVE SPACE TO K2.
           MOVE SPACE TO K3.
           MOVE SPACE TO K4.
           READ WRK INTO INN-IP AT END GO TO 3020-SORT.
           MOVE I-RECORD TO SAVE-REC.
           ADD 1 TO IP-REC.
           ADD 1 TO WS-K5.
           IF (I-RECORD = BLANK80) GO TO 3010-READ.
           IF (I-MEM = 'MEMBER')
               PERFORM BUILD-KEY
               GO TO 3010-READ.
           IF (I-MEM = 'MEMBER') NEXT SENTENCE ELSE MOVE 0 TO SW-MEM.
           MOVE SAVE-KEY TO K0.
           MOVE I-TYP    TO K2.
           MOVE I-SEQ    TO K4.
           MOVE WS-K5    TO K5.
           IF (I-LET = ' ')
               MOVE I-FST TO K-FST
             ELSE
               MOVE I-NO TO K1.
           IF (I-TYP = 'TT')
               MOVE I-FMT TO K3
             ELSE
               MOVE '    ' TO K3.
           IF (I-TYP = 'CA')
               MOVE I-PREFIX TO K3.
           IF (I-KEY2 = 'DL') MOVE R-FST TO K3.
           IF (I-KEY2 = 'FM') MOVE I-CT  TO K3.
           IF (I-TYP  = 'TB' OR 'TA' OR 'TC')
               MOVE T-FMT TO TA-KEY
               MOVE TA-KEY TO K1.
           IF (I-TYP  = 'TB' OR 'TA' OR 'TC') MOVE T-FMT TO K3.
           MOVE I-RECORD TO S-SORT.
           RELEASE SORRT.
           MOVE SPACE TO SORRT.
           GO TO 3010-READ.
       BUILD-KEY.
           IF (SW-MEM = 1) MOVE SAVE-REC TO S-SORT
                           MOVE SAVE-KEY TO K0
                           RELEASE SORRT
                           MOVE SPACE TO SORRT.
           ADD 1 TO FL-CNT.
           MOVE I-FILE TO SAVE-KEY.
           MOVE 1 TO SW-MEM.
       3020-SORT                SECTION.
           MOVE SAVE-KEY TO K0.
           MOVE I-RECORD TO S-SORT.
           RELEASE SORRT.
           MOVE SPACE TO SORRT.
           DISPLAY IP-REC.
       3040-RETURN-RECORD       SECTION.
           RETURN SORTE RECORD AT END GO TO 3999-CLOSE.
           MOVE S-SORT TO O-RECORD.
           MOVE K0     TO O-KEY.
           ADD 1 TO OP-REC.
           WRITE OP FROM O-RECORD.
      *    DISPLAY '**** O-RECORD = ' O-RECORD.
           GO TO 3040-RETURN-RECORD.
       3999-CLOSE               SECTION.
           DISPLAY OP-REC.   
Back to top
View user's profile Send private message
nguyenh
Beginner


Joined: 09 Mar 2004
Posts: 52
Topics: 6

PostPosted: Tue Nov 09, 2004 10:29 am    Post subject: Reply with quote

Hi Kolusu,
First, could you please delete my last post. since it would help anyone with I think there was too much uneccessary information there.

Here is the question that i have.

How to use fileaid to peform this sort. assume sort keys are K0-K5:
I want to sort the input file in orders keys K0-K5 base on the following conditions:
Code:

K0 = columns (39-44)

If (column 1 is blank, Or columns 77-78 = "TA", "TB", or "TC")
    K1 = columns (11-14)
Else
   K1= columns(1-10)

K2 = columns (77-78)

If columns (77-78)  =  "TA", "TB", "TC" or "TT"
   K3 = columns (11-14)
ElseIf columns (77-78)  = "CA"
   K3 = columns (73-76)
ElseIf columns (77-78)  = "DL"
   K3 = columns (1-4)
ElseIf columns (77-78)  = "FM"
   K3 = blank

K4 = (79-80)

K5 = Record counts (record's order)

Is this possible to do that using FILEAID ?
Thank you!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group