Page 1 of 2

How to find the number of records altered using DFSORT

PostPosted: Tue Apr 12, 2011 10:01 pm
by Prasanna G
Hi all,

I have one flat file of LRECL 80 with the following records.

AAAAAAAAAAAAAAAAA72BBBBBB.....
AAAAAABBBBBCCCCCCC76BBBBBB....
AAAAAACCCCCCCCCCC72CCBBBB....
AAAAAACCCCCCBBCCC72BBBBBB....
BBBCCCCCCCCCCCCCC76BBBBBB....

The characters 72 and 76 appear in the input file at the same position say 18. I would like to change 72 to 63 and 76 to 66 using a SORT card.
After changing I would like to know how many 72 got changed to 63 and how many 76 got changed to 66 in the SORT step itself.
Is it possible to find the count?

Thanks
Prasanna G

Re: How to find the number of records altered using DFSORT

PostPosted: Tue Apr 12, 2011 10:39 pm
by Frank Yaeger
Well, it would have been helpful if you'd shown your expected output, but assuming you just want the counts on a separate line at the end, you can use a DFSORT job like the following:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAAAAAAAAAAAAAAAA72BBBBBB.....
AAAAAABBBBBCCCCCC76BBBBBB....
AAAAAACCCCCCCCCCC72CCBBBB....
AAAAAACCCCCCBBCCC72BBBBBB....
BBBCCCCCCCCCCCCCC76BBBBBB....
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'00')),
   IFTHEN=(WHEN=(18,2,CH,EQ,C'72'),
    OVERLAY=(18:C'63',81:C'1')),
   IFTHEN=(WHEN=(18,2,CH,EQ,C'76'),
    OVERLAY=(18:C'66',82:C'1'))
  OUTFIL REMOVECC,BUILD=(1,80),
    TRAILER1=(/,'72 TO 63 COUNT = ',TOT=(81,1,ZD,M10,LENGTH=5),
                ', 76 TO 66 COUNT = ',TOT=(82,1,ZD,M10,LENGTH=5))
