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

Sequential file access in Assembler (HLASM)


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sinusam

New User


Joined: 06 Jan 2004
Posts: 18

PostPosted: Thu Apr 28, 2005 9:05 pm
Reply with quote

How to READ / WRITE sequential files in Assembler ?

I tried to do it with DCB macro, but found lot of problems. Shall i set the AMODE, RMODE to 24? what DCB options should i specify ?

Any sites available with sample programs ?

Rgds,
Sinu
Back to top
View user's profile Send private message
somasundaran_k

Active User


Joined: 03 Jun 2003
Posts: 134

PostPosted: Sat Apr 30, 2005 12:31 am
Reply with quote

Sinu
Here is a sample program that will read an input file and write into another one. I have not provided any file handling or error handling. Just GET and PUT. Also note that this program will return a return code
0 in all codition since I'm initialising R(15).

Anyway here is something to start with .. icon_lol.gif
Code:

FILEASM  CSECT                   
         STM 14,12,12(13)       
         BALR 12,0               
         USING *,12             
         ST 13,SAVE+4           
         LA 13,SAVE             
         OPEN (INDCB,(INPUT))   
         OPEN (OUTDCB,(OUTPUT)) 
IOLOOP   MVC INAREA,=80C' '     
         GET INDCB,INAREA       
         MVI OUTCARR,C' '       
         MVC OUTLINE(80),INAREA 
         PUT OUTDCB,OUTAREA     
         B IOLOOP               
FINISH   CLOSE (INDCB)           
         CLOSE (OUTDCB)         
EXIT     L 13,SAVE+4             
         LM 14,12,12(13)         
         XR 15,15                                                       
         BR 14                                                         
INDCB    DCB DSORG=PS,MACRF=(GM),DDNAME=SYSIN,EODAD=FINISH,                                                X
               RECFM=FB,LRECL=80,BLKSIZE=0                             
OUTDCB   DCB DSORG=PS,MACRF=(PM),DDNAME=OUTPUT,                                                            X
               RECFM=FBA,LRECL=133,BLKSIZE=0                           
INAREA   DS CL80                                                       
OUTAREA  DS 0CL133                                                     
OUTCARR  DC CL1' '                                                     
OUTLINE  DC CL132' '                                                   
SAVE     DS 18F                                                         
         END                                                           


You don't have to specify RMODE to 24. You can specify AMODE(31),RMODE(ANY). Go thru the manual for more details.

hth
-Som
Back to top
View user's profile Send private message
somasundaran_k

Active User


Joined: 03 Jun 2003
Posts: 134

PostPosted: Sat Apr 30, 2005 12:41 am
Reply with quote

Oops..
Alignment problem in INDCB and OUTDCB.

Please note that the continuation X should be in the 72nd column.

like (hope this will come correct icon_lol.gif )

Quote:

-----------------------------------------------------------5----+----6----+----7--
INDCB DCB DSORG=PS,MACRF=(GM),DDNAME=SYSIN,EODAD=FINISH, X


Regds
-Som
Back to top
View user's profile Send private message
sinusam

New User


Joined: 06 Jan 2004
Posts: 18

PostPosted: Sat Apr 30, 2005 10:08 pm
Reply with quote

Dear Somu,

U R Great.. icon_biggrin.gif Thanks!!! for the source code.. Lemme try to compile..
Back to top
View user's profile Send private message
lapkow

New User


Joined: 17 Oct 2006
Posts: 1

PostPosted: Tue Oct 17, 2006 3:31 am
Reply with quote

I have a follow-up question:

I take the above program and assemble/link it in the unix enviroment.
How do I specify the in and out DD statements to the program trying
to invoke it from the unix environment.

Chris
Back to top
View user's profile Send private message
cchidhu

New User


Joined: 18 Aug 2007
Posts: 4
Location: India

PostPosted: Fri Feb 27, 2009 12:23 pm
Reply with quote

Dear Somu,
If you have document with you then share it here. It will be more helpful
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: Fri Feb 27, 2009 4:18 pm
Reply with quote

Quote:
ou don't have to specify RMODE to 24. You can specify AMODE(31),RMODE(ANY).
Have you actually tried this? I've had to use DCBE to get 31-bit addressability for the DCB; otherwise the DCB macro forces you into 24-bit mode.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Fri Feb 27, 2009 4:50 pm
Reply with quote

Hi !

Right Robert !

Or you use the AMODE=24,RMODE=24 for compile and link and within the programm you switch to 31-BitMode before the Dataset operation.

Compile/Link:

LET,LIST,XREF,NCAL,AMODE=24,RMODE=24'

DCB-Definition:

S3FILE_DCB DCB

DDNAME=S3DAT,DSORG=PS,MACRF=PM,DCBE=S3FILE_DCBE
S3FILE_DCBE DCBE RMODE31=BUFF

Dataset operation:

CHGAMODE 31,R14

USING IHADCB,R4
L R4,=A(S3FILE_DCB)

MVC S3JCLNAM,DCBDDNAM

IF DCBOFLGS,Z,DCBOFOPN,TM
OPEN ((R4),OUTPUT)
EIF
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 -> PL/I & Assembler

 


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