Now that we are comfortable with a simple module, lets look at it's big brother, the Service Program.
A service program can be created using a couple different ingredients, but the one thing that is required is a module. An optional ingredient is Binder Language, but we'll touch on that later. You can also include additional modules and or other service programs, but for now, lets look at creating a service program named F.MATH from our single module, also named F.MATH.
Creating a service program uses the Create Service Program (CRTSRVPGM) command. On this command you can specify a list of modules, service programs, and/or a Binding Directory which is nothing more than a list of modules and/or service programs. Our example will be quite simple though, since we are only interested in converting our F.MATH module into a service program:
CRTSRVPGM SRVPGM(ILESAMPLE/F.MATH) MODULE(ILESAMPLE/F.MATH) EXPORT(*ALL)
Examining our command we will so two obvious pieces. First is the name of the service program we are creating (F.MATH), and second is the name of a module that the service program will be created from (F.MATH).
We will also see that we are specifying EXPORT(*ALL). I'll be the first to say that in production using this is a no-no. The "why" will make more sense when we get into Binding Directories, Binder Language and Signatures but for now it will service the purpose. But please, do NOT use this keyword in production.
To understand why it's not a good idea, let's first examine what the EXPORT keyword does.
We see that the EXPORT keyword accepts 2 values, *SRCFILE and *ALL. What this does is tell the system which procedures we want to export to make available for use in our service program. When we say *ALL this tells the system that each procedure coded with the EXPORT keyword (remember that?) will be exported. So that means that for our service program the #math_getSumInt procedure will be exported and available in our F.MATH service program.
We can view the available procedures using the DSPSRVPGM command:
DSPSRVPGM SRVPGM(ILESAMPLE/F.MATH) DETAIL(*PROCEXP)
Up next, we will look at using the *SRCFILE option and Binder Language for the EXPORT keyword on the CRTSRVPGM command.