View previous topic :: View next topic |
Author |
Message |
THRIVIKRAM Beginner
Joined: 03 Oct 2005 Posts: 70 Topics: 34
|
Posted: Tue Apr 27, 2010 11:25 am Post subject: Eliminate the Last record type before insertin into table |
|
|
Hi All,
I have records on MQ. I need to read each record and store it in a table as free form text area.
This record will be multiples of 130 bytes. The colum in the table can hold upto 76 chunks of this 130 bytes. So, max bytes than can be inserted into the table are 76*130=9880bytes
If the record on the MQ is greater than this, I split the record into multiples of 9880 and insert into the table with incremented seq_nr to distinguish different parts of the same record.
Code: |
If (Rec-count < 76)
{
COMPUTE WS-LENGTH = rec-Count * 130
MOVE MQ-Record(1:WS-LENGTH) to table-dclgen
Insert into Table
}else{
ws-length =76 * 130
COMPUTE some-counter = (rec-count / 76 ) + 1
PERFORM VARYING WS-SUB FROM 1 BY 1
UNTIL WS-SUB > some-counter
MOVE MQ-Reocrd(WS-START-POS:WS-LENGTH)
TO table-dclgen
Insert into Table
COMPUTE WS-START-POS = WS-START-POS + WS-LENGTH
ADD 1 TO SEQ_NR
END-PERFORM
END-IF
|
The problem now is if the MQ record has a chunk starting with 9999 (Usually the last record), I should not insert that particular chunk into the table.
If the record length is < 76, I am just subtracting one from rec-count so that I ignore the last chunk "COMPUTE WS-LENGTH = (rec-Count - 1) * 130". But how can I do this when the record-count > 76...?
Thanks!! |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Apr 27, 2010 1:01 pm Post subject: |
|
|
THRIVIKRAM,
If there is nothing to indicate the last records then read the record and move it into buffer and then read the next record and set the End-of-file flag. If the flag is NOT on then perform your split and insertion into table.
Btw Your logic about splitting needs to be reworked. for ex : if the REC-COUNT is 100. You are setting the counter to 2 and you will be populating junk data at the end as the WS-LENGTH is already set to 9880 already. You need to use DIVIDE function and get the remainder also and then move accordingly.
Kolusu |
|
Back to top |
|
 |
|
|