Page 1 of 1

Reformat OutPut File

PostPosted: Fri Apr 19, 2013 11:30 pm
by rayngerfan
Hi

I have two files FB,LRECL=80. File 1 has data starting in COL 1 – 18 & file 2 has data starting in col 37 – 65. Both file contain 80 records. I would like to copy the records from file 1 as is and overlay the records in file 2 starting in col 20. I tried using the REFOMAT paramter but I can't get the records from file 2 to be rewitten in col 20 with the data from file 1. I was thinking that this might be possible with the overlay parameter? Any help is greatly appreciated.

I/P FILE1 (80 RRECORDS cols 1-18)

NAXXXXXX HAABWIL I
NAXXXXXX BATOSHO A

I/P FILE2 (80 RECORDS COLS 37 – 70)

                                                  Able WILSON
                                                  Thomas Shoe   


O/P FILE

NAXXXXXX HAABWIL I Able WILSON
NAXXXXXX BATOSHO A Thomas Shoe


Code'd

Re: Reformat OutPut File

PostPosted: Sat Apr 20, 2013 2:40 am
by MrSpock
Sounds to me like a good case for using JOINKEYS. Make one pass of each of the files to add sequence numbers to each so you have a key to join. Use JOINKEYS, and just reformat the resulting output.

Re: Reformat OutPut File

PostPosted: Sat Apr 20, 2013 3:58 am
by BillyBoyo
Yes, JOINKEYS. However, is your SyncSort the latest, which does support JNFnCNTL files, needed to do the sequence number in one step? If not, you'll need to add the sequence numbers in two separate steps, then do the JOINKEYS and doing your data-arranging with REFORMAT (which only works with JOINKEYS).

Re: Reformat OutPut File

PostPosted: Sat Apr 20, 2013 10:34 pm
by rayngerfan
I was able to add squence numbers as Suggested and then use the JOINKEY parameter. Is it possible when reformation to get the 2nd file data to start in col 20?

//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(81,4,A)
JOINKEYS FILES=F2,FIELDS=(81,4,A)
REFORMAT FIELDS=(F1:1,18,F2:20,37)
SORT FIELDS=COPY

O/P/F                                              2nd file
1                            18               37                             80
NASUBMIT HAABWIL I                 ABLE WILSON
NASUBMIT BATOSHO A                THOMAS SHOE

Re: Reformat OutPut File

PostPosted: Sat Apr 20, 2013 11:49 pm
by BillyBoyo
No, the REFORMAT can only include data from the JOINKEYS files.

You can instead:

  INREC BUILD=(1,18,2X,19,37)

Re: Reformat OutPut File

PostPosted: Sun Apr 21, 2013 2:30 am
by rayngerfan
Hi BillyBoyo

I was able to get the results using this card.

INREC BUILD=(1,18,19:35,15)

I appreciate your time & help.

Re: Reformat OutPut File

PostPosted: Sun Apr 21, 2013 4:05 am
by BillyBoyo
OK. On your REFORMAT it is best to have only the data you need. If you don't need 37 bytes of file 2, but only 15 instead, put 19,15 on the REFORMAT.

Using the column on the BUILD will work, it will pad two spaces in between the data file file 1 and the start of the data from file 2.

The difference between that and specifying the two spaces (2X) comes when you need to change something. In your case it doesn't matter, but if you had more than one field after your column number, each with their own column number, then they'd all have to change if, for instance, the length of the file 1 data has to change for some reason. So, for me, the 2X is easier to maintain.