What you will get
When you run this COBOL application, a window will prompt you to Enter a name or Q to quit.

Tools/Equipment used
- IBM Rational Developer for System z with Java V8.0.3
- Windows XP SP3
- Lenovo Thinkpad W530
Application Details
This application consists of two COBOL programs:
- StartApp COBOL program
- PrintApp COBOL program
Identification Division.
Program-ID. StartApp.
Data Division.
Working-Storage Section.
01 Program-pass-fields.
05 Temp-name Pic x(30).
01 Program-other-fields.
05 Input-name Pic x(30).
05 Char-count Pic 99 Value ZEROS.
01 Program-flags.
05 Loop-flag Pic 9(01).
88 Loop-done Value 1.
Procedure Division.
Initialize Program-pass-fields
Program-other-fields
Program-flags.
Perform until Loop-done
Display " "
Display "Enter a name or Q to quit:"
Move Spaces to Input-name
Accept Input-name
IF Input-name = Spaces
Move "Q" to Input-name
End-IF
Move 1 to Char-count
Inspect Input-name Tallying Char-count For Leading Spaces
Move Input-name(Char-count: 30 - Char-count) to Temp-name
If function upper-case (Temp-name) = "Q"
or Temp-name = Spaces
Set Loop-done to true
Else
Call 'PrintApp' using Program-pass-fields
End-if
End-perform.
Goback.
The PrintApp COBOL program source code
Identification Division.Program-ID. PRINTAPP.
Data Division.
Working-Storage Section.
01 Work-Parms.
05 In-Len PIC S9(4) BINARY.
05 Char-count Pic 99 Value ZEROS.
05 Out-Name PIC X(100).
Linkage Section.
01 Recvd-Parms.
05 In-name Pic x(30).
Procedure Division using Recvd-Parms.
Move spaces to Out-Name.
Move 0 to Char-count
Inspect Function Reverse(In-Name)
Tallying Char-count For Leading Spaces
Compute In-Len = 30 - Char-count
Move "Thanks to " to Out-Name (1:10).
Move In-name(1:In-Len) to Out-Name(11:In-Len)
Move " for succeeding!" to Out-Name ((11 + In-Len):16).
Display Out-name.
Goback.
Let's get started
We will be using IBM Rational Developer for System z with Java V8.0.3 to build, compile, and test this app.We will be using a sample COBOL program provided by the tool (RDz).
- Select File\New/Example

- Select Workstation COBOL\COBOL Sample 1

- NOTE: COBOL Sample 1 contents
COBOL Sample 1 contains 2 COBOL programs. When an application consists of 2 or more COBOL programs, you have to nominate one of them as the entry point by clicking the desired program and selecting Nominate as entry point on the pop-up menu.
- Enter the following information and click Finish. When you click Finish, the COBOL source code is automatically compiled.
- Project name - localCOBOL
- Use default - check
- COBOL Sample Property Group - check
- Test the compiled COBOL program by selecting StartApp.exe and double-clicking it.

- Enter a name or Q to quit and hit Enter key.

No comments:
Post a Comment