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
 

 

Need help on Tallying

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

New User


Joined: 30 Mar 2007
Posts: 1
Location: kolkata

PostPosted: Tue Sep 16, 2008 6:16 pm    Post subject: Need help on Tallying
Reply with quote

I need to validate a value in a field. If the value contains spaces in the middle, then it should check for the rest of the characters until 15 positons and if all are spaces, then continue else if a character found after 1st space then error message should be displayed.

ex: UDAY KIRAN , so after UDAY it should capture this space and then check the next character. As it is K, it should display an error message.
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Sep 16, 2008 6:54 pm    Post subject:
Reply with quote

Check if this solves your requirement
Code:

*WS
01 ORIGVAR PIC X(30) VALUE 'UDAY KIRAN'
01 TRUNCVAR PIC X(15).                 
01 DESTVAR1 PIC X(15).                 
01 DESTVAR2 PIC X(15).                 

*PD
MOVE ORIGVAR(1:15) TO TRUNCVAR.     
UNSTRING TRUNCVAR DELIMITED BY SPACES
INTO DESTVAR1 DESTVAR2.             
IF DESTVAR2(1:1) NOT =  ' ' THEN     
DISPLAY "YOUR ERROR MESSAGE".       
Back to top
View user's profile Send private message
Cristopher

New User


Joined: 31 Jul 2008
Posts: 53
Location: NY

PostPosted: Tue Sep 16, 2008 8:24 pm    Post subject: Reply to: Need help on Tallying
Reply with quote

kiran1 if i have understood your requirement correctly thn : There should be an error mssg displayed if there is a character found in 1st 15 bytes of the string after the 1st space found.

You can try this aswell :
Code:

01 A PIC X(25).                                               
01 B PIC X(15) VALUE SPACES.
01 Y PIC 9(01) VALUE ZEROES.
01 SPACE-STATUS   PIC X(1) VALUE 'N'.                         
   88 NO-SPACE               VALUE 'N'.                         
   88 SPACES-FOUND            VALUE 'Y'. 

PERFORM UNTIL Y = LENGTH OF A OR SPACES-FOUND   
Increment Y by 1                                                   
IF A (Y:1) EQUAL TO  SPACES                 
  Increment Y by 1
MOVE A (Y: ) to b
  if b not equal to spaces
     display "error found"
  end-if   
  SET SPACES-FOUND TO TRUE                   
END-IF                                         
END-PERFORM


Cris
Back to top
View user's profile Send private message
Aaru

Senior Member


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

PostPosted: Wed Sep 17, 2008 11:34 am    Post subject: Reply to: Need help on Tallying
Reply with quote

Sambhaji,

Quote:
IF DESTVAR2(1:1) NOT = ' ' THEN
DISPLAY "YOUR ERROR MESSAGE".


What if the first byte after the first space is also spaces and next few bytes with characters? In that case i think your code would not display the error message.

The above code should be put in a loop with the check for the spaces.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Sep 17, 2008 12:39 pm    Post subject:
Reply with quote

lil correction to code
Code:


*WS
01 ORIGVAR PIC X(30) VALUE 'UDAY KIRAN'
01 TRUNCVAR PIC X(15).                 
01 DESTVAR1 PIC X(15).                 
01 DESTVAR2 PIC X(15).                 

*PD
MOVE ORIGVAR(1:15) TO TRUNCVAR.     
UNSTRING TRUNCVAR DELIMITED BY ALL SPACES
INTO DESTVAR1 DESTVAR2.             
IF DESTVAR2(1:1) NOT =  ' ' THEN     
DISPLAY "YOUR ERROR MESSAGE".     


It sould be ALL SPACES
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 INSPECT, TALLYING and then REPLACING maxsubrat COBOL Programming 1 Thu Mar 11, 2010 11:38 am
No new posts Reference modification with tallying ... meenakshi_forum COBOL Programming 1 Fri Dec 04, 2009 3:29 pm
No new posts Why TALLYING field increments when th... suneelv COBOL Programming 10 Thu Jan 22, 2009 11:36 pm


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