Mainframe programming using DFSORT

I am trying to add a header to a mainframe file and I found this:

SORT FIELDS=COPY
OUTFIL REMOVECC,
HEADER1=(1:C'COUNTRY_CODE',13:C',',14:C'CHECK_SEQ_NUMBER',30:C',',
         31:C'FORM_INDICATOR')
OUTREC BUILD=(1:1,2,3:C',',4:4,5,9:C',',10:10,1,80:X)

Do I need the 2nd AND 5th row? What will the 5th accomplish?

Sorry I am leaning how to write code for the mainframe.

Upvotes: 0

Views: 2181

Answers (2)

Karthick
Karthick

Reputation: 662

@William Edward Sanchez-Weeks , Also you don't need to do the math by counting the position when you do BUILD with data and header you have. SORT will handle it internally.

Sort card you posted:

SORT FIELDS=COPY
OUTFIL REMOVECC,
HEADER1=(1:C'COUNTRY_CODE',13:C',',14:C'CHECK_SEQ_NUMBER',30:C',',
     31:C'FORM_INDICATOR')
OUTREC BUILD=(1:1,2,3:C',',4:4,5,9:C',',10:10,1,80:X)

can be written as

SORT FIELDS=COPY
OUTFIL REMOVECC,
HEADER1=(C'COUNTRY_CODE',C',',C'CHECK_SEQ_NUMBER',C',',C'FORM_INDICATOR')
OUTREC BUILD=(1,2,C',',4,5,C',',10,1,80:X)

Both gives same result.

Upvotes: 1

user6542823
user6542823

Reputation: 1476

The 'CC' in REMOVECC stands for carriage control character. These characters are needed to create printable reports. But if you don't need that character (we mostly don't) then you can suppress them by using REMOVECC. So, you may want to keep the 2nd Line.

HEADER1 builds the header with columns as you mentioned, COUNTRY_CODE etc. This header is Not present in your input dataset, so you are creating this new record in the output dataset.

And, then you are copying your input records to output (after header) via OUTREC. So, you want to keep Line 5 as well.

.

Upvotes: 1

Related Questions