display not outputting correct number of characters



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

display not outputting correct number of characters

Postby theju112 » Sat Apr 06, 2013 3:54 pm

hi im a cobol beginner trying to run this program in ideone.com online comipler...but i am not getting correct output for one display shown below..please help
program
------------------------
        IDENTIFICATION DIVISION.
        PROGRAM-ID. SAMPLE.
        ENVIRONMENT DIVISION.
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01    WS-CUSTRECORD.           
              05     WS-ACNO     PIC   9(05).
              05     WS-NAME     PIC   X(10).
              05     WS-BALANCE  PIC   9(07).
              05     WS-TYPE     PIC   X(02)   VALUE SPACES.
              05     WS-AMOUNT   PIC   9(06).
        PROCEDURE DIVISION.
        MAIN-PARA.
            DISPLAY "INSIDE MAIN PARA".
            PERFORM ACCEPT-PARA.       
            PERFORM CHECK-PARA.
            STOP RUN.
        ACCEPT-PARA.
            DISPLAY "INSIDE ACCEPT PARA".
            ACCEPT WS-ACNO.
            ACCEPT WS-NAME.
            ACCEPT WS-BALANCE.
            ACCEPT WS-AMOUNT.
            ACCEPT WS-TYPE.
           
        CHECK-PARA.
            DISPLAY "WS-TYPE=", WS-TYPE.     <------------------------------------wrong output
            DISPLAY "NAME =", WS-NAME.
            DISPLAY "DEPOSIT TRANSACTION".
            DISPLAY "BALANCE = ", WS-BALANCE.
            DISPLAY "AMOUNT = ", WS-AMOUNT.
            COMPUTE WS-BALANCE = WS-BALANCE + WS-AMOUNT.
            DISPLAY " BALANCE = ", WS-BALANCE.


input
-----------------------------------------
AC101
THEJWAL...
0900001
004002
D.


output
------------------------
INSIDE MAIN PARA
INSIDE ACCEPT PARA
WS-TYPE=D     ====================> wrong output (not printing D. printing only D)
NAME =THEJWAL...
DEPOSIT TRANSACTION
BALANCE = 0900001
AMOUNT = 004002
 BALANCE = 0904003


Code'd
theju112
 
Posts: 3
Joined: Sat Apr 06, 2013 3:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: display not outputting correct number of characters

 

Re: display not outputting correct number of characters

Postby enrico-sorichetti » Sat Apr 06, 2013 4:47 pm

the program.
EDIT       ENRICO.TEST.COB(MF001) - 01.03                  Columns 00001 00072
Command ===>                                                  Scroll ===> CSR
****** ***************************** Top of Data ******************************
000001        IDENTIFICATION DIVISION.
000002        PROGRAM-ID     MF001.
000003        AUTHOR.        <SOME AUTHOR>
000004        ENVIRONMENT    DIVISION.
000005        DATA           DIVISION.
000006        WORKING-STORAGE SECTION.
000007        01 WS-REC.
000008           05 WS-ACCT PIC 9(06).
000009           05 WS-NAME PIC X(20).
000010           05 WS-BLNC PIC 9(06).
000011           05 WS-TYPE PIC X(02).
000012           05 WS-AMNT PIC 9(06).
000013        PROCEDURE      DIVISION.
000014            DISPLAY 'MF001 - STARTED'.
000015            PERFORM ACPT-PARA.
000016            PERFORM UPDT-PARA.
000017            DISPLAY 'MF001 - ENDED  '.
000018            GOBACK.
000019        ACPT-PARA.
000020            DISPLAY 'MF001 - ACPT-PARA ENTER'.
000021            ACCEPT WS-ACCT.
000022            ACCEPT WS-NAME.
000023            ACCEPT WS-BLNC.
000024            ACCEPT WS-TYPE.
000025            ACCEPT WS-AMNT.
000026            DISPLAY 'MF001 - ACPT-PARA LEAVE'.
000027        UPDT-PARA.
000028            DISPLAY 'MF001 - UPDT-PARA ENTER'.
000029            DISPLAY 'WS-ACCT     = ' WS-ACCT.
000030            DISPLAY 'WS-NAME     = ' WS-NAME.
000031            DISPLAY 'WS-BLNC     = ' WS-BLNC.
000032            DISPLAY 'WS-TYPE     = ' WS-TYPE.
000033            DISPLAY 'WS-AMNT     = ' WS-AMNT.
000034            COMPUTE WS-BLNC = WS-BLNC + WS-AMNT.
000035            DISPLAY 'WS-BLNC NEW = ' WS-BLNC.
000036            DISPLAY 'MF001 - UPDT-PARA LEAVE'.
****** **************************** Bottom of Data ****************************

