View previous topic :: View next topic
|
Author |
Message |
kbmkris
Active User

Joined: 24 Jun 2006 Posts: 101
|
|
|
|
Hi,
I am having a file with say n fields of which I have a field with a single alphabetic character. In the output file, I have to replace this alphabetic character with the corresponding number and with all the other fields remaining same. Could you please help me in doing this?
Moreover, my input file has millions of records. Whether it is good to do the above task using sort or COBOL program and which is efficient?
Thanks,
Bala |
|
Back to top |
|
 |
muthuvel
Active User

Joined: 29 Nov 2005 Posts: 217 Location: Canada
|
|
|
|
If it is a single replacement for ex:whether it is "a" ,"b" or "c" you are going to replace by it one number say "5" then you can use sort with OUTREC option.
If it is a replacement of different numbers for different alphabets then COBOL is preferable.
In case of efficiency test both(COBOL and Sort) and see which consumes less CPU time or elapsed time. |
|
Back to top |
|
 |
kbmkris
Active User

Joined: 24 Jun 2006 Posts: 101
|
|
|
|
Hi,
It is like replacing different alphabets with different numbers.
I would like to know whether this can be done by Syncsort. If so, could you let me know how to do that?
Thanks,
Bala |
|
Back to top |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Like DFSort, Syncsort can convert characters. Look at the ALTSEQ and the TRAN parameters in your manual. |
|
Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
kbmkris wrote: |
Hi,
I am having a file with say n fields of which I have a field with a single alphabetic character.
Bala |
Bala,
Please let me know,
1. Is the file FB or VB ?
2. Do you know the position of that single alphabetic character.
3. Character position is static or varies. |
|
Back to top |
|
 |
raak
Active User

Joined: 23 May 2006 Posts: 166 Location: chennai
|
|
|
|
Hey,
With Syncsort use this.
Code: |
OPTION COPY
ALTSEQ CODE=(D5E8)
INREC FIELDS=(1,3,4,1,TRAN=ALTSEQ,5,195) |
here input is a 200 byte FB file.
I am changing the value 'N' in position 4 to 'Y'. ( D5 is the Hex code of N and E8 is the hex-code of Y)
If u want more values to be changed, u can give that in the ALTSEQ CODE line seperated by a comma. |
|
Back to top |
|
 |
kbmkris
Active User

Joined: 24 Jun 2006 Posts: 101
|
|
|
|
Hi anuj,
I have to do the same thing in a FB file and in a VB file also. Yes, I know the position of the character i want to change and the character will vary.
For e.g.
in my input file, if position 4 is
'C' then i have to change it to '1'.
'A' then to '2'.
'D' then to '3' like that.
Thanks,
Bala |
|
Back to top |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
You can translate more than one character at a time:
ALTSEQ CODE=(F0B7,F1B8,F2B9,F3BA,F4BB,F5BC,F6BD,F7BE,F8BF,F9C0)
Have you checked your manual? |
|
Back to top |
|
 |
kbmkris
Active User

Joined: 24 Jun 2006 Posts: 101
|
|
|
|
hi William,
I am not sure how to formulate the corresponding hexcode for the alphabets. Please let me know how to find the corresponding hexcode for alphabets and numbers?
I went on checking with the previous Syncsort related posts in the forum and from that i came to know that some of the commands available in DFSORT will work in SYNCSORT also. I tried and it is working.
The code I used is
Code: |
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(9,1,CH,EQ,C'C'),OVERLAY=(9:C'1') |
All, thanks for your help.
Thanks,
Bala |
|
Back to top |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
How many "IFTHEN" sort of substituions do you have? ONe for every letter in the alphabet? Or just a select few? |
|
Back to top |
|
 |
kbmkris
Active User

Joined: 24 Jun 2006 Posts: 101
|
|
|
|
Hi William,
i have to do that based on some condition, say, if my position 7 and 8 of my input file contains TT and the character is C at position 9, i have to replace it to 1. Similarly i have to do for 8 conditions. So i have totally 8 ifthen in my sortcard. The full sortcard i used is
Code: |
SORT FIELDS=(1,6,PD,A,7,2,CH,A,9,1,CH,A)
INREC IFTHEN=(WHEN=(7,2,CH,EQ,C'TT',AND,9,1,CH,EQ,C'C'),
OVERLAY=(9:C'1')),
IFTHEN=(WHEN=(7,2,CH,EQ,C'TT',AND,9,1,CH,EQ,C'F'),
OVERLAY=(9:C'2')),
IFTHEN=(WHEN=(7,2,CH,EQ,C'TT',AND,9,1,CH,EQ,C'I'),
OVERLAY=(9:C'3')),
IFTHEN=(WHEN=(7,2,CH,EQ,C'TT',AND,9,1,CH,EQ,C'M'),
OVERLAY=(9:C'4')),
IFTHEN=(WHEN=(7,2,CH,EQ,C'TT',AND,9,1,CH,EQ,C'L'),
OVERLAY=(9:C'5')),
IFTHEN=(WHEN=(7,2,CH,NE,C'TT',AND,9,1,CH,EQ,C' '),
OVERLAY=(9:C'1')),
IFTHEN=(WHEN=(7,2,CH,NE,C'TT',AND,9,1,CH,EQ,C'M'),
OVERLAY=(9:C'2')),
IFTHEN=(WHEN=(7,2,CH,NE,C'TT',AND,9,1,CH,EQ,C'L'),
OVERLAY=(9:C'3')) |
Thanks,
Bala |
|
Back to top |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Looks like you got it, what's the problem? |
|
Back to top |
|
 |
kbmkris
Active User

Joined: 24 Jun 2006 Posts: 101
|
|
|
|
Hi William,
My input file contains 90000000 records. I want to know what i have to use. I have a COBOL program to do the same without sorted output and this JCL. Which is efficient? Could you please suggest me?
Thanks,
bala |
|
Back to top |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
I'd say, it's pretty much your choice.....
If you already have the COBOL program, why not run both and see which id more efficient? |
|
Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi Bala,
Sorry I was away from net for some days, so could not check your reply.
By the way, I hope you got your answer . |
|
Back to top |
|
 |
kbmkris
Active User

Joined: 24 Jun 2006 Posts: 101
|
|
|
|
hi Anuj,
Yes i got that. Thanks for your reply:-) |
|
Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
You are welcome.  |
|
Back to top |
|
 |
|
|