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
 

 

Problem having a length check in cobol

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

New User


Joined: 27 Feb 2008
Posts: 72
Location: india

PostPosted: Sun Jun 24, 2012 1:48 pm    Post subject: Problem having a length check in cobol
Reply with quote

I have a a requirement of a lenghth check..

FIELDA = X(800)

FIELDA has data varying 3 to 10.

IF FIELDA is less and equal to X(10)
perform para-100
else
perform para-200
end-if.

How to meet the above requirement.Thanks for any suggestion.
Thanks
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1714
Location: UK

PostPosted: Sun Jun 24, 2012 2:11 pm    Post subject:
Reply with quote

jeesh! And with your daily reading of the forum nothing came to mind as to previous topis on this subject?
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Sun Jun 24, 2012 3:50 pm    Post subject:
Reply with quote

Hello,

I suspect that different people will have different understandings of what you have asked.

Personally, i do not understand at all. How can FIELDA be compared to X(10)?

Maybe if you show some samples of the "input" and the result of the IF statement for each of the input samples it will help clarify.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Sun Jun 24, 2012 4:44 pm    Post subject: Reply to: Problem having a length check in cobol
Reply with quote

I'm not sure what you actually want either.

Code:
01  a-nice-name-which-describes-the-field pic x(10).

MOVE FIELDA TO a-nice-name-which-describes-the-field

IF FIELDA EQUAL TO a-nice-name-which-describes-the-field
    perform para-100
ELSE
    perform para-200
END-IF


This assumes trailing spaces in your FIELDA.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Sun Jun 24, 2012 6:30 pm    Post subject: Re: Problem having a length check in cobol
Reply with quote

Assuming that I understood your requirement

maxsubrat wrote:
FIELDA has data varying 3 to 10.


Do you mean the actual data of 3 to 10 bytes apart from spaces ,low-values ??

Code:
If FIELDA(11:790) NOT = SPACES OR LOW-VALUES
   perform para-100
Else
   perform para-200
End-if
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7908
Location: Bellevue, IA

PostPosted: Sun Jun 24, 2012 6:39 pm    Post subject:
Reply with quote

COBOL does not have strings in the same way other languages have strings (variables whose length changes at run time). FIELDA, if you defined it as PIC X(800) in WORKING-STORAGE, has a length of 800. It will have a length of 800 no matter what the data is in the variable. A variable in WORKING-STORAGE is fixed length -- even variables with OCCURS DEPENDING ON have the maximum possible amount of storage reserved for them, no matter how many occurrences exist at any given time.

If a variable is defined in LINKAGE SECTION, with OCCURS DEPENDING ON, then the length can vary at run time -- but the memory for the variables is not local to the executing program.

Variables in an 01 in the FILE SECTION can also use OCCURS DEPENDING ON to have varying length, but in this case the length is based upon what the file record contains.

As others have said, perhaps if you explain what you need to accomplish, rather than how you're trying to do it, we can provide more assistance.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Sun Jun 24, 2012 9:44 pm    Post subject: Re: Problem having a length check in cobol
Reply with quote

Pandora-Box wrote:
Assuming that I understood your requirement

maxsubrat wrote:
FIELDA has data varying 3 to 10.


Do you mean the actual data of 3 to 10 bytes apart from spaces ,low-values ??

Code:
If FIELDA(11:790) NOT = SPACES OR LOW-VALUES
   perform para-100
Else
   perform para-200
End-if


Code:
01  FIELDA.
    05  FILLER PIC X(10).
    05  FILLER PIC X(790).
        88  FIELDA-TRAILING-VALUE-ONLY VALUE SPACE.

If FIELDA-TRAILING-VALUE-ONLY
   perform para-100
Else
   perform para-200
End-if


Your solution, Pandora-box, just not encouraging the reference-modification.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Sun Jun 24, 2012 10:48 pm    Post subject:
Reply with quote

Thanks Bill :-)

I get that :-)
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 What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm


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