Page 1 of 2

Problem in defining 88 level values

PostPosted: Mon Feb 11, 2013 2:40 pm
by chenky
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.

Re: Problem in defining 88 level values

PostPosted: Mon Feb 11, 2013 2:51 pm
by BillyBoyo
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?

Re: Problem in defining 88 level values

PostPosted: Mon Feb 11, 2013 2:54 pm
by chenky
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

Re: Problem in defining 88 level values

PostPosted: Mon Feb 11, 2013 3:11 pm
by BillyBoyo
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 "?

Re: Problem in defining 88 level values

PostPosted: Mon Feb 11, 2013 3:17 pm
by chenky
there are 3

Re: Problem in defining 88 level values

PostPosted: Mon Feb 11, 2013 3:47 pm
by BillyBoyo
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.

Re: Problem in defining 88 level values

PostPosted: Mon Feb 11, 2013 4:00 pm
by chenky
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 :)

Re: Problem in defining 88 level values

PostPosted: Mon Feb 11, 2013 4:17 pm
by BillyBoyo
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.

Re: Problem in defining 88 level values

PostPosted: Mon Feb 11, 2013 4:25 pm
by chenky
Ok Billy

Re: Problem in defining 88 level values

PostPosted: Fri Mar 01, 2013 12:44 am
by pmartyn
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