Presentation is loading. Please wait.

Presentation is loading. Please wait.

More Syntax in COBOL  Moving Data  Selection Statements  System Date  Indicators in Display files.

Similar presentations


Presentation on theme: "More Syntax in COBOL  Moving Data  Selection Statements  System Date  Indicators in Display files."— Presentation transcript:

1

2 More Syntax in COBOL

3  Moving Data  Selection Statements  System Date  Indicators in Display files

4

5 MOVE Identifier/Variable or Literal/Constant TO (Indentifier/Variable)s

6 Sending FieldReceiving Field Okay?Numeric ◦ Field sizes NumericAlphanumeric ◦ Decimal places ◦ Packed fields Numeric Group Item

7 Sending FieldReceiving Field Okay? Alphanumeric Numeric ◦ Decimal Places ◦ Packed fieldsAlphanumeric ◦ Field sizes Alphanumeric Group Item

8 Sending FieldReceiving Field Okay? ZerosNumeric ZerosAlphanumerics ZerosGroup Item

9 Sending FieldReceiving Field Okay? SpacesNumeric Spaces Alphanumerics Spaces Group Items

10 Field A PIC 9(3) Field B PIC 9(3) 100 Field A PIC 9(3)Field B PIC 9(4) 100 Field APIC 9(3) Field B PIC 9(2) 100

11 MOVE numeric TO numeric. Field A PIC 9(3)V99 Field B PIC 99V9 100.03 Field A PIC 9(3)V99 Field B PIC 9(4)V999 100.03 Field A PIC 9(3)V99 Field B PIC 9(3) 100.03

12 MOVE numeric TO alphanumeric. Field A PIC 9(3) Field B PIC X(3) 100 Field A PIC 9(3) Field B PIC X(4) 100 Field A PIC 9(3) Field B PIC X(2) 100

13 MOVE numeric TO alphanumeric. Field A PIC 9(3)V99 Field B PIC X(3) 100.03

14 Field A PIC 9(3)Field B. Field C PIC 99. Field D PIC 9. Field AField BField CField D 124

15 MOVE numeric TO group item Field A PIC 9(3)Field B. Field C PIC 99. Field D PIC 99. Field AField BField CField D 124

16 MOVE numeric TO group item Field A PIC 9(3)Field B. Field C PIC 9. Field D PIC 9. Field AField BField CField D 124

17 MOVE numeric TO group item Field A PIC 9(3)Field B. Field C PIC XX. Field D PIC X. Field AField BField CField D 124

18 MOVE numeric TO group item Field A PIC 9(3)Field B. Field C PIC XX. Field D PIC XX. Field AField BField CField D 124

19 MOVE numeric TO group item Field A PIC 9(3)Field B. Field C PIC X. Field D PIC X. Field AField BField CField D 124

20 MOVE alphanum TO alphanum. Field APIC X(3) Field B PIC X(3) CJM Field A PIC X(3)Field BPIC X(4) CJM Field APIC X(3) Field BPIC X(2) CJM

21 MOVE alphanum TO group item Field A PIC X(3)Field B. Field C PIC XX. Field D PIC X. Field AField BField CField D CJM

22 MOVE alphanum TO group item Field A PIC X(3)Field B. Field C PIC XX. Field D PIC XX. Field AField BField CField D CJM

23 MOVE alphanum TO group item Field A PIC X(3)Field B. Field C PIC X. Field D PIC X. Field AField BField CField D CJM

24 MOVE alphanum TO numeric. Field APIC X(3) Field B PIC 9(3) ABC

25 MOVE zeros TO numeric. Field B PIC 9(3) Field BPIC 9(4)V99

26 MOVE zeros TO alphanumeric. Field B PIC X(3) Field BPIC X(1)

27 MOVE zero TO group item Field B. Field C PIC 99. Field D PIC 9. Field BField CField D

28 MOVE zeros TO group item Field B. Field C PIC XX. Field D PIC XX. Field BField CField D

29 MOVE spaces TO numeric. Field B PIC 9(3) Field BPIC 9(4)V99 Note: This is not supposed to work!

30 MOVE spaces TO alphanumeric. Field B PIC X(3) Field BPIC X(1)

31 MOVE spaces TO group item Field B. Field C PIC 99. Field D PIC 9. Field BField CField D Note: this is not supposed to work!

32 MOVE spaces TO group item Field B. Field C PIC XX. Field D PIC XX. Field BField CField D

33

34 Sorting on the iSeries EBCDIC Sort 1. Blanks 2. Special Characters 3. Lower Case Letters 4. Upper Case Letters 5. Numbers

35 Selection Condition? Statement2 Statement1

36 Selection IF Condition THEN Statement(s) ELSE Statement(s) END-IF

37 If-Then-Else A = 10 B = 20 If (A > B) THEN MOVE B TO A.

