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: 7999
Location: Bellevue, IA

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: 6966
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 RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 am
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm


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