/*

Re: How to find the number of records altered using DFSORT

PostPosted: Tue Apr 12, 2011 10:58 pm
by Prasanna G
Thanks for a quick reply Frank.. I should have been more clear in my previous post.
As this is my first post, I was not aware the way of asking questions.
Is it possible to generate a report of the below format using SORT?

PROGRAM-R01 XYZ COMPANY PAGE: 1
RUN DATE: 10/26/06 HARTFORD STANDARD REPORT
RUN TIME: 09:12:41 EDITED FILE TRANSACTION CONVERSION
CONTROL REPORT

1.0 TOTAL RECORDS READ: 100
2.0 TOTAL HEADER RECORDS READ: 1
3.0 TOTAL RECORDS 72 TRNS CODE CONVERTED TO 63: 2
4.0 TOTAL RECORDS 76 TRNS CODE CONVERTED TO 66: 3
5.0 TOTAL UNPROCESSED RECORDS: 90


*** END OF REPORT ***

Re: How to find the number of records altered using DFSORT

PostPosted: Tue Apr 12, 2011 11:19 pm
by Frank Yaeger
Well, yes, you can do that with OUTFIL. But if you want me to show you how, you need to tell me where the various information comes from. What would be hardcoded (Program name, Company name, etc)?. What does the header record count represent? I don't see any header records in your example input.

Please show me a better example of the records in your input file (with headers) and what you expect for output and explain the rules for getting from input to output.

Re: How to find the number of records altered using DFSORT

PostPosted: Wed Apr 13, 2011 1:27 am
by Prasanna G
Yes Frank.
This is how the exact input file will look like.

AAAAAAHEADER                     102010                               
H1036799    ANDERSON    TIM     119220101 172SH06302010121561  20101215
H1036800    ANDERSON    JIM     119220101 176SH06302010121561  20101215


Except the Time, Date and Counter values all others are constants in the control report. The rule for getting them in the output file is copy all the records from the input file with transaction codes 72 converted to 63 and 76 to 66 and all other trans codes left untouched.

Please let me know if my requirement is not clear.
Thanks in advance.

Re: How to find the number of records altered using DFSORT

PostPosted: Wed Apr 13, 2011 1:48 am
by Frank Yaeger
That doesn't help much. I wanted to see a good example of the input records (e.g. more than one header, records to be processed, records not to be processed), and the expected output for those input records so I could tell what you really wanted. Please show such an example of input and output.

Also:

Is there only one header record or can there be more than one?

Is a header record identified by 'HEADER' in positions 7-12 or by something else (what)?

Do the '72' and '76' appear in positions 44-45 or somewhere else (where)?

Re: How to find the number of records altered using DFSORT

PostPosted: Wed Apr 13, 2011 2:15 am
by Prasanna G
1. The input will have only one header.
2. The header will always start with AAAAAAHEADER in position 1 of the file
3. The transaction codes appear only in position 44-45

Input File:
AAAAAAHEADER                     102010                                 
H1036799    ANDERSON    TIM     119220101 172SH06302010121561  20101215
H1036800    ANDERSON    JIM     119220101 176SH06302010121561  20101215
H1036801    TAMMY       TIM     119220101 161SH06302010121561  20101215
H1036802    RINONLD     BOB     119220101 176SH06302010121561  20101215
H1036803    PETER       PRKER   119220101 172SH06302010121561  20101215
H1036804    DONALD      MC      119220101 163SH06302010121561  20101215



Output File:
AAAAAAHEADER                     102010                                 
H1036799    ANDERSON    TIM     119220101 163SH06302010121561  20101215
H1036800    ANDERSON    JIM     119220101 166SH06302010121561  20101215
H1036801    TAMMY       TIM     119220101 161SH06302010121561  20101215
H1036802    RINONLD     BOB     119220101 166SH06302010121561  20101215
H1036803    PETER       PRKER   119220101 163SH06302010121561  20101215
H1036804    DONALD      MC      119220101 163SH06302010121561  20101215



After creating the output file, I need the control report in the below format.
PROGRAM-R01                             XYZ COMPANY                                          PAGE: 1
RUN DATE: 10/26/06                     HARTFORD                                   STANDARD REPORT
RUN TIME: 09:12:41           EDITED FILE TRANSACTION CONVERSION
                                              CONTROL REPORT

1.0 TOTAL RECORDS READ: 100
2.0 TOTAL HEADER RECORDS READ: 1
3.0 TOTAL RECORDS 72 TRNS CODE CONVERTED TO 63: 2
4.0 TOTAL RECORDS 76 TRNS CODE CONVERTED TO 66: 3
5.0 TOTAL UNPROCESSED RECORDS: 90


                                                 *** END OF REPORT ***

Re: How to find the number of records altered using DFSORT

PostPosted: Wed Apr 13, 2011 2:57 am
by Frank Yaeger
Sigh. I wanted you to show me the corresponding output for your input example. You show 100 records read but I only see 7 input records in your example. So shouldn't it be 7 records read (or 6 depending on whether you want to count the header)? Please, please show me the correct expected values for the control report so I can verify that I understand what you're trying to do. That is, fill in the correct values for the question marks here:

1.0 TOTAL RECORDS READ: ?
2.0 TOTAL HEADER RECORDS READ: ?
3.0 TOTAL RECORDS 72 TRNS CODE CONVERTED TO 63: ?
4.0 TOTAL RECORDS 76 TRNS CODE CONVERTED TO 66: ?
5.0 TOTAL UNPROCESSED RECORDS: ?

based on your input example of:

AAAAAAHEADER                     102010
H1036799    ANDERSON    TIM     119220101 172SH06302010121561  20101215
H1036800    ANDERSON    JIM     119220101 176SH06302010121561  20101215
H1036801    TAMMY       TIM     119220101 161SH06302010121561  20101215
H1036802    RINONLD     BOB     119220101 176SH06302010121561  20101215
H1036803    PETER       PRKER   119220101 172SH06302010121561  20101215
H1036804    DONALD      MC      119220101 163SH06302010121561  20101215


Please take some time and get it right so I don't have to ask again. I shouldn't have to guess.

Re: How to find the number of records altered using DFSORT

PostPosted: Wed Apr 13, 2011 3:02 am
by Prasanna G
Am extremely sorry Frank.
Here is what the control report has to look like for the input file that I have provided previously

1.0 TOTAL RECORDS READ: 7
2.0 TOTAL HEADER RECORDS READ: 1
3.0 TOTAL RECORDS 72 TRNS CODE CONVERTED TO 63: 2
4.0 TOTAL RECORDS 76 TRNS CODE CONVERTED TO 66: 2
5.0 TOTAL UNPROCESSED RECORDS: 2

Re: How to find the number of records altered using DFSORT

PostPosted: Wed Apr 13, 2011 4:24 am
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//OUT DD DSN=...     output file (FB/80)
//RPT DD DSN=...     control file (FB/120)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'000')),
   IFTHEN=(WHEN=(7,6,CH,EQ,C'HEADER'),
    OVERLAY=(81:C'000')),
   IFTHEN=(WHEN=(44,2,CH,EQ,C'72'),
    OVERLAY=(44:C'63',81:C'1')),
   IFTHEN=(WHEN=(44,2,CH,EQ,C'76'),
    OVERLAY=(44:C'66',82:C'1')),
   IFTHEN=(WHEN=NONE,
    OVERLAY=(83:C'1'))
  OUTFIL FNAMES=OUT,BUILD=(1,80)
  OUTFIL FNAMES=RPT,REMOVECC,NODETAIL,
    OVERLAY=(120:X),
    TRAILER1=('PROGRAM-R01',41:'XYZ COMPANY',
      94:'PAGE: ',PAGE=(M10,LENGTH=3),/,
     'RUN DATE: ',DATE=(MDY/),40:'HARTFORD',83:'STANDARD REPORT',/,
     'RUN TIME: ',TIME=(24:),30:'EDITED FILE TRANSACTION CONVERSION',
     /,47:'CONTROL REPORT',/,X,/,
     '1.0 TOTAL RECORDS READ: ',COUNT=(M10,LENGTH=8),/,
     '2.0 TOTAL HEADER RECORDS READ:         1',/,
     '3.0 TOTAL RECORDS 72 TRNS CODE CONVERTED TO 63: ',
       TOT=(81,1,ZD,M10,LENGTH=8),/,
     '4.0 TOTAL RECORDS 76 TRNS CODE CONVERTED TO 66: ',
       TOT=(82,1,ZD,M10,LENGTH=8),/,
     '5.0 TOTAL UNPROCESSED RECORDS: ',
       TOT=(83,1,ZD,M10,LENGTH=8),/,X,/,X,/,
       50:'*** END OF REPORT ***')
/*