Passing values to COBOL which uses OCCURS clause



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

Passing values to COBOL which uses OCCURS clause

Postby kevin1 » Sat Jan 30, 2010 11:05 am

Hi Everyone,

I am happy to join this forum, thank you for having such forum.

Please, can someone tell me how to pass values to a cobol programme which uses OCCURS CLAUSE... here is example

          77 I   PIC   9(2).   
          01 REC1
                   02 A-TAB OCCURS 5 TIMES INDEXED BY A1
                        03 ACNO        PIC  X(6).
                        03 PERNAME   PIC  A(10).
                         03 AMOUNT   PIC   9(8).
          PROCEDURE DIVISION.
                     MOVE1 TO I.
                     PERFORM UNTIL I>5
                          ACCEPT ACNO(I)
                          ACCEPT PERNAME(I)
                          ACCEPT AMOUNT(i)
                          ADD 1 TO I.
                       END-PERFORM.     


Awaiting for answer....."Thanks in Advance"
kevin1
 
Posts: 9
Joined: Sat Jan 30, 2010 8:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: Passing values to COBOL which uses OCCURS clause

 

Re: Passing values to COBOL which uses OCCURS clause

Postby dick scherrer » Sat Jan 30, 2010 11:38 am

Hello and welcome to the forum,

Is there some problem with what you posted?

While ACCEPTing data is usually not permitted by most standards, the posted code could get data into the array.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Passing values to COBOL which uses OCCURS clause

Postby kevin1 » Sat Jan 30, 2010 2:19 pm

Thank you for your quick reply,

I dont know exactly. But, can you give me some example to using OCCURS clause and passing values to it.
kevin1
 
Posts: 9
Joined: Sat Jan 30, 2010 8:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: Passing values to COBOL which uses OCCURS clause

Postby dick scherrer » Sat Jan 30, 2010 9:25 pm

Hello,

"Passing" values to an array is accomplished by a MOVE typically.

Instead of multiple ACCDEPT statements, the 3 values would be placed in mujltiple records which would be READ from a file and then MOVEd into the proper place in the array.

"Passing" also usually implies information that comes into the program via a PARM rather than as data.

Your actual requirement is not clear so it is difficult to provide much guidance.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Passing values to COBOL which uses OCCURS clause

Postby kevin1 » Sat Jan 30, 2010 10:24 pm

Thank you for your valuable answers... :) Mr.Scherrer
kevin1
 
Posts: 9
Joined: Sat Jan 30, 2010 8:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: Passing values to COBOL which uses OCCURS clause

Postby dick scherrer » Sun Jan 31, 2010 2:32 am

You're welcome :)

If you post some clarification of your requirement, someone should be able to offer a suggestion.

Good luck!
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Passing values to COBOL which uses OCCURS clause

Postby kranthi.kumarmca22 » Sun Jan 31, 2010 11:10 pm

Hai kevin,
This is kranthi.
I hope that you want to pass values into the array A-tab.
As per my knowledge you have to pass the values through jcl.

In your jcl pass the values as follows

//GO.SYSIN DD *
AC0001
NAME1
5000
AC0002
NAME2
6000
AC0003
NAME3
3000
AC0004
NAME4
4000
AC0005
NAME5
1000
/*
//



I hope this is what you required.
If anything is wrong in what i have mentioned please let me know
kranthi.kumarmca22
 
Posts: 14
Joined: Thu Jan 07, 2010 9:50 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Passing values to COBOL which uses OCCURS clause

Postby dick scherrer » Mon Feb 01, 2010 5:03 am

Hello,

As per my knowledge you have to pass the values through jcl.
While this could work, it is not permitted in most organizatons. . .

At best this might be used for learning, not a real business problem.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Passing values to COBOL which uses OCCURS clause

Postby kranthi.kumarmca22 » Mon Feb 01, 2010 7:00 am

Then please explain how can we pass the values in a real business.
I am a fresher learning cobol.
Your explanation helps me a lot.
Thank you dick,
kranthi.kumarmca22
 
Posts: 14
Joined: Thu Jan 07, 2010 9:50 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Passing values to COBOL which uses OCCURS clause

Postby Robert Sample » Mon Feb 01, 2010 8:11 am

Production programs in business may get some values from parameters (if needed), but most of the data they use comes from files.
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