Write VSAM file

HLASM for MVS. PL/I for MVS & Enterprise PL/I for z/OS.
Post Reply
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Write VSAM file

Post by kingo »

Hi all,

I wrote a sample program to write a record to VSAM file using value from a constant , The program executed and ended ok but I don't see the new record written to file.

I know there is something not ok in the program, Could anyone please point me what could I be missing?

Code: Select all

TEST     CSECT
         BASR  12,0
         USING *,12
         SAVE  (14,12)
         ST    13,SAVE+4     SAVE BACK CHAIN
         LA    11,SAVE       SET UP FORWARD CHAIN
         ST    11,8(13)      SAVE FORWARD CHAIN
         LR    13,11         SET UP FOR NEXT SAVE AREA CHAIN
         OPEN  OUTF
         MVC   OUTR,INPR
         PUT   RPL=RPL1
         CLOSE OUTF
         L     13,SAVE+4     GET BACK CHAIN
         LM    14,12,12(13)  RESTORE REGISTERS
         LA    15,0
         BR    14
START    EQU   *
SAVE     DS    18F
OUTR     DS    CL80
INPR     DS    0CL80
         DC    80C'9'
END      EQU   *
OUTF     ACB   AM=VSAM,MACRF=OUT
RPL1     RPL   ACB=OUTF,                                               X
               AREA=OUTR,                                              X
               AREALEN=80,                                             X
               RECLEN=80
         END   TEST
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Write VSAM file

Post by Robert Sample »

After your OPEN, you really should have

Code: Select all

         LTR   15,15
         BNZ   BADOPEN
so you verify the OPEN worked. Hint: OPEN is usually OPEN (dcb/acb,mode) where mode can be INPUT, OUTPUT, etc. I don't know if OPEN has a default mode, so I suspect if you add the test of register 15 you'll find your OPEN is not working. Adding error checking is usually a good thing for every I/O statement (OPEN, READ, WRITE, REWRITE, CLOSE) since you never know when something is not going to work.

Are you dealing with an ESDS, RRDS, or KSDS VSAM data set? I would expect it to be ESDS since you do not have OPTCD=(KEY,???) nor KEYLEN specified in your RPL. Your ACB does not specify a DDNAME so where is the program getting the DD name from?
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Re: Write VSAM file

Post by kingo »

Hi Robert,

Thanks for your comments

I am trying to write to a KSDS file

I added BADOPEN in code and added DDNAME in ACB is it necessary to mention OPTCD=(key,upd) as I am just writing to the dataset ?

But Anyway I added and my code looks like this

Code: Select all

TEST     CSECT
         BASR  12,0
         USING *,12
         SAVE  (14,12)
         ST    13,SAVE+4     SAVE BACK CHAIN
         LA    11,SAVE       SET UP FORWARD CHAIN
         ST    11,8(13)      SAVE FORWARD CHAIN
         LR    13,11         SET UP FOR NEXT SAVE AREA CHAIN
         OPEN  (OUTF,OUTPUT)
         LTR   15,15
         BNZ   BADOPEN
         MVC   OUTR,INPR
         PUT   RPL=RPL1
BADOPEN  EQU   *
         WTO   'OPEN FAILED'
         ABEND 1111,DUMP
         CLOSE OUTF
         L     13,SAVE+4     GET BACK CHAIN
         LM    14,12,12(13)  RESTORE REGISTERS
         LA    15,0
         BR    14
START    EQU   *
SAVE     DS    18F
OUTR     DS    CL80
INPR     DS    0CL80
         DC    80C'9'
END      EQU   *
OUTF     ACB   AM=VSAM,MACRF=OUT,DDNAME=OUTF
RPL1     RPL   ACB=OUTF,OPTCD=(KEY,UPD),KEYLEN=5,                      X
               AREA=OUTR,                                              X
               AREALEN=80,                                             X
               RECLEN=80
         END   TEST
         
