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

Can we reverse the string in cobol ?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sahaanup

New User


Joined: 16 Feb 2006
Posts: 9

PostPosted: Mon Apr 06, 2009 10:39 pm
Reply with quote

Hi,
Can we reverse the string in cobol ? See the following problem :
77 NAME PIC X(10) VALUE 'MANOJ'.
77 SRNAME PIC X(10).

I want JONAM in SRNAME.

Regards,
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Mon Apr 06, 2009 10:50 pm
Reply with quote

There's a link at the top of the page to the manuals. Click on it, find the COBOL Language Reference manual, and look up the REVERSE function. This has also been the topic of a thread or two which you could find by using the SEARCH function.
Back to top
View user's profile Send private message
leo_sangha

New User


Joined: 11 Aug 2005
Posts: 85
Location: England

PostPosted: Tue Apr 07, 2009 3:41 pm
Reply with quote

Is there any specific reason to use 77 Levels ?

i think you can do that by using below logic

start from the last byte ...

SET WS-SUB to 10.

Perform below logic until WS-SUB = 1

IF WS-SUB =spaces
Subtract 1 from WS-SUB giving WS-SUB
ELSE
MOVE Name(WS-SUB:1) TO SRNAME
Subtract 1 from WS-SUB giving WS-SUB
END-IF
Back to top
View user's profile Send private message
sahaanup

New User


Joined: 16 Feb 2006
Posts: 9

PostPosted: Tue Apr 07, 2009 3:55 pm
Reply with quote

[quote="leo_sangha"]Is there any specific reason to use 77 Levels ?

No, there is no specific reason for using 77 level.

Thru coding we can reverse the string .. but i was actually looking for some COBOL verv that will do the same without putting any logic.

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

New User


Joined: 11 Aug 2005
Posts: 85
Location: England

PostPosted: Tue Apr 07, 2009 4:03 pm
Reply with quote

You should have mentioned you are looking for a COBOL VERB.

did you try REVERSE as Robert advised.
I'm not sure but may INSPECT clause might help as well. Look for the syntax and usage.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 07, 2009 4:05 pm
Reply with quote

Quote:
but i was actually looking for some COBOL verv that will do the same without putting any logic.


Anup,

have you bothered to look up the REVERSE function that Robert Sample suggested?
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 -> COBOL Programming

 


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 COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top