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

Low value in a string


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

New User


Joined: 25 Jul 2006
Posts: 23

PostPosted: Fri Jan 25, 2008 3:53 am
Reply with quote

I have a string and the first character is a low value (X'05') and the string is 20 characters long and it has other varialbles like 'CLIENT'.

When I am checking this in the Perform until condition if the string is <= spaces the condition satisfies. The string definitely has the word 'CLIENT' in it so it has to be greater than spaces. But still the condition satisfies and it comes out of the loop. Is it because of the presence of 1 low value that the entire string is considered < spaces. Please advise.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jan 25, 2008 4:11 am
Reply with quote

First x'05' is a TAB not a low-value.

Second try string <= all spaces
Back to top
View user's profile Send private message
gragha

New User


Joined: 25 Jul 2006
Posts: 23

PostPosted: Fri Jan 25, 2008 4:20 am
Reply with quote

The current condition is perform until string <= spaces.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Jan 25, 2008 4:27 am
Reply with quote

A correction. LOW-VALUE is X'00'.

Try this -

Code:

03  WS-STRING  PIC X(20).
03  WS-SUB     PIC 9(08) BINARY.
03  WS-FLENGTH PIC 9(08) BINARY.

MOVE ZERO         TO TALLY.

INSPECT WS-STRING TALLYING TALLY FOR CHARACTERS BEFORE INITIAL 'CLIENT'.


Then, if TALLY is less than the LENGTH OF WS-STRING, then 'CLIENT' can be found at WS-STRING (TALLY + 1:6).

Otherwise, it's not in WS-STRING.

_O R_

Code:

COMPUTE WS-FLENGTH     = (LENGTH OF WS-STRING - 5).
MOVE 1                 TO WS-SUB.
MOVE ZERO              TO TALLY.

PERFORM UNTIL WS-SUB > WS-FLENGTH
    IF  WS-STRING (WS-SUB:6) = 'CLIENT'
        MOVE WS-SUB    TO TALLY
        COMPUTE WS-SUB = (WS-FLENGTH + 1)
    ELSE
        ADD  1         TO WS-SUB
    END-IF
END-PERFORM.


Then, if TALLY > ZERO, then 'CLIENT' can be found at WS-STRING (TALLY:6).

Otherwise, it's not in WS-STRING.

HTH....

Regards,

Bill
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jan 25, 2008 9:01 pm
Reply with quote

Hello,

If you look at the field in hex, is there more than 1 x'05' among the variables?

How was this field created? Is it possible that you have tab-delimited data?

If you do, you could UNSTRING the variables into separate fields using the x'05' as the delimiter.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Fri Jan 25, 2008 10:53 pm
Reply with quote

I was going to speculate that the x'05' might be the length of the data in the character field. Like when you pull a VARCHAR from DB2.

Although x'05' doesn't equal len('CLIENT') but maybe the O/P gave us data from two different records.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jan 25, 2008 10:59 pm
Reply with quote

gragha wrote:
The current condition is perform until string <= spaces.


If the first character of the field is x'05' then it would be less than space (x'40').
Back to top
View user's profile Send private message
vsgaikwad

New User


Joined: 20 Nov 2007
Posts: 6
Location: Pune

PostPosted: Mon Feb 04, 2008 6:58 pm
Reply with quote

Hi,

I saw like following.

Code:
IF ABC IS GREATER THAN SPACE/SPACES THEN


where ABC is X(05).

what is the meaning of above code. I got confused..Because suppose if ABC contains either 123 or 12ABC or ABC12 or ABCDEF, what will happen..Even I tried with program...But still confused..whether it's comparing with EBCDIC value or something else.....

Vikas.[/code]
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Feb 04, 2008 8:42 pm
Reply with quote

Hello,

Is this an additonal question or is this part of the original question?

Is the field PIC X(05) or does the field contain one or more characters with a value of x'05'.

This code:
Code:
IF ABC IS GREATER THAN SPACE/SPACES THEN
will compare the content of ABC against spaces and continue execution accordingly.

If you post what you tried with a program and the result you received, someone will be able to clarify.
Back to top
View user's profile Send private message
rag swain

New User


Joined: 17 Dec 2007
Posts: 33
Location: pune,INDIA

PostPosted: Tue Feb 05, 2008 10:16 pm
Reply with quote

Quote:

Hi,

I saw like following.

Code:
IF ABC IS GREATER THAN SPACE/SPACES THEN


where ABC is X(05).

what is the meaning of above code. I got confused..Because suppose if ABC contains either 123 or 12ABC or ABC12 or ABCDEF, what will happen..Even I tried with program...But still confused..whether it's comparing with EBCDIC value or something else.....


Vikas-You should have started a new thread instead. however there is nothing wrong with the code you showed.

Dick,

The O/P is different than the last one who posed this question.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Feb 06, 2008 1:39 am
Reply with quote

Quote:
The O/P is different than the last one who posed this question.
Yup, noticed that. When "round 2" started, i couldn't convince myself whether the new post was a continuation or a completely new question - so i asked. So far, no response. . .

I'll be happy to split this into a separate topic or leave it where it is. Any preferences?

d
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 2
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