Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
maxsubrat

New User

Joined: 27 Feb 2008
Posts: 92
Location: india

 Posted: Sun Jun 24, 2012 1:48 pm    Post subject: Problem having a length check in cobol 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

Nic Clouston

Global Moderator

Joined: 10 May 2007
Posts: 2011
Location: UK

 Posted: Sun Jun 24, 2012 2:11 pm    Post subject: jeesh! And with your daily reading of the forum nothing came to mind as to previous topis on this subject?
dick scherrer

Site Director

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

 Posted: Sun Jun 24, 2012 3:50 pm    Post subject: 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.
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

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

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.
Pandora-Box

Moderator

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

Posted: Sun Jun 24, 2012 6:30 pm    Post subject: Re: Problem having a length check in cobol

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
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8317
Location: Dubuque, Iowa, USA

 Posted: Sun Jun 24, 2012 6:39 pm    Post subject: 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.
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

Posted: Sun Jun 24, 2012 9:44 pm    Post subject: Re: Problem having a length check in cobol

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.
Pandora-Box

Moderator

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

 Posted: Sun Jun 24, 2012 10:48 pm    Post subject: Thanks Bill :-) I get that :-)
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Cobol program till a given time or fo... ankita agarwal COBOL Programming 7 Fri May 18, 2018 2:24 pm Compute statement with Cobol Z/os 5.2 Chetan Kumar COBOL Programming 2 Fri May 11, 2018 8:02 pm Ways to share data between Cobol and ... Benchwarmer Java & MQSeries 3 Thu May 10, 2018 9:16 pm Removing the period or dot from the v... gopinak COBOL Programming 6 Wed May 09, 2018 1:53 pm How to display offset thru cobol prog... tvinodkumar7 CICS 2 Sun Apr 22, 2018 8:42 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us