0

I have a dataset that has multiple rows of data, I have to do something with some of these rows(not all, and there is no logic to be able to pick them out), I have a list of rownumbers that have to be selected and it's too big a list to copy them all by hand.

So does anyone know a dfsort command that for example could get records from this bit of data:

parameter10000500006
parameter20000100002
parameter30000400007
parameter40000000006
parameter50000100001
parameter60000500012
parameter70000700013

And will only return me the 2nd and 3rd for example like this:

parameter20000100002
parameter30000400007
Jeremy C.
  • 2,405
  • 1
  • 12
  • 28

2 Answers2

0

Figured it out, appearantly you need to use an outfile in combination with STARTREC and ENDREC so now I can just create a bunch of outfiles for every record I need.

For record 2 and 3 it could look a bit like this:

//SYSIN DD *
 SORT FIELDS=(1,1,CH,A)
 OUTFIL STARTREC=2,ENDREC=3
/*
Bill Woodger
  • 12,968
  • 4
  • 38
  • 47
Jeremy C.
  • 2,405
  • 1
  • 12
  • 28
  • So you want the second and third records after they have been SORTed? Can you make that clear in your question, please? – Bill Woodger Jul 13 '15 at 13:46
0

If you want to do this one at a time, it would be better to use OPTION SKIPREC=1,STOPAFT=2:

 OPTION SKIPREC=1,STOPAFT=2,COPY

In your answer, you just show a plain OUTFIL statement, starting in column one. All SORT statements must start after column one. There must always be, explicit or implicit, a SORT, MERGE or COPY operation, else your step will fail.

A COPY operation can be specified as OPTION COPY or SORT FIELDS=COPY or MERGE FIELDS=COPY.

The reason it is better to do it on the OPTION statement is that the data is deleted/included at the earliest possible point.

If you, for instance, had a SORT (non-COPY) operation then your OUTFIL solution would still work, but you would have SORTed the entire file before you get to your final exclusion.

STARTREC and ENDREC will typically be seen when SKIPREC and STOPAFT cannot be used for your task because there is a SORT or MERGE happening (so you don't know which will be the first record in the new data).

On Mainframe datasets we don't have "rows" of data, we have records. It will confuse you if you consult documentation for how to deal with "rows" because outside of DB2, the term will mean nothing at best, or not what you think it means at worst.

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47
  • yes you are right, I had a sort step before that, i'll edit my answer – Jeremy C. Jul 13 '15 at 10:58
  • @JeremyC do you want to do this for more than one selection at once? – Bill Woodger Jul 13 '15 at 11:17
  • that's not really necessary, we have a rexx script that can run this jcl multiple times, it just has to be done over time (we have several weeks) all at once would take too long, we do about 10 each day during lunch when the system is less busy – Jeremy C. Jul 13 '15 at 11:20
  • I was wondering if you could take a look at this question: http://stackoverflow.com/questions/31381336/dfsort-findrep-a-short-string-with-longer-without-overwriting-next-column you seem to be the only person right now (that is online) who knows a bit about dfsort and maybe you can help me out with this – Jeremy C. Jul 13 '15 at 11:22