38 If-Then-Else A = 10 B = 20 If A > B THEN MOVE B TO A ELSE MOVE A TO B.

39 If-Then-Else A = 10 B = 20C = 30D = 40 If A < B THEN IF A > C THEN MOVE A TO C ELSE MOVE C TO A END-IF ELSE MOVE A TO B END-IF.

40 Sign Test A = 10B = -10 If A IS NEGATIVEIF A IS POSITIVE MOVE B TO A MOVE B TO AELSE MOVE A TO B. MOVE A TO B.

41 Numeric Test A = 10B = -10 If A IS NUMERIC ADD A TO B.

42 Alphabetic Test C = ‘CJ’ D = ‘Christy’ If C is ALPHABETIC THEN MOVE C TO OLDER-SISTER ELSE MOVE D TO OLDER-SISTER END-IF

43 Alphabetic-Upper Test C = ‘CJ’ D = ‘Christy’ If C is ALPHABETIC-UPPER THEN MOVE C TO OLDER-SISTER ELSE MOVE D TO OLDER-SISTER END-IF

44 Alphabetic-Lower Test C = ‘CJ’ D = ‘Christy’ If D is ALPHABETIC-LOWER THEN MOVE D TO OLDER-SISTER ELSE MOVE C TO OLDER-SISTER END-IF

45 AND

46 OR

47 AND/OR Order of Operations Brackets First ANDs (From Left to Right) ORs (From Left to Right)

48 ANDs/ORs A = 10B = -10C = 20 If (A<B) OR (B<C) AND (A<C) THEN MOVE A TO C ELSE MOVE A TO B END-IF

49 ANDs/ORs A = 10B = -10C = 20 If ((A<B) OR (B<C)) AND (A<C) THEN MOVE A TO C ELSE MOVE A TO B END-IF

50 Case Statements

51 IF-THEN-ELSE Statements IF MARKS >= 80 THEN MOVE ‘A’ TO GRADE ELSE IF MARKS >= 70 THEN MOVE ‘B’ TO GRADE ELSE IF MARKS >= 60 THEN MOVE ‘C’ TO GRADE ELSE IF MARKS >= 55 THEN MOVE ‘D’ TO GRADE ELSE MOVE ‘F’ TO GRADE END-IF ENDIF.

52 CASE Statements EVALUATE TRUE WHEN MARKS >= 80 MOVE ‘A’ TO GRADE WHEN MARKS >= 70 AND MARKS < 80 MOVE ‘B’ TO GRADE WHEN MARKS >= 60 AND MARKS < 70 MOVE ‘C’ TO GRADE WHEN MARKS >= 55 AND MARKS < 60 MOVE ‘D’ TO GRADE WHEN OTHER MOVE ‘F’ TO GRADE END-EVALUATE.

53 EVALUATE GRADE WHEN ‘A’ DISPLAY ‘WONDERFUL!!!!’ WHEN ‘B’ DISPLAY ‘GREAT!!!’ WHEN ‘C’ DISPLAY ‘NEED ANY HELP?’ WHEN ‘D’ DISPLAY ‘COME AND SEE ME!’ WHEN ‘F’ DISPLAY ‘SEE YOU NEXT SEMESTER’ WHEN OTHER DISPLAY ‘WE HAVE A PROBLEM!’ END-EVALUATE.

54 Problem ANNAME is a 20 character field in the file, ANMPF that stores an animal name. ANMPF is a Physical file that contains a record for each of animals clients at the Seneca Vet Clinic. You are required to write a COBOL program that selects all of the animals listed in ANMPF that start with a C. What COBOL statement would select all of the animals names that start with the letter ‘C’.

55  Function current-date  Function convert-date-time

56

57  Binary Values  Working Storage Definition example 01 ws-indicator-list. 05 IN88 INDICATOR 88 PIC 1 value B’0’.  Passed to display files in the write statement Write Display-record format is ‘RECORD1’ indicators are ws-indicator-list.

58 Working Storage. 01 ws-indicators. 05 IN90 INDICATOR 90 pic 1. Procedure Division. If scr-employee-name is equal to spaces move b’1’ to IN90 else move b’0’ to IN90 end-if.

59  Stored as binary values in the display file and passed as PIC X(2) via the control Area. Select Display-file assign to workstation-dspfile-si organization is transaction control area is ws-control. Working Storage Section. 01 ws-control. 05 ws-function-key pic x(2).

60 Select Display-file assign to workstation-dspfile-si organization is transaction control area is ws-control. Working Storage Section. 01 ws-control. 05 ws-function-key pic x(2). Procedure Division. if ws-function-key = ’03’ ….. end-if.

61  Input and Output buffers  REDEFINES clause ◦ Different data specifications for same memory location  Screens with both fields need an input and an output buffer.


Download ppt "More Syntax in COBOL  Moving Data  Selection Statements  System Date  Indicators in Display files."

Similar presentations


Ads by Google