IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Opening VSAM file is giving ASRA Abend


IBM Mainframe Forums -> CICS
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
zanyzap4u

New User


Joined: 13 Dec 2008
Posts: 38
Location: Mexico City

PostPosted: Wed Jan 14, 2009 11:51 am
Reply with quote

I am trying to open a vsam ksds cluster from a C- CICS program.

Code:

#include <stdio.h>                       
#include <stdlib.h>                       
#include <memory.h>                       
#include <string.h>                       
#include <//'XXXXXX.XXX.COPY(VSAMAP1)'>   
struct data_struct                       
{                                         
   char unique_key<:8:>;                 
   char data<:72:>;                       
}buf1;                                   
main()                                   
{                                         
  FILE *KSDSfile;                         
  char *key;                             
  int w_retcd;                           
  int l_retcd;                           
 int r_retcd;                                                         
 KSDSfile = fopen("DD:KSDSCLUS", "rb+,type=record");                 
 printf("fopen() returned 0X%.8x\n",KSDSfile);                       
 if (KSDSfile==NULL)                                                 
    exit;                                                             
 printf("calling fopen(\"dd:ksdsclus\",\"rb+,type=record\");\n");     
 EXEC CICS                                                           
 SEND MAP("vsamap1");       
  EXEC CICS RECEIVE                                       
  MAP("vsamap1");                                         
  memcpy(key,vsamap1.vsamap1i.inputi,8);                 
  l_retcd = flocate(KSDSfile, key, 8, __KEY_EQ);         
  printf("flocate() returned %d\n",l_retcd);             
  if (l_retcd !=0)                                       
     exit;                                               
  r_retcd = fread(&buf1, 1, sizeof(buf1), KSDSfile);     
  printf("fread() returned %d\n",r_retcd);               
  printf("\n\ndata:%s\n\n",buf1.data);                   
  memcpy(vsamap1.vsamap1o.datao,buf1.data,72);           
  EXEC CICS                                               
  SEND MAP("vsamap1");                                   
  EXEC CICS                                               
  RETURN;                 
  fclose(KSDSfile);
  return(0);       
 }                 
                                                                       


When we are running the transaction it is giving this error :

Code:

DFHAC2206 11:28:32 CICSB1 Transaction BM30 failed with abend ASRA. Updates to local recoverable resources backed out.                                     


I have defined the VSAM correctly in the FCT, with recsize,keylenth and share op.
I guess it is not taking the DD name(logical file name) or maybe there is some problem while defining.

I tried searching the forum, but i didnot find anything helpful.
Because very few of them have done it with C program.

Kindly Help.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jan 14, 2009 1:03 pm
Reply with quote

Code:
KSDSfile = fopen("DD:KSDSCLUS", "rb+,type=record");     

Quote:
I am trying to open a vsam ksds cluster from a C- CICS program.


we can see that, but You can not do it
You can get all the help You need in the cics manuals

it would be wiser, before proceeding to the programming
to get a better grasp of the overall cics architecture

for the whole manual set
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/Shelves/DFHASJ00
Back to top
View user's profile Send private message
satishk

New User


Joined: 20 Jul 2007
Posts: 7
Location: Hyderabad

PostPosted: Wed Jan 14, 2009 1:47 pm
Reply with quote

Hi Zan,

The link provided by me below is the reference for your query:-

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/Shelves/DFHASJ00

The code written by you is wrong. You cannot define a KSDS file in this manner while openinig a VSAM file.
KSDSfile = fopen("DD:KSDSCLUS", "rb+,type=record");

Have case study for this KSDS in the link provided by me. Henceforth, if u still find your query is unresolved. mail to me.....we will look into the matter.....


--
satishk
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jan 14, 2009 5:52 pm
Reply with quote

This is not a C problem. This is a problem with your understanding of CICS. No program running in CICS should ever attempt to directly open a file, read a file, write a file, or close a file. The CICS API has commands to do all these things and more; not following the API and attempting to do things on your like this has been known to cause the entire CICS region to come down.
Back to top
View user's profile Send private message
zanyzap4u

New User


Joined: 13 Dec 2008
Posts: 38
Location: Mexico City

PostPosted: Thu Jan 15, 2009 4:44 pm
Reply with quote

I can understand what u are saying Robert.
I should try to access the VSAM through CICS. Am i right..!?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Jan 15, 2009 6:04 pm
Reply with quote

Quote:
I should try to access the VSAM through CICS. Am i right..!?
EXEC CICS READ is what you want to use -- CICS manages the open and close so you don't have to worry about it. There's a link to manuals at the top of this page and there's CICS Programming Reference that gives the possible commands.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CICS

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top