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
 
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: 82
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: 1894
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: 7315

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: 1542
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: 8165
Location: East Dubuque, Illinois, USA

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: 7315

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: 1542
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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am

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