MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Occurs Depending On cluase

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
rgk
Beginner


Joined: 11 Feb 2003
Posts: 6
Topics: 3

PostPosted: Tue Feb 11, 2003 1:52 am    Post subject: Occurs Depending On cluase Reply with quote

I have a doubt in Occurs Depending On Clause
When i have two ODOs within a group level variable i need to give the count variable for both the ODOs before the ODO clause like in the following code.

Code:

 
01 ws-stage1. 
  05 ws-count1 pic 9(01). 
  05 ws-count2 pic 9(01).
  05 ws-odo1 occurs 1 to 10 times     
                 depending on ws-count1. 
  05 ws-odo2 occurs 1 to 10 times 
                     depending on ws-count2.



This will make the compile to allocate the memory without any problem.But if i give ws-count1 followed by ws-odo1 and then ws-count2 followed by ws-odo2 like in the following code, i get error saying ws-count2 is defined in a variably located area and hence results are unpredictable.
Code:

01 ws-stage1.
  05 ws-count1 pic 9(01).
  05 ws-odo1 occurs 1 to 10 times
                depending on ws-count1.
  05 ws-count2 pic 9(01).
  05 ws-odo2 occurs 1 to 10 times
                depending on ws-count2.



I could understand this.

But if i do the same thing in two different group level variables like in the following code i do not get any error.
Code:

01 WS-STAGE1.
    05 WS-COUNT-1    PIC 9(01).   
    05 WS-ODO-1  OCCURS 01 TO 10 TIMES
                     DEPENDING ON WS-COUNT-1.   
            10 WS-ODO-1-E    PIC X(05).   
01 WS-STAGE2.   
     05 WS-COUNT-2    PIC 9(01).   
      05 WS-ODO-2  OCCURS 01 TO 10 TIMES     
                 DEPENDING ON WS-COUNT-2.   
          10 WS-ODO-2-E    PIC X(05). 

 

Can anybody explain me how the memory is allocated for each group level variables.
Where could i find the information regarding that?

Thanks in advance

Kannan
Back to top
View user's profile Send private message
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Tue Feb 11, 2003 4:36 am    Post subject: Reply with quote

Hi Kannan,

The following is an explanation of your problem as far as my knowledge goes. Gurus - Please correct me if I am wrong.

Basically, when you compile a program, the compiler checks your code syntax and then generates offsets for all your working storage variables from a Base Locator(BLW). It does not allocate memory for the WS variables. It just generates offsets for all the variables with respect to a base. After compilation, the object code contains everything(all your reference to the WS variables in MOVES,COMPUTES etc. ) in the form of those offsets. Now, during run of the program, the base address is determined depending on where contigouous memory area is available for all the variables. After the base address is determined, memory is allocated for all the variables depending on the pre-determined offsets. This is clear for static WS variables.
Now, let us consider dynamic variables where DEPENDING ON clause is used. Now, if you use a DEPENDING ON clause, then offsets cannot be generated at compile time for the OCCURS variable because the exact number of times the variable will occur will be known only at run time. In such a case, if you put another variable below the variable which OCCURS DEPENDING ON, then offset of the other variable also cannot be obviously determined at compile time. Thats why you could not put WS-COUNT2 below WS-ODO1.
However, if you put WS-COUNT2 in a separate group level variable, offset will be generated for it as each 01 level variable starts from a separate boundary.

Hope all this makes sense. Smile

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
rgk
Beginner


Joined: 11 Feb 2003
Posts: 6
Topics: 3

PostPosted: Tue Feb 11, 2003 6:10 am    Post subject: Reply with quote

Hi Manas,
Thanks for your reply. Can you tell me where could i get information about this BLW and the funda behind it?
Thanks in Advance,
Kannan
Back to top
View user's profile Send private message
somuk
Beginner


Joined: 04 Feb 2003
Posts: 113
Topics: 37

PostPosted: Tue Feb 11, 2003 12:51 pm    Post subject: Reply with quote

Hi Kannan,
Try this..
Code:

01 ws-stage1.
    05 ws-count1 pic 9(01).
    05 ws-count2 pic 9(01).
    05 ws-odo1 occurs 1 to 10 times depending on ws-count1.   
    05 ws-odo2 occurs 1 to 10 times depending on ws-count2.


Note that I've moved the ws-count2 before the first OCCURS clause.
_________________
Regds,
Somu
Back to top
View user's profile Send private message Yahoo Messenger
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Wed Feb 12, 2003 6:08 am    Post subject: Reply with quote

Hi Kannan,

Basically, the way I knew about this was, after seeing all the BLW and offset listings on the compilation listing, I asked someone about it and he told me about the meaning of BLWs and offsets. I have never done an extensive study on these topics because I practically don't need these concepts often. I will try to get you some links. If somebody here provides me with some link, then i will also benefit from it.

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
rgk
Beginner


Joined: 11 Feb 2003
Posts: 6
Topics: 3

PostPosted: Thu Feb 13, 2003 12:33 am    Post subject: Reply with quote

Thanks Manas

Regards,
Kannan
Back to top
View user's profile Send private message
Novice
Beginner


Joined: 27 Dec 2002
Posts: 46
Topics: 15

PostPosted: Thu Mar 31, 2005 1:13 am    Post subject: Reply with quote

Manas, Just had the same doubt which Kannan had and your explanation addressed it. Can you suggest some further reading in BLW/BLL's?

Regards
'Novice
Back to top
View user's profile Send private message
dtf
Beginner


Joined: 10 Dec 2004
Posts: 110
Topics: 8
Location: Colorado USA

PostPosted: Thu Mar 31, 2005 1:31 pm    Post subject: Reply with quote

Quote:

01 ws-stage1.
05 ws-count1 pic 9(01).
05 ws-count2 pic 9(01).
05 ws-odo1 occurs 1 to 10 times depending on ws-count1.
05 ws-odo2 occurs 1 to 10 times depending on ws-count2.


I have not read this entire thread so maybe this already been addressed. Since the ODO variables are defined with only a single digit, it would seem that you'd have a "signifcant" digit problem if you ever got to 10.
________
marijuana sativa
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group