Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
srikanthkailasam

New User

Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

Posted: Fri Feb 20, 2009 6:42 am    Post subject: Perform array to add \$ fields into a TEMP variable

I have a variable say TEMP which is a \$ field. I have 35 different \$ fields say A1,A2...A35 which can add up to TEMP in any order. For example.

A1+A2 can be = Temp in one case.
A1+A4+A34 can be =Temp in another case.
A1+A2+A3+....+A35 can be =Temp in another case.

I came up with a Peform array where in I will store the A1....A35.

I have taken a case where I have A1, A2, A3 and A4.

 Code: PERFORM VARYING A FROM 1 TILL 4                                          PERFORM VARYING B FROM A+1 TILL 4                                          PERFORM VARYING C FROM B+1 TILL 4                                          PERFORM VARYING D FROM C+1 TILL 4                                          CHECK TEMP = Z(A) + Z(B) + Z(C) + Z(D)                        END-PERFORM                                                     CHECK TEMP = Z(A) + Z(B) + Z(C)                                     END-PERFORM                                                  CHECK TEMP = Z(A) + Z(B) + Z(C)                                      END-PERFORM                                                     CHECK TEMP = Z(A) + Z(B)                                             END-PERFORM.

The above will work even for 35 fields, but is there any better solution to check the same

dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

 Posted: Fri Feb 20, 2009 8:15 am    Post subject: Hello, When people start a topic nearly every one of them requires help - which make that a meaningless topic subject. . . Help may be required, but there is no definition of what is needed What should happen if multiple combinations match "temp"? What should happen if none do? Will/should all of the values that are non-zero add up to temp?
srikanthkailasam

New User

Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

 Posted: Fri Feb 20, 2009 9:37 am    Post subject: Reply to: Help required.. Whenever I hit a TEMP, i should exit out of the loop. There can be more than one combination for TEMP but we should consider only the first hit. If there is no combination available, just exit out of loop.
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

Posted: Fri Feb 20, 2009 9:51 am    Post subject:

Hello,

I'm still confused. . . When a hit is found, the loop should exit. When no combination is found, the loop should exit.

 Quote: There can be more than one combination for TEMP but we should consider only the first hit.
What should be considered?

Is this by chance an accounts receivable process that is trying to apply a payment to outstanding invoices?
srikanthkailasam

New User

Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

 Posted: Fri Feb 20, 2009 10:21 am    Post subject: Yes. It is exactly the same process you have mentioned..
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

 Posted: Sat Feb 21, 2009 7:57 am    Post subject: Hello, It has been a long time and so this is from memory. Your organizations "rules" may also be different from what we used. Our first cut was to look for an invoice that was an exact match (if the customer did not specify which invoice(s) to pay). Our next cut was something like what you have coded. We looked at the combination of any 10 invoices that were less than the payment amount for an exact match. Large customers could have hundreds of outstanding invoices . . . If there was not an exact match, we paid the oldest invoices up to the amoung of the payment. Customers were not so happy with this as they wanted to get their discount and wanted the payment applied to the newest invoices. . .
Terry Heinze

JCL Moderator

Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

 Posted: Sun Feb 22, 2009 4:53 am    Post subject: Using your logic, you are going to have PERFORMs nested 35 levels deep. I'd consider an alternate approach.
srikanthkailasam

New User

Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

 Posted: Mon Feb 23, 2009 11:07 pm    Post subject: This is exactly what I want to avoid. Can someone suggest a better alternative approach?
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Sum the fields in particular format f... sharana64 DFSORT/ICETOOL 9 Fri Jan 05, 2018 1:11 am SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us