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

Need the COBOL code to form the structure of a table


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Load new table with Old unload - DB2 DB2 6
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts run rexx code with jcl CLIST & REXX 15
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top