Problem in defining 88 level values



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Problem in defining 88 level values

Postby chenky » Mon Feb 11, 2013 2:40 pm

H i all,

I am facing issue in including one of these values in 88 level in cobol, could you please help me in handling it.

05 COMMON-INP     PIC X(20).
   88 COMMON-SPL-INP VALUES 
      'EL_$O.:CREKM3}B9}3I+'
      'ESSL.U$D<8WEHCKT"HF`
'

ONE OF THE VALUES IN COMMON-SPL-INP is "JUYP'<SDKKP>}.$+SDD FOR WHICH I AM FACING THE ISSUE ..as its having both " and ' in the data itself its not allowing me to include in this. Kindly help me.
chenky
 
Posts: 16
Joined: Tue Nov 20, 2012 4:59 pm
Has thanked: 7 times
Been thanked: 0 time

Re: Problem in defining 88 level values

 

Re: Problem in defining 88 level values

Postby BillyBoyo » Mon Feb 11, 2013 2:51 pm

That's tricky. You can use hexadecimal notation, VALUE X'F1' for instance is the same as VALUE '1'.

Problem is, a 40-hex-digit string is not going to be easy to understand/maintain. How many values do you have on the 88?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Problem in defining 88 level values

Postby chenky » Mon Feb 11, 2013 2:54 pm

I have more than 20 values in 88 level..also i cant move all the values to a file , because opening and close for each record will effect the system severely
chenky
 
Posts: 16
Joined: Tue Nov 20, 2012 4:59 pm
Has thanked: 7 times
Been thanked: 0 time

Re: Problem in defining 88 level values

Postby BillyBoyo » Mon Feb 11, 2013 3:11 pm

Well, I've no idea why you'd want to "open and close" for each record, but there would be some overhead.

How many of the 88s have both ' and "?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Problem in defining 88 level values

Postby chenky » Mon Feb 11, 2013 3:17 pm

there are 3
chenky
 
Posts: 16
Joined: Tue Nov 20, 2012 4:59 pm
Has thanked: 7 times
Been thanked: 0 time

Re: Problem in defining 88 level values

Postby BillyBoyo » Mon Feb 11, 2013 3:47 pm

01  a-field redefines your field.
    05  filler pic x(10).
        88  a-new-88 value 'some of your text'.
    05  filler pic x.
        88  a-quote value '"'.
    05  filler pic x(5).
        88  another-new-88 value 'some more of your text'.
    05  filler pic x.
        88  an-apost value "'".
    05  filler pic x(3).
        88  a-final-new-88 value 'the last of your text'.

You'd need three of them, and then

IF original-88
OR ( a-new-88
    AND a-quote
    AND another-new-88
    AND an-apost
    AND a-final-new-88 )
OR ( same set-up, twice more


Alternatively, three new data-names with the above set-up, and test those for any being equal, along with the remain 88 excluding the three which don't work.

The advantage over the X'...' version is understandabilty and maintainability.

These users thanked the author BillyBoyo for the post:
chenky (Mon Feb 11, 2013 3:52 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Problem in defining 88 level values

Postby chenky » Mon Feb 11, 2013 4:00 pm

Thanks BillyBoyo..also I have come up with another soln like this ..

01  WS-SPL-VAR1.                                 
    05 WS-VAR1-1 PIC X(04) VALUE '"JUYP'.       
    05 WS-VAR1-2 PIC X(16) VALUE "'<SDKKP>}.$+SDD".


and using this type of 2 more special variables for furthur processing..

intiated this thought from your logic thanks again :)
chenky
 
Posts: 16
Joined: Tue Nov 20, 2012 4:59 pm
Has thanked: 7 times
Been thanked: 0 time

Re: Problem in defining 88 level values

Postby BillyBoyo » Mon Feb 11, 2013 4:17 pm

Good work.

You should put more effort into your data-names. It can make understanding a program much clearer.

01  WS-TEST-FOR-whatever-WITH-QUOTE-AND-APOST.
    05 FILLER PIC X(04) VALUE '"JUYP'.       
    05 FILLER PIC X(16) VALUE "'<SDKKP>}.$+SDD".



Where "whatever" describes the particular value best. Two more of those. I made the sub-fields FILLER as they will never be referenced, so don't need a name. Also a good case for using comments to explain why the IF turns out that way, so that it doesn't have to be "discovered" every time someone looks at the program.

These users thanked the author BillyBoyo for the post:
chenky (Mon Feb 11, 2013 4:24 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Problem in defining 88 level values

Postby chenky » Mon Feb 11, 2013 4:25 pm

Ok Billy
chenky
 
Posts: 16
Joined: Tue Nov 20, 2012 4:59 pm
Has thanked: 7 times
Been thanked: 0 time

Re: Problem in defining 88 level values

Postby pmartyn » Fri Mar 01, 2013 12:44 am

The Enterprise COBOL compilers support mixing of quotes.

Any of these will work:

DISPLAY 'He said, "Hello"'. DISPLAY "He said, ""Hello""".

DISPLAY "I'm tired". DISPLAY 'I''m tired'.

The QUOTE/APOST option has to do with the figurative constant QUOTE(S), which can always be used as a backup option
pmartyn
 
Posts: 42
Joined: Thu Feb 28, 2013 7:11 pm
Has thanked: 5 times
Been thanked: 3 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post