IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

string comparison


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
amar.mce

New User


Joined: 01 Dec 2007
Posts: 2
Location: india

PostPosted: Fri Dec 07, 2007 5:15 pm
Reply with quote

i wanted to compare the 1st three characters of a string.

Ex.

length of variable is 10. of which 1st three characters must be AAA.

THANKS IN ADVANCE
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Dec 07, 2007 5:24 pm
Reply with quote

Hello Amar,
Welcome to this forum.

Code:
IF WS-VAR(1:3) = 'AAA' THEN
    .
    .
    .


Correct me if I am wrong.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Dec 07, 2007 5:28 pm
Reply with quote

amar,

Hi and welcome to the forums.

Quote:
i wanted to compare the 1st three characters of a string.


You can use reference modification technique.

Code:
IF B(1:3) = 'AAA'  THEN   
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Fri Dec 07, 2007 5:53 pm
Reply with quote

Addition to above suggestions -

using 'redefine'.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Dec 07, 2007 5:56 pm
Reply with quote

Murali,

Quote:
using 'redefine'.


Could you explain in detail?
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Fri Dec 07, 2007 6:31 pm
Reply with quote

Gnanas,

Code:
01   A PIC X(10).
01   B REDEFINES A.
      02 FIRST-A-3 PIC X(3).
      02 REM-A-OPTIONAL PIC X(n).
====> where n=1 to 7 <==== comment


Now use FIRST-A-3 var for comparision.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Dec 07, 2007 7:17 pm
Reply with quote

Fine. Thanks Murali.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts file manager is doing string conversion IBM Tools 3
No new posts Search string in job at regular Spool... CLIST & REXX 0
Search our Forums:

Back to Top