String

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
Sandrit
Member
Posts: 6
Joined: Fri Sep 11, 2015 11:06 pm

String

Post by Sandrit » Tue Sep 22, 2015 2:41 am

Code: Select all

EVALUATE TRUE
            WHEN B100-DOLLAR >  A100-AMOUNT
               MOVE 'BOLD'                 TO   B100-STATE
           WHEN B100-DOLLAR =  A100-AMOUNT
               MOVE 'RICH'                TO    B100-STATE 
           WHEN B100-DOLLAR <  75 AND F100-ACCOUNT&#40;1&#58;1&#41; = 9
               MOVE 'POOR'                TO    B100-STATE
              
              STRING B100-DOLLAR
                  'Dollars left'          INTO B100-NOTICE
          WHEN OTHER
                CONTINUE.
Hi
I want to write a notice to “B100-NOTICE”, when there is less than 75 dollars left and for customer with account number starting with 3. The notice is " XXX Dollars left", XXX should state the amount of money left.
I am getting this error message.

Code: Select all

COBCH0155E Numeric item should be an integer and without a 'P' in its picture clause
Can someone please explain to me what I am doing wrong.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Tue Sep 22, 2015 4:10 am

You're using a Micro Focus COBOL. Are you using it for off-line development for the Mainframe?

Code: Select all

EVALUATE TRUE
            WHEN B100-DOLLAR >  A100-AMOUNT
               MOVE 'BOLD'                 TO   B100-STATE
           WHEN B100-DOLLAR =  A100-AMOUNT
               MOVE 'RICH'                TO    B100-STATE
           WHEN B100-DOLLAR <  75 AND F100-ACCOUNT&#40;1&#58;1&#41; = 9
               MOVE 'POOR'                TO    B100-STATE
             
              STRING B100-DOLLAR
                  'Dollars left'          INTO B100-NOTICE
          WHEN OTHER
                CONTINUE. 
Firstly, when using verbs, like evaluate, which have a scope-delimiters (END-...), use that, not a full-stop/period to terminate the statement:

Code: Select all

EVALUATE TRUE
            WHEN B100-DOLLAR >  A100-AMOUNT
               MOVE 'BOLD'                 TO   B100-STATE
           WHEN B100-DOLLAR =  A100-AMOUNT
               MOVE 'RICH'                TO    B100-STATE
           WHEN B100-DOLLAR <  75 AND F100-ACCOUNT&#40;1&#58;1&#41; = 9
               MOVE 'POOR'                TO    B100-STATE
             
              STRING B100-DOLLAR
                  'Dollars left'          INTO B100-NOTICE
          WHEN OTHER
                CONTINUE
        END-EVALUATE 
Secondly, you can't use non-integer numerics in a STRING, is what the message is telling you.

Thirdly, when you correct that, you may still have a problem. Certainly in the COBOL Standard, DELIMITED BY is required by STRING.

Fourthly, your dollar amount will be contiguous with your text, probably not what you want.

To fix the issues, you need to MOVE B100-DOLLAR to a numeric-edited field (simple one is to create a new field, with the same PICture, except it has an actual decimal-point instead of the V, implied decimal-point.

Then include s space in between the opening quote and the D of Dollar.

Sandrit
Member
Posts: 6
Joined: Fri Sep 11, 2015 11:06 pm

Post by Sandrit » Tue Sep 22, 2015 10:34 pm

You're using a Micro Focus COBOL. Are you using it for off-line development for the Mainframe?
I downloaded the trial version of Micro Focus on my laptop when I started to learn Cobol for a couple of weeks ago.
Firstly, when using verbs, like evaluate, which have a scope-delimiters (END-...), use that, not a full-stop/period to terminate the statement:
Thanks for pointing that out. I have just learned how to write evaluate some days ago. I still need Lots of practice.
To fix the issues, you need to MOVE B100-DOLLAR to a numeric-edited field (simple one is to create a new field, with the same PICture, except it has an actual decimal-point instead of the V, implied decimal-point.
Thank you for your help.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Sep 23, 2015 1:32 am

OK. Another choice of COBOL compiler is GnuCOBOL, you can find it at SourceForge.net. Just for information.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others