View previous topic :: View next topic
|
Author |
Message |
abdulrafi
Active User
Joined: 14 Sep 2009 Posts: 184 Location: Coimbatore
|
|
|
|
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 |
|
|
abdulrafi
Active User
Joined: 14 Sep 2009 Posts: 184 Location: Coimbatore
|
|
|
|
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 |
|
|
manikawnth
New User
Joined: 07 Feb 2007 Posts: 61 Location: Mumbai
|
|
|
|
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 |
|
|
manikawnth
New User
Joined: 07 Feb 2007 Posts: 61 Location: Mumbai
|
|
|
|
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 ...
Do I make some sense??? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
manikawnth
New User
Joined: 07 Feb 2007 Posts: 61 Location: Mumbai
|
|
|
|
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 |
|
|
abdulrafi
Active User
Joined: 14 Sep 2009 Posts: 184 Location: Coimbatore
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
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... |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Hi Abdul,
We'd like to hear which solution you've adopted.
After all, we're here because we care. |
|
Back to top |
|
|
|