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 

VSAM Assembler PUT (add) fails after GET (not found)

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


Joined: 03 Aug 2006
Posts: 2
Topics: 1
Location: North Carolina

PostPosted: Thu Aug 03, 2006 8:03 pm    Post subject: VSAM Assembler PUT (add) fails after GET (not found) Reply with quote

I have an Assembler program which reads a control file of record keys used to update a key-sequenced VSAM file. When a matching record is found, it must be updated. When a matching record is not found a new record must be added using the key from the control file.

ACB options are MACRF=(DIR,OUT)
RPL options are MACRF=(DIR,UPD)

Update of an existing record (GET/FDBK=0 then PUT) works perfectly, but when I do PUT after record not found (GET/FDBK=16, then PUT) I get a feedback code of 92 (X'5C') which, according to the manual, means "The application issued a PUT for update... without a previous GET for update".
Which sort of makes sense, since the get for update failed because the record wasn't found.

So how do you add a record in this situation?? Should I use a 2nd RPL defined as NUP (meaning no update/new records only)? Or is there some cleaner way?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Aug 03, 2006 9:03 pm    Post subject: Reply with quote

mvsmaven,

check and see if this is of any help

http://www.xephon.com/cgi-bin/xephon3/licence/getcode.cgi?pubfile=July.2002&datafile=A046A03

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mvsmaven
Beginner


Joined: 03 Aug 2006
Posts: 2
Topics: 1
Location: North Carolina

PostPosted: Fri Aug 04, 2006 3:10 pm    Post subject: Reply with quote

Looks like the trick is to use MODCB to switch the RPL from UPD to NUP and back again. Here is the essential code I used and now it works fine. Non-essential code was omitted for sake of brevity, so ACB OPEN/CLOSE, ERROR routine, variables, etc, will be needed to make this sample useable.
Code:
 
* SAMPLE CODE USING MODCB TO ADD RECORD IF RECORD NOT FOUND *     
LOOP MVC KEY,KEYVAR                       SET RECORD KEY                   
         GET   RPL=RPL                    GET RECORD FOR UPDATE           
         LTR   R15,R15                    GOT A RECORD?                   
         BZ    UPDATE                     YES: GO UPDATE                 
         SHOWCB RPL=RPL,FIELDS=FDBK,AREA=FDBK,LENGTH=4                 
         CLC   FDBK+2(2),=H'16'           RECORD NOT FOUND?               
         BNE   ERROR                      NO: SOME OTHER ERROR           
         MODCB RPL=RPL,OPTCD=NUP          YES: SET RPL TO ADD (NOT UPD)   
UPDATE   MVC   DATA,DATAVAR               MOVE VARIABLE DATA TO RECORD     
         PUT   RPL=RPL                    UPDATE (OR ADD) RECORD           
         CLC   FDBK+2(2),=H'16'           "NEW RECORD"?                   
         BNE   LOOP                        NO: CONTINUE                   
         MODCB RPL=RPL,OPTCD=UPD           YES: RESET RPL TO UPD (NOT ADD)
         B     LOOP                        CONTINUE                   
ACB      ACB   DDNAME=VSAM,MACRF=(DIR,OUT)                             
RPL      RPL   ACB=ACB,OPTCD=(DIR,UPD),AREA=REC,AREALEN=16,ARG=KEY     
REC      DS    0CL16 
KEY      DS    CL8   
DATA     DS    CL8
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Fri Aug 04, 2006 5:08 pm    Post subject: Reply with quote

mvsmaven,

Thanks for the code

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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