View previous topic :: View next topic
|
Author |
Message |
Sudeshna Sarkar
New User
Joined: 11 Sep 2008 Posts: 29 Location: Kolkata
|
|
|
|
I have an input like following, where I have to read an Account number of 8 digits from another Accounts file and match with the CPI01-NBASE-ID of the following file layout. Now in the below file I also have a field called CPI01-CPRECORD-TYPE. Ideally, if I read the below VSAM file with a partial key avaible , i.e. only the value of Base ID and Branch No etc, then I do a Start Read, and then Read Next and try to fetch corresponding records.
The Partial Key for above file is CPI01-PARTIAL-START-KEY. Below is a partial layout of the above file.
Code: |
FD I-CPIMAST-FILE.
01 CPI01-BASIC-ACCOUNT-RECORD.
05 CPI01-BASIC-KEY.
10 CPI01-CP-NACCT-NBR.
15 CPI01-PARTIAL-START-KEY.
20 CPI01-NFIRM-CODE PIC X(3).
20 CPI01-NBRANCH-NBR PIC X(5).
20 CPI01-NBASE-ID PIC X(8).
15 CPI01-NCHECK-DIGIT PIC X.
15 CPI01-NPRODUCT-CODE PIC X(3).
10 CPI01-CPRECORD-TYPE PIC X(2).
88 CPI01-BASIC-RECD-TYPE VALUE '01'.
88 CPI01-INT-PARTY-RECD-TYPE VALUE '03'.
88 CPI01-SUPP-RECD-TYPE VALUE '04'.
88 CPI01-ALT-ADDRESS-RECD-TYPE VALUE '05'.
88 CPI01-PREF-RATE-RECD-TYPE VALUE '06'.
88 CPI01-ACCT-TRNSFR-RECD-TYPE VALUE '07'.
88 CPI01-UNSEC-ABPROP-RECD-TYPE VALUE '08'.
88 CPI01-FXD-FIELD-RECD-TYPE VALUE '09'
88 CPI01-SUITABILITY-TYPE VALUE '10'.
10 FILLER REDEFINES CPI01-CPRECORD-TYPE.
15 FILLER PIC X(01).
88 CPI01-DVP-RVP-RECD-TYPE VALUE '2'.
15 FILLER PIC X(01).
10 CPI01-KEY-FILLER PIC X(2). |
Below are the read paragraphs.
Code: |
4001-PRIME-KEY.
*
MOVE '4001-PRIME-KEY' TO WS-PARA-NAME.
*
INITIALIZE CPI01-BASIC-ACCOUNT-RECORD.
*
MOVE '001' TO W-SBS-ACCT-FIRM.
MOVE '00' TO W-SBS-ACCT-BR-1.
MOVE I-BR TO W-SBS-ACCT-BR-2.
MOVE I-BR-BASE TO W-SBS-ACCT-BASE.
*
MOVE W-SBS-START-KEY TO CPI01-PARTIAL-START-KEY.
================================
4002-START.
MOVE '4002-START' TO WS-PARA-NAME.
MOVE 'START' TO WS-VSAM-ERR-MSG-FUNC.
MOVE W-SBS-ACCT-BASE TO WS-VSAM-ERR-MSG-KEY.
WE NEED TO DO A START BECAUSE WE ONLY HAVE A PARTIAL KEY.
START I-CPIMAST-FILE KEY = CPI01-PARTIAL-START-KEY.
EVALUATE CPIMAST-STATUS
WHEN '00'
PERFORM 4003-READ-CPI THRU 4003-EXIT
WHEN '23'
DISPLAY 'NOT ON CPI (START) = ' W-SBS-START-KEY
' STATUS = ' CPIMAST-STATUS
ADD +1 TO CPI-NF-CTR
ADD 1 TO ACCOUNT-CNT-CTR
WHEN OTHER
PERFORM 9200-CPI-ERROR THRU 9200-EXIT
END-EVALUATE.
4002-EXIT.
EXIT.
============================================
4003-READ-CPI.
*
MOVE '4003-READ-CPI' TO WS-PARA-NAME.
MOVE 'READ' TO WS-VSAM-ERR-MSG-FUNC.
MOVE W-SBS-ACCT-BASE TO WS-VSAM-ERR-MSG-KEY.
*
READ I-CPIMAST-FILE NEXT.
*
EVALUATE CPIMAST-STATUS
WHEN '00'
ADD +1 TO CPI-FOUND-CTR
PERFORM 4004-MOVE-CPI-INFO THRU 4004-EXIT
WHEN '04'
ADD +1 TO CPI-O4-FOUND-CTR
DISPLAY 'ACCOUNT O4 ' W-SBS-ACCT-BASE
PERFORM 4004-MOVE-CPI-INFO THRU 4004-EXIT
WHEN '23'
DISPLAY 'NOT ON CPI = ' W-SBS-START-KEY
' STATUS = ' CPIMAST-STATUS
ADD +1 TO CPI-NF-CTR
ADD 1 TO ACCOUNT-CNT-CTR
WHEN OTHER
PERFORM 9200-CPI-ERROR THRU 9200-EXIT
========================================== |
Ideally what I want is to retrieve all the Records for CPI01-PARTIAL-START-KEY provided; this will give me almost similar output as above. Which means I will be able to fetch all Record Types (CPI01-CPRECORD-TYPE) for a particular Account or Base ID. Also there is no Sort, duplicate removal or filter on the field CPI01-CPRECORD-TYPE. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Although it is not clear from what you've posted, I would guess you're getting a file status 10 on the READ NEXT which is performing your error paragraph. Using START KEY = requires a match on the key -- when the key stops matching, the records aren't retrieved any more. Try using START KEY >= instead -- but you'll have to watch for the account number change. |
|
Back to top |
|
|
Sudeshna Sarkar
New User
Joined: 11 Sep 2008 Posts: 29 Location: Kolkata
|
|
|
|
Hi Robert,
You have almost got my query, Thanks and also apologies for not clearly explaining the problem.
Actually I am not getting any file status on the Read Next. i.e. No File status of 10. The read operation happens properly, but end result is its selecting the top record(record type 01) and that's all, it stops there. This can be due to using START KEY = as you mentioned, tomorrow at my shop I ll try my code with START KEY >= and see if the results come for all record types for an account number.
As of now, I am only worried that why in this existing piece of code, its only fetching the first record for each account.
When you say keep a check on account number change, what do you mean? Is there a separate way? Moreover, I need all record type for all account numbers, so should I really care about the change?
Thanks again. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
How is control being passed to the 4001/4002/4003 paragraphs? |
|
Back to top |
|
|
Sudeshna Sarkar
New User
Joined: 11 Sep 2008 Posts: 29 Location: Kolkata
|
|
|
|
Code: |
3000-PROCESS-ACCOUNTS.
MOVE '3000-PROCESS-ACCOUNTS' TO WS-PARA-NAME.
INITIALIZE O-ACCOUNT-REC-WS
ACCOUNT-CNT-CTR.
MOVE I-ACCOUNT TO O-ACCOUNT.
PERFORM 4000-CPI THRU 4000-EXIT.
IF O-ACCOUNT = 'OTCACCOUNT'
MOVE 0 TO O-ACCOUNT-CNT
ELSE
MOVE ACCOUNT-CNT-CTR TO O-ACCOUNT-CNT
END-IF.
PERFORM 6000-WRITE THRU 6000-EXIT.
PERFORM 2000-READ-ACCOUNT THRU 2000-EXIT.
3000-EXIT.
EXIT.
4000-CPI. |
You may notice that 4003 is called inside 4002. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Where is "4000-EXIT"?
Where are you looping back to "4003-READ-CPI" to continue reading the rest of the matching accounts?
Why the "WHEN '04'" on the read? |
|
Back to top |
|
|
Sudeshna Sarkar
New User
Joined: 11 Sep 2008 Posts: 29 Location: Kolkata
|
|
|
|
Sorry I have not mentioned all parts of the code.
Code: |
01016 4000-CPI. BEAB705
01017 * BEAB705
01018 MOVE '4000-CPI' TO WS-PARA-NAME. BEAB705
01019 * BEAB705
01020 PERFORM 4001-PRIME-KEY THRU 4001-EXIT. BEAB705
01021 PERFORM 4002-START THRU 4002-EXIT. BEAB705
01022 * BEAB705
01023 4000-EXIT. BEAB705
01024 EXIT. BEAB705 |
after this 4001 paragraph. Looping of 4003 is done again as a set from 4001 itself at the beginning of the program.
When 04 on the read is just to handle one set of 04 records on program, this is an existing program in our system, hence I am not too sure of the business. But can look through it. But seems otherwise this is not significant. |
|
Back to top |
|
|
icemanroh
New User
Joined: 23 Aug 2008 Posts: 25 Location: Mumbai
|
|
|
|
You can try following:
Code: |
START filename
KEY IS NOT LESS THAN the-partial-key
END-START
READ filename NEXT RECORD
END-READ |
At this point u'll b able to read the 1st record provided your key is correct. Now if u want to read next records u'll have to use
Code: |
READ filename NEXT RECORD
END-READ |
For e.g.
Code: |
PERFORM read-next-para UNTIL
(some condition to check the next records is different than the current one). |
Unless u use the read next command u won't be able to read next records. |
|
Back to top |
|
|
Sudeshna Sarkar
New User
Joined: 11 Sep 2008 Posts: 29 Location: Kolkata
|
|
|
|
I used START KEY >=
And also I am doing a READ NEXT.
but this did not work either, seems that the problem is somewhere else in the code, we do have something called check digits for each record, I think we need to handle that. getting some more details on that internally.
Till then will try your solution too icemanroh |
|
Back to top |
|
|
icemanroh
New User
Joined: 23 Aug 2008 Posts: 25 Location: Mumbai
|
|
|
|
Sudeshna Sarkar wrote: |
I used START KEY >=
And also I am doing a READ NEXT.
but this did not work either, seems that the problem is somewhere else in the code, we do have something called check digits for each record, I think we need to handle that. getting some more details on that internally.
Till then will try your solution too icemanroh |
I can see u r using read next
Code: |
4003-READ-CPI.
*
MOVE '4003-READ-CPI' TO WS-PARA-NAME.
MOVE 'READ' TO WS-VSAM-ERR-MSG-FUNC.
MOVE W-SBS-ACCT-BASE TO WS-VSAM-ERR-MSG-KEY.
*
READ I-CPIMAST-FILE NEXT. |
But this read will only fetch the very first record which u r getting at the moment. There should be another Read next to get the next record or some sort of loop to keep reading next record until the key changes. I hope u understand what Im trying to say. |
|
Back to top |
|
|
Sudeshna Sarkar
New User
Joined: 11 Sep 2008 Posts: 29 Location: Kolkata
|
|
|
|
Hi,
Yes I got your point. Somehow it reads record for one Account, and stops with the first found record type. For the next record read of a different record type for the same account number, we need to provide a Read Next Loop. Let me try. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Sudeshna Sarkar wrote: |
Yes I got your point. Somehow it reads record for one Account, and stops with the first found record type. |
Not 'somehow', that is how you have the program coded.....
Quote: |
For the next record read of a different record type for the same account number, we need to provide a Read Next Loop. Let me try. |
Yes, that is right. Good luck. |
|
Back to top |
|
|
|