Interest calculation is an important business of banks, including daily proxy customer collection, calculation of customer interest, and annual interest calculation. Currently, most of this work is performed on the Safe Application System Platform of the IBM es9000 host. The online program and the on-line interest rate program are implemented in the IBM 370 assembly language. For ease of reading and writing in assembly language, the data storage format is defined in the data stored in the VSAM file. For example, if the date is stored in the X (3) type, the ebcd code will be stored in the format of X (3) from January 1, 010315 '. During annual interest calculation, in order to implement various complex operations, we generally use the COBOL language to implement various operations. When using the COBOL language to read X (3) type data, the reading is the compile type data and cannot be directly computed. It must be converted to the COBOL data type before corresponding processing. For example, in the preceding section, we need to convert x '0010315c' to the internal decimal data '. This article introduces a method to convert between a string X (3) and an internal decimal data using the COBOL language.
Convert from X (3) to internal decimal
Since the date data is always greater than zero, after defining the variable date-first in the unit of work section of the COBOL language, append the minimum data unit x '000c' of the COBOL language, that is, decimal 12. After redefinition of date-case as date-change, date-change is 1000 times the original date data. Therefore, the date-change must be divided by 1000 in the Process Section.
First, define the following content in the working-storage section. Of the COBOL program:
Working-storage section.
01 date-case.
02 date-first pic x (3 ).
02 date-sign PIC 9 (4) comp value 12.; Fixed Point binary number
01 date-change redefines date-case PIC 9 (9) COMP-3.; internal decimal data
01 date-hex pic x (3).; data before conversion
01 DATE-DEC PIC s9 (7) COMP-3.; converted data
Then, add the following statement to the procedure devision. Process:
Procedure devision.
Move date-hex to date-first.
Compute date-change = date-
Change/1000.
Move date-change to DATE-DEC.
Convert from internal decimal to X (3) Type
In the opposite conversion, we need to remove the plus 0 before the original date data caused by the "c" data type mark of the COBOL language. Therefore, we need to multiply the conversion data by 10, retrieve the first six digits of data.
First, define the following content in the working-storage section. Of the COBOL program:
Working-storage section.
01 work-date PIC s9 (7) COMP-3.
01 AA redefines work-date.
02 A1 pic x (3 ).
02 A2 PIC x (1 ).
01 date-hex pic x (3).; converted data
01 DATE-DEC PIC s9 (7) COMP-3.
; Data before conversion
Then, add the following statement to the procedure devision. Process:
Procedure division.
Move DATE-DEC to work-date.
Compute work-date = work-date * 10.
Move A1 to date-hex.