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
 

 

string comparison

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: string comparison
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: 785
Location: Chennai, India

PostPosted: Fri Dec 07, 2007 5:24 pm    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Fri Dec 07, 2007 5:28 pm    Post subject: Reply to: string comparison
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: 1439
Location: Bangalore,India

PostPosted: Fri Dec 07, 2007 5:53 pm    Post subject:
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: 785
Location: Chennai, India

PostPosted: Fri Dec 07, 2007 5:56 pm    Post subject:
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: 1439
Location: Bangalore,India

PostPosted: Fri Dec 07, 2007 6:31 pm    Post subject:
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: 785
Location: Chennai, India

PostPosted: Fri Dec 07, 2007 7:17 pm    Post subject:
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    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 CICS NEW SIT PARAMETERS CICS BEHAVIOR... Kyle Carroll CICS 0 Fri Nov 04, 2016 11:55 pm
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm
No new posts How to insert a lengthy string havin... vidyaa DB2 7 Thu Aug 25, 2016 5:20 pm
No new posts Which function does the Ampersand (&a... Andi1982 PL/I & Assembler 3 Wed Aug 24, 2016 2:05 pm


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