Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need the COBOL code to form the structure of a table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sudhee_rb

New User


Joined: 29 Mar 2006
Posts: 34

PostPosted: Sun Sep 10, 2006 5:21 pm    Post subject: Need the COBOL code to form the structure of a table
Reply with quote

Hi 2 all,
This is sudheer,
i need this requirement , could u please any body please give the code.
The table is like this..

using occurs

|st_no| st_name |st_add
-----------------------------------
1 |
-----------------------------------
2 |
------------------------------------
.
.
.

20 times


Thanks in advance

sudheer
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Sun Sep 10, 2006 8:33 pm    Post subject: Re: Regarding the structure of a table
Reply with quote

Sudheer,

This is the way I code tables. It?s more than you asked for and I hope it does not confuse you to much. The specific question you asked is answered with the ?05 ST-ENTRY? and related ?10? variables. The remaining supporting variables I like to put with the table for easy of understanding. Other variables related to the ?ST-TABLE? structure may need to be defined.

?05-SUB? is the subscript used when accessing the table.
?ST-MAX-NUM-ENTRIES? is used to reference in your code for the maximum number of entries available in the table.
?ST-CURR-NUM-ENTRIES? is contains the number of entries in the table actually used.

Code:

    01  ST-TABLE.
        05  ST-ENTRY              OCCURS 20 TIMES.
            10  ST-NO             PIC S9(9) COMP-3.
            10  ST-NAME           PIC X(40).
            10  ST-ADD            PIC X(40).
        05  ST-SUB                PIC S9(9) COMP-3.
        05  ST-MAX-NUM-ENTRIES    PIC S9(9) COMP-3 VALUE 20.
        05  ST-CURR-NUM-ENTRIES   PIC S9(9) COMP-3 VALUE 0.


It is a good practice to test the number of entries in the table prior to adding another entry. This will prevent exceeding the table and corrupting the memory adjacent to it.

Code:

    ADD-NEW-ST-ENTRY.       
        ADD +1          TO ST-CURR-NUM-ENTRIES.
        IF ST-CURR-NUM-ENTRIES > ST-MAX-NUM-ENTRIES
        THEN
            PERFORM ST-TABLE-EXCEEDED
        ELSE
            MOVE ST-CURR-NUM-ENTRIES TO ST-SUB
            MOVE NEW-ST-NO           TO ST-NO(ST-SUB)
            MOVE NEW-ST-NAME         TO ST-NAME(ST-SUB)
            MOVE NEW-ST-ADD          TO ST-ADD(ST-SUB)
        END-IF.


Dave
Back to top
View user's profile Send private message
sudhee_rb

New User


Joined: 29 Mar 2006
Posts: 34

PostPosted: Mon Sep 11, 2006 7:22 pm    Post subject: Re: Need the COBOL code to form the structure of a table
Reply with quote

Hi Dave,

First i wd like 2 tell the thanks to u ones again for sendig the replay,

Sorry,
i couldent sent the query clearly,

i need that structure in 2 dimentional form,

i think wt u sent to me is 1 dim structure..

if u know please send the 2 dim structure.


thanks in advance


Sudheer
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Mon Sep 11, 2006 7:48 pm    Post subject: Re: Need the COBOL code to form the structure of a table
Reply with quote

Check out the link below on Defining a tables. At the bottom of the link page are examples of 1,2, and 3 dimensional tables.

Defining a Table

From your description in your first post, I don't know how you would like the 2nd dimension defined.

You described a one dimensional table; several variables occurring 20 times. For a 2nd dimension, you'd need to have the set of 20 variables occurring x number of times. Like under 'school of' type. i.e. School of Law, School of Art, School of Science.

Let me know how you want this to structure and we can help you.

Dave
Back to top
View user's profile Send private message
vijayakumar.yellala

New User


Joined: 19 Apr 2006
Posts: 63
Location: Chennai

PostPosted: Tue Sep 12, 2006 11:37 am    Post subject: Re: Need the COBOL code to form the structure of a table
Reply with quote

Hello sudhee_rb,

Please elaborate your request, so that every one will help you...

Regards
Vijay
Back to top
View user's profile Send private message
sudhee_rb

New User


Joined: 29 Mar 2006
Posts: 34

PostPosted: Tue Sep 12, 2006 11:28 pm    Post subject: Re: Need the COBOL code to form the structure of a table
Reply with quote

Hi dave ,

could u please send the diff between 1 dim and 2 dim with structures and

example values.

Thanks in advance.

sudheer
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Sep 12, 2006 11:51 pm    Post subject: Re: Need the COBOL code to form the structure of a table
Reply with quote

sudheer,

I'm not sure how to explain it better than in the link in 'Defining a Table' in my previous post, but I can try. Can you give specific questions about what you did not understand in the link? I know tables can be troublesome for those not familiar with them.

Dave
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Job failing with USER = 4093 REASON C... Pradeepa S ABENDS & Debugging 1 Wed May 17, 2017 3:35 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us