Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Confused! Whether the problem is with OCCURS/INITIALIZE???

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

New User


Joined: 27 May 2010
Posts: 10
Location: Chennai

PostPosted: Sat May 29, 2010 1:14 pm    Post subject: Confused! Whether the problem is with OCCURS/INITIALIZE???
Reply with quote

Hi,
When we are testing a COBOL code, we came thru an unexpected result, which driven us to the confusion. The problem is in a simple COBOL logic which reformats the input file accordingly and writes the required fields to the output file.
The input file is of length 20000, which contains 10 occurrences of Product information. And each product has 10 occurrences of program information. The layout will be like:
Code:
05 :XXXX                              PIC X(04).   
05 :XXXXX                         PIC X(20).   
05 :Date.                       
   10  : -9SCOMP-DATE-N           PIC 9(08).   
05 :-TERMINATION-DATE                   PIC 9(08).   
05 :XXXXX                      PIC X(20).   
05 : PRODUCT- COUNT                   PIC 9(04).   
05 :-PRODUCT-ARRAY                         OCCURS 10 TIMES.
   10 :in-PRODUCT-ID                     PIC X(15).   
   10 :in-PRODUCT-NAME                    PIC X(100). 
   10 :in-PRODUCT-VERSION                 PIC 9(15).   
   10 :in-PRODUCT-VENDOR-NAME             PIC X(50).   
   10 :PROGRAM-ARRAY-COUNT             PIC 9(04).   
   10 :PROGRAM-ARRAY                     OCCURS 10 TIMES.
      15 :PROGRAM-ID                      PIC X(15).   
      15 :PROGRAM-NAME                 PIC X(100). 
      15 :PROGRAM-VERSION              PIC 9(15).   
      15 :PROGRAM-VENDOR-NAME          PIC X(50).   
                                                       
05 FILLER                                                    PIC X(96). 

Where as the output file is of length 1100, with the key size of 16 which contains only few fields and its lay out is like:

Code:
05 :-KEY.                                       
   10 : XXXX                           PIC X(04).   
   10 : XXXXX                       PIC X(04).   
   10 :EFFECTIVE-DATE.                   
      15  : 9SCOMP-EFFECTIVE-DATE-N    PIC 9(08).   
05 :TERMINATION-DATE                  PIC 9(08).   
05 :out-PRODUCT-ARRAY                  OCCURS 10 TIMES.
   10 :out-PRODUCT-ID                     PIC X(15).   
   10 :out-PRODUCT-NAME                  PIC X(60).   
05 FILLER                                      PIC X(326).

My code logic:
Code:
PERFORM UNTIL SUB > 10                                     
   IF PRODUCT-ID(SUB) >    SPACES                     
      MOVE in-PRODUCT-ID(SUB)   TO out-PRODUCT-ID(SUB) 
      MOVE in-PRODUCT-NAME(SUB) TO out-PRODUCT-NAME(SUB)
      ADD 1                       TO SUB                   
   ELSE                                                   
      MOVE 11                     TO SUB                   
   END-IF                                                 
END-PERFORM

Now the problem is:
In the input file which has about 3000 records, one record (assume it to be the 1st record) have 3 product occurrences (Let us assume them as 141, 142, 143) and rest of the records got only 1 product occurrence say 140.
When we ran the job, every 125th record came as the problematic record. (I.e. even though the record got only one product, in the output it shoots 3 products. There is no problem with the first product occurrence. it is same as that in the input file, but the second and third products are taking the same secondd and third occurrence as of the first record.)

After including the INITIALIZE step before the perform statement, the problem was solved. But I didn’t understand one thing: If the problem is with the initialization, why only every 125th record is problematic, why not all the records.
Please let me know if I am not clear and do me the needful.
Back to top
View user's profile Send private message

Markandeyulu

New User


Joined: 27 May 2010
Posts: 10
Location: Chennai

PostPosted: Sat May 29, 2010 1:17 pm    Post subject: Excuse
Reply with quote