the data.
EDIT       ENRICO.TEST.COB($$RUNIT) - 01.20                Columns 00001 00072
Command ===>                                                  Scroll ===> CSR
****** ***************************** Top of Data ******************************
...... ......
000009 //SYSIN     DD *
000010 000001
000011 NAME.........
000012 000100
000013 T.
000014 000200
****** **************************** Bottom of Data ****************************

the result.
********************************* TOP OF DATA **********************************
MF001 - STARTED
MF001 - ACPT-PARA ENTER
MF001 - ACPT-PARA LEAVE
MF001 - UPDT-PARA ENTER
WS-ACCT     = 000001
WS-NAME     = NAME.........
WS-BLNC     = 000100
WS-TYPE     = T.
WS-AMNT     = 000200
WS-BLNC NEW = 000300
MF001 - UPDT-PARA LEAVE
MF001 - ENDED
******************************** BOTTOM OF DATA ********************************

not a MF ( IBM ) COBOL Problem
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: display not outputting correct number of characters

Postby Robert Sample » Sat Apr 06, 2013 4:58 pm

Since you did you not use the Code button when posting your program and data, it is not possible to determine what happened. There could be a space before the D, for example -- as posted, spacing is not preserved so we cdannot rule that out.

What platform are you running this program on?
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: display not outputting correct number of characters

Postby BillyBoyo » Sat Apr 06, 2013 6:00 pm

ideaone is a website with various "online" compilers and processors. The Cobol on the site is OpenCobol or TinyCobol.

I can't see anything wrong with the program, and enrico has run it.

It is either something with whichever compiler you chose to use, or with how you entered the data on the site.

You could download OpenCobol for yourself, and try it independently of the site. Depending on results, take it up with OpenCobol (at SourceForge) or ideone or with TinyCobol.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: display not outputting correct number of characters

Postby enrico-sorichetti » Sat Apr 06, 2013 6:18 pm

since I was curious,
my program as written does not compile on ideone.

getting
Error: syntax error, unexpected WORD, expecting '.'


I am just curious, and I do not speak COBOLESE
so my program could be just wrong in other ways ;)
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: display not outputting correct number of characters

Postby Robert Sample » Sat Apr 06, 2013 6:56 pm

PROGRAM-ID needs a period after it before the program name. This is not an error in Enterprise COBOL, but ideaone thinks it is.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: display not outputting correct number of characters

Postby enrico-sorichetti » Sat Apr 06, 2013 6:58 pm

:oops:
thank You Robert

retested and it works also there.
Last edited by enrico-sorichetti on Sat Apr 06, 2013 7:05 pm, edited 1 time in total.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: display not outputting correct number of characters

Postby c62ap90 » Sat Apr 06, 2013 7:05 pm

Just for fun...
Change WS-TYPE from PIC X(02) to PIC X(03)
and see if the period gets displayed [I think it will ]
c62ap90
 
Posts: 125
Joined: Thu Oct 11, 2012 10:24 pm
Has thanked: 1 time
Been thanked: 6 times

Re: display not outputting correct number of characters

Postby theju112 » Sat Apr 06, 2013 8:29 pm

hi i tried changing pic x(02) to pic x(03)...then it printed D. but..thats not how it is supposed to be :) ...ill download open cobol and see..
theju112
 
Posts: 3
Joined: Sat Apr 06, 2013 3:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: display not outputting correct number of characters

Postby Robert Sample » Sat Apr 06, 2013 9:28 pm

but..thats not how it is supposed to be
A big problem for beginning programmers is that they "know" what the results should be as opposed to what actually occurred. No matter what compiler you use, there should be a manual available for it. That manual will tell you what the results will be for any given expression in the language. You may think the result you got is not how it is supposed to be, but it is entirely likely that the results you got are what to expect from that compiler. As previously indicated, the results you got are NOT the results you would get by using the IBM Enterprise COBOL compiler on a mainframe, but there are differences between compilers. Using words like "supposed" or "should" are red flags and indicate you are projecting your desires onto the computer rather than accepting the results you got.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post