Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Strange Code

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
amitc23

New User


Joined: 05 Nov 2014
Posts: 83
Location: India

PostPosted: Tue Nov 28, 2017 11:25 am    Post subject: Strange Code
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: 8201
Location: East Dubuque, Illinois, USA

PostPosted: Tue Nov 28, 2017 6:17 pm    Post subject: Reply to: Strange Code
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: 83
Location: India

PostPosted: Tue Nov 28, 2017 8:09 pm    Post subject: Reply to: Strange Code
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: 83
Location: India

PostPosted: Tue Nov 28, 2017 8:11 pm    Post subject:
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: 8201
Location: East Dubuque, Illinois, USA

PostPosted: Tue Nov 28, 2017 8:42 pm    Post subject:
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: 83
Location: India

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

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

Senior Member


Joined: 21 Sep 2010
Posts: 1827
Location: NY,USA

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

Very Old but Similar.
http://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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IBEGENER RETURN CODE 12 anilkumar922 All Other Mainframe Topics 5 Wed Dec 13, 2017 11:41 am
No new posts Finding the plan when code compiled u... Ahemad DB2 1 Fri Dec 01, 2017 6:38 pm
No new posts Speed-up/reduce CPU use of code prino PL/I & Assembler 0 Tue Sep 26, 2017 12:05 am
This topic is locked: you cannot edit posts or make replies. how to code for GDG in Rexx cvnlynn CLIST & REXX 13 Wed Aug 09, 2017 9:13 pm
This topic is locked: you cannot edit posts or make replies. rexx code to create a ps file Bharath Vikraman CLIST & REXX 4 Mon Aug 07, 2017 10:30 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us