Creating the Project

You will make use of two tools of tool type Execute OS Command from the OS function package:

  • A tool which returns a list of issues filtered by the issue priority.
  • A tool which returns the raiser of a given issue.

You can develop a tool of type Execute OS Command as a local COBOL program to generate an .exe file that can be specified as a tool of type Execute OS Command in the AWM model.

Start by creating a COBOL project:

  1. Launch Enterprise Developer. Specify a path for the Eclipse workspace when prompted.

    If this is the first time you start Eclipse, the IDE displays the Eclipse Welcome page. Click Open Team Developer Perspective which is the default perspective in Enterprise Developer.

    If the IDE does not start in the Team Developer perspective, click Window > Perspective > Open Perspective > Other, click Team Developer (default), and then click OK.
  2. In the Application Explorer view, click File > New > Other.

    This opens the New dialog box.

  3. Click Micro Focus COBOL > COBOL Project.
  4. Click Next.
  5. In the Project name field, type IssueTrackingSystem.
  6. Click Finish.
    Tip: If your project is not visible in the Application Explorer view, right-click Enterprise Developer Projects, and then click Load Application.

You now need to create the two COBOL programs:

  1. In the Application Explorer view, right-click the IssueTrackingSystem project.
  2. Click New > File > COBOL Program.

    This opens the New COBOL Program dialog box.

  3. In the New file name field, type GetIssues.cbl
  4. Click Finish.

    This opens the program in the COBOL editor.

  5. Copy and paste the following COBOL code into the editor, overwriting the existing text:
           program-id. GetIssues as "GetIssues".
          ******************************************************************
          * This COBOL program is part of the AWM tutorial "Issue Tracking *
          * System".                                                       *
          * The program reads the issues from the sample data set and      *
          * creates an output file according to the AWM model file         *
          * descriptor containing the issues to display in the AWM Table   *
          * Results view.                                                  *
          * The program allows to filter the issues by the input parameter *
          * priority.                                                      *
          ******************************************************************
           environment division.
           configuration section.
           input-output section.
           file-control.
    
           select out-file assign to disk
           organization is line sequential.
           
           select in-file assign to disk
           organization is line 
           sequential
           file status is ws-file-status.
    
           data division.
    
           file section.
          
          * output file cotaining the input for the AWM Table Results view;
          * will be written under c:\temp\issue_list.txt .
           fd out-file
           label records are standard
           value of file-id is"c:\temp\issue_list.txt".
          
           01 out-rec.
              05 ticket-no         pic 9(8).
              05 filler            pic x.
              05 raiser            pic x(20).
              05 filler            pic x.
              05 creation-date     pic x(10).
              05 filler            pic x.
              05 priority          pic 9.
              05 filler            pic x.
              05 description       pic x(30).
              05 filler            pic x.
              05 issue-status      pic 9.
              05 filler            pic x.
              05 ele-type          pic x(5).
          
          * file containing the sample issues; expected to reside under    *
          * c:\temp\issue_input.txt .  
           fd in-file
           label records are standard
           value of 
           file-id is"c:\temp\issue_input.txt".
          
           01 in-rec.
              05 ticket-no         pic 9(8).
              05 raiser            pic x(20).
              05 creation-date     pic x(10).
              05 priority          pic 9.
              05 description       pic x(30).
              05 issue-status      pic 9.
              
           working-storage section.
           01 cmdline-text.
              03 issue-prio              pic x(12).
           01 ws-file-status.
              03 ws-file-status-key1     pic x.
              03 ws-file-status-key2     pic x.
              03 ws-file-status-key2-bin 
                redefines ws-file-status-key2 pic 99 comp-x.
           01 ws-eof                     pic x.
           
           procedure division.
               
           main-section section.
           
           main-processing-start.
               open input in-file
               if ws-file-status not = "00"
                  if ws-file-status-key2-bin = 53
                     display "ReturnCode: 12"
                     display "Message: Input file not found! "
                     goback
                  end-if   
               end-if
           
               open output out-file
          * read tool input parameter
               accept cmdline-text from command-line
          * read all records of the input file 
               perform until ws-eof = 'Y'
                   read in-file into in-rec
                       at end move 'Y' to ws-eof
                       not at end perform process-rec through
                                  process-rec-end
                   end-read
               end-perform    
               
               close in-file.
               close out-file
          * return the name of the written file as AWM output parameter
               display 
                  "OutParm: c:\temp\issue_list.txt".
           main-processing-end.       
               goback.
               
           process-rec.
          * ignore blank lines 
               if in-rec = spaces then
                  go to process-rec-end
               end-if  
          * initialize the output record with the parameter delimiter
          * defined in the AWM model
               move all ";" to out-rec
          * entered priority '*' means process all records     
               if issue-prio = '*' then
                  move corresponding in-rec to out-rec
          * set the element type property        
                  move "ISSUE" to ele-type
                  write out-rec
               else
          * check if priority of the record equals entered priority     
                  if priority of in-rec = issue-prio then
                     move corresponding in-rec to out-rec
          * set the element type property            
                     move "ISSUE" to ele-type
                     write out-rec
                   end-if
               end-if.
              
           process-rec-end.
               exit.
           end program GetIssues.
    
  6. Click File > Save.
  7. In the Application Explorer view, right-click the IssueTrackingSystem project.
  8. Click New > File > COBOL Program.

    This opens the New COBOL Program dialog box.

  9. In the New file name field, type GetIssueRaiser.cbl
  10. Click Finish.

    This opens the program in the COBOL editor.

  11. Copy and paste the following COBOL code into the editor, overwriting the existing text:
           program-id. GetIssueRaiser as "GetIssueRaiser".
          ******************************************************************
          * This COBOL program is part of the AWM tutorial "Issue Tracking *
          * System".                                                       *
          * The program returns the raiser of a certain issue in the AWM   *
          * output format of a local OS tool.                              *
          ******************************************************************
           environment division.
           configuration section.
           input-output section.
           file-control.
    
           select in-file assign to disk
           organization is line 
           sequential
           file status is ws-file-status.
           
           data division.
           
           file section.
          * file containing the sample issues; expected to reside under    *
          * c:\temp\issue_input.txt .                                      *
           fd in-file
           label records are standard
           value of 
           file-id is"c:\temp\issue_input.txt".
          
           01 in-rec.
              05 ticket-no         pic 9(8).
              05 raiser            pic x(20).
              05 creation-date     pic x(10).
              05 priority          pic 9.
              05 description       pic x(30).
              05 issue-status      pic 9.
              
           working-storage section.
           01 cmdline-text.
              05 ticket-no                 pic    x(12).
           01 ws-eof                       pic x. 
           01 ws-file-status.
              03 ws-file-status-key1     pic x.
              03 ws-file-status-key2     pic x.
              03 ws-file-status-key2-bin 
                redefines ws-file-status-key2 pic 99 comp-x.
           
           01 out-line.
              05 outparm                  pic x(9) value 'OutParm: '.
              05 raiser                   pic x(20). 
           procedure division.
               open input in-file
               if ws-file-status not = "00" 
                  if ws-file-status-key2-bin = 53
                     display "ReturnCode: 12"
                     display "Message: Input file not found! "
                     goback
                  end-if   
               end-if
          * read tool input parameter     
               accept cmdline-text from command-line
          * read the file until record with entered ticket number is found
          * or end of file is reached
               perform until ws-eof = 'Y'
                   read in-file into in-rec
                       at end move 'Y' to ws-eof
                       not at end perform process-rec through
                                  process-rec-end
                   end-read
               end-perform
               display out-line
               
               goback.
           process-rec.
               if ticket-no of in-rec = ticket-no of cmdline-text then
                  move raiser of in-rec to raiser of out-line
                  move 'Y' to ws-eof
               end-if.   
           process-rec-end.
               exit.
           end program GetIssueRaiser.
  12. Click File > Save.