How to properly select, assign files?



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

How to properly select, assign files?

Postby dexik » Fri Jun 22, 2012 3:39 am

When I have these files selected and assigned like this:

       SELECT ICECREAM-FILE
               ASSIGN TO DATABASE-ICEPF
               ORGANIZATION IS INDEXED
               RECORD KEY IS IC-ICE-CREAM-CODE.

            SELECT SHIPPING-FILE
               ASSIGN TO DATABASE-ICSHIPPF
               ORGANIZATION IS INDEXED
               ACCESS IS RANDOM
               RECORD KEY IS SHIPPING-CODE.


It gives me i-o error, then I press enter twice (one per file) and the program seems to run fine. But when I select, assign like this:

            SELECT ICECREAM-FILE
               ASSIGN TO DISK-ICEPF.


            SELECT SHIPPING-FILE
               ASSIGN TO DATABASE-ICSHIPPF.


It generates no errors, but of course it won't run as needed due to access mode problems. What am I doing wrong? The display file generates no errors. Only two physical files.

           OPEN I-O ICECREAM-FILE
                    DISPLAY-FILE.
           OPEN INPUT SHIPPING-FILE.
dexik
 
Posts: 28
Joined: Tue Jun 12, 2012 4:30 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to properly select, assign files?

 

Re: How to properly select, assign files?

Postby Robert Sample » Fri Jun 22, 2012 4:56 am

What platform and COBOL are you running this code on?
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: How to properly select, assign files?

Postby dexik » Fri Jun 22, 2012 6:15 am

Hmm, that I don't know. It is not a real server, I guess it is an emulator for education purposes. This is what the intro to this course says:

"We will be working primarily within the native system i environment (OS/400) in this course"

If you are asking me this question then I gather there are no syntax problems with my piece of code. That's a good sign ;)
dexik
 
Posts: 28
Joined: Tue Jun 12, 2012 4:30 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to properly select, assign files?

Postby Robert Sample » Fri Jun 22, 2012 6:32 am

Not necessarily -- I asked because almost all the posts (maybe 99.99%?) on this forum are related to z/OS and z-architecture machines. Your code may or may not be correct for OS/400 -- I don't know. You may want to check the COBOL manual for your system, though, to find out the precise syntax for the ASSIGN clause; if you are using ASSIGN incorrectly it could cause you problems with file access.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: How to properly select, assign files?

Postby steve-myers » Fri Jun 22, 2012 6:39 am

dexik wrote:... I guess it is an emulator for education purposes. This is what the intro to this course says:

"We will be working primarily within the native system i environment (OS/400) in this course" ...
You are probably correct in estimating it's an emulator, but not necessarily for education purposes, though you may have an isolated system so your activities do not damage a production environment.

OS/400 was the native OS for the AS/400 platform. Some years ago IBM abandoned the AS/400 platform and developed an emulator for PC class platforms so OS/400 users were not left out in the cold. This is almost certainly the emulation environment you're thinking about.

In any event, this forum is mainly for MVS and z/OS people: OS/400 is an entirely different environment.
steve-myers
Global moderator
 
Posts: 1886
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: How to properly select, assign files?

Postby NicC » Fri Jun 22, 2012 12:14 pm

I once trouble-shot a Prime to AS400 PL/1 conversion. One of the problems was the files. AS400 uses a s unix-like file system so you would have to allocate your files as you would for Unix or PC compilers e.g. SELECT my-file ASSIGN TO 'C:\My Documents\cobol\icecream.dat'

THIS IS JUST A GUESS - you can try it and then look in the manual or look in the manual and then use the correct syntax. However - if you are in training your tutor should tell you the correct syntax AND explain the difference between the required syntax and syntax for other systems.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: How to properly select, assign files?

Postby dexik » Sat Jun 23, 2012 3:29 am

Problem solved. The thing was that those two physical files have duplicates keys, so I just had to add WITH DUPLICATES clause. Is this something unique to OS/400 Cobol or it is applicable to your system too?

SELECT ICECREAM-FILE
ASSIGN TO DATABASE-ICEPF
ORGANIZATION IS INDEXED
RECORD KEY IS IC-ICE-CREAM-CODE
WITH DUPLICATES.

SELECT SHIPPING-FILE
ASSIGN TO DATABASE-ICSHIPPF
ORGANIZATION IS INDEXED
ACCESS IS RANDOM
RECORD KEY IS SHIPPING-CODE
WITH DUPLICATES.
dexik
 
Posts: 28
Joined: Tue Jun 12, 2012 4:30 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to properly select, assign files?

Postby Monitor » Sat Jun 23, 2012 11:25 am

"With Duplicates" is part of the COBOL Language.
My suggestion is that you do some reading about Indexed files and Alternate Index for your system and the COBOL Language.
Without this knowledge, I doubt you can support or understand the code you are referring to.
Monitor
 
Posts: 98
Joined: Wed Jan 18, 2012 8:59 pm
Has thanked: 0 time
Been thanked: 7 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post