View previous topic :: View next topic
|
Author |
Message |
km_abdullah
New User
Joined: 03 Nov 2008 Posts: 60
|
|
|
|
Hi,
My input file is like below.
Code
------
P500
P300
My IMS segment occurrences are like below.
P3008XYA1234 - Key is P3008XYZ
P3008XYB3256 - Key is P3008XYB
P3008XYC7412 - Key is P3008XYC
P4008XYC7555 - Key is P4008XYC
P5009XYA3253 - Key is P5009XYA
P5009XYB8522 - Key is P5009XYB
P6009XYA8527 - Key is P6009XYA
I want to fetch all the records matching my input file code. Since i have only 'Partial Key', I issue a GN call with Qualified SSA with key as below.
Key >= P500
I will now be able to fetch both the P500 segments occurrences.
Then i read the next record from input which is P300.
I now modify my qualified SSA with key as below -
Key >= P300
Then i issue a GN call, but it fetches 'P6009XYA8527' not what i need (P3008XYA1234).
However if i sort my input file so that it is like below
Code
------
P300
P500
then changing the SSA with new code fetches me correct data, i.e., it fetches P5009XYA3253 after P3008XYA1234 and not P4008XYC7555 as it
was doing in the previous case.
For the first case (without sort),
I think i need to refresh the current position first before issuing a GN call for each input project code. But can you tell me how to do that?
Any suggessions welcome? |
|
Back to top |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
Keep in mind that IMS does not have a "read previous". You are positioned at your last successful call. You are keyed sequential. I would always sort my input file in sequential order. |
|
Back to top |
|
|
Ajay Baghel
Active User
Joined: 25 Apr 2007 Posts: 206 Location: Bangalore
|
|
|
|
what about using GU Key >= code-key and then using GN
With this you need not sort the input file by code.
Thank you
Ajay |
|
Back to top |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
Why would you make more work for IMS? Remember that IMS is positional.
If you want to go sequentially from lowest database key to high, you need to sort your input file in sequential order. IMS is NOT DB2. IMS reads left to right in the database. We do not do "fetches" in IMS. It will take you about 5 minutes total to put together an external sort and the JCL against that input file.
The below logic is correct. Once you position yourself on the first segment with that partial key, then you can GN UNTIL the partial key changes. If you want ONLY segments with the partial keys on your input file, you will need to check if the segment retrieved has a different partial key. You will then load the partial key from your input file - making sure to check if you have already retrieved a segment match.
Quote: |
I want to fetch all the records matching my input file code. Since i have only 'Partial Key', I issue a GN call with Qualified SSA with key as below.
Key >= P300 |
|
|
Back to top |
|
|
km_abdullah
New User
Joined: 03 Nov 2008 Posts: 60
|
|
|
|
I found a way to deal with this when input is not sorted.
I simply moved
1) Project code to PROJ1 and PROJ2
2) low-values to FIL1
3) high-values to FIL2
4) '&' to OP
in below SSA and perform until 'GE' to get my required segment occurrences.
Code: |
01 SSA-PRO.
05 SEGMENT-NAME PIC X(8) VALUE 'SUBPMT '.
05 FILLER PIC X(1) VALUE '('.
05 FIELD-NAME1 PIC X(8) VALUE 'PROJNO '.
05 FILLER PIC X(2) VALUE '>='.
05 KEY1.
10 PROJ1 PIC X(4).
10 FIL1 PIC X(27).
05 OP PIC X(1) VALUE '&'.
05 FIELD-NAME2 PIC X(8) VALUE 'PROJNO '.
05 FILLER PIC X(2) VALUE '<='.
05 KEY2.
10 PROJ2 PIC X(4).
10 FIL2 PIC X(27).
05 FILLER PIC X(1) VALUE ')'. |
Thanks |
|
Back to top |
|
|
|