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

How to reverse a string using DFSORT?


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

New User


Joined: 15 Mar 2012
Posts: 5
Location: India

PostPosted: Wed Jan 22, 2014 6:07 pm
Reply with quote

Hello All,

How to reverse a string for ex: "STUDENTS into STNEDUTS" using DFSORT?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jan 22, 2014 6:15 pm
Reply with quote

pretty boring, but ...
use BUILD/OVERLAY moving byte per byte in reverse order
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jan 22, 2014 6:42 pm
Reply with quote

You have to code the reverse. It is a rare need, so don't expect any built-in way to do it.

OVERLAY would be more exciting, because you'd need an extra byte.

BUILD creates a new current record, so no extra byte needed.

Examples with Fixed-length records:

Code:
BUILD=(3,1,2,1,1,1)


Would make ABC into CBA

Code:
OVERLAY=(3,1,2,1,1,1)


And bearing in mind the default start position for OVERLAY of 1 (for F, 5 for V) would make ABC into CBC, because by the time it gets to 1,1, that position has already been replaced by 3,1.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jan 22, 2014 8:35 pm
Reply with quote

If you have the cusion of using COBOL (FUNCTION REVERSE ) would be handy...
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Jan 22, 2014 8:42 pm
Reply with quote

If the data is not too large, you could write a small Rexx exec.

This would help with different length fields and eliminate trailing spaces becoming leading spaces (with a Strip function).

You could run it in batch.

I guess more complete requirements would help (as usual).
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top