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

How to pass tables in program


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
anoop_mf

New User


Joined: 27 Sep 2005
Posts: 6

PostPosted: Tue Dec 13, 2005 7:27 pm
Reply with quote

hi how can we pass tables from one pgm to another.

Why 77 level is used as an elementary level.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Tue Dec 13, 2005 9:23 pm
Reply with quote

Quote:
hi how can we pass tables from one pgm to another.

Are they passed, from one prog to another.... You include tables in your program....

May be I m wrong... Plz correct....

Quote:
Why 77 level is used as an elementary level.

icon_cool.gif Because 66 is used in RENAME & 88 in Conditional.

Regards,

Priyesh.
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 411
Location: Colarado, US

PostPosted: Wed Dec 14, 2005 6:57 am
Reply with quote

Hi anoop_mf,


Quote:
hi how can we pass tables from one pgm to another


Your question looks vague. What Priyesh said is right. Tables are used to improve the efficiency of programs.

One solution to my undestanding is you can code the FD section for the file in a separate program and access the program by using TABLES along with INDEX.

Example

Say your FD code is in "FDPGM.CBL"

Inside the main program under FILE SECTION use this statement,
COPY "FDPGM.CBL"

Code:
FDPGM.CBL
* Primary Key - STATE-CODE
* NAME is required
* NAME and CODE should be uppercase
*--------------------------------
FD  STATE-FILE
LABEL RECORDS ARE STANDARD.
01  STATE-RECORD.
05  STATE-CODE               PIC X(2).
05  STATE-NAME               PIC X(20).


Filling a table from a file.

Code:
Under FILE SECTION use COPY "FDPGM.CBL in the main program"

01  TABLE-STATE-RECORD OCCURS 50 TIMES
                      INDEXED BY STATE-INDEX.
05  TABLE-STATE-CODE          PIC XX.
05  TABLE-STATE-NAME          PIC X(20).


Make use of INDEX variable in your main program

Code:
SET STATE-INDEX TO 1.
PERFORM PARA-A
        UNTIL STATE-INDEX > 50 OR
TABLE-STATE-RECORD(STATE-INDEX) = SPACE
.

Hope you got some understanding on how to use tables along with INDEX variable.

Please correct me if I am wrong.




Quote:
2)Why 77 level is used as an elementary level.


Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.
01 level can have sublevels from 02 to 49. 77 cannot have sublevel.
Back to top
View user's profile Send private message
prasad43

New User


Joined: 21 Oct 2005
Posts: 7
Location: blore

PostPosted: Tue Dec 27, 2005 1:57 pm
Reply with quote

plz clarify this one,
49 level is elementary or not?
If it is elementary why we cannot useinstead of 77?
Back to top
View user's profile Send private message
reddy007

New User


Joined: 22 Dec 2005
Posts: 1

PostPosted: Tue Dec 27, 2005 2:19 pm
Reply with quote

Yes , 49 is elementry
Back to top
View user's profile Send private message
Sankh_a

New User


Joined: 28 Dec 2005
Posts: 1
Location: India

PostPosted: Wed Dec 28, 2005 3:35 pm
Reply with quote

Quote:
2)Why 77 level is used as an elementary level.

If your data definition is as follows

01 var-1.
03 var-2 pic 9.
03 var-3 pic x.
03 var-4 pic x.

Then the data will be placed in adjecent memory locations.

But if you use 77 level it will be placed arbitrarily in memory.

This may increase your processing time as it might take more time to fetch data from individual memory location.


Correct me if I am wrong.

Thanks
Sankha[/quote]
Back to top
View user's profile Send private message
Nanda Krishna

New User


Joined: 30 Nov 2005
Posts: 19
Location: Bangalore

PostPosted: Thu Dec 29, 2005 4:16 pm
Reply with quote

plz clarify this one,
49 level is elementary or not?
If it is elementary why we cannot useinstead of 77?

Hi Prasad,

49 level is not Elementary. Plz see the explanation from iknow ...
"Elementary level item Cannot be subdivisions of other items " ..... you can't use 49 level item independently. It will come under 01 level.
But, it is not the case with 77. Hope now u got the diff. b/n 49 and 77 level no's.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jan 01, 2006 4:47 am
Reply with quote

You can pass tables like this:

Main pgm.
Code:

01 tbl.
05 tbl-entry occurs 10 times indexed by tbl-idx.
    10  a ....
    10  b ....
 
call pgmx using tbl.


Sub pgm.
Code:


WS.

01 sub-tbl.
05 tbl-entry occurs 10 times indexed by tbl-idx.
    10  a ....
    10  b ....

LS.

01 tbl pic x(???) where ??? is the total length of the Main pgm's tbl.

PD using tbl.

move tbl to sub-tbl.


You could also reference the tbl in the sub by using a subscript. In that case you can define the tbl in the Linkage Sect (LS), but don't use the INDEX clause.

You might also want to look at the GLOBAL/EXTERNAL features of COBOL. I haven't used them so I can't venture an opinion.

Re. level 49:

I know it's used exclusively for DB2 data items. I can't remember exactly; either the length field for variable length data items or the null indicator.
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts Dynamically pass table name to a sele... DB2 2
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
Search our Forums:

Back to Top