Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Can we do dynamic masking using DFSORT?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
jsk

New User


Joined: 20 Feb 2006
Posts: 12

PostPosted: Tue May 24, 2011 3:57 pm    Post subject: Can we do dynamic masking using DFSORT?
Reply with quote

Hi,

I recently came across with a requirement in which, file has account number. Requiremnet was to mask alternate charcters with "X".If any space encountered in between, masking need to reset and start again.For example

Eg 1:-
I/p:-
12345 678
O/p:-
1X3X5X 6X8--After "5" we have a blank so masking rest and started again.

Eg 2:-
12345678
1X3X5X7X

Eg 3:-
A1234
O/p
AX2X3X.

I know if we have fixed size we can harcode using OUTREC FIELDS=(1:1,...). But size of field can vary from 5 to 15 Bytes max. Meaning one time it will be 5 bytes next time it will be 10 bytes and so on. Can we do it using DFSORT?
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed May 25, 2011 1:19 am    Post subject:
Reply with quote

Quote:
Requiremnet was to mask alternate charcters with "X".If any
space encountered in between, masking need to reset and start again.


Your description of the rules is subject to some questions.

Can there only be one blank between groups of characters or can there be more than one blank? If more than one blank between groups, should all the blanks be kept or only one?

Can the size of each group of characters vary from 5 to 15 bytes, or can the total number of characters vary from 5 to 15 bytes?

Could you have something like:

Code:

1 2 3 4


so that no masking would be needed?

What is the RECFM and LRECL of the input file?

It would help if you would show a better example of input and expected output for all possible cases you have to handle and use ubb code tags so we can see where the spaces are.
Back to top
View user's profile Send private message
jsk

New User


Joined: 20 Feb 2006
Posts: 12

PostPosted: Wed May 25, 2011 11:04 am    Post subject:
Reply with quote

Hi Frank,

Thanks for reply. Please find below for the questions asked.

Quote:

Q)Can there only be one blank between groups of characters or can there be more than one blank? If more than one blank between groups, should all the blanks be kept or only one?


A) Yes there can be multiple blanks between Group(s).If multiple spaces found single space need to be retained and rest of spaces need to be masked.Pls see Example 3.

LRECL/RECFM 80/FB

I/P- Example with three Groups(Group1- 1234,Group2 -A5678,Group3-B4567. Only one space with be there between the groups.If multiple spaces found then First Space with treated as space and rest will be treated as characters for masking. Pls see example 3.
Note:- At a single point of time there can be max of 10 Records with combinations mentioned in below examples.Meaning Records with single group or records with multiple groups or records with mix of single or mutliple records.

Code:

Ex:1
1234 A5678 B4567
O/P
1X3X AX6X8 BX5X7


EX 2 i/p- Single Group with 15 Characters
Code:

ABC123456789045
o/p
AXCX2X4X6X8X0X5.


EX 3- Groups with multiple spaces in between.


Code:

A123  B1234  C1-123

O/P
AX2X XBX2X3 CX-X2X---> Two spaces found between group1 and group2 but first space is treated as itself and masking started from second space considering, space as a character.Its kind of string delimited by first occurance of space.


Ex 4:- Example with all combination from file.
Code:

i/p
1234567890ABCDE
A123 B234 C45678
A111  B222  C2345

0/P
1X3X5X7X9XAXCXE
AX2X BX3X CX5X7X
AX1X XBX2X XCX3X5


Quote:

q)Can the size of each group of characters vary from 5 to 15 bytes, or can the total number of characters vary from 5 to 15 bytes?

a) No Not groups. Only the characters vary from 5 to 15 Bytes.Meaning 5- 15 charactesr can be in single group or in multiple group.But max characters will be 15.


Hope I answered your questions.
Thanks A lot.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu May 26, 2011 1:28 am    Post subject:
Reply with quote

Well, I thought this could be done with DFSORT using PARSE, but given this rule:

Quote:
can be multiple blanks between Group(s).If multiple spaces found single space need to be retained and rest of spaces need to be masked


