Page 1 of 1

SORT Help

PostPosted: Fri Apr 29, 2011 3:00 am
by SpadoBeans
I posted a while back to parse out characters in between 'DOC' and 'INDEX' for a fixed 80 byte record and this is what I received:

SORT FIELDS=COPY
INCLUDE COND=(1,3,CH,EQ,C'DOC')
INREC PARSE=(%01=(STARTAFT=C'DOC',ENDBEFR=C'INDEX',FIXLEN=80)),
BUILD=(%01,JFY=(SHIFT=LEFT))

I now need to accomplish a similar task but am using a variable length record instead of fixed. This time I'd like to take what's in between 'DocumentId</EventAttributeName> <EventAttributeValue>' and '</EventAttributeValue>' and I'm not sure how it changes the above control card for a variable length file.

Here is what the input looks like and what I want to strip out of it and sort:

Input:
DocumentId</EventAttributeName> <EventAttributeValue>RENEW70D</EventAttributeValue>

Output:
RENEW70D

Any help is greatly appreciated.

Re: SORT Help

PostPosted: Fri Apr 29, 2011 5:38 am
by Frank Yaeger
What is the RECFM and LRECL of your input file?

What do you want for the RECFM and LRECL of your output file?

Does the INCLUDE need the entire string of 'DocumentId</EventAttributeName> <EventAttributeValue>' or can it just use something shorter like 'DocumentId'?

What is the maximum length of the field you want to extract?

Re: SORT Help

PostPosted: Mon May 02, 2011 7:32 pm
by SpadoBeans
Input file - RECFM = VB, and LRECL - 32746.

I want the output file to be RECFM = FB and LRECL - 80 bytes.

The field that I want to take out of this file will always be in between 'DocumentId</EventAttributeName> <EventAttributeValue>' and '</EventAttributeValue>'.

The max length of the field that I want to extract can be 20 bytes.

Re: SORT Help

PostPosted: Tue May 03, 2011 12:19 am
by Frank Yaeger
Here's a DFSORT job that will do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (VB/32746)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN DD *
  OPTION COPY,VLSCMP
  INCLUDE COND=(5,32700,SS,EQ,
   C'DocumentId</EventAttributeName> <EventAttributeValue>')
  INREC PARSE=(%01=(FIXLEN=20,
  STARTAFT=C'DocumentId</EventAttributeName> <EventAttributeValue>',
  ENDBEFR=C'</EventAttributeValue>')),
  BUILD=(1,4,%01)
  OUTFIL VTOF,BUILD=(5,20,80:X)
/*