Opening an assembler file from a variable



High Level Assembler(HLASM) for MVS & VM & VSE

Opening an assembler file from a variable

Postby vinodj » Fri Dec 16, 2011 8:01 pm

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
vinodj
 
Posts: 29
Joined: Wed Nov 23, 2011 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Opening an assembler file from a variable

 

Re: Opening an assembler file from a variable

Postby dick scherrer » Fri Dec 16, 2011 11:36 pm

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"?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Opening an assembler file from a variable

Postby steve-myers » Sat Dec 17, 2011 12:08 am

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.
steve-myers
Global moderator
 
Posts: 1886
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: Opening an assembler file from a variable

Postby dick scherrer » Sat Dec 17, 2011 12:17 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Opening an assembler file from a variable

Postby vinodj » Mon Dec 19, 2011 12:40 pm

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.
vinodj
 
Posts: 29
Joined: Wed Nov 23, 2011 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Opening an assembler file from a variable

Postby enrico-sorichetti » Mon Dec 19, 2011 1:03 pm

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')
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Opening an assembler file from a variable

Postby vinodj » Mon Dec 19, 2011 3:06 pm

Is it possible to associate an already existing dataset name with a DCB in assembler?
vinodj
 
Posts: 29
Joined: Wed Nov 23, 2011 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Opening an assembler file from a variable

Postby vinodj » Mon Dec 19, 2011 3:11 pm

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.
vinodj
 
Posts: 29
Joined: Wed Nov 23, 2011 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Opening an assembler file from a variable

Postby enrico-sorichetti » Mon Dec 19, 2011 4:54 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Opening an assembler file from a variable

Postby enrico-sorichetti » Mon Dec 19, 2011 6:04 pm

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!
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Next

Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post