IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to Split, Swap and Reverse a string using Sort?


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
simmimahajan

New User


Joined: 27 Mar 2007
Posts: 30
Location: USA

PostPosted: Wed Jul 16, 2008 8:48 pm
Reply with quote

Hello,

I have a requirement wherein I would have a file which will contain FirstName, LastName, and other such fields. Consider FName = Brena
LName = Lori
I need to do the following:

1. Swap FName and LName
O/p Should be FName = LORI, LName = BRENA

2. Split the FName & LName by getting the midpoint and reverse again as follows

FNAME
'LORI' Split = Char(Length of FName/2) = Output will be O
'LORI' Reverse = OLIR --> Final output of Step 2

LNAME
'Brena' Split = Char(Length of NName/2) = Output will be 'E'
'BRENA Reverse' = RBEAN --> Final output of Step 2

3. Reverse the output of Step 2

FName = RILO

LName = NAEBR

May I know how can I achieve this through SORT.

Also is there some other faster and easier way to achieve this other than SORT?
We may have to do this for millions of records, hence performance is also a criteria.

Looking forward for some positive reply.

Thanks!
Back to top
View user's profile Send private message
simmimahajan

New User


Joined: 27 Mar 2007
Posts: 30
Location: USA

PostPosted: Wed Jul 16, 2008 10:51 pm
Reply with quote

Hello Again,

In the earlier post I did not specify the exact objective of doing this. Basically we are trying to scramble the String. But we need to ensure that any logic provided should be irreversible.

Hence we were working on different options like SQL using DB2, Sort OR Cobol/ Rexx Program. Ideally we want to achieve this at database level but doing this through DB2 would hit the performance drastically hence we have rejected this option. Also I got to know it is not advisable to use SORT on the String as it works more better for Packed Decimals and Numbers.

If anybody can suggest me some better alogrithm to scramble strings which will not affect the 1)Performance, 2)Is irreversible, 3) is not very simple & which can even work for Oracle and Sql Server. I understand this forum is just for Mainframes but we are looking for an aproach will can be global and can be applied irrespective of System in question but at the same time we are looking for the solution in Mainframes.

Thanks Again! Please feel free to provide your inputs on the same.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jul 16, 2008 11:02 pm
Reply with quote

Quote:
If anybody can suggest me some better alogrithm to scramble strings which will not affect the 1)Performance, 2)Is irreversible, 3) is not very simple & which can even work for Oracle and Sql Server. I understand this forum is just for Mainframes but we are looking for an aproach will can be global and can be applied irrespective of System in question but at the same time we are looking for the solution in Mainframes.
You need to decide which of these goals are most important, since "not very simple" conflicts with "not affect the (p)erformance". What you're looking for is asynchronous encryption, such as PGP. But unless you're very skilled already in encryption coding, be prepared to spend some money for a product to do the encryption.
Back to top
View user's profile Send private message
simmimahajan

New User


Joined: 27 Mar 2007
Posts: 30
Location: USA

PostPosted: Wed Jul 16, 2008 11:05 pm
Reply with quote

I understand there is a trade off. But it should be relatively complex, not easily deducible. But performance is important as well coz we may deal with millions of records. Moreover client is not ready to invest in any external products, hence this option is ruled out.

Thanks for the quick reply!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jul 17, 2008 12:26 am
Reply with quote

Hello,

Once encrypted, how would the "new" records be used?

If the data is in some database (Mainframe, UNIX, Win-Based) why does the security rules of that database not provide what you need to secure the data?

Possibly i misunderstand where the data is to be encrypted. . .
Back to top
View user's profile Send private message
simmimahajan

New User


Joined: 27 Mar 2007
Posts: 30
Location: USA

PostPosted: Thu Jul 17, 2008 12:42 am
Reply with quote

Hello Dick,

Data will be loaded in QA for testing but we need to achieve this scrambling before data is loaded in to QA from actual live production region(i.e. Mainframe Prod to QA Prod database, Sql Prod database to Sql Prod and so on]. Currently we do not have any such process in place, hence this new process.

Hope this answers your queries. Let me know if there is some disconnect.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jul 17, 2008 12:51 am
Reply with quote

Hello,

Quote:
we need to achieve this scrambling before data is loaded
Why?

If the data is srambled before the load, it will likely be useless for processing transactions or other queries?

If the data is load "normally" why would the permissions for the database environment not suffice to protect the data?

There must be something i am missing. . . icon_redface.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Jul 17, 2008 2:41 pm
Reply with quote

instead of scrambling with a home grown algorithm which will give very poor statistical uniqueness

why don' t You look into using a checksumming algorithm

just do a little research ( MD5 SHA ... ) just to name a couple
Back to top
View user's profile Send private message
simmimahajan

New User


Joined: 27 Mar 2007
Posts: 30
Location: USA

PostPosted: Thu Jul 17, 2008 10:57 pm
Reply with quote

Hello,

Yes, we are still working on options, but something which can be developed and easily maintained is what we are looking for.

But would like to thank you for your suggestion.

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

Senior Member


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

PostPosted: Thu Jul 17, 2008 11:28 pm
Reply with quote

simmimahajan,

A cobol program can written in less than an hour to do what you want.

1. get the length of the string(fname/lname) using Using Inspect function reverse checking for leading spaces and once you get the length divide it into half and use reference modification to move the desired length

2. Function Reverse lets you reverse the string.

3. Concatenate 2 strings and perform the reverse again
Back to top
View user's profile Send private message
simmimahajan

New User


Joined: 27 Mar 2007
Posts: 30
Location: USA

PostPosted: Fri Jul 18, 2008 1:25 am
Reply with quote

Thanks Skolusu! We are working on similar approach and may finalize on using Cobol for scrambling.

Thanks Again!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Jul 18, 2008 2:01 pm
Reply with quote

In my previous reply I had misunderstood Your requirement..

What You are asking for is commonly called data masking/obfuscation

search google with "data obfuscation" and You will get lots of links

as usual, when I answer, I tend to point out the organizational, security, auditing, certification issues

that' s why for sensitive data manipulation I usually advice against home grown algorithm
they seldom pass an audit/security process

for an issue like this one usually Higher management should be involved,
in many countries they bear legal responsibilities for data mishandling and improper diffusion

that' s why a certified approach would be safer

just being picky,
an algorithm which gives as result the same number of bytes as the source
is seldom irreversible
Back to top
View user's profile Send private message
simmimahajan

New User


Joined: 27 Mar 2007
Posts: 30
Location: USA

PostPosted: Fri Jul 18, 2008 6:27 pm
Reply with quote

Thanks Enrico for all your help! We are exploring different possibilities.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 8
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top