View previous topic :: View next topic |
Author |
Message |
shiv_swami Beginner
Joined: 29 Nov 2003 Posts: 68 Topics: 14
|
Posted: Thu Jan 15, 2004 9:24 am Post subject: Incremental File Preparation using Match files logic |
|
|
Hi All,
I have a following requirement in which I need your help to decide on what tool/language to use.
I have extract data from IDMS Database everyday & send the files in an incremental way.
If file has key of 10 chars & remaining data of 2400 CHARACTERS
YESTERDAY EXTRACT
Code: | 1234567890 ABCDEF
2234567890 GHIJKL
3234567890 MNOPQR |
TODAY EXTRACT
Code: | 1234567890 STUVWX <<<--- Modified the field for rec-key of 1234567890
4234567890 BBBBBB <<<--- Added record |
INCREMENTAL file to be sent should have ADDED or Modified Records only (No deleted records)
Code: | 1234567890 STUVWX <<<--- Modified the field for rec-key of 1234567890
4234567890 BBBBBB <<<--- Added record |
I have tried the following EASYTRIEVE code which gets compiled successfully but gets S0c4 Abend.
Is the length of argument (2490 ehre) a problem for comparison or I have made some mistake in the code ?
Code: | FILE TODAY
WS-TODAY-REC 1 2500 A
WS-TOD-KEY 1 10 A
WS-TOD-DESC * 2490 A
FILE YESTDAY
WS-YEST-REC 1 2500 A
WS-YEST-KEY 1 10 A
WS-YEST-DESC * 2490 A
IF MATCHED
COUNT-MATCHED = COUNT-MATCHED + 1
IF WS-TOD-DESC = WS-YEST-DESC
DISPLAY 'DATA MATCHED TOO'
ELSE
DISPLAY 'DATA MODIFIED >>> SHOULD GO TO OUPUT FILE'
END-IF
ELSE-IF YESTDAY
DISPLAY 'DELETED >>> SHOULD BE DROPPED FROM OUPUT FILE' ' WS-YEST-KEY
COUNT-DELETED = COUNT-DELETED + 1
ELSE-IF TODAY
DISPLAY ' RECORD ADDED >>> SHOULD GO TO OUPUT FILE' WS-TOD-KEY
COUNT-ADDED = COUNT-ADDED + 1
END-IF |
Also please let me know if there is way to do it in shorter time say in Sort or Fileaid ?
Culprit allows the MATCH key run but my SHOP does not prefer Culprit programs due to some constraints.
Regards,
Shivprakash
Why Walk when you can Run ?
Nicola Iacocca |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Jan 15, 2004 11:43 am Post subject: |
|
|
Shiv,
Just change the definition for WS-TOD-DESC & WS-YEST-DESC. Specify the absolute start position for the compare fields which is 11 instead of letting easytrieve calculate it.
The reason is simple. You have defined the enitre RECORD with WS-TODAY-REC and next fields are just a redefinition of the ws-today-rec. When you use '*' for specifying field positions you cannot use redefinition.
so you can either change it to
Code: |
FILE TODAY
WS-TODAY-REC 1 2500 A
WS-TOD-KEY 1 10 A
WS-TOD-DESC 11 2490 A
|
OR
Code: |
FILE TODAY
WS-TOD-KEY 1 10 A
WS-TOD-DESC * 2490 A
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
shiv_swami Beginner
Joined: 29 Nov 2003 Posts: 68 Topics: 14
|
Posted: Fri Jan 16, 2004 3:30 am Post subject: |
|
|
Kolusu,
Thank you very much for the solution .
The new definition of the variables is correct & I am getting the desired results.
I would like to know whether there would be any performance issues due to high record length (upto 3000) & high number of records in the Matched files (appx 10000 to 15000).
Also I need to do this for 12 different file types..Is this the best solution ?
What are the factors that I have to consider before implementing this solution
Regards,
Shivprakash
Why Walk when you can Run ?
Nicola Iacocca |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Fri Jan 16, 2004 6:35 am Post subject: |
|
|
shiv,
I don't think performance will be an issue. why don't you just run a couple of tests and compare the cpu times.
Quote: |
Also I need to do this for 12 different file types..Is this the best solution ?
|
Does all the files have the same record layout? If they are different are you going to code 12 different programs?
With easytrieve you should able to code one generic program which can be used for any file length
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
shiv_swami Beginner
Joined: 29 Nov 2003 Posts: 68 Topics: 14
|
Posted: Fri Jan 16, 2004 7:06 am Post subject: |
|
|
Kolusu,
Thanks for your response.
As per your suggestion,I will do test for the large record length program.I was happy with CPU time it used for small number of records in match files.
For the 12 files ,that I want to create incremental files, they do not have same record layout.They have different layouts.(Sorry I did not make my requirements clear straight away)
Quote: |
With easytrieve you should able to code one generic program which can be used for any file length
|
This is what I want actually but I was not sure whether record & key descriptions could be made generic as such.Would it be a MACRO or parms would be passed.Please explain.
Regards,
Shiv
Why Walk when you can Run ?
Nicola Iacocca |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Fri Jan 16, 2004 9:21 am Post subject: |
|
|
Shiv,
The following is a general easytrieve program which can be used for any file length up to 9999. I assumed that your key of 10 bytes always starts in position 1. A brief explanation of the program.
Unlike cobol , easytrieve allows you to define the files as workareas. so we define both the input files as workarea and define only the key fields on both the files.
Define another working storage variable W-TODAY-REC which is redefined as an array of 1 byte character field with an occurs clause of 9999. The same applies for the definition of
W-YESTDAY-REC
Now using reference modification we move the contents of the file to another working storage variable which are used as comparision fields.
But for reference modification to work we need to know the lrecl of the file. For this we use the variable RECORD-LENGTH which is a two-byte binary field used for all file types to determine or establish the length of the current data record. For variable-length records, this field contains only the length of the record's data.
we use a START proc(as it execuetes only once at the begining) to find LRECL of both the files . once we have the LRECL of the files we calculate the no: of bytes of data to be compared by subtracting the key field length from the TOTAL LRECL.
Code: |
FILE TODAY WORKAREA 9999
TOD-REC 01 9999 A
TOD-KEY 01 0010 A
FILE YESTDAY WORKAREA 9999
YEST-REC 01 9999 A
YEST-KEY 01 0010 A
W-TODAY-REC W 9999 A
W-T-REC W-TODAY-REC 01 A OCCURS 9999
W-YESTDAY-REC W 9999 A
W-Y-REC W-YESTDAY-REC 01 A OCCURS 9999
W-TODAY-HOLD-AREA W 9999 A
W-YESTDAY-HOLD-AREA W 9999 A
W-TODAY-LRECL W 0009 N 0
W-YESTDAY-LRECL W 0009 N 0
W-TODAY-ENDPOS W 0009 N 0
W-YESTDAY-ENDPOS W 0009 N 0
W-COUNT-DELETED W 0009 N 0
W-COUNT-MATCHED W 0009 N 0
W-COUNT-ADDED W 0009 N 0
JOB INPUT (TODAY KEY (TOD-KEY) +
YESTDAY KEY (YEST-KEY)) START FINDLEN
IF MATCHED
W-COUNT-MATCHED = W-COUNT-MATCHED + 1
W-TODAY-REC = TOD-REC
W-YESTDAY-REC = YEST-REC
MOVE W-T-REC(11) W-TODAY-ENDPOS TO W-TODAY-HOLD-AREA
MOVE W-Y-REC(11) W-YESTDAY-ENDPOS TO W-YESTDAY-HOLD-AREA
IF W-TODAY-HOLD-AREA = W-YESTDAY-HOLD-AREA
DISPLAY 'DATA MATCHED TOO'
ELSE
DISPLAY 'DATA MODIFIED >>> SHOULD GO TO OUPUT FILE'
END-IF
ELSE-IF YESTDAY
DISPLAY 'DELETED >>> SHOULD BE DROPPED FROM OUPUT FILE' YEST-KEY
W-COUNT-DELETED = W-COUNT-DELETED + 1
ELSE-IF TODAY
DISPLAY ' RECORD ADDED >>> SHOULD GO TO OUPUT FILE' TOD-KEY
W-COUNT-ADDED = W-COUNT-ADDED + 1
END-IF
W-TODAY-REC = ' '
W-YESTDAY-REC = ' '
W-TODAY-HOLD-AREA = ' '
W-YESTDAY-HOLD-AREA = ' '
FINDLEN. PROC
W-TODAY-LRECL = TODAY:RECORD-LENGTH
W-YESTDAY-LRECL = YESTDAY:RECORD-LENGTH
W-TODAY-ENDPOS = W-TODAY-LRECL - 10
W-YESTDAY-ENDPOS = W-YESTDAY-LRECL - 10
END-PROC
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
shiv_swami Beginner
Joined: 29 Nov 2003 Posts: 68 Topics: 14
|
Posted: Fri Jan 16, 2004 12:39 pm Post subject: |
|
|
Thanks Kolusu.
It works well & with definition of outfile as FB (0 0) ,with this one need not bother about the record lenth of output fille too as it will be on JCL card.
Key-length is the only thing I have to bother about....
Regards,
Shivprakash
Why Walk when you can Run ?
Nicola Iacocca |
|
Back to top |
|
|
|
|