Page 1 of 1

Assistance on Masking

PostPosted: Fri May 07, 2010 7:38 pm
by samurai007
Hi,

I am in a situation where i need to mask some data.

Say, input data is like
000001 ABCDEF____NEW______DAY
000002 GHIJ______DEVELOPT__NIGHT
000003 KLMNO____OLD_______EVENING
000004 PQRSTUVW_MEDIUM___MORNING
000005 XYZ_______SAFE______AFTERNOON

Output required is like
000001 AXXXXX____NYY_______DTT
000002 GXXX______DYYYYYYY__NTTTT
000003 KXXXX_____OYY_______ETTTTTT
000004 PXXXXXXX__MYYYYY____MTTTTTT
000005 XXX_______SYYY______ATTTTTTTT

[I have added dashes here to get the correct alignment of data. The file is FB and LRECL is 30. There are 3 fields of length 10 each in the file. The numbers at the beginning are only line numbers].


That is, other than the first letter of each field, all the other characters need to be changed to a pre-decided character, here 'X', 'Y' and 'T'. I tried using ALTSEQ and succeeded. However, the trouble is am able to use just one ALTSEQ. Is there any way i can use multiple ALTSEQ, one to replace each field ?? Or what is the other way of doing this ??

I would be glad if you can assist me on this.

Thanks,
Sam.

Re: Assistance on Masking

PostPosted: Fri May 07, 2010 8:01 pm
by CICS Guy
samurai007 wrote:I have added dashes here to get the correct alignment of data.
More work than it's worth, and it's still sloppy...
Say, input data is like
000001 ABCDEF____NEW______DAY
000002 GHIJ______DEVELOPT__NIGHT
000003 KLMNO____OLD_______EVENING
000004 PQRSTUVW_MEDIUM___MORNING
000005 XYZ_______SAFE______AFTERNOON

Output required is like
000001 AXXXXX____NYY_______DTT
000002 GXXX______DYYYYYYY__NTTTT
000003 KXXXX_____OYY_______ETTTTTT
000004 PXXXXXXX__MYYYYY____MTTTTTT
000005 XXX_______SYYY______ATTTTTTTT
Why didn't you just wrap 'code' around it and save yourself the time?
Say, input data is like
000001 ABCDEF    NEW      DAY     
000002 GHIJ      DEVELOPT NIGHT   
000003 KLMNO     OLD      EVENING 
000004 PQRSTUVW  MEDIUM   MORNING 
000005 XYZ       SAFE     AFTERNOON

Output required is like
000001 AXXXXX    NYY      DTT     
000002 GXXX      DYYYYYYY NTTTT   
000003 KXXXX     OYY      ETTTTTT 
000004 PXXXXXXX  MYYYYY   MTTTTTT 
000005 XXX       SYYY     ATTTTTTTT

Re: Assistance on Masking

PostPosted: Fri May 07, 2010 10:21 pm
by Frank Yaeger
Sam,

Which characters are you trying to replace? Is it any non-blank, or just A-Z, or something else?

Re: Assistance on Masking

PostPosted: Mon May 10, 2010 11:04 am
by samurai007
@ CICS Guy
Why didn't you just wrap 'code' around it and save yourself the time?


I didnt know this. Will use it going forward. Thanks.
But this was not the problem to which i needed a solution.

@ Frank
Which characters are you trying to replace? Is it any non-blank, or just A-Z, or something else?


For every field, we have a character between [A-Z] assigned to it.
Suppose a field, NAME, has the value as 'FRANK' and if the character assigned to it is 'S', i would like the field to appear as 'FSSSS' in my output file.
Suppose a field, COUNTRY, has the value as 'AMERICA' and if the character assigned to it is 'M', i would like the field to appear as 'AMMMMMM' in my output file.

In essence, other than the first letter of each field, all the other non-blank letters in the field have to be replaced with the pre-defined character. This pre-defined character varies from field to field, say, for NAME it is 'S', for COUNTRY it is 'M' and so on.
Now if you can compare this with the data I gave you initially, i believe you would get a fair idea of how each field would appear at the output.

Using an OVERLAY in the OUTREC replaces ALL the letters in the field, including blanks, with the pre-defined character. I would like the blanks to remain unchanged.
Using ALTSEQ allows me to replace the contents of the entire file with only one character. I would want to replace each field with its corresponding pre-defined character.


Let me know if this is sufficient explanation.

Thanks,
Sam.

Re: Assistance on Masking

PostPosted: Mon May 10, 2010 11:32 pm
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
XA,'A'
XB,'B'
XC,'C'
XD,'D'
XE,'E'
XF,'F'
XG,'G'
XH,'H'
XI,'I'
XJ,'J'
XK,'K'
XL,'L'
XM,'M'
XN,'N'
XO,'O'
XP,'P'
XQ,'Q'
XR,'R'
XS,'S'
XT,'T'
XU,'U'
XV,'V'
XW,'W'
XX,'X'
XY,'Y'
XZ,'Z'
//SORTIN DD DSN=...  input file (FB/30)
//SORTOUT DD DSN=...  output file (FB/30)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
    FINDREP=(STARTPOS=2,ENDPOS=10,OUT=C'X',
     IN=(XA,XB,XC,XD,XE,XF,XG,XH,XI,XJ,XK,XL,XM,XN,XO,XP,XQ,
         XR,XS,XT,XU,XV,XW,XX,XY,XZ))),
  IFTHEN=(WHEN=INIT,
    FINDREP=(STARTPOS=12,ENDPOS=20,OUT=C'Y',
     IN=(XA,XB,XC,XD,XE,XF,XG,XH,XI,XJ,XK,XL,XM,XN,XO,XP,XQ,
         XR,XS,XT,XU,XV,XW,XX,XY,XZ))),
  IFTHEN=(WHEN=INIT,
    FINDREP=(STARTPOS=22,ENDPOS=30,OUT=C'T',
     IN=(XA,XB,XC,XD,XE,XF,XG,XH,XI,XJ,XK,XL,XM,XN,XO,XP,XQ,
         XR,XS,XT,XU,XV,XW,XX,XY,XZ)))
/*