Not able to read next record while browsing KSDS in CICS



Support for CICS/ESA, CICS/TS & Transaction Gateway, CICS Configuration Manager and CICS Performance Analyzer

Not able to read next record while browsing KSDS in CICS

Postby ritesh45 » Sat Jul 07, 2018 5:29 pm

I am trying to read a VSAM KSDS file sequentially using STARTBR and READNEXT. I am able to read the 1st record. After processing 1st record, I was expecting the read of 2nd record from the VSAM when READNEXT is executed but only first record is read again. Could you please help here? I am using same lines 2 times: 1 after STARTBR and 1 while reading the next record after 1st.

MOVE LENGTH OF WS-INPUT-DATA TO X01-KEY1-LENGTH
EXEC CICS READNEXT DATASET(X01-INPUT-NAME)    
               INTO(WS-INPUT-DATA)        
               RIDFLD(X01-KEY1)            
               LENGTH(X01-KEY1-LENGTH)    
               RESP(X-RESP)                
END-EXEC
ritesh45
 
Posts: 2
Joined: Sat Jul 07, 2018 5:26 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Not able to read next record while browsing KSDS in CICS

Postby Robert Sample » Sat Jul 07, 2018 5:36 pm

The code snippet you posted is useless as far as diagnosing the problem -- you have a READNEXT, so what? Something that WOULD help us would be to give us the RESP code for the STARTBR and each READNEXT. Something that WOULD help us would be to tell us how many records are in the KSDS (LISTCAT tells you that). Something that WOULD help us would be to post the code from the STARTBR through the READNEXT, instead of just what you did post.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Not able to read next record while browsing KSDS in CICS

Postby ritesh45 » Sat Jul 07, 2018 5:56 pm

01 X01-KEY1                                    PIC X(1).
01 X01-KEY1-LENGTH                          PIC S9(4) COMP.
 


MOVE LOW-VALUES TO X01-KEY1                    
EXEC CICS STARTBR DATASET(X01-INPUT-NAME)      
                  RIDFLD(X01-KEY1)            
END-EXEC                                      
MOVE LENGTH OF WS-INPUT-DATA TO X01-KEY1-LENGTH
EXEC CICS READNEXT DATASET(X01-INPUT-NAME)    
                   INTO(WS-INPUT-DATA)        
                   RIDFLD(X01-KEY1)            
                   LENGTH(X01-KEY1-LENGTH)    
                   RESP(X-RESP)                
END-EXEC                                      
EVALUATE X-RESP                                      
    WHEN DFHRESP(NORMAL)                              
    WHEN DFHRESP(LENGERR)                            
         CONTINUE                                    
    WHEN OTHER                                        
         MOVE 'ERROR'                       TO WS-MSG1
         MOVE 'ERROR IN READ OF VSAM FILE:' TO WS-MSG2
         MOVE X-RESP TO WS-MSG3                      
         PERFORM Z000-ABEND-PARA THRU Z000-EXIT      
END-EVALUATE                                          
                                                     
MOVE 0              TO WS-FILE-END                    
PERFORM C300-VALIDATE-INPUT UNTIL WS-FILE-END = 1
 


*lots of processing here. Whatever processing is done doesn't matter at all. but for information, DB2 is updated, VSAM is updated and output VSAM file is updated after successfull update in DB*

MOVE LENGTH OF WS-INPUT-DATA TO X01-KEY1-LENGTH      
EXEC CICS READNEXT DATASET(X01-INPUT-NAME)            
                   INTO(WS-INPUT-DATA)                
                   RIDFLD(X01-KEY1)                  
                   LENGTH(X01-KEY1-LENGTH)            
                   RESP(X-RESP)                      
END-EXEC                                              
                                                     
EVALUATE X-RESP                                      
    WHEN DFHRESP(NORMAL)                              
    WHEN DFHRESP(LENGERR)                            
         CONTINUE                                    
    WHEN DFHRESP(ENDFILE)                            
         MOVE 1 TO WS-FILE-END                        
    WHEN OTHER                                        
         MOVE 'ERROR'                       TO WS-MSG1
         MOVE 'ERROR IN READ OF VSAM FILE:' TO WS-MSG2
         MOVE  X-RESP                       TO WS-MSG3
         PERFORM Z000-ABEND-PARA THRU Z000-EXIT      
        END-EVALUATE
*                  
*                  
     .              
 E000-EXIT.        
     EXIT.          
 


No error is thrown while second READNEXT. It simply reads the first record again. No data is moved in X01-KEY1 anywhere is program.

Kindly help..
ritesh45
 
Posts: 2
Joined: Sat Jul 07, 2018 5:26 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Not able to read next record while browsing KSDS in CICS

Postby Robert Sample » Sat Jul 07, 2018 8:32 pm

VSAM is updated and output VSAM file is updated after successfull update in DB*
WHICH VSAM is updated? From the CICS Application Programming Guide manual (V4R2):
You must issue the ENDBR command before performing an update operation on the same file (a READ UPDATE, DELETE with RIDFLD, or WRITE command). If you do not, you get unpredictable results, possibly including deadlock within your own transaction. You can also end the browse by using the SYNCPOINT and SYNCPOINT ROLLBACK commands.
So if you are attempting to update the same VSAM that you are browsing, you are definitely having issues relating to invalid browsing.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Not able to read next record while browsing KSDS in CICS

Postby NicC » Sun Jul 08, 2018 2:02 pm

Do not post the same question on multiple forums. It is bad manners.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times


Return to CICS

 


  • Related topics
    Replies
    Views
    Last post