You will make use of two tools of tool type Execute OS Command from the OS function package:
You can develop a tool of type Execute OS Command as a local COBOL program to generate an executable file that can be specified as a tool of type Execute OS Command in the AWM model.
Start by creating a COBOL project:
If this is the first time you start Eclipse, the IDE displays the Eclipse Welcome page. Click Open COBOL Perspective which is the default perspective in Visual COBOL.
If the IDE does not start in the COBOL perspective, click , click COBOL (default), and then click OK.This opens the New dialog box.
You now need to create the two COBOL programs:
This opens the New COBOL Program dialog box.
This opens the program in the COBOL editor.
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 /tmp/test/issue_list.txt . fd out-file label records are standard value of file-id is"/tmp/test/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 * * /tmp/test/issue_input.txt . * fd in-file label records are standard value of file-id is"/tmp/test/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: /tmp/test/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.
This opens the New COBOL Program dialog box.
This opens the program in the COBOL editor.
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 * * /tmp/test/issue_input.txt . * fd in-file label records are standard value of file-id is"/tmp/test/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.