IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

fetching data from table using occurs clause


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
malathys

New User


Joined: 07 Aug 2008
Posts: 10
Location: chennai

PostPosted: Thu Aug 14, 2008 11:32 am
Reply with quote

Hi,
I am a new user to this forum.
I am trying to fetch the data from the table using occurs clause.I have tried using perform statement for accepting table variables. can i do it?
Here is my code:
working-storage section.
01 emp-record.
02 emp-table occurs 3 times indexed by idx.
03 emp-id pic 9(10).
03 emp-name pic x(10).
procedure division.
para1.
set idx to 1.
perform varying idx from 1 by 1 until idx is greater than 2
accept emp-id(idx)
accept emp-name(idx)
set idx up by 1
end-perform.


please help me.thanks in advance.
Back to top
View user's profile Send private message
rakesha.hg

Active User


Joined: 21 Mar 2008
Posts: 161
Location: bangalore

PostPosted: Thu Aug 14, 2008 11:38 am
Reply with quote

Hi malathys,

Welcome to the forums!

Quote:
I am trying to fetch the data from the table using occurs clause

please clarify? give us what your inputs looks like & sample output?

If your using accept variable? are you passing the values through jcl?

please make the requirement clear.
Back to top
View user's profile Send private message
malathys

New User


Joined: 07 Aug 2008
Posts: 10
Location: chennai

PostPosted: Thu Aug 14, 2008 11:45 am
Reply with quote

Hi,

Thanks for your reply. Yes, you are correct. I am passing the values through jcl.See i am trying to fetch the variables from the table and write it into the file.My output file should contain the table variables.should i be more clear? or is it enough? waiting for reply.thanks.
Back to top
View user's profile Send private message
nuthan

Active User


Joined: 26 Sep 2005
Posts: 146
Location: Bangalore

PostPosted: Thu Aug 14, 2008 11:56 am
Reply with quote

Hi,
The code you have posted here will just take the data from JCL and load into your array/table. Once your array is loaded, do the process u want by reading the array and move the table variables to file record fields. Then write into your file record.
Back to top
View user's profile Send private message
rakesha.hg

Active User


Joined: 21 Mar 2008
Posts: 161
Location: bangalore

PostPosted: Thu Aug 14, 2008 12:04 pm
Reply with quote

hi ,

In that case as nuthan suggested this will load your table ....... you can write file as per your requirement in the file.

If you have to consider any other things let the forum know?
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Aug 14, 2008 4:26 pm
Reply with quote

malathys wrote:
Code:
working-storage section.
    01 emp-record.
          02 emp-table occurs 3 times indexed by idx.
               03 emp-id       pic 9(10).
               03 emp-name pic x(10).
procedure division.
para1.
    set idx to 1.
    perform varying idx from 1 by 1 until idx is greater than 2
         accept emp-id(idx)
         accept emp-name(idx)
         set idx up by 1
    end-perform.
Huh? Why are you setting idx up by one when the perform is doing it too?
First pass, idx is one, second pass idx is three and the perform loop is terminated.......
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Aug 14, 2008 9:31 pm
Reply with quote

Hello,

Once you correct the handling of idx, what will you do with the values in the array?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top