And I executed as expected it fails in OPEN,How Would I add something like FILE-STATUS here? Is there a macro for that?

And this is the output of the program

Code: Select all

  PSW AT ENTRY TO ABEND   078D1000  00007062  ILC  02  INTC  000D
PSW LOAD MODULE             ADDRESS = 00007000  OFFSET = 00000062 

Code: Select all

                                              38          ABEND 1111,DUMP
00000052                                      40+         DS    0H
00000052 4110 0457               00000457     43+         LA    1,1111
00000056 4100 0080               00000080     44+         LA    0,128(0,0)
0000005A 8900 0018               00000018     45+         SLL   0,24(0)
0000005E 1610                                 46+         OR    1,0
00000060 0A0D                                 47+         SVC   13
                                              48          CLOSE OUTF
00000062 0700                                 49+         CNOP  0,4
So my question is will adding a flag variable help to identify the file status? and is it possible to add a file status and how?

Thanls
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Write VSAM file

Post by Robert Sample »

File status is for COBOL, but https://www.ibm.com/support/knowledgece ... 0/x1cb.htm says
If register 15 contains a nonzero return code, use the SHOWCB macro to display the corresponding reason code. The SHOWCB macro displays the error field in each access method control block specified by the OPEN macro.
so add SHOWCB RPL=RPL1,AREA=OUTR,LENGTH=80,FIELDS=(ACB,FTNCD) in your BADOPEN code.
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Re: Write VSAM file

Post by kingo »

Hi Robert,

I added this piece of code SHOWCB but I am sorry I do not know how to read the dumps? Could you please tell me which section in dump I need to be looking into?

Having said that

Code: Select all

          GENERAL PURPOSE REGISTER VALUES
      0-3  00001000  008B8000  008CD780  00000064
      4-7  00000690  80E58008  1DFC3308  1DFC32E0
      8-11 00000000  008BB752  008BB7FA  7F621770
     12-15 8332C000  008CD804  8332C036  00000000

                 64-BIT GPRS FROM TCB/STCB
          LEFT HALVES OF ALL REGISTERS CONTAIN ZEROS
           0-3  00001000  008B8000  008CD780  00000064
           4-7  00000690  80E58008  1DFC3308  1DFC32E0
           8-11 00000000  008BB752  008BB7FA  7F621770
          12-15 8332C000  008CD804  8332C036  00000000
          
                 64-BIT GPRS FROM THE RB/XSB
LEFT HALVES OF ALL REGISTERS CONTAIN ZEROS
 0-3  FD000008  00006000  00000040  008D79D4
 4-7  008D79B0  008FF350  008C4FE0  FD000000
 8-11 008FCC80  008CDCC8  00000000  008FF350
12-15 834C4BAA  00006008  008FCCCC  008FCCB0
Edited: I see Register 15 is 0 in few cases in dump I am not sure which section I need to be checking for.

Which set of registers should I be checking?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Write VSAM file

Post by Robert Sample »

The usual registers you use in assembler are general purpose registers (GPR) 0 to 15. With z/OS supporting 64-bit addresses, these registers were extended to support 64 bits as well. That is why the first two sets of registers you see have the same values (TCB is task control block and relates to your program). Usually a dump will have some memory listed as well, which can be helpful in debugging. From https://www.ibm.com/support/knowledgece ... /shwcb.htm I find
After SHOWCB processing is completed, VTAM sets register 15 to indicate successful or unsuccessful completion. If the operation is completed successfully, register 15 is set to 0, and register 0 contains the total number of bytes that SHOWCB extracted and placed in the work area.
so you probably should save register 15 before the SHOWCB instruction. Register 0 shows 4,096 bytes placed in the work area, so you might want to increase the work area to that size. Register 3 has a value of 100, 4 has 1680, register 12 looks to be your base register and 14 shows the SHOWCB was invoked at offset 36 in your program. You may need to use SNAP to print some of the work area to see what shows up there (80 or 100 bytes should be enough).
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Assembler & PL/I.”