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 directly compare two alphanumeric data items

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sri.mainframes

New User


Joined: 16 Feb 2006
Posts: 29
Location: MUMBAI

PostPosted: Wed Apr 12, 2006 1:41 pm    Post subject: can we directly compare two alphanumeric data items
Reply with quote

two data items A and B

A PIC A(5) VALUE 'S123S'
B PIC A(5) VALUE 'S123S'

CAN I DIRECTLY COMPARE LIKE

IF A = B
MOVE SPACES TO B.
ELSE MOVE A TO B.

CAN ANYONE FIND OUT WEATHER THE ABOVE CODE CORRECT OR NOT . IF NOT THEN HOW CAN I COMPARE TWO DATA ITEMS WITH '=' OPERTOR

thanks in advance
sri.prince
Back to top
View user's profile Send private message

Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1243
Location: Israel

PostPosted: Wed Apr 12, 2006 3:03 pm    Post subject:
Reply with quote

The answer to your question is yes, this is the way to do it.

BUT

you defined your areas as PIC A(5). As such, they can contain only alphabetic characters or spaces (no numbers).
Most programmers would use PIC X(5) which allows more freedom.

ALSO

The dot (.) before the ELSE should be removed.
Personnaly, I prefer to use END-IF over a final dot.
Very Important: Use indentation. Like this you can immediately see where the IF ends, when the ELSE starts and so on...

Code:
IF A = B THEN
    MOVE SPACES TO B
ELSE
    MOVE A TO B
END-IF
Back to top
View user's profile Send private message
crrindia

Active User


Joined: 02 Jul 2005
Posts: 124
Location: Gurgaon

PostPosted: Wed Apr 12, 2006 3:21 pm    Post subject:
Reply with quote

Hi Marso, I see in your sample code you have coded like shown below.

IF A = B THEN
MOVE SPACES TO B
ELSE
MOVE A TO B
END-IF[/code][/quote]

I think you have to code THEN instead of THAN. If I am wrong please excuse me. The correct code I am thinking is

IF A = B THAN
MOVE SPACES TO B
ELSE
MOVE A TO B
END-IF[/code][/quote]


Thanks!
Rat..
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 Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts opening a dataset after reading it fr... arunsoods DFSORT/ICETOOL 5 Wed Oct 04, 2017 3:54 pm
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 11 Fri Sep 22, 2017 11:35 pm

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