Page 1 of 1

LOGIC TO SUM THE SAMQ RECORD IN - Easytrieve

PostPosted: Wed Mar 21, 2012 12:21 am
by aripalli
Hi All,

I have Two files as input

FILE1
DATA1 1 8 A

FILE2
DATA2 1 8 A
QUANTITY 9 5 A
INDICATOR 14 1 A

FILE3
DATA3 1 8 A
QUANTITY3 9 5 A

IN FILE1 I HAVE RECORDS AS FOLLOW

ITEM1
ITEM2
ITEM3

IN FILE2 I HAVE RECORDS AS THERE IS NO LIMIT FOR OCCURENCES OF THE EACH RECORD I MEAN DUPLICATE IS ALLOWED.

ITEM1 10 P
ITEM1 5 P
ITEM1 2 P
ITEM2 10 P
ITEM3 1 P
ITEM3 2 P
ITEM3 1 U
ITEM3 6 P

BELOW IS REQUIREMENTS:

GET RECORD FROM FILE1
I.,E. ITEM1 READ AGAINST FILE2 AN ADD THE QUANTITY WHERE INDICATOR IS 'P' AGAINST ITEM1
AND WRITE TO SUM TO FILE3 QUANTITY

IF ONLY ONE RECORD IS MATCHING FROM FILE1 TO FILE2 WRITE THAT ALONE WITH QUANITY FROM FILE2

SIMILARY READ FILE1 GET ITEM3 AND SUM THE QUANITY AGAINST IND 'P' WRITE FILE3

IN FILE 3 THERE SHOULD BE ONLY ONE ENTRY PER RECORD.

I AM LOOKING FOR THE HELP TO WRITE CODE, WHAT WORK-VARIABLES NEEDS TO BE DEFINED AND HOW WE CAN SUM THESE QUANITY USING EAZYTRIEVE AND WRITE THE TOTAL SUM OF VALUES.

PLEASE HELP ME

Re: LOGIC TO SUM THE SAMQ RECORD IN - Easytrieve

PostPosted: Wed Mar 21, 2012 12:48 am
by enrico-sorichetti
posting in all CAPITALS is like shouting and is a symptom of bad manners

Re: LOGIC TO SUM THE SAMQ RECORD IN - Easytrieve

PostPosted: Wed Mar 21, 2012 1:31 am
by dick scherrer
Hello,

Suggest you post what the processing logic would be (use pseudo code, not "real" code). We can review this and if your approach is correct, then we can work on implementing in Easytrieve.

If you do not understand the logic needed, which language will not matter.

Re: LOGIC TO SUM THE SAMQ RECORD IN - Easytrieve

PostPosted: Wed Mar 21, 2012 9:15 am
by aripalli
sorry Enrico, i thought Caps makes easy readability

Re: Logic To Sum The Same Record values in - Easytrieve

PostPosted: Wed Mar 21, 2012 9:21 am
by aripalli
Hi d.sch
Thanks for the reply,

REQUIREMENTS:

If ITEM1 (file1) = ITEM1 (file2) and INDICATOR = ‘P’

Then Sum the “Quantity” against the ITEM1 (from file2) and write as “Quantity3” (to file3) together with ITEM1

End-if

Need to perform the same comparison for each record of FILE1 with FILE2

I don't have idea how i can add up the Quantity fileds for the same record and writing.

Please Help me..

Re: LOGIC TO SUM THE SAMQ RECORD IN - Easytrieve

PostPosted: Wed Mar 21, 2012 2:06 pm
by BillyBoyo
OK, now look at Synchronised File Processing in the Easytrieve Plus Reference Guide. This will tell you how to write your JOB statement, how to identify change-of-key.