MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

left justification of a character field

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
doubt_man
Beginner


Joined: 12 Mar 2004
Posts: 15
Topics: 6

PostPosted: Tue Mar 30, 2004 1:57 am    Post subject: left justification of a character field Reply with quote

hi all,
i wanted to convert a packed decimal field to charecter. so i used the following sort card fot that

SORT FIELDS=(1,03,BI,A),EQUALS
OUTREC FIELDS=(1:1,107,108:108,5,PD,EDIT=(IIIIIIIII),
117:113,49,166:C'1100')

now the converted field is appearing in the file as follows

MD---21212
NC---28105
LA---70130
LS---70130

the one showed in bold is converted field.
but i want it to be left justified. ie if we take the first one as example , it should be like MD21212---
is there any way to do this??
I went thru the editting characters to see wether we can do this. but i couldnt find it.
thanks
doubt_man
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Mar 30, 2004 6:52 am    Post subject: Reply with quote

Doubt_man,

Quote:

SORT FIELDS=(1,03,BI,A),EQUALS
OUTREC FIELDS=(1:1,107,108:108,5,PD,EDIT=(IIIIIIIII),
117:113,49,166:C'1100')


A couple of errors in your sort card. First thing is you don't have 3 bytes of binary field. BInary field can be 2,4, 8 bytes. so first check that.

You used edit mask iiii which means to supress the leading zero. If you want the number then you just put all TTTTTTT which will print the number.Try the following sort card.

Code:

 SORT FIELDS=(1,03,CH,A)           
 OUTREC FIELDS=(1,107,             
               108,5,PD,EDIT=(TTTTTTTTT),
               1113,49,
               C'1100')



Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
doubt_man
Beginner


Joined: 12 Mar 2004
Posts: 15
Topics: 6

PostPosted: Tue Mar 30, 2004 7:07 am    Post subject: Reply with quote

hi kolsu,
thanks for the response. but the problem is that if we use EDIT=(TTTTTTTTT) the output will be (if we take the first record) MD00021212 . but i dont want that. The real problem is that i want to load the ouptput of this step to the database. so if the field is ---21212 , we cannot give a querry based on that.( This happens to be the zip code). so if in a querry we give WHERE ZIP='21212', it would not get me the row. thats why i am trying to put the number first followed by the spaces(in this case 21212---). i think you understand the requirement.
And regarding the error in the sort card, i wonder how it worked earlier. Actually the first and third line of the sort card ie

SORT FIELDS=(1,03,BI,A),EQUALS
117:113,49,166:C'1100')

where originally in the sortcard which was in the production version. i will clarify that.
thanks.
doubt_man.
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Mar 30, 2004 7:30 am    Post subject: Reply with quote

doubtman,

If your max value is only 5 bytes , then code 5 T's for the edit mask and code 4x to put 4 space afterwards.

i.e
Code:

SORT FIELDS=(1,03,CH,A)           
OUTREC FIELDS=(1,107,             
               108,5,PD,EDIT=(TTTTT),
               4X,
               113,49,
               C'1100')


Btw Can you please spell my name correctly. I already mentioned it once in an earlier post.

Thanks,

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
doubt_man
Beginner


Joined: 12 Mar 2004
Posts: 15
Topics: 6

PostPosted: Tue Mar 30, 2004 10:39 am    Post subject: Reply with quote

hi kolusu,
sorry. that was a typo.
The problem is that the max value is not always 5 bytes. sometimes a zip extension will come. so we cannot put 5T's. is there any other way??
thanks
doubt_man
Back to top
View user's profile Send private message Yahoo Messenger
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Mar 30, 2004 11:25 am    Post subject: Reply with quote

Kolusu said
Quote:
First thing is you don't have 3 bytes of binary field. BInary field can be 2,4, 8 bytes. so first check that.


Kolusu,

A 3-byte BI field is fine in the SORT statement (it's the SUM statement that only allows 2, 4 or 8 bytes).
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Mar 30, 2004 11:29 am    Post subject: Reply with quote

doubt man,

You're not making it clear what you want to do. You showed xx---ddddd and asked how to make it xxddddd. Kolusu showed you how to do that. Then you said the max value is not always 5 bytes. It's unclear what that means. Please show an example of your input and what you want the output to look like that tells us what exactly you want to do that Kolusu's response doesn't cover.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
doubt_man
Beginner


Joined: 12 Mar 2004
Posts: 15
Topics: 6

PostPosted: Tue Mar 30, 2004 11:17 pm    Post subject: Reply with quote

hi frank,
i wil make it more clear. if i change it like what kolsu has said, it will work fine only if we are recieving a 5 byte zipcode in the input. But that is not the case always . sometimes we will have a zip extension which will increase the no of bytes of the field to 6 or 7. so if we give it

SORT FIELDS=(1,03,CH,A)
OUTREC FIELDS=(1,107,
108,5,PD,EDIT=(TTTTT),
4X,
113,49,
C'1100')
if the input field is comming as 1121212, then according to this we will get only
21212.
sample input of special case(in which zip extension is included)

This is the input when i gave a hex on(as input is in pd)
MD
DC01222
440111F

The field following 'MD' is the zip which is in discussion.
REQUIRED OUTPUT
MD1121212
PRESENT OUTPUT
MD21212

i think it is clear now.
please get back to me if something more is to be clarified.
thanks
doubt_man.
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Mar 31, 2004 9:31 am    Post subject: Reply with quote

Doubtman,

The following JCl will give you the desired results. A brief explanation of the JOb. We first reformat the zip field to 9 bytes using the outrec fields. Using Outfil fnames we split the file into 2 seperate files. One files will have all the records which have an extension for the zip and the other which does not have extension. The no extension records are now aligned to remove the leading zeroes and pad spaces to right of zip code using outrec.

The second step concatenates these 2 files together and sorts on the key.

Code:

//STEP0100 EXEC PGM=SORT                           
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD DSN=YOUR INPUT FILE,                                   
//            DISP=SHR
//EXTZIP   DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//NOEXT    DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *                                       
  SORT FIELDS=COPY
  OUTREC FIELDS=(1,107,             
                 108,5,PD,EDIT=(TTTTTTTTT),
                 113,49,
                 C'1100')
  OUTFIL FNAMES=NOEXT,INCLUDE=(108,4,ZD,EQ,0),
  OUTREC=(1,107,112,5,4X,117,53)
  OUTFIL FNAMES=EXTZIP,SAVE
//*
//STEP0200 EXEC PGM=SORT                           
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD DSN=&T1,DISP=OLD                                   
//         DD DSN=&T2,DISP=OLD
//SORTOUT  DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *                                       
  SORT FIELDS=COPY
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group