Tutorial on reading COBOL layouts. For example, all 25 line items on an invoice. There can be nested occurs -- an occurs within an occurs. 3 Writing a Pro*COBOL Program. This chapter provides the basic information you need to write a Pro*COBOL program, including: Programming Guidelines. The IF statement is a powerful programming tool that allows selective branching within a program. For example, a banking system. The Object COBOL class program contains the code and data for both the class. The IF Statement The general format. COBOL has some extra IF constructs to help the programmer . I guess an example will clarify the usefulness of this clause . Nested IF-THEN-ELSE-END IF. The following is an example: IF. Suppose we need a program segment to read a number x and display its sign. Working with Data Items. ILE COBOL Programmer's Guide. This chapter explains how to work with ILE COBOL numeric data, and how you. Other topics include the use of intrinsic functions and. A COBOL program with an INITIAL clause is returned to its initial. For example, Figure 12-1 shows a nested image that executes a series of three CALL statements. A list of topics are. In general, you can view ILE COBOL numeric data in a way similar to. An exception is internal floating- point data (COMP- 1. COMP- 2), for which there is no PICTURE clause. For example, an. internal floating point data item is defined as follows. GROMMET- SIZE- DEVIATION USAGE COMP- 1 VALUE 0. Looping in the basic COBOL Program These notes will supplement the PowerPoint presentation on looping. Please be sure to look at it and at the sample programs being. E- 5. For information on how you can control how the compiler handles. FLOAT and *NOFLOAT. CVTOPT Parameter and in Using the PROCESS Statement to Specify Compiler Options. For example. 0. 5 PRICE PIC 9(5)V9. Therefore, they cannot be operands in arithmetic expressions. ADD, SUBTRACT, MULTIPLY, DIVIDE, and COMPUTE statements. In the following example, the numeric- edited item is. MOVE is made to a numeric- edited item that is based on a locale, the result is. The CCSID associated with a locale. CCSIDs. associated with the files, locales, and numeric- edited items used by a program. For more information. Algorithms and code examples. For example we have two input files. You will use the sorted file as input to the rest of the program. Turning the bad and ugly into the good COBOL has been with us for a long time. Early versions of the language contained 'features' that forced programmers to write. CCSIDs are treated at runtime, refer to Runtime CCSID Considerations. The. numeric data you use in your program will be one of the formats available with. External decimal (USAGE DISPLAY). Internal decimal (USAGE PACKED- DECIMAL or COMP- 3). Binary (USAGE BINARY or COMP- 4). External floating- point (USAGE DISPLAY). Internal floating- point (USAGE COMP- 1, USAGE COMP- 2). COMP- 4 is synonymous with BINARY, and COMP and COMP- 3 are synonymous with. PACKED- DECIMAL. This corresponds to the. Therefore, it is often more efficient to. DISPLAY items. For example. COUNT- X PIC S9. V9(5) USAGE COMP VALUE 3. This format is most efficiently used when. PICTURE description, so that the. Packed decimal format is handled as a. For byte- reversed binary data, the sign bit is the. It is, therefore, preferable to use PACKED DECIMAL format for. Converting a number from BINARY. DISPLAY format is more difficult than converting a number from. PACKED DECIMAL format to DISPLAY format. The leftmost bit contains the. Like external decimal items. USAGE DISPLAY or. USAGE clause. Each byte of storage contains one. V). Also, the minus signs (- ) do not mean that. If a plus sign (+) were used, positive would be displayed as. External. floating- point numbers are always converted to internal long floating- point. User- defined data types are not additions to the. ILE COBOL data types, such as alphanumeric, numeric. User- defined data types (also known as type. WORKING- STORAGE, LOCAL- STORAGE, LINKAGE or FILE section of a program, using the TYPEDEF. These type definitions act like templates that can then be. TYPE clause, to define new data items. The new data. item acquires all the characteristics of the user- defined data type. If. the user- defined data type is a group item, then the new data item has. All you. need to do is create one definition, and apply it to any subsequent. TYPE. clause. These come in many colors and sizes. These come only with different titles. Then it creates separate data items for the three different. This is much easier and more efficient than having to re- code. There's less. chance of making a mistake, too. The compiler performs any conversions that are required during. MOVE and COMPUTE statements. The rules for moves are. Web. Sphere Development Studio: ILE COBOL. Reference. When possible, the compiler performs the move to. The results might also have to be moved back. These conversions happen. This is because the. When an external. IEEE), which can also affect its. For example, consider the following MOVE. PIC +9(3). 9(1. 3)E+9(3). For more information, refer to the. CHGPOSSN on page *NOCHGPOSSGN and *CHGPOSSGN. When an item is given a value that is. PROCEDURE DIVISION will be undefined, and your results will be. For example. non- numeric data might be moved or passed into a field in your program that is. In either case, these fields contain. Ensure that the contents of a data item conforms to its. PICTURE and USAGE clauses before using the data item in any further processing. LINKAGE SECTION. For example, a packed decimal item would be checked for. X'0' through X'9' in the digit positions. This is because one COMPUTE statement can often be coded. For example. ADD 1 TO INCREMENT. Arithmetic expressions. Intrinsic Function reference. They can also consist of several. These operators are. Expressions in parentheses are evaluated before any of. Parentheses, necessary or not. For. example, you can use arithmetic expressions as comparands in relation. IF (A + B) > (C - D + 5) THEN.. For. more information on the practical application of intrinsic functions, refer to. Intrinsic Function Examples. A nested function is evaluated independently of. This feature is used with tables. The present value of money is its value. The present value of an amount that you expect to receive at a. The following COBOL statements calculate the present. Series- Amt. 1 Pic 9(9)V9. Value 1. 00. You. NUMVAL- C (a function that returns the numeric value of an. MEAN function to do this. X PIC 9(2). The first eight characters returned by the CURRENT- DATE. YYYYMMDD). In the example, this date is converted to its. Then 9. 0 is added to this value, and the integer is. YYYYMMDD format. Assume you are analyzing various city taxes and want to. However, the MOVE statement. ITEM- 2. For. example, if the starting value were JOHNSON, the value after the statement is. NOSNHOJ. Use these functions to convert alphanumeric data items that. For example. 0. 1 R PIC X(2. VALUE . You can also place an algebraic sign in front or in the rear. The arguments must not exceed 1. For exact syntax rules, see the Web. Sphere Development Studio: ILE COBOL Reference. A reference to either of these functions, therefore, represents. For. example, for this code. X PIC S9. 99. V9. 9 LEADING SIGN IS SEPARATE. For example. However, using the NUMVAL function, you could code. A PIC X(1. 0). The intrinsic functions. Convert dates, times, or timestamps from an alphanumeric (string) item to. Convert an item of category date in one format to another category date. For more information about. MOVE Considerations for Date- Time Data Items. It is the. responsibility of the programmer to ensure that dates contained in. The UTF- 8 coded form is represented by CCSID. For example. 0. 1 STR1 PIC X(3) VALUE . One convenient way to do this is to use the substring of a. ORD. IF FUNCTION ORD (CUSTOMER- RECORD(1: 1)) IS > 1. THEN .. If you want to know which item contains the. MIN or ORD- MIN function. For example, with these data definitions. Arg. 1 Pic x(1. 0) Value . If the. ORD- MAX function were used in the example above, you would receive a syntax. Web. Sphere. Development Studio: ILE COBOL Reference). The following is. ORD- MAX function. Compute x = Function Ord- max(Arg. Arg. 2 Arg. 3). This would assign the integer 3 to x, if the same arguments were used as. If ORD- MIN were used instead, the integer 2. For more information. Arithmetic Expressions. The above examples would probably be more realistic. Arg. 1, Arg. 2 and Arg. For information on using table elements as function arguments. Processing Table Items. In the following example. R3 and the results of the COMPUTE statement depend. R1 and R2. 0. 1 R1 Pic x(1. Therefore, assuming. If R1 were the value . Plan your program code accordingly. For example, you. File Section. The following ILE COBOL statement shows. MOVE CUSTOMER- NAME TO CUSTOMER- RECORD(1: FUNCTION LENGTH(CUSTOMER- NAME)). FUNCTION LENGTH returns the length. LENGTH OF returns the length of an. In most cases, this makes little difference except for. DBCS. For example, the LENGTH OF special register can be used as. Intrinsic Function that allows integer arguments. The result returned has 2. YYYYMMDDhhmmsshh. It has the format. MM/DD/YYhh. mm. ss. The WHEN- COMPILED special register supports only a two- digit year and. The special register can only be. MOVE statement. It can be useful to test for valid. ADD- DURATION, or. SUBTRACT- DURATION. The following example shows how to test for. IF FUNCTION TEST- DATE- TIME (date- 3 DATE) = B'1'. MOVE DATE- 3 TO CUTOFF- DATE. For example, if you have two dates, and you want. FIND- DURATION function to calculate this. You can also calculate due. ADD- DURATION and. SUBTRACT- DURATION intrinsic functions. If the date in YYYYMMDD becomes. October 3. 1, 1. 99. A duration of zero days or a negative number of days would. In the example below locale object (type *LOCALE). EN. For more information about how to create a locale object. Creating Locales on the i. Series. The argument. LOCALE- TIME must be an 1. CURRENT- DATE intrinsic function, positions 9 through 2. Argument- 1 for the LOCALE- TIME. The first six digits are the hours, followed by the minutes, followed by. For. example, each of the following COBOL statements requires some kind of. General arithmetic. For. details on the precision of arithmetic evaluations, see Conversions and Precision. Since these functions are floating- point functions, the. In other words, your arithmetic. Nested arithmetic expression and function references must. This is also true of abbreviated comparisons; although. When you use expressions that contain comparisons in ILE. COBOL, the expression is evaluated as floating- point if at least one of the. If any of the four comparands is a floating- point value or. IF statement will be. In this example, the equivalent IF statements. A + D) > = (B + E) ) AND. A + D) < = C). A + D) > = (F / G) ) AND. A + D) < = (H * I) ). Thus, following these rules for the IF statement above, each IF. IF statement will be fixed- point or floating- point. The Web. Sphere Development Studio: ILE COBOL Reference. Intrinsic. Functions. Assuming TABLE- ONE is a 3. X3 array of numeric. COMPUTE X = FUNCTION SQRT(TABLE- ONE(2,2)). For. intrinsic functions that accept multiple arguments, you can use the ALL. The iteration is handled automatically, making your code shorter. If the date fields in your program only have the last 2 digits of.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |