need a solution for replacing an array of nos to alphabets



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

need a solution for replacing an array of nos to alphabets

Postby prasanthbalan » Tue Jan 08, 2013 9:46 pm

Hi everyone,

I have a requirement where i want a data translation as given below

i/p file: FB recl 1050
array (occurs 25 times):
value1 pic xx.
value2 pic 9(8).
value3 pic x(14).

now for all the occurances of value1, i need to change the value as follows
01 -> A ( meaning A followed by a space)
02 -> B
03 -> C
.
.
.
.
25 -> Z.

I tried altseq but i think it translates only for 1 byte daya.
using findrep seems very complex.

Is there anything that can be easier

Thanks!
prasanthbalan
 
Posts: 7
Joined: Tue Jan 08, 2013 9:37 pm
Has thanked: 1 time
Been thanked: 0 time

Re: need a solution for replacing an array of nos to alphabe

Postby tivrfoa » Tue Jan 08, 2013 9:53 pm

tivrfoa
 
Posts: 84
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 60 times
Been thanked: 0 time

Re: need a solution for replacing an array of nos to alphabe

Postby Akatsukami » Tue Jan 08, 2013 10:04 pm

prasanthbalan wrote:now for all the occurances of value1, i need to change the value as follows
01 -> A ( meaning A followed by a space)
02 -> B
03 -> C
.
.
.
.
25 -> Z.

What letter are you leaving out?

What is to be done when value1 is greater than 25, or non-numeric? (And don't tell me "Oh, that will never happen!")
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: need a solution for replacing an array of nos to alphabe

Postby prasanthbalan » Tue Jan 08, 2013 10:12 pm

@akatsukami sorry the values are
00 -> A
01 -> B
.
.
25 -> Z.
prasanthbalan
 
Posts: 7
Joined: Tue Jan 08, 2013 9:37 pm
Has thanked: 1 time
Been thanked: 0 time

Re: need a solution for replacing an array of nos to alphabe

Postby dick scherrer » Tue Jan 08, 2013 10:59 pm

Hello and welcome to the forum,

Please note you have repeated the error (a-z is 26 not 25) ;)

There is also the question about other values as Akatsukami asked?

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: need a solution for replacing an array of nos to alphabe

Postby skolusu » Tue Jan 08, 2013 11:06 pm

prasanthbalan wrote:Hi everyone,

I have a requirement where i want a data translation as given below

i/p file: FB recl 1050
array (occurs 25 times):
value1 pic xx.
value2 pic 9(8).
value3 pic x(14).

now for all the occurances of value1, i need to change the value as follows
01 -> A ( meaning A followed by a space)
02 -> B
03 -> C
.
.
.
.
25 -> Z.

I tried altseq but i think it translates only for 1 byte daya.
using findrep seems very complex.

Is there anything that can be easier

Thanks!


Are you preparing the Data or is this an existing file and you want to change the contents? If so what is the position of the array in the file? Do you need to initialize the other 2 variables also?

dick scherrer wrote:Please note you have repeated the error (a-z is 26 not 25) ;) d


D,

He is starting the sequence from zero. so you will only have 25
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: need a solution for replacing an array of nos to alphabe

Postby dick scherrer » Wed Jan 09, 2013 2:55 am

Aaargh . . . I missed the "updated" list . . . :oops:

This could be a long and ugly year . . . .

Thanks,

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: need a solution for replacing an array of nos to alphabe

Postby prasanthbalan » Thu Jan 10, 2013 2:43 pm

@skolusu

I dont want to initialize the other two variables.
The array position in my file is from 49th byte, extending for 600 bytes (24 bytes occuring 25 times).

This is an existing file where i want to change the contents.
prasanthbalan
 
Posts: 7
Joined: Tue Jan 08, 2013 9:37 pm
Has thanked: 1 time
Been thanked: 0 time

Re: need a solution for replacing an array of nos to alphabe

Postby dick scherrer » Thu Jan 10, 2013 8:58 pm

Hello,

This is an existing file where i want to change the contents.
You may want this as the result, but you do NOT want to change the contents of the existing file.

You should copy the original input to a new file and then rename as appropriate. If this dataset was a gdg, all you might need to do is create a +1 generation. Then you would have the new content as well as a full backup of the original data.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: need a solution for replacing an array of nos to alphabe

Postby skolusu » Fri Jan 11, 2013 1:55 am

prasanthbalan,

Use the following DFSORT JCL which will give you the desired results. The trick here is to copy the 2 byte of each occurrence and place it at end of the record and then use FINDREP to replace the numerics to alphabets. Once replaced , user overlay to replace the contents back to their original position.
//STEP0100 EXEC PGM=SORT     
//SYSOUT   DD SYSOUT=*       
//SORTIN   DD DISP=SHR,DSN=Your input FB 1050 File
//SORTOUT  DD SYSOUT=* 
//SYSIN    DD *         
  OPTION COPY
  INREC IFOUTLEN=1050,IFTHEN=(WHEN=INIT,                             
  OVERLAY=(1051:049,2,074,2,099,2,124,2,149,2,174,2,199,2,224,2,     
                249,2,274,2,299,2,324,2,349,2,374,2,399,2,424,2,     
                449,2,474,2,499,2,524,2,549,2,574,2,599,2,624,2,     
                649,2,674,2)),                                       
  IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=1051,                           
  INOUT=(C'00',C'A ',C'01',C'B ',C'02',C'C ',C'03',C'D ',C'04',C'E ',
         C'05',C'F ',C'06',C'G ',C'07',C'H ',C'08',C'I ',C'09',C'J ',
         C'10',C'K ',C'11',C'L ',C'12',C'M ',C'13',C'N ',C'14',C'O ',
         C'15',C'P ',C'16',C'Q ',C'17',C'R ',C'18',C'S ',C'19',C'T ',
         C'20',C'U ',C'21',C'V ',C'22',C'W ',C'23',C'X ',C'24',C'Y ',
         C'25',C'Z '))),                                             
  IFTHEN=(WHEN=INIT,                                                 
  OVERLAY=(049:1051,2,074:1053,2,099:1055,2,124:1057,2,149:1059,2,   
           174:1061,2,199:1063,2,224:1065,2,249:1067,2,274:1069,2,   
           299:1071,2,324:1073,2,349:1075,2,374:1077,2,399:1079,2,   
           424:1081,2,449:1083,2,474:1085,2,499:1087,2,524:1089,2,   
           549:1091,2,574:1093,2,599:1095,2,624:1097,2,649:1099,2,   
           674:1101,2))                                               
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post