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

Cobol file using index


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mmurilloa

New User


Joined: 31 May 2023
Posts: 2
Location: MEXICO

PostPosted: Wed May 31, 2023 11:57 pm
Reply with quote

Coding a new program I'm trying to use this:
SELECT AMBSR ASSIGN TO AMBSR
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS AMBS-KEY
FILE STATUS IS FS-AMBSR.


FD AMBSR.
01 REG-AMBS.
03 AMBS-KEY.
05 AMBS-APP PIC X(013).
05 AMBS-CUENTA PIC X(019).



01 WS-AMBS-FILE.
03 FILLER PIC X(006) VALUE 'AMBSR1'.
03 FILLER PIC X(006) VALUE 'AMBSR2'.
03 FILLER PIC X(006) VALUE 'AMBSR3'.
03 FILLER PIC X(006) VALUE 'AMBSR4'.
03 FILLER PIC X(006) VALUE 'AMBSR5'.
03 FILLER PIC X(006) VALUE 'AMBSR6'.
03 FILLER PIC X(006) VALUE 'AMBSR7'.
03 FILLER PIC X(006) VALUE 'AMBSR8'.
03 FILLER PIC X(006) VALUE 'AMBSR9'.
03 FILLER PIC X(006) VALUE 'AMBSRA'.
01 WS-AMBS-FILER REDEFINES WS-AMBS-FILE.
03 WS-FILE-READ OCCURS 10 INDEXED BY FILE-INDX.
05 AMBS-NAME PIC X(006).


01 WS-FS-AMBS.
03 FILLER PIC X(009) VALUE 'FS-AMBSR1'.
03 FILLER PIC X(009) VALUE 'FS-AMBSR2'.
03 FILLER PIC X(009) VALUE 'FS-AMBSR3'.
03 FILLER PIC X(009) VALUE 'FS-AMBSR4'.
03 FILLER PIC X(009) VALUE 'FS-AMBSR5'.
03 FILLER PIC X(009) VALUE 'FS-AMBSR6'.
03 FILLER PIC X(009) VALUE 'FS-AMBSR7'.
03 FILLER PIC X(009) VALUE 'FS-AMBSR8'.
03 FILLER PIC X(009) VALUE 'FS-AMBSR9'.
03 FILLER PIC X(009) VALUE 'FS-AMBSRA'.
01 WS-FS-FILLER REDEFINES WS-FS-AMBS.
03 WS-FS-READ OCCURS 10 INDEXED BY FS-INDX.
05 AMBS-FS PIC X(009).

1200-READ-AMBS.
SET FILE-INDX TO 1
SET FS-INDX TO 1
MOVE AMBS-FS(FS-INDX) TO WS-AMBS-FS
MOVE AMBS-NAME(FILE-INDX) TO AMBSR WS-AMBS-NAME
IGYPS2074-S "AMBSR" was defined as a type that was invalid in this context. The statement was discarded.


OPEN INPUT AMBSR
IF FS-AMBSR NOT = ZEROES
DISPLAY 'NO SE PUEDE ABRIR AMBSR:' FS-AMBSR
MOVE 12 TO RETURN-CODE
STOP RUN
END-IF

I need to read several files (same data structure) so, I thoguht using an array and changing its index value it cpuld work
Does it make sense?

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

Global Moderator


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

PostPosted: Thu Jun 01, 2023 12:58 am
Reply with quote

Look into BPXWDYN -- it can be used in COBOL to dynamically allocate / free data sets. Read the specifications carefully, though, as it is NOT a simple thing to use.
Back to top
View user's profile Send private message
mmurilloa

New User


Joined: 31 May 2023
Posts: 2
Location: MEXICO

PostPosted: Sat Jun 10, 2023 12:09 am
Reply with quote

Robert Sample wrote:
Look into BPXWDYN -- it can be used in COBOL to dynamically allocate / free data sets. Read the specifications carefully, though, as it is NOT a simple thing to use.


Thanks a lot Robert.. I've implemented another solution..

Best Regards
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 7
No new posts COBOL sorting, with input GDG base COBOL Programming 7
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 0
No new posts Replacing FILLER with FILLER<SeqNu... DFSORT/ICETOOL 2
No new posts how to eliminate null indicator value... DB2 7
Search our Forums:

Back to Top