View previous topic :: View next topic
|
Author |
Message |
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Hi,
We have 1 reference file and 4 other files. We have to compare each of these 4 files with the reference file on the same field. Can we declare more than 2 files in JOB activity and compare in a single easytrieve program as shown below?
Below is the JOB activity:
Code: |
JOB INPUT (FLSBRNCH KEY (WS-KEY) +
INFODLY KEY (WS-KEY1) +
MSTDLY KEY (WS-KEY2) +
PRMNBR KEY (WS-KEY3) +
RELHST KEY (WS-KEY4))
|
Below is the comparison code:
Code: |
IF WS-KEY = WS-KEY1
MOVE WS-FC-NBR TO PRI-FA-KEY
END-IF.
IF WS-KEY = WS-KEY2
MOVE WS-ACCT-TO-ACCT TO NACCT-NO
END-IF.
IF WS-KEY = WS-KEY3
MOVE WS-DEPT-NBR TO NEW-FA-BR
END-IF.
IF WS-KEY = WS-KEY4
MOVE WS-SPLT-FC-ASST TO PRI-FA-SPLT-FC-INFO
END-IF.
PUT OUTFILE.
|
Please note that here we have to extract different fileds from different input files by comparing the branch number of reference file with the branch number of each of the other files and write it to a single output file. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I believe jour JOB INPUT will work for the 5 files.
I believe your code to determine syncronization needs to be different. IIRC, you would use IF MATCHED to detect that all files matched. You would use IF MATCHED f1, f2 for the compare of only file1 to file2. And so on matching the first file against the other files.
You might also code to ensure a particular file currently has data (IF FILENAME or IF NOT FILENAME) or is at end of file (IF EOF FILENAME or IF NOT EOF FILENAME).
Good luck and i'll check back when i get online again. |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Dick,
Thanks for the information. I have changed the matching logic as suggested above and program is running.
Reference (FLSBRNCH) file has 50 records and out of 4 other files, one file (INFODLY) has about 12 Million records and all other files have in hundreds and thousands. Job is running for the last 2.5 hours.
Is there any way to reduce the time? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Is there any way to reduce the time? |
How long does it take to simply read the 12millon record file in Easytrieve (without matching against anything). How long in a simple cobol program? Does the file have disp=old or might something else be reading it at the same time? |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Dick,
We are now extracting with limited number of records for testing and facing the following problem.
When we are writing signed packed decimal value into output file by readi ng an input file, it's writing the value correctly but sign part is writing with spaces.
Input declaration is as below.
Code: |
FILE RELHST F 74
WS-KEY4 1 3 A
WS-DATA7 4 8 A
WS-DATA8 12 51 A
WS-SPLT-FC-ASST 63 5 P 5
WS-SPLT-FCT-GR 69 5 P 5
|
Output declaration is
Code: |
FILE OUTFILE F 66
PRI-FA-KEY 1 6 A
PRI-FA-SPLT-FC-INFO 7 5 P 5
PRI-FA-SPLT-FC-INFO1 13 5 P 5
NACCT-NO 19 16 A
NEW-FA-KEY 35 6 A
NEW-FA-BR 41 6 A
NEW-FA-SPLT-PCT-F 47 5 P 5
NEW-FA-SPLT-PCT-F1 53 5 P 5
OUT-KEY 59 3 A
OUT-KEY1 62 5 A
|
Input value as shown below.
Code: |
...°.....°..
000900000900
00000C00000C
|
Output also should be displayed as above but it's displaying spaces inplace of sign.
Code: |
00090[b]4[/b]00090[b]4[/b]
00000[b]0[/b]00000[b]0[/b]
|
In the above example, spaces are getting displayed inplace of sign. What could be the problem for the above? Everything is getting displayed properly except SIGN part. |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Please note that above values are for Packed Decimal fields (PRI-FA-SPLT-FC-INFO, PRI-FA-SPLT-FC-INFO1, NEW-FA-SPLT-PCT-F and NEW-FA-SPLT-PCT-F fields) |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I believe what has happened is that the data is 6 positions long but has been defined as 5. The spaces are the unspecified bytes between the fields. |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Data has been defined as 5P5, 5 positions before decimal position and 5 positions after decimal position. So, total memory 6 bytes ((5+5+1)/2=5.5=6 bytes).
Spaces are not unspecified bytes, we have checked twice. When we declared 4 bytes after decimal (5P4), space was truncated and all other digits were displayed except sign.
Defining signed packed decimal as "P" is enough or we have to handle sign differently? Also after writing into output file, we initialized all fields. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Checking many times will not help. . . .
You have defined the fields to be 5 bytes in length - not 6.
Quote: |
{field-length}
Field-length specifies the length (in bytes) of the defined field. Field-length
must be an unsigned integer. |
Simply said, the definitions do not match the input data and the definitions leave an open byte beteween the fields in the output which is where the unwanted blanks/spaces originate. |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Thanks Dick. Program got executed successfully after changing the declaration to 6P5. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Code: |
FILE RELHST F 74
WS-KEY4 1 3 A
WS-DATA7 4 8 A
WS-DATA8 12 51 A
WS-SPLT-FC-ASST 63 5 P 5
WS-SPLT-FCT-GR 69 5 P 5 |
Code: |
...°.....°..
000900000900
00000C00000C
|
Note that the actual posted data is 2 6-byte fields, not 5. Also note, that when the length is added to the displacement of a field in the file definition, the next displacement results - except fot the last 2 fields. I believe those field definitions should be "nn 6 P 5". |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
We were typing at the same time. . .
Good to hear it is working - thanks for letting us know
d |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Dick,
I have one question here on declaration of the field.
I want to have 5 digits after decimal and 1 digit before decimal.
E.g.,
Code: |
0.10000
1.00000 so on...
|
For this I have declared the variable as 1 P 5, but it's giving invalid declaration. And I found from the available Easytrieve manual that before decimal declaration must be greater than or equal to the after decimal declaration.
If we want to have values as shown above, how should we declare the variable? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Try 6 P 5 (length of 6 with 5 positions after the decimal). |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Thanks Dick. I have declared as 6P5 but I was thinking this declaration is for 6 digits before decimal and 5 digits after decimal. Thanks for clarification.
Regards,
KSK |
|
Back to top |
|
|
|