Copy file using DFSORT based on a value



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Copy file using DFSORT based on a value

Postby nkulkarni » Mon Sep 28, 2015 7:06 pm

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?
NK
nkulkarni
 
Posts: 52
Joined: Mon Sep 28, 2015 2:28 pm
Has thanked: 17 times
Been thanked: 0 time

Re: Copy file using DFSORT based on a value

Postby nkulkarni » Thu Oct 08, 2015 6:34 pm

Hi,

Above requirement is quite challenging, anyone's help is much appreciated...
NK
nkulkarni
 
Posts: 52
Joined: Mon Sep 28, 2015 2:28 pm
Has thanked: 17 times
Been thanked: 0 time

Re: Copy file using DFSORT based on a value

Postby enrico-sorichetti » Thu Oct 08, 2015 6:40 pm

we reply on our own time and free of charge
soliciting for answers is just lowering the willingness of people to help You
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Copy file using DFSORT based on a value

Postby BillyBoyo » Thu Oct 08, 2015 8:26 pm

And you already asked this elsewhere, so I thought you weren't keen on answers here.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Copy file using DFSORT based on a value

Postby BillyBoyo » Thu Oct 08, 2015 8:56 pm

//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
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Copy file using DFSORT based on a value

Postby nkulkarni » Fri Oct 09, 2015 2:16 pm

Hi BillyBoyo,

Thank you very much for the code, I'll run it and keep this thread updated about the result...
NK
nkulkarni
 
Posts: 52
Joined: Mon Sep 28, 2015 2:28 pm
Has thanked: 17 times
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post