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
 

 

How to reverse each record of a file using SORT?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: How to reverse each record of a file using SORT?
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

Site Director


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

PostPosted: Sun Aug 01, 2010 4:59 am    Post subject:
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

Senior Member


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

PostPosted: Sun Aug 01, 2010 9:13 am    Post subject:
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

Senior Member


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

PostPosted: Sun Aug 01, 2010 9:21 am    Post subject:
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:

http://www.ibmmainframes.com/viewtopic.php?t=7782&highlight=reverse
http://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    Post subject:
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: 2179
Location: @my desk

PostPosted: Mon Aug 02, 2010 10:35 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 3 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm


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