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

How to reverse each record of a file using SORT?


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ChowHan

New User


Joined: 16 Oct 2009
Posts: 15
Location: India

PostPosted: Sun Aug 01, 2010 2:47 am
Reply with quote

I was asked this question,
the input would be like say LRECL 80 (the interviewer was quite accommodating in this regard icon_rolleyes.gif and ABCDE etc. don't refer to field names, it was indivdual characters in the record)


Code:

ABCDEFGH
IJKLMNOP
QRSTUVWX


Output would be the same LRECL but with the whole record reversed
Code:

HGFEDCBA
PONMLKJI
XWVUTSRQ


In my short career, I never faced such a business need, but in any case, is it possible to do it using SORT? ( I didn't ask whether they want to use DFSORT or SYNCSORT because I was flummoxed).

A cobol reverse function would do the needful very easily, With SORT I know it could be done the cumbersome way, I guess, building the record one char at a time, but is there any way to do this without using a huge sysin card?
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: Sun Aug 01, 2010 4:59 am
Reply with quote

Hello,

I know of nothing automatic with either DFSORT or Syncsort, but you could do as you mention and build the reversed output one byte at a tme.

And also as you mention, there is not business need - it is just an exercise icon_smile.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Sun Aug 01, 2010 9:13 am
Reply with quote

I believe a combination of PARSE and SQZ functions can be used to do what you asked for. I've used that to reverse the CSV file.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Sun Aug 01, 2010 9:21 am
Reply with quote

If you are a DFSORT user and are at correct PTF level to use PARSE and SQZ, have a look on these threads - they provide a good hint:

www.ibmmainframes.com/viewtopic.php?t=7782&highlight=reverse
www.ibmmainframes.com/viewtopic.php?t=20877&highlight=reverse
Back to top
View user's profile Send private message
ChowHan

New User


Joined: 16 Oct 2009
Posts: 15
Location: India

PostPosted: Mon Aug 02, 2010 1:49 am
Reply with quote

icon_redface.gif icon_redface.gif icon_redface.gif

I went thru most of the search results before posting the question, sorry...

But most of the results were regarding reversing the order of records (last record in input --->first record in o/p ). So i gave up after some time spent futilely clicking on links in first page of search results...


Thanks Anuj, I will try this solution tomorrow... I would suggest deleting my topic, but it seems it is a valid interview question that could help someone. But please delete if you feel it is redundant... my query is solved in any case icon_cool.gif .
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Aug 02, 2010 10:35 am
Reply with quote

ChowHan,

If it's just a rearrange of fields, I guess a simple INREC pass will do for the sample you have given.
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top