SOCOBOL

The SOCOBOL UNIX program type is used to run COBOL programs.

The SOCOBOL UNIX program type is used to run COBOL programs. COBOL programs can have three requirements. They can:

The SOCOBOL program type allows for these three requirements by accepting a special set of prompts.

The SOCOBOL program type, however, is not initially defined within Applications Manager. You must set up the program type yourself. The parameters for setting up the program type are listed below.

Parameter Value

Type

SOCOBOL

Command Path

/exec

Description

COBOL programs

Param format

#d

Default varname

not applicable

File extension

as applicable

Host command

SOCOBOL

Program Type Script

$ cat -n SOCOBOL

1  

2  :

3  #!/bin/sh

4  # Created by Automic Software GmbH

5  #Copyright 2007 Automic Software GmbH

6  # $Header: EXEC-SOCOBOL,v 1.1 96/01/22 09:41:25 soport Exp $

7  #

8  # General format for prompts for cobol job

9  # Prompt

10  #   1           (t) Total number of Environment variables to be set

11  #   2           (N) Number of Env Variables with output filenames

12  #   3..N+2      variable=output_file_name(s)

13  #   N+3..t+2    variable=value

14  #   t+3..       Standard input lines as required

15  #

16  #               You will also need to setup a new command type

17  #               generally the same name as this filename

18  #               don't forget extension and user #v for format

19  i=0

20  lines=`cat $par|wc -l`

21  save_file=$file

22  export='export '

23  par1=$par'1'

24  par2=$par'2'

25  par3=$par'3'

26  touch $par1

27  touch $par2

28  touch $par3

29  cat $par|while read line

30  do

31          i=`expr $i + 1`

32          if [ $i -eq 1 ]; then

33                  total=$line

34                  max=`expr $line + 2`

35                  err=$?

36                  if [ $err -ne 0 ]; then

37                          exit $err

38                  fi

39          elif [ $i -eq 2 ]; then

40                  out=$line

41                  maxout=`expr $line + 2`

42                  if [ $out -gt $total ]; then

43    echo "Output files number is greater than number of envs $out vs

$total"

44                          exit 1

45                  fi

46          elif [ $i -le $maxout ]; then

47                  var=`echo $line|awk '{{ FS = "="}{ print $1}}'`

48                  file=`echo $line|awk '{{ FS = "="}{ print $2}}'`

49                  bigline=$bigline$line';'

50                  export=$export$var' '

51                  echo $file >>$par3

52          elif [ $i -le $max ]; then

53                  var=`echo $line|awk '{{ FS = "="}{ print $1}}'`

54                  bigline=$bigline$line';'

55                  export=$export$var' '

56          else

57                  echo $line >>$par1

58          fi

59          if [ $i -eq $lines ]; then

60                  echo  $bigline$export >$par2

61          fi

62  done

63  eval `cat $par2`

64  err=$?

65  if [ $err -ne 0 ]; then

66          exit $err

67  fi

68  cat $par1|rstora $program

69  err=$?

70  i=0

71  cat $par3|while read filename

72  do

73          i=`expr $i + 1`

74          if [ -f $filename ]; then

75                  echo $filename|grep '/' >/dev/null

76                  status=$?

77                  if [ $status -eq 0 ]; then

78                          filename=$save_file'.'$count

79                  fi

80                  file=$filename

81                  export file

82                  $AW_HOME/exec/FILESIZE $file $err

83          else

84          echo "Could not find output file # $i - '$filename'"

85          fi

86  done

87  if [ "$CLEAN" = "YES" ]; then

88          rm $par1 $par2 $par3

89  fi

90  exit $

The Host command entry may need to be changed for certain COBOL environments—see the note on changing the SOCOBOL program type script at the end of the Program Type Script section below.

Format for SOCOBOL Job Prompts

If you create an Applications Manager job to run a COBOL program, you should use the format for the prompts shown in the table below. COBOL programs will not run correctly (or at all) if the prompts are not defined correctly.

Prompt Description

1

(t) Total number of prompts that will set environment variables

2

(N) Number of prompts that will specify output filename environment variables

3...N+2

Output environment variable(s) and file name(s)

N+3...t+2

Other environment variable(s)