I don't really see a way to do it since I don't see a way to distinguish between one blank and multiple blanks that could handle the masking you want.

I'd suggest you write a program or exit to do this.
Back to top
View user's profile Send private message
jsk

New User


Joined: 20 Feb 2006
Posts: 12

PostPosted: Thu May 26, 2011 10:17 am    Post subject:
Reply with quote

Hi Frank,

Thanks for your reply.

Yes requirement was completed thru COBOL. But was curious to know how would it have been done in DFSORT,if we have single spaces in between Group(s).Could you please share your views.

Thanks a Lot!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu May 26, 2011 9:15 pm    Post subject:
Reply with quote

jsk wrote:

EX 3- Groups with multiple spaces in between.
Code:

A123  B1234  C1-123

O/P
AX2X XBX2X3 CX-X2X---> Two spaces found between group1 and group2 but first space is treated as itself and masking started from second space considering, space as a character.Its kind of string delimited by first occurance of space.



Did you have a typo in the above example? Shouldn't the second part be XBX2X4 instead of XBX2X3 . Also there are 2 spaces between the 2nd and 3rd word shouldn't it be XCX-X2X as explained in example 4?

jsk wrote:

Ex 4:- Example with all combination from file.
Code:

i/p
1234567890ABCDE
A123 B234 C45678
A111  B222  C2345

0/P
1X3X5X7X9XAXCXE
AX2X BX3X CX5X7X
AX1X XBX2X XCX3X5




FWIW it is worth here is a job which will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
1234 A5678 B4567                                                       
ABC123456789045                                                       
A123  B1234  C1-123                                                   
1234567890ABCDE                                                       
A123 B234 C45678                                                       
A111  B222  C2345                                                     
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,FINDREP=(ENDPOS=20,INOUT=(C'  ',C' @'))),   
  IFTHEN=(WHEN=INIT,FINDREP=(ENDPOS=20,INOUT=(C' ',C'$'))),           
                                                                       
  IFTHEN=(WHEN=INIT,                                                   
   PARSE=(%01=(ENDAT=C'$',FIXLEN=16),%02=(ENDAT=C'$',FIXLEN=16),       
          %03=(ENDAT=C'$',FIXLEN=16),%04=(ENDAT=C'$',FIXLEN=16),       
          %05=(ENDAT=C'$',FIXLEN=16)),BUILD=(%01,%02,%03,%04,%05)),   
                                                                       
  IFTHEN=(WHEN=(01,1,CH,NE,C'@'),OVERLAY=(02:C'X',04:C'X',06:C'X',   
                08:C'X',10:C'X',12:C'X',14:C'X'),HIT=NEXT),         
  IFTHEN=(WHEN=(17,1,CH,NE,C'@'),OVERLAY=(18:C'X',20:C'X',22:C'X',   
                24:C'X',26:C'X',28:C'X',30:C'X'),HIT=NEXT),         
  IFTHEN=(WHEN=(33,1,CH,NE,C'@'),OVERLAY=(34:C'X',36:C'X',38:C'X',   
                40:C'X',42:C'X',44:C'X',46:C'X'),HIT=NEXT),         
  IFTHEN=(WHEN=(49,1,CH,NE,C'@'),OVERLAY=(50:C'X',52:C'X',54:C'X',   
                56:C'X',58:C'X',60:C'X',62:C'X'),HIT=NEXT),         
  IFTHEN=(WHEN=(65,1,CH,NE,C'@'),OVERLAY=(66:C'X',68:C'X',70:C'X',   
                72:C'X',74:C'X',76:C'X',78:C'X'),HIT=NEXT),         
                                                                     
  IFTHEN=(WHEN=(01,1,CH,EQ,C'@'),OVERLAY=(03:C'X',05:C'X',07:C'X',   
                09:C'X',11:C'X',13:C'X',15:C'X'),HIT=NEXT),         
  IFTHEN=(WHEN=(17,1,CH,EQ,C'@'),OVERLAY=(19:C'X',21:C'X',23:C'X',   
                25:C'X',27:C'X',29:C'X',31:C'X'),HIT=NEXT),         
  IFTHEN=(WHEN=(33,1,CH,EQ,C'@'),OVERLAY=(35:C'X',37:C'X',39:C'X',   
                41:C'X',43:C'X',45:C'X',47:C'X'),HIT=NEXT),         
  IFTHEN=(WHEN=(49,1,CH,EQ,C'@'),OVERLAY=(51:C'X',53:C'X',55:C'X',   
                57:C'X',59:C'X',61:C'X',63:C'X'),HIT=NEXT),         
  IFTHEN=(WHEN=(65,1,CH,NE,C'@'),OVERLAY=(67:C'X',69:C'X',71:C'X',   
                73:C'X',75:C'X',77:C'X',79:C'X'))                   
                                                                     
  OUTREC IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'XXXXXXXXXXXXXX',C''))),
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'X X X X X X X',C''))),         
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'X X X X X X',C''))),           
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'X X X X X',C''))),             
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'X X X X',C''))),               
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'X X X',C''))),                 
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'X X',C''))),                   
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'@$',C' '))),                   
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'$  ',C' '))),                 
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'$ ',C' '))),                   
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'@',C'X'))),                   
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C' X ',C''))),                   
  IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C'  ',C' ')))                   
