View previous topic :: View next topic
|
Author |
Message |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
Hi,
I have field whcih is of chracter (20) and i need to check all characters whethere it is 'Y' or 'N' .
Like below
01 WS-X PIC X(20).
88 YES VALUE 'YYYYYYYYYYYYYYYYYYYY'
88 NO VALUE 'NNNNNNNNNNNNNNNNNN'.
Is that can we represent the above with below like ,
01 WS-X PIC X(20).
88 YES VALUE '(20)Y'.
88 NO VALUE '(20)N'.
In COBOL ?
I know it will not work , i want the same to specify the count of occurence of Y & N instead of specifying twenty ''Y's & 'N's .
Can any one help me ?
Thanks
Balaji K |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Btw why do you want specify like 20(Y) or 20(N) ?? |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Code: |
01 WS-X PIC X(20).
88 YES VALUE ALL 'Y'.
88 NO1 VALUE ALL 'N'. |
? |
|
Back to top |
|
|
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
Thanks buddy .... |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Or:
Code: |
01 WS-CUSTOMER-NUMBER-OF-LEGS PIC X(20).
88 WS-CUSTOMER-HAS-TWO-LEGS VALUE ALL 'Y'.
88 WS-CUSTOMER-HAS-THREE-LEGS VALUE ALL 'N'. |
I've made a completely blind guess at what your field and 88's might mean in business terms, and I could be completely wrong.
The point is, that you can always use well thought out and accurate names for your data-names and procedure-names to not leave the next person who looks at the program making the same type of "blind guess" as to what they mean.
You'll even discover that it helps you whilst writing the code. You'll find you never write:
Code: |
ADD WS-NUMBER-OF-ORANGES-THIS-CLIENT TO WS-TOTAL-APPLES-THIS-AREA |
But you might well write:
Code: |
ADD WS-VAR5 TO WS-TOTVAR4 |
and if you did write that, then you will have wasted time and money until it is found and corrected. Sometimes not so much, sometimes a lot.
You feel that it would be a terrible amount of extra typing? Learn how to use the editor effectively, please.
Even if you stick with the foolishness of short names which convey no further information, don't use single English words, ever. You never know when a new compiler will come along and use your data-name for a RESERVED WORD. Then your program no longer compiles. |
|
Back to top |
|
|
|