This is my first post in the forums. Please let me know if i have missed something.
Thanks in advance.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Sat May 29, 2010 1:21 pm    Post subject: Reply to: Confused! Whether the problem is with OCCURS/INITI
Reply with quote

this is a technical forum, not a chat room,
Your initial post was edited to get rid of the useless and annoying colors
and to use the code tags
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sat May 29, 2010 2:28 pm    Post subject:
Reply with quote

Quote:
Code:
  IF PRODUCT-ID(SUB) >    SPACES                     
      MOVE in-PRODUCT-ID(SUB)   TO out-PRODUCT-ID(SUB)

Is 'PRODUCT-ID' the same as 'in-PRODUCT-ID'?
Have you verified that the three PRODUCT-IDs of the 125th record are actually SPACES or less? And how did you verify that?

What is the recfm, lrecl and blocksize of the input file?
Back to top
View user's profile Send private message
Markandeyulu

New User


Joined: 27 May 2010
Posts: 10
Location: Chennai

PostPosted: Sat May 29, 2010 3:00 pm    Post subject:
Reply with quote

Sorry, I missed to edit the code perfectly before submitting the query.

Yes, the 'PRODUCT-ID' and the 'in-PRODUCT-ID' are same, i forgot to edit it in the first line.
The first product-id of the 125th record is not space, whereas the second and third product-ids are spaces, I verified that by opening the file in the file manager. The problem is every 125th output record i.e.(125th, 250th, 375th, 500th...) are the problematic records.

when i debugged the logic, I observed that the values in every 125th output records are not initialized. They are displayed with the first records 3 products before writing. So when it is checking the logic, the first product-id is not spaces so it is writing the first product correctly. and the second product-id is spaces so it is coming out of the loop. But as i mentioned that the values in every 125th record are not initialized they are displaying the same 2nd and 3rd products of the first record.

The RECFM is FB, LRECL is 20000, and BLKSIZE is 20000 for the input file
The RECFM is FB, LRECL is 1100, and BLKSIZE is 27500 for the output file
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sat May 29, 2010 4:25 pm    Post subject:
Reply with quote

Markandeyulu wrote:
The first product-id of the 125th record is not space, whereas the second and third product-ids are spaces, I verified that by opening the file in the file manager.
Quote:
when i debugged the logic, I observed that the values in every 125th output records are not initialized. They are displayed with the first records 3 products before writing.....
But as i mentioned that the values in every 125th record are not initialized they are displaying the same 2nd and 3rd products of the first record.
How do you explain these opposite statements?
Or does the first refer to input and the second refer to your output?
Or are you saying that the input (every 125th record) is bad? Shouldn't the solution be in the program that created that input?
Back to top
View user's profile Send private message
Markandeyulu

New User


Joined: 27 May 2010
Posts: 10
Location: Chennai

PostPosted: Sat May 29, 2010 4:51 pm    Post subject:
Reply with quote

What i tried to say is:
In the input file, the 125th record has only one product occurrence.
But the same record in the output file is displayed with three product occurrences.
The input file doesn't have any problem, I hope there is no problem with the program that creates input file, but i will check that program again will let u know regarding this. Thanks for your suggestion.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Sat May 29, 2010 6:05 pm    Post subject:
Reply with quote

Some observations:
1. you have 25 records per block and the default for QSAM is 5 buffers per file -- which is 125 records before you start reusing buffers. Off-topic note: adding buffers will usually speed up the program (frequently cutting elapsed run times by 75%).

2. although you did not include the READ statement, I expect that your code is NOT doing a READ INTO, just a READ.

3. why are you using the IF statement to move the occurrences? Working in the buffers, you need to move ALL 10 occurrences to get rid of any data in the buffers from the last record in the buffer at that location.
Back to top
View user's profile Send private message
Markandeyulu

New User


Joined: 27 May 2010
Posts: 10
Location: Chennai

PostPosted: Mon May 31, 2010 1:11 pm    Post subject:
Reply with quote

Thank you very much Robert, that really helped me.
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 SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm
No new posts Problem with GETMAIN command amitc23 CICS 6 Thu Sep 01, 2016 1:01 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us