Page 1 of 1

How to properly select, assign files?

PostPosted: Fri Jun 22, 2012 3:39 am
by dexik
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.

Re: How to properly select, assign files?

PostPosted: Fri Jun 22, 2012 4:56 am
by Robert Sample
What platform and COBOL are you running this code on?

Re: How to properly select, assign files?

PostPosted: Fri Jun 22, 2012 6:15 am
by dexik
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 ;)

Re: How to properly select, assign files?

PostPosted: Fri Jun 22, 2012 6:32 am
by Robert Sample
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.

Re: How to properly select, assign files?

PostPosted: Fri Jun 22, 2012 6:39 am
by steve-myers
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.

Re: How to properly select, assign files?

PostPosted: Fri Jun 22, 2012 12:14 pm
by NicC
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.

Re: How to properly select, assign files?

PostPosted: Sat Jun 23, 2012 3:29 am
by dexik
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.

Re: How to properly select, assign files?

PostPosted: Sat Jun 23, 2012 11:25 am
by Monitor
"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.