1

We're trying to migrate our application from Mainframe to AS400. We have sent our COBOL program to AS400 and compiled it in AS400 successfully after a lot of struggle as none of my team mates have experience in AS400. We're now stuck with running the COBOL program. The sample CL programs that we have checked and the stuff over internet didn't do any good.

So, Can somebody provide a sample program for running a COBOL program in AS400? The COBOL program has two input files and one output file. The input files are present in the AS400 library. And, how to create an indexed file(like KSDS VSAMs in Mainframe)? A brief explanation about the commands would be a lot better.

Praveen
  • 113
  • 1
  • 13

1 Answers1

2

It's pretty simple...

CALL COBOLPGM PARM('PARM1' 'PARM2')

To create the output file, you will either need the DDS source and compile it with the CRTPF command or use SQL DDL to create it using your favorite SQL environment or the STRSQL command.

David G
  • 3,940
  • 1
  • 22
  • 30
  • David, Thanks for the response. But I don't understand the connection between the file and the DD name. For example, my input file is in LIBRARY/FILE/INPUTFILE1, in the source we have 'ASSIGN TO INPUT-FILE-1', as you have suggested if I use 'CALL COBOLPGM PARM('INPUT-FILE-1')' how it will find the INPUTFILE1 stored in the aforementioned location? I have the same query for output file as well. Can you please elaborate? – Praveen Dec 30 '15 at 14:47
  • 1
    Sorry, the parameters have no specific relationship to the files. They are just parameter input values to the program. COBOL isn't my first language, so I'm not 100% sure about how you would declare the files. However, your program would have to declare both the input & output files. The preferred method is to use DDS or SQL to define them and code the COBOL program that they are externally defined. The program would find the files by looking for them in the library list (or qualified location [library/file]). – David G Dec 30 '15 at 17:11
  • Thanks David! Will try that – Praveen Dec 30 '15 at 17:16
  • 2
    The library list is the commonly preferred way for programs to connect to files. However, an OVRDBF (Override with Data Base File) statement may be used before a CALL is executed. The OVRDBF will associate a DD name with a supplied library/file reference in cases where library list is inappropriate. The override will be in effect for the life of the process or until it's explicitly removed with DLTOVR. – user2338816 Dec 31 '15 at 09:57
  • Thank you! `OVRDBF FILE(LIB/FILE) TOFILE(COBOL-DD-NAME) SHARE(*YES)` Is this above enough for input files? For the output file, `OVRDBF FILE(COBOL-DD-NAME) TOFILE(LIB/FILE) SHARE(*YES)` Is that all? – Praveen Jan 04 '16 at 05:58
  • Thank you both. I ran the COBOL program. I directly gave the file name present in the LIB as the DD name in the COBOL program, created the empty files as output files and called the COBOL program. – Praveen Jan 04 '16 at 09:29