Page 1 of 3

Opening an assembler file from a variable

PostPosted: Fri Dec 16, 2011 8:01 pm
by vinodj
Hello,

I want to open an already existing dataset (with data) on mainfame using assembler program.
The dataset name is in a variable.
For example : X_DSN is a variable in assembler program and has value 'aaa.bbb.ccc'
I want to open this dataset.
Please tell me if this can be done and how?

Regards,
Vinod

Re: Opening an assembler file from a variable

PostPosted: Fri Dec 16, 2011 11:36 pm
by dick scherrer
Hello,

You need to define a DCB for the file in the assembler code and OPEN/READ the file. Your system probably has standard macros that people use for working with data files. Ask someone who supports the assembler or a co-worker with assembler experience.

What is an "assembler file"?

Re: Opening an assembler file from a variable

PostPosted: Sat Dec 17, 2011 12:08 am
by steve-myers
Before you open a dataset by dataset name, you must allocate the dataset using dynamic allocation. It's not difficult (though I've been doing dynamic allocation for more than 30 years, so my opinion should not be trusted!), but it's too involved to discuss here. Dynamic allocation is discussed here. You can also use BPXWDYN to do the allocation, as discussed here, though this discussion is not oriented to Assembler.

Re: Opening an assembler file from a variable

PostPosted: Sat Dec 17, 2011 12:17 am
by dick scherrer
Hello,

You can use dynamic allocation, but unless there is some requirement to do so, it is probably not needed.

Assembler can open a file described in JCL very much the same way as a file is opened in COBOL.

If you explain what you really want to do (other than open/read) some file, we may be able to offer suggestions along the line of what you need, not just what might be possible.

Re: Opening an assembler file from a variable

PostPosted: Mon Dec 19, 2011 12:40 pm
by vinodj
Hello d and steve,

I have a variable x_dsn (containing dataset name a.b.c). I am dynamically allocating this dataset using a routine dyn_alloc (it works smoothly).
I am checking the return code from this routine like this : IF (CLC,x_retcode,EQ,=H'-26868').

If the dataset to be allocated already exists on mainframe it will go into this If condition and will give message 'already exists on mainframe'.

Now if I try to allocate a big dataset and the space on mainframe is insufficient it will still go into If condition and give same error message which is wrong because the dataset is definitely not existing (it will not give any system code like B37 or E37 and we have already handled these codes in our program).

In this case of big dataset I want to show a message 'insufficient space on mainframe'.

Kindly help.

Regards,
Vinod

P.S. Thanks for your quick responses earlier.

Re: Opening an assembler file from a variable

PostPosted: Mon Dec 19, 2011 1:03 pm
by enrico-sorichetti
from your explanation, looks like the <dynamic allocation> subroutine returns an invalid RC,
if so that' s the first place to look at

and ( just being picky :D )
I would rather have coded something along the lines of
         CALL <dynalloc>,....,MF=...
         IF (C,(r15),<EQ>/<NE>,=F'0')

Re: Opening an assembler file from a variable

PostPosted: Mon Dec 19, 2011 3:06 pm
by vinodj
Is it possible to associate an already existing dataset name with a DCB in assembler?

Re: Opening an assembler file from a variable

PostPosted: Mon Dec 19, 2011 3:11 pm
by vinodj
To enrico's post I would like to reply that for both the conditions (already existing dataset and insufficient space) the dynamic allocation routine returns same RC.

Re: Opening an assembler file from a variable

PostPosted: Mon Dec 19, 2011 4:54 pm
by enrico-sorichetti
if You confirm that the dynamic allocation subroutine returns a misleading RC
the only thing to do is to fix it in order to return a proper RC
nothing more, nothing less :geek:

the hex representation for Your supposed return code -26868, corresponds to a 0x970C
which IIRC is a proper dynamic allocation return code ...

would be wiser to use the proper HEX representation in order not to have people
waste time finding the corresponding HEX which is needed to search the manuals

DARC 970C indicates an SMS reason code (97xx) and is described in chapter
26.3.2 of MVS Authorized Assembler Services Guide:
Severe SMS VTOC service error.

available for example here
http://publibz.boulder.ibm.com/cgi-bin/ ... 0602053331

Re: Opening an assembler file from a variable

PostPosted: Mon Dec 19, 2011 6:04 pm
by enrico-sorichetti
follow on...
odd return/reason codes from dynalloc spring out at the early stages of use,
generally because of <programming errors>
after a while, only <very severe> errors should come out , and the <end user> will probably not be able to resolve the problems themselves
( x7xx class reason codes are an example ) so just <hinting> and advice to report to the storage support is more than enough!