GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Mainframe  >  COBOL
Go To First  |  Previous Question  |  Next Question 
 COBOL  |  Question 66 of 162    Print  
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.

  
Total Answers and Comments: 5 Last Update: October 23, 2006     Asked by: manoj 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 25, 2006 06:55:25   #1  
MANOJ        

RE: Can we reverse the string in cobol ? See the follo...

Hi

we can reverse the string using cobol prog like this :

IDENTIFICATION DIVISION.
PROGRAM-ID. MID.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 STR1 PIC X(7) VALUE IS 'MANOJ'.
01 STR2 PIC X(1).
01 STR3 PIC X(7) VALUE SPACE.
*01 STR4 PIC X(7).
01 STRLEN PIC 9(1).
01 CTR1 PIC 9(1) VALUE IS 1.
PROCEDURE DIVISION.
INSPECT STR1 TALLYING STRLEN FOR CHARACTERS.
DISPLAY STRLEN.
PERFORM UNTIL STRLEN < 1

MOVE STR1(STRLEN:1) TO STR2
DISPLAY STR2
STRING
STR3 DELIMITED BY SPACE
STR2 DELIMITED BY SPACE
INTO STR3
COMPUTE STRLEN STRLEN - 1
DISPLAY STR3
END-PERFORM.
DISPLAY STR3.
STOP RUN.

Thanking you.

manoj


 
Is this answer useful? Yes | No
September 08, 2006 10:12:36   #2  
rahul        

RE: Can we reverse the string in cobol ? See the follo...

hello

Is there any other method?

regards

rahul


 
Is this answer useful? Yes | No
September 08, 2006 10:22:19   #3  
rahul        

RE: Can we reverse the string in cobol ? See the follo...

hello

Suppose I have 1000 records in one PS file . My requirement is taking first 2 records.

In each record contain 6 fields eg.

NAME ADDRESS-1 ADDRESS-2 CITY SATATE ZIPCODE

My requirement is write record vertically 1st record and 2ed record is beside of first record

Input PS

Rahulhyderabada.pdvcddgfgdsjfgdgf

Rohandsagfdhfkhdkshfhdhsfkdskkfkh

Output PS

Rahul Rohan

Hyderab dsagf

.pdvcdd fkhdksh

Jfgdgf hsdfdfd

Sdvffjds dvfdsjfvds

Regards

rahul


 
Is this answer useful? Yes | No
September 12, 2006 00:52:46   #4  
techieheart Member Since: September 2006   Contribution: 4    

RE: Can we reverse the string in cobol ? See the follo...
Pls use COBOL intrinsic functionm:FUNCTION REVERSE('MANOJ') ... This should do the trick.
 
Is this answer useful? Yes | No
October 23, 2006 21:37:32   #5  
Mark        

RE: Can we reverse the string in cobol ? See the follo...
You can also define table of PIC(X) elements that occurs depending on the string length.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape