View previous topic :: View next topic
|
Author |
Message |
chandrarkar
New User
Joined: 27 May 2008 Posts: 24 Location: india
|
|
|
|
i have a situation like, there are 2 files A and B(BOTH ARE PS). For each record in A the FILE B has to be read for the some condition.
for the above logic i tried 2 ways.
1.)job input A
GET B
CHECK LOGIC
PRINT O/P
IF i am doing this then the FILE B is reaching the end of file and giving the logical error.can u help me by saying how can i make the pointer go the first record of B after each record in A is processes.
2.)i tried IF MATCHED(FILEA(KEY) FILEB(KEY))
But it is only reading the file B ONLY ONCE.
CAN AMYONE SUGGEST A SOLUTION FOR THIS.BOTH FILES ARE PS |
|
Back to top |
|
|
Manuneedhi K
Active User
Joined: 07 May 2008 Posts: 115 Location: Chennai
|
|
|
|
If FILEB is relatively try declaring it as a TABLE and do a search.
Thanks
Manu |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello Chandra and welcome to the forums,
Quote: |
how can i make the pointer go the first record of B after each record in A is processes. |
You can't - easytrieve does not do this.
You need to use a 2-file match/merge to do what you need.
Easytrieve has a match function (documented in the ezt manual) od you could use cobol. There is a "Sticky" near the top of the COBOL section of the forum that contains working sample code for what i believe is your requirement.
Download and review the sample code and post back here if there is something you do not understand. I have not done so, but i believe the same logic could be used in ezt if tyhe ezt match does not do what you need. |
|
Back to top |
|
|
chandrarkar
New User
Joined: 27 May 2008 Posts: 24 Location: india
|
|
|
|
hi
thanks for ur reply, and i have some questions about a table which i thought can be helped by u.
1.)my sequential file has around 600 rceords.so its an external table
2.)do i have to get the records sorted in ALPHABATECIAL ORDER IN THE PS to declare it as a table.
3.)file inpfile table {literal-10}
arg 1 16 a desc 17 44 a
this is the decleration i have to give for external table decleration.
if my file size is not variable can i declare it to have an approximate size.
if i am mistaken pls correct me. |
|
Back to top |
|
|
chandrarkar
New User
Joined: 27 May 2008 Posts: 24 Location: india
|
|
|
|
hi
thanks for the reply.
wat my inclination towards "if matched " was
if FILEA has no dups FILEB has dups and
now for every record in FILEB, FILEA has to be searched.
so
job input(filea(key1) -
fileb(key2))
if matched
{process}
goto job
i was thinking that for if matched the FILEA is not bieng searched every time fileb is read.
our requirement is it should be read multiple times.so after every job input will the filea be read from the top again. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
our requirement is it should be read multiple times |
If both files are in the proper sequence, i believe there is no need to read either file multiple times.
If the build-in easytrieve "match" does not do what you need, i'd suggest using the above mentioned cobol code or converting that code to easytrieve if there is some need to use easytrieve.
A properly coded "match" will only process each record of each file one time.
Unless there is something in the requirement that i do not yet understand. |
|
Back to top |
|
|
chandrarkar
New User
Joined: 27 May 2008 Posts: 24 Location: india
|
|
|
|
i tried using "matched" and found that
both the files should be soted before using "matched"
FILEA - HAS NO DUPS(THINK ITS THE MASTER)
FILEB - HAS DUPS
BOTH FILES SHOULD BE SORTED BEFORE USING MATCHED
NOW MY REQUIREMENT IS GETTING SATISFIED WHEN I USE "IF MATCHED (FILEA(KEY1)+
(FILEB(KEY2)) "
FOR EVERY KEY IN FILEB WE HAVE MANY DUP KEYS IN FILEB.
SO ITS ABLE TO MATCH WHEN USING THE ABOVE LOGIC.
EVEN IF THE FILE ORDER IN "IF MATCHED()()" IS CHANGED ITS NOT ABLE TO DO IT. |
|
Back to top |
|
|
Manuneedhi K
Active User
Joined: 07 May 2008 Posts: 115 Location: Chennai
|
|
|
|
Can you try using the Search TABLE and then using the IF MATCHED. This might not be efficient method but it works.
Mods,
There are two topics running for the same issue i guess.
Other one is ibmmainframes.com/viewtopic.php?p=136824#136824
Can we merge these two or close one of them |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
This topic and one titled "Processing table in eastrieve " are the same. I am closing the other topic as we don't need the same discussion 2 places.
I suggest you try the previously mentioned match/merge code. It should only take a short amount of time and you will have another "tool" that you will be able to use over and over for other requirements. |
|
Back to top |
|
|
chandrarkar
New User
Joined: 27 May 2008 Posts: 24 Location: india
|
|
|
|
thank u for ur suggestion,i will try that |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
You're welcome - good luck
Someone will be here if there are questions.
d |
|
Back to top |
|
|
chandrarkar
New User
Joined: 27 May 2008 Posts: 24 Location: india
|
|
|
|
hi this is working gr8
JOB INPUT SAM2
W-COUNTER = 0
MOVE SAM2-FIRST TO W-SAM2-FIRST
SEARCH SAM1 WITH W-SAM2-FIRST GIVING W-DESCRIPTION
IF SAM1
W-FLAG = W-FLAG + 1
DISPLAY 'FOUND'
W-COUNTER = W-COUNTER + 1
DISPLAY W-FLAG
GO TO JOB
END-IF
IF W-COUNTER EQ 0
DISPLAY 'NOTFOUND' W-SAM2-FIRST
END-IF
GOTO JOB
the sequential table is the only thing thats sorted the other sequential file need not be sorted.
thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Well, hopefully, the volume will be very small and the process will run very seldom. While that code may work it will waste an incredable amount of system resources (the larger the run, the more waste). I suppose this could be a good thing if your family sells hardware. . . |
|
Back to top |
|
|
chandrarkar
New User
Joined: 27 May 2008 Posts: 24 Location: india
|
|
|
|
but what can be done if not a table, sequential processing is itself resource consuming.
we have to use vsams instead.but our requirement is not the same. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Have you yet downloaded and used the 2-file match/merge code? Do so and i believe you will see a reduction in resources used.
Reading 2 files sequentionally uses less resources than running back and forth thru some table/array. |
|
Back to top |
|
|
chandrarkar
New User
Joined: 27 May 2008 Posts: 24 Location: india
|
|
|
|
ya i downloaded that code given and i will see the feasibility of implementing it.
thats a gr8 suggestion
thank u |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
ya i downloaded that code given and i will see the feasibility of implementing it. |
Good luck - someone will be here if there are questions
d |
|
Back to top |
|
|
chandrarkar
New User
Joined: 27 May 2008 Posts: 24 Location: india
|
|
|
|
hi
i have a scenario like i have to insert records in a table that has been defined by me
the layout of table is
inpfile
arg 1 21 A
desc 22 44 A
WHEN I AM TRYING TO INSERT RECORDS IN THIS TABLE USING ARG AND DESC ITS SAYING *******B082 NAME IS UNDEFINED - ARG
*******B082 NAME IS UNDEFINED - DESC |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Please post the problem code and the associated info from the sysout=. |
|
Back to top |
|
|
|