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
 

 

Can we reverse the string in cobol ?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Cobol character handling
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: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Mon Apr 06, 2009 10:50 pm    Post subject:
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    Post subject: Reply to: Can we reverse the string in cobol ?
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    Post subject: Re: Reply to: Can we reverse the string in cobol ?
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    Post subject: Reply to: Can we reverse the string in cobol ?
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: 6967
Location: porcelain throne

PostPosted: Tue Apr 07, 2009 4:05 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


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