by manisubbu » Thu Nov 19, 2009 9:42 pm
It is coding question. I am writing Easytrieve program to change pack values in the input file to some other pack values if the input records matches specific condition.
For Example:
If the input file contains two types of record such as Type A and Type B. I need to change 5th field of the B type record (which is the packed variable) when it satisfies some condition otherwise I need to add the records in output file.
Sample Code:
File1 = Input file
Input –record 80 A
File2 = Output file
Output –record 80 A
GET File1
Do while until EOF file1
Move input-Record to output-Record
IF record type = ‘a’
Nop
Else
If record type = ‘b’
If 3rd pos = ‘c’
5th pos = packed value
End-if
End-if
End-if
Put File2
Get file1
End-Do
Case: 1
If B type records satisfy the above condition. I am passing packed value (50) to that field.
Case: 2
If B type records does not satisfy the above condition. I am writing the records to output file without changing the pack value.
Output:
For Case 1: I am getting ‘F’ in packed field
For Case 2: I am getting ‘C’ in packed fields which is same as input file.
Note: The packed field which I am changing contains “F†in the sign bit remaining Pack field Contains “C†in the sign bit.