Page 1 of 2

Passing values to COBOL which uses OCCURS clause

PostPosted: Sat Jan 30, 2010 11:05 am
by kevin1
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"

Re: Passing values to COBOL which uses OCCURS clause

PostPosted: Sat Jan 30, 2010 11:38 am
by dick scherrer
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.

Re: Passing values to COBOL which uses OCCURS clause

PostPosted: Sat Jan 30, 2010 2:19 pm
by kevin1
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.

Re: Passing values to COBOL which uses OCCURS clause

PostPosted: Sat Jan 30, 2010 9:25 pm
by dick scherrer
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.

Re: Passing values to COBOL which uses OCCURS clause

PostPosted: Sat Jan 30, 2010 10:24 pm
by kevin1
Thank you for your valuable answers... :) Mr.Scherrer

Re: Passing values to COBOL which uses OCCURS clause

PostPosted: Sun Jan 31, 2010 2:32 am
by dick scherrer
You're welcome :)

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

Good luck!

Re: Passing values to COBOL which uses OCCURS clause

PostPosted: Sun Jan 31, 2010 11:10 pm
by kranthi.kumarmca22
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

Re: Passing values to COBOL which uses OCCURS clause

PostPosted: Mon Feb 01, 2010 5:03 am
by dick scherrer
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.

Re: Passing values to COBOL which uses OCCURS clause

PostPosted: Mon Feb 01, 2010 7:00 am
by kranthi.kumarmca22
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,

Re: Passing values to COBOL which uses OCCURS clause

PostPosted: Mon Feb 01, 2010 8:11 am
by Robert Sample
Production programs in business may get some values from parameters (if needed), but most of the data they use comes from files.