Page 1 of 1

need a solution for replacing an array of nos to alphabets

PostPosted: Tue Jan 08, 2013 9:46 pm
by prasanthbalan
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!

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

PostPosted: Tue Jan 08, 2013 9:53 pm
by tivrfoa

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

PostPosted: Tue Jan 08, 2013 10:04 pm
by Akatsukami
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!")

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

PostPosted: Tue Jan 08, 2013 10:12 pm
by prasanthbalan
@akatsukami sorry the values are
00 -> A
01 -> B
.
.
25 -> Z.

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

PostPosted: Tue Jan 08, 2013 10:59 pm
by dick scherrer
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

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

PostPosted: Tue Jan 08, 2013 11:06 pm
by skolusu
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

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

PostPosted: Wed Jan 09, 2013 2:55 am
by dick scherrer
Aaargh . . . I missed the "updated" list . . . :oops:

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

Thanks,

d

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

PostPosted: Thu Jan 10, 2013 2:43 pm
by prasanthbalan
@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.

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

PostPosted: Thu Jan 10, 2013 8:58 pm
by dick scherrer
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.

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

PostPosted: Fri Jan 11, 2013 1:55 am
by skolusu
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))                                               
//*