Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 8165
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: 6968
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 line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us