Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Perform array to add $ fields into a TEMP variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
srikanthkailasam

New User


Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

PostPosted: Fri Feb 20, 2009 6:42 am    Post subject: Perform array to add $ fields into a TEMP variable
Reply with quote

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
Back to top
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Fri Feb 20, 2009 8:15 am    Post subject:
Reply with quote

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 icon_confused.gif

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?
Back to top
View user's profile Send private message
srikanthkailasam

New User


Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

PostPosted: Fri Feb 20, 2009 9:37 am    Post subject: Reply to: Help required..
Reply with quote

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.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Feb 20, 2009 9:51 am    Post subject:
Reply with quote

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?
Back to top
View user's profile Send private message
srikanthkailasam

New User


Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

PostPosted: Fri Feb 20, 2009 10:21 am    Post subject:
Reply with quote

Yes. It is exactly the same process you have mentioned..
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Sat Feb 21, 2009 7:57 am    Post subject:
Reply with quote

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. . .
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


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

PostPosted: Sun Feb 22, 2009 4:53 am    Post subject:
Reply with quote

Using your logic, you are going to have PERFORMs nested 35 levels deep. I'd consider an alternate approach.
Back to top
View user's profile Send private message
srikanthkailasam

New User


Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

PostPosted: Mon Feb 23, 2009 11:07 pm    Post subject:
Reply with quote

This is exactly what I want to avoid. Can someone suggest a better alternative approach?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Sort two file having same field, one ... himanshu malik DFSORT/ICETOOL 7 Thu Feb 02, 2017 10:09 am
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us