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
rahul
Sep 8th, 2006
hello
Is there any other method?
regards,
rahul
rahul
Sep 8th, 2006
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
Pls use COBOL intrinsic functionm:FUNCTION REVERSE('MANOJ') ... This should do the trick.
Mark
Oct 23rd, 2006
You can also define table of PIC(X) elements that occurs depending on the string length.
abdul muneer
Feb 17th, 2012
Yes we can reverse a string by using move reference modification concept
eg:01 name pic x(4).
01 rname pic x(4).
move name(1:1) to rname(4:1).
move name(2:1) to rname(3:1).
move name(3:1) to rname(2:1).
move name(4:1) to rname(1:1).
Nik
May 14th, 2012
Have you tried doing this -
Code
RAMESH
Jul 3rd, 2012
by using reference modification......
IDENTIFICATION DIVISION.
PROGRAM-ID. REVSTRN.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 STR1 PIC X(5) VALUE IS MANOJ.
01 STR2 PIC X(5).
01 I PIC 9(1).
01 J PIC 9(1) VALUE 5.
01 K PIC 9(1) VALUE 5.
PROCEDURE DIVISION.
DISPLAY " STRING:", STR1.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > K
MOVE STR1(I: 1) TO STR2(J: 1)
COMPUTE J = J - 1.
END-PERFORM.
DISPLAY " REV STRNG:", STR2.
STOPRUN.
RESULT:
STRING: MANOJ
REV STRNG: JONAM
Rishi Sharma
May 22nd, 2014
Yes it can be done by following code:
Code
sashi
Nov 19th, 2014
i have one ps file it contain 2 headers ans 2 tiles each header contain some records now my requirement is i want 2 header contain some records copy to out put file is this possible could u please suggest me.
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.