//*


The output of this is
Code:

1X3X AX6X8 BX5X7     
AXCX2X4X6X8X0X5       
AX2X XBX2X4 XCX-X2X   
1X3X5X7X9XAXCXE       
AX2X BX3X CX5X7X     
AX1X XBX2X XCX3X5     
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Fri May 27, 2011 2:13 am    Post subject:
Reply with quote

Excellent!!!!

36_8_11.gif

Thanks,
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri May 27, 2011 2:11 pm    Post subject:
Reply with quote

sqlcode1 wrote:
Excellent!!!!

36_8_11.gif

Thanks,

Yes.. Even I was watching this topic.. Good one Kolusu
Back to top
View user's profile Send private message
jsk

New User


Joined: 20 Feb 2006
Posts: 12

PostPosted: Fri May 27, 2011 3:22 pm    Post subject:
Reply with quote

Hi Skolusu,

Yes that was a typo. Sorry for that..

This is a Fabulous work!!

Thanks a Lot for your Time and Help!
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri May 27, 2011 9:19 pm    Post subject:
Reply with quote

Quote:
FWIW it is worth here is a job which will give you the desired results.


The student long ago surpassed the teacher. icon_cool.gif

But at least the teacher was smart enough to hire the student. icon_lol.gif
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Fri May 27, 2011 11:39 pm    Post subject:
Reply with quote

Wow... Excellent..


Skolusu, Can you please also explain the logic of the above solution?
Back to top
View user's profile Send private message
jsk

New User


Joined: 20 Feb 2006
Posts: 12

PostPosted: Mon May 30, 2011 10:12 am    Post subject:
Reply with quote

Please find the logic

Step1:- Identify groups with single space and multiple space and mask it with " @" for double space and "$" for single space using Find and Replace function.

Step2:-Build the reformated record with " @" and "$" so that making can be done based on " @" and "$".

Strep3:- Mask Alternate Char with "X" based on condition.

Step4:- Reformat the records by removing unwanted masking done at end of records.

Belive I am in right track. Skolusu can put more views on this.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue May 31, 2011 9:38 pm    Post subject:
Reply with quote

Frank Yaeger wrote:
The student long ago surpassed the teacher. icon_cool.gif
But at least the teacher was smart enough to hire the student. icon_lol.gif


Thank you Frank. The student is still wet behind the ears and has a very long way to go to even be compared with the master.

sqlcode1 wrote:
Excellent!!!!


Escapa wrote:
Good one Kolusu


Thank you

gylbharat wrote:
Wow... Excellent..Skolusu, Can you please also explain the logic of the above solution?


I think JSK has pretty much covered it. The only trick in that solution is to identify the double space and retain the first space as a seperate character. The first FINDREP does that. The second FINDREP takes care of single space records. Once we get that then it is easy to split the records into words delimited by space. Then a bunch of ifthen statements are used to mask out even or odd numbered characters checking if the first character is a space or not. once the masking is completed we now try to squeeze everything back to as it is with another set of FINDREPs and replace the double space and single space characters to their original format.
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Wed Jun 01, 2011 11:36 am    Post subject:
Reply with quote

Thanks Skolusu...

But i have not understood why we are testing on Fixed positions like 1,17,33 etc for '@' ?
Code:

IFTHEN=(WHEN=(01,1,CH,NE,C'@'),OVERLAY=(02:C'X',04:C'X',06:C'X',   
                08:C'X',10:C'X',12:C'X',14:C'X'),HIT=NEXT),         
  IFTHEN=(WHEN=(17,1,CH,NE,C'@'),OVERLAY=(18:C'X',20:C'X',22:C'X',   
                24:C'X',26:C'X',28:C'X',30:C'X'),HIT=NEXT),         
  IFTHEN=(WHEN=(33,1,CH,NE,C'@'),OVERLAY=(34:C'X',36:C'X',38:C'X',   
                40:C'X',42:C'X',44:C'X',46:C'X'),HIT=NEXT),         
  IFTHEN=(WHEN=(49,1,CH,NE,C'@'),OVERLAY=(50:C'X',52:C'X',54:C'X',   
                56:C'X',58:C'X',60:C'X',62:C'X'),HIT=NEXT),         
  IFTHEN=(WHEN=(65,1,CH,NE,C'@'),OVERLAY=(66:C'X',68:C'X',70:C'X',   
                72:C'X',74:C'X',76:C'X',78:C'X'),HIT=NEXT),         
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 01, 2011 9:35 pm    Post subject: Reply to: Can we do dynamic masking using DFSORT?
Reply with quote

glypharat wrote:
Thanks Skolusu...
But i have not understood why we are testing on Fixed positions like 1,17,33 etc for '@' ?


The best way to understand the job is to run the job with 1 IFTHEN statement and check the results of it. Run these 3 jobs and check the output after each run. The output from the 3rd job will make u understand as to why I am checking on fixed positions.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
A123  B1234  C1-123                                                   
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,FINDREP=(ENDPOS=20,INOUT=(C'  ',C' @')))
//*


Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
A123  B1234  C1-123                                                   
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,FINDREP=(ENDPOS=20,INOUT=(C'  ',C' @'))),   
  IFTHEN=(WHEN=INIT,FINDREP=(ENDPOS=20,INOUT=(C' ',C'$')))
//*



Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
A123  B1234  C1-123                                                   
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,FINDREP=(ENDPOS=20,INOUT=(C'  ',C' @'))),   
  IFTHEN=(WHEN=INIT,FINDREP=(ENDPOS=20,INOUT=(C' ',C'$'))),           
                                                                       
  IFTHEN=(WHEN=INIT,                                                   
   PARSE=(%01=(ENDAT=C'$',FIXLEN=16),%02=(ENDAT=C'$',FIXLEN=16),       
          %03=(ENDAT=C'$',FIXLEN=16),%04=(ENDAT=C'$',FIXLEN=16),       
          %05=(ENDAT=C'$',FIXLEN=16)),BUILD=(%01,%02,%03,%04,%05))
//*
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Thu Jun 02, 2011 1:00 pm    Post subject:
Reply with quote

Thanks Skolusu... Got it... icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts Masking Db2 data kishpra DB2 3 Fri Sep 02, 2016 9:23 pm
No new posts DFSORT sorting only specific records akodakka DFSORT/ICETOOL 4 Thu Aug 04, 2016 11:24 am
No new posts Creating a dynamic sort card in JCL u... ChitraChhabra DFSORT/ICETOOL 4 Wed Aug 03, 2016 6:15 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us