Page 1 of 1

Data alignment

PostPosted: Mon Apr 23, 2012 2:48 pm
by jvinoth
Hi i need to align my fileds from left to right alignment,

Please tell me how to do that

my unload sort card

SELECT A.UN_NO,               CHAR('|'),         
 A.ID_NO,                      CHAR('|'),         
 B.LST_NM,                     CHAR('|'),         
 SUBSTR(CHAR(COUNT(*)),1,3),   CHAR('|')         
 FROM table1 a , table2 b           
 WITH UR;

and the formatting sort card


    SORT FIELDS=COPY                             
    OUTREC FIELDS=(01:01,08,09:09,08,17:17,17,   
          34:34,3)

in this the position i need to change is that 34:34,3



output data

0004000|000000.|............    |8 
0004000|000000.|............    |82
0004000|000000.|............    |823
0004000|000000.|............    |8
0004000|000000.|............    |564
0004000|000000.|............    |5



thanks

Re: Data alignment

PostPosted: Mon Apr 23, 2012 3:19 pm
by BillyBoyo
You could try applying this:

//EDITNUM  EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INREC OVERLAY(1:1,3,UFF,EDIT=(TTT))
//SORTIN DD *
1
12
123


Gives:

001
012
123


OUTREC FIELDS=(01:01,08,09:09,08,17:17,17,   
          34:34,3)


The above is much easier to follow as:

OUTREC FIELDS=(01:01,08,09,08,17,17,   
          34,3)


Other than the first column number, all the column numbers you are specifying at at the point where the next data would go anyway, so are not needed, are confusing if used because not needed, are more difficult to read, and introduce another element of potential error through typo.

Taking them all out, you realise more easily that you are just copying the data that is already there to the same positions.

OUTREC FIELDS=(34:34,3,UFF,EDIT=(TTT))


is probably all you need.

Re: Data alignment

PostPosted: Mon Apr 23, 2012 5:25 pm
by jvinoth
thank you so much billy for your quik reply

Re: Data alignment

PostPosted: Mon Apr 23, 2012 11:33 pm
by BillyBoyo
Jeepers. Just noticed you have FIELDS. From all the columns I just thought it was an OVERLAY. There we go.

You probably want to use OVERLAY instead of the FIELDS for this anyway, but the FIELDS= I gave will not give you what you want. As far as I understand it, FIELDS and BUILD are the same in this context. If you just want to change part of the data you have, OVERLAY will do that without having to be concerned about the other data on the record.