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

Query regarding a table declaration


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

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Wed Mar 10, 2010 12:39 pm
Reply with quote

I have a table like this,

Code:
05  FILLER REDEFINES U207T-OUT-COMNT-CODE-TBL.             
    10  FILLER                             OCCURS 02 TIMES.
        15  FILLER                         OCCURS 15 TIMES.
            20  AHZCMOUT-COMNT-GRP-CODE-ATTR     PIC X(02).
            20  U207T-OUT-COMNT-GRP-CODE              PIC X(03).

It has a total of 150 bytes.

But i need this to make it to 155 bytes. One important condition is that the occurs 2 times needs to be changed to occurs 3 times.
This is because my 1st row will have 75 bytes, 2nd row will have 75 bytes and the 3rd row will have only 5 bytes.

Please help me if it is possible??

Edited: Please use BBcode when You post some code/error, that's rather readable, Thanks... Anuj
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Wed Mar 10, 2010 1:02 pm
Reply with quote

Whether can i do it like this and whether it will achieve my requirement??

Code:
05  FILLER REDEFINES U207T-OUT-COMNT-CODE-TBL.
    10  FILLER                             OCCURS 02 TIMES.
        15  FILLER                         OCCURS 15 TIMES.
            20  AHZCMOUT-COMNT-GRP-CODE-ATTR     PIC X(02).
            20  U207T-OUT-COMNT-GRP-CODE         PIC X(03).
    10  FILLER                             OCCURS 01 TIMES.
        15  FILLER                         OCCURS 01 TIMES.
            20  AHZCMOUT-COMNT-GRP-CODE-ATTR     PIC X(02).
            20  U207T-OUT-COMNT-GRP-CODE         PIC X(03).


Edited: Please use BBcode when You post some code/error, that's rather readable, Thanks... Anuj
Back to top
View user's profile Send private message
manikawnth

New User


Joined: 07 Feb 2007
Posts: 61
Location: Mumbai

PostPosted: Wed Mar 10, 2010 2:21 pm
Reply with quote

Yes it will suffice. But the problem is same variable name is not allowed twice under similar groups.
Try changing the variable.
Also filler occurs 1 time is not necessary.
Just declare level 10 and you can directly declare level 20 under it (for readability).
Or you can declare the two data items at level 10 only (under level 5).
Back to top
View user's profile Send private message
manikawnth

New User


Joined: 07 Feb 2007
Posts: 61
Location: Mumbai

PostPosted: Wed Mar 10, 2010 2:23 pm
Reply with quote

My point is that I donno how u access the variable of the third row???
You cant acceess like this:
U207T-OUT-COMNT-GRP-CODE OF FILLER ... icon_smile.gif
Do I make some sense???
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Mar 10, 2010 2:33 pm
Reply with quote

Why not just change "occurs 2" to "occurs 3"
Code:
05  FILLER REDEFINES U207T-OUT-COMNT-CODE-TBL.             
10  FILLER                             OCCURS 03 TIMES.
        15  FILLER                         OCCURS 15 TIMES.
            20  AHZCMOUT-COMNT-GRP-CODE-ATTR     PIC X(02).
            20  U207T-OUT-COMNT-GRP-CODE              PIC X(03).
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Mar 10, 2010 2:35 pm
Reply with quote

manikawnth wrote:
Do I make some sense???
Yup, you do make a sense - I, for one, not very sure yet, what actually needs to be done. Probably what I've suggested in previous post is what OP is looking for...
Back to top
View user's profile Send private message
manikawnth

New User


Joined: 07 Feb 2007
Posts: 61
Location: Mumbai

PostPosted: Wed Mar 10, 2010 2:53 pm
Reply with quote

The problem here is the data you declared in the previous post will sum upto 225 bytes.
But Mr. Abdul rafi is actually looking for 155 bytes.
The structure is like this.
1st row. 15 occurences of 5 bytes
2nd row. 15 occurences of 5 bytes
3rd row. 1 occurence of 5 bytes.
Total number of bytes he required under 05 level redefinition is 155 bytes.

Mr Rafi,
It should be your call to decide what actually u want. May be u r looking for 225 bytes as anuj told. And the same variable name is always a problem.
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Wed Mar 10, 2010 2:59 pm
Reply with quote

No i need only 155 bytes as a whole.

As mani said earlier my table should have like,
1st row. 15 occurences of 5 bytes
2nd row. 15 occurences of 5 bytes
3rd row. 1 occurence of 5 bytes.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed Mar 10, 2010 3:18 pm
Reply with quote

abdulrafi wrote:
No i need only 155 bytes as a whole.

In that case, the following fits the request:
Code:
05  FILLER REDEFINES U207T-OUT-COMNT-CODE-TBL.
    10  FILLER                             OCCURS 31 TIMES.
        15  AHZCMOUT-COMNT-GRP-CODE-ATTR     PIC X(02).
        15  U207T-OUT-COMNT-GRP-CODE         PIC X(03).

With that, you will have to adjust the index (assuming ROW and COL are your cell location):
Code:
COMPUTE WS-INDEX = (WS-ROW - 1) * 15 + WS-COL

Like this, if you want to access occurs 5 of row one, your index will be (1 - 1) * 15 + 5 = 5
If you want to access occurs 8 of row 2 your index will be (2 - 1) * 15 + 8 = 23
and so on...
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Wed Mar 10, 2010 3:52 pm
Reply with quote

Hi Abdul,

I would interested in knowing one additional information ...
Quote:
But i need this to make it to 155 bytes. One important condition is that the occurs 2 times needs to be changed to occurs 3 times. This is because my 1st row will have 75 bytes, 2nd row will have 75 bytes and the 3rd row will have only 5 bytes.
Since you have mentioned that you are receiving 3 rows of data, I have a feeling you are getting the details from the same table (or 3 records of a file). If that is the case then the 3rd row / record currently might have only 5 bytes of "relevant" data but in whole it might be 75 bytes. If this is the case I would go with Anuj's suggestion to be more reliable and flexible... icon_wink.gif
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Mar 13, 2010 7:49 am
Reply with quote

Hi Abdul,

The safest/most reasonable approach would be to make the 1st level of the table 3 instead of 2.

True, you'll waste 70 bytes of storage, but you'll have a more readable piece of code and you've built some flexibility into the pgm.

But, if you insist, just add the following to the end of your existing table declaration:
Code:
10  FIL.
    20  FIL       PIC  X(002).
    20  FIL       PIC  X(003).

Then MOVE 3 & 1 into SUB1 & SUB2 respectively. BTW, make sure SSRANGE is not active.

I haven't tested, but I'm pretty sure it'll work, because I've done things like that before by mistake (without the pre-defined fields as above) and if lucky, the pgm abends w/an 0C4/0C7 etc., otherwise, the MOVE finds a friendly place to move the data and I don't find out until the users start calling.

Again, let me say that some of the other approaches suggested are safer and more straight forward.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Sat Mar 13, 2010 10:59 am
Reply with quote

Hi Abdul,
We'd like to hear which solution you've adopted.
After all, we're here because we care.
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 Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts RC query -Time column CA Products 3
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top