Page 1 of 1

Copy file using DFSORT based on a value

PostPosted: Mon Sep 28, 2015 7:06 pm
by nkulkarni
Hi,

I have an input file which contains lot of data (80 bytes length) about the return code information of steps of a batch job.

Number of records in input file vary depending on the number of steps in every batch job, a string "BAD RC" is placed in the file in any random position if any of the step in the job has produced an unacceptable return code.

My requirement is to read and copy the content of the input file only if at least one "BAD RC" string is found anywhere in the file ELSE a string "DUMMY" needs to be written to output.

If Input is as below

A
AB
ABC BAD RC
ABCD
ABCDEF

then output should be the same

A
AB
ABC BAD RC
ABCD
ABCDEF

If input is as below

A
AB
ABC
ABCD
ABCDEF

then the output should be

DUMMY

Could anyone please inform me if this can be done using DFSORT and if so then how?

Re: Copy file using DFSORT based on a value

PostPosted: Thu Oct 08, 2015 6:34 pm
by nkulkarni
Hi,

Above requirement is quite challenging, anyone's help is much appreciated...

Re: Copy file using DFSORT based on a value

PostPosted: Thu Oct 08, 2015 6:40 pm
by enrico-sorichetti
we reply on our own time and free of charge
soliciting for answers is just lowering the willingness of people to help You

Re: Copy file using DFSORT based on a value

PostPosted: Thu Oct 08, 2015 8:26 pm
by BillyBoyo
And you already asked this elsewhere, so I thought you weren't keen on answers here.

Re: Copy file using DFSORT based on a value

PostPosted: Thu Oct 08, 2015 8:56 pm
by BillyBoyo
//GENDUMMY EXEC PGM=SORT
//SYMNAMES DD *
DUMMY-TEXT,C'DUMMY'
//SYMNOUT  DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD DISP=(,PASS),DSN=&&DUMMY,
// UNIT=SYSDA,SPACE=(TRK,1)
//SORTIN DD *
A
AB
ABC BAD RC
ABCD
ABCDEF
//SYSIN    DD *
  OPTION COPY,STOPAFT=1
                                       
  INREC BUILD=(DUMMY-TEXT,80:X)
//ONLYBAD  EXEC PGM=SORT
//SYMNAMES DD *
DUMMY-TEXT,C'DUMMY'
F1-DATA,1,80,CH
F2-DATA-FOR-SS,=,80
EXT-F1-KEY,*,1,CH
POSITION,F1-DATA
SKIP,79
LAST-REC-BYTE,*,1,CH
F2-KEY,1,1,CH
F2-DUMMY-POSITION,1,5,CH
F2-SEQ,*,5,CH
KEY-OF-ONE-TO-MATCH,C'1'
KEY-TO-NOT-MATCH,C'5'
ONLY-ON-F2,C'2'
SS-SEARCH-VALUE,C'BAD RC'
//SYMNOUT  DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  JOINKEYS F1=INA,FIELDS=(EXT-F1-KEY,A),SORTED,NOSEQCK
  JOINKEYS F2=INB,FIELDS=(F2-KEY,A)
  JOIN UNPAIRED,F2
  REFORMAT FIELDS=(F1:F1-DATA,?)
                                                     
  INREC IFOUTLEN=80,
        IFTHEN=(WHEN=(EXT-F1-KEY,EQ,ONLY-ON-F2),
                 BUILD=(DUMMY-TEXT,LAST-REC-BYTE:X))
                                                     
//JNF1CNTL DD *
 INREC OVERLAY=(EXT-F1-KEY:KEY-OF-ONE-TO-MATCH)
                                                     
//JNF2CNTL DD *
 INCLUDE COND=(F2-DATA-FOR-SS,SS,EQ,SS-SEARCH-VALUE,
              OR,
               F2-DUMMY-POSITION,EQ,DUMMY-TEXT)
 INREC IFTHEN=(WHEN=INIT,
        OVERLAY=(F2-SEQ:SEQNUM,5,ZD)),
       IFTHEN=(WHEN=(F2-DUMMY-POSITION,EQ,DUMMY-TEXT,
                      AND,
                     F2-SEQ,EQ,C'00001'),
                OVERLAY=(F2-KEY:KEY-TO-NOT-MATCH)),
       IFTHEN=(WHEN=NONE,
                OVERLAY=(F2-KEY:KEY-OF-ONE-TO-MATCH))
 SUM FIELDS=NONE
//INA     DD *
A
AB
ABC BAD RC
ABCD
ABCDEF
//INB DD *
A
AB
ABC
ABCD
ABCDEF
// DD DISP=(OLD,PASS),DSN=&&DUMMY

Re: Copy file using DFSORT based on a value

PostPosted: Fri Oct 09, 2015 2:16 pm
by nkulkarni
Hi BillyBoyo,

Thank you very much for the code, I'll run it and keep this thread updated about the result...