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

Strange Code


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

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Tue Nov 28, 2017 11:25 am
Reply with quote

Hi Friends

I have been getting this below problem. Could anybody please help out in this.
When testing one of our applications, we are running into a very strange bug.

In the code below we found is that the XFILE-BUFFER still contain low-values instead of spaces after initialization. We tried different compilers Cobol 4 or Cobol 5 and still encountered the same issue.

What is strange is that by duplicating this same line of code, it corrects the issue by initializing XFILE-BUFFER to spaces. If we removed this one line, we can recreate the issue again i.e. the buffer is set with low-values.

Code:
 001663 156400* INITIALIZE X FILE:                                     
 001664 156610     MOVE SPACES TO XFILE-BUFFER.              This is the original code                 
 001665 156611     MOVE SPACES TO XFILE-BUFFER.              This is the same line we added !!                 
 001666 156620     DISPLAY 'XFILE-INIT:' XFILE-INIT (1:16).                 
 001667 156800     DISPLAY 'XFILE-BUFFER CCC SPACES:' XFILE-BUFFER (1:16). 
   


Any help will be greatly appreciated.

Thanks

Changed from quoted text to coded text - spacing now correct
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Nov 28, 2017 6:17 pm
Reply with quote

Is XFILE-BUFFER part of an FD? If so, the NORMAL initialization will be to LOW-VALUES.
Back to top
View user's profile Send private message
amitc23

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Tue Nov 28, 2017 8:09 pm
Reply with quote

Hi Robert
Thanks for that. Even if XFILE BUFFER is part of FD . The statement MOVE SPACES TO XFILE BUFFER (not initialisation) should move spaces to it. Not sure then why we need two move spaces to space this out.
Back to top
View user's profile Send private message
amitc23

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Tue Nov 28, 2017 8:11 pm
Reply with quote

Sorry I am not at work now so can't check if it's part of FD or not
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Nov 28, 2017 8:42 pm
Reply with quote

I think you need to understand that the variables associated with a file (everything in the FD for that file) are NOT part of your program -- they are associated with the buffer used to pass data between the operating system and your program. I have seen unexpected results occur many times where someone believes the FD variables can be treated like WORKING-STORAGE variables; this simply is not true. For example, referencing an FD variable before the associated file is opened or after it is closed will NOT have good results -- often resulting in a storage violation ABEND, for example. If XFILE-BUFFER is part of an FD, then do not expect it to work like a WORKING-STORAGE variable.
Back to top
View user's profile Send private message
amitc23

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Tue Nov 28, 2017 9:28 pm
Reply with quote

Thanks Robert. Very nice explanation.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Nov 28, 2017 11:10 pm
Reply with quote

Very Old but Similar.
ibmmainframes.com/about35767.html
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 run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
No new posts Monitoring production job progress. N... JCL & VSAM 4
Search our Forums:

Back to Top