t+3...

Command line argument(s)

Program Type Script

The program type script that runs COBOL programs is SOCOBOL. It is located in the $AW_HOME/exec directory. The script's primary behaviors are to:

If you understand UNIX shell scripts, it may be useful for you to examine the SOCOBOL script to increase your understanding of how it behaves.

You may need to change the SOCOBOL script to use a different command for running COBOL programs than the rstora command (shown on line 68 in the script above). To do so, copy the $AW_HOME/exec/SOCOBOL script to another name (e.g. SOCOBOLMF for MicroFocus COBOL) and alter the new script by replacing rstora with the appropriate command for your COBOL environment (e.g.: runcob). You may also want to add a path. In some cases, rstora may need to be removed completely.

Do not modify the SOCOBOL script itself because it will be overwritten when you next upgrade, eliminating any changes you have made. Modify a copy instead. Also note that if you use a script other than SOCOBOL to run your COBOL tasks, you will need to change the Host command entry for your SOCOBOL program type definition to match your new script (see the SOCOBOL Program Type Parameters section below).

When you create a program type script, be sure to give Applications Manager execute privileges for the script by issuing the chmod 700 script_name command.

Program Type Parameters

The program type parameters for the SOCOBOL program type script are listed below.

Parameter Value

Type

SOCOBOL

Command Path

/cobol

Description

Runs COBOL Programs

Param format

#d

Default varname

not applicable

File extension

none

Host command

SOCOBOL

You can use the Command Path field to define the subdirectory containing COBOL programs. The Command Path entry is combined with the directory specified in the Library to provide a full path where the program type will look for COBOL programs. The Command Path field is optional.

Job Prompts Example

Imagine you have a COBOL program that:

The eight prompts for the job would be defined as follows:

Prompt Description Data Type Default Value

Total number of environment variables:

Number

5

Number of output file environment variables:

Number

2

Enter environment variable and first output file:

Character

OUT1=file1.out

Enter environment variable and second output file:

Character

OUT2=file2.out

Enter environment variable and first flag setting:

Character

Flag1=yes

Enter environment variable and second flag setting:

Character

Flag2=no

Enter environment variable and third flag setting:

Character

Flag3=yes

Enter start date (dd-MMM-yy):

Date

01-JAN-96

There is no need or requirement to fill in the Variable Name field for any of the above prompts.

$par

The $par variable in the shell script is set by Applications Manager. It is the name of the file holding information from the job's prompts. The $par file would look as follows for the SOCOBOL job in this example.

5

2

OUT1=file1.out

OUT2=file2.out

Flag1=yes

Flag2=no

Flag3=yes

01-JAN-96

The SOCOBOL program type script uses the first two prompt values to process the subsequent prompts correctly. These values and the order of the remaining prompts are therefore very important.

System Output

The system output file (o4841 in this case) for the example 8-prompt COBOL job is shown below.

The information about this run of the job is presented at the beginning of the file and the contents of the parameter file ($par) are shown under the heading 'parameter file'. Also note the PRINTEM statements at the bottom of the output showing the two files file1.out and file2.out (the two output filenames specified in the third and fourth prompts) being registered as output.

Started

        Process Id is 2797 on Mon Sep 23 09:56:32 EDT 1996

        source SOCOBOL program /apps/am/cobol/prog1

        Operator DEFAULT

        application COBOL module COBOL_1 job_number 57

        jobid 27627

        batch_home /apps/am output /apps/am/out

        rpf_options   printer TEST

        app_path /apps/am

        file b.4841 command_dir /cobol copies 1 user SQLOPER

        function LOG log run Y output required N

        db_type ORACLE net_connect

 

parameter file

5

2

OUT1=file1.out

OUT2=file2.out

Flag1=yes

Flag2=no

Flag3=yes

01-JAN-96

PRINTEM Mon Sep 23 09:56:35 EDT 1996

file move and stored as file1.out in /apps/am/out

No printer type specified - using ANY

PRINTEM Mon Sep 23 09:56:37 EDT 1996

file move and stored as file2.out in /apps/am/out

No printer type specified - using ANY

end of /apps/am/exec/BODY status 0

Finished on Mon Sep 23 09:56:37 EDT 1996