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

Author Message
sreekusr
Warnings : 1

New User

Joined: 28 Aug 2006
Posts: 54

 Posted: Wed Aug 29, 2007 9:13 am    Post subject: Query on Array: get the unique value from Field A Hi, Follwing is the scenario An array which occurs 10 times has two fileds Field A X(3) and Field B 9(2) Following are the values in array AAA 10 AAA 20 AAA 30 ABC 01 ABC 02 ABC 03 CCC 05 CCC 10 Desired O/p AAA 60 ABC 06 CCC 15 get the unique value from Field A and Other should have the Summation of the corresponding values. Please help me out in this. Thanks, Sree

agkshirsagar

Active Member

Joined: 27 Feb 2007
Posts: 686
Location: Earth

 Posted: Wed Aug 29, 2007 9:41 am    Post subject: It is fairly simple logic with a perform loop and maybe 1 or 2 add statements. Let us know where are you facing problems in this..?
sreekusr
Warnings : 1

New User

Joined: 28 Aug 2006
Posts: 54

 Posted: Wed Aug 29, 2007 10:11 am    Post subject: Reply to: Query on Array Hi agkshirsagar, Thanks for the reply. we tried to put the following logic feld A - a Field B- b perform varying i from 1 to 1 until i > 10 if a(i) EQ a (i+1) compute ws-add = b (i) to b(i+1) else move a(i) to ws-comp move ws-add to ws-add1 end-if end-perform. problem- ws-add ,the sum total will not correct. thanks, sree
Aji

New User

Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

 Posted: Wed Aug 29, 2007 10:28 am    Post subject: Reply to: Query on Array Please check this one. perform .... if a(i) = a(i+1) add b(i) to ws-sum end-if if a(i) not = a(i+1) add b(i) to ws-sum display a(i) ws-sum move zeros to ws-sum end-if end-perform. Aji
sreekusr
Warnings : 1

New User

Joined: 28 Aug 2006
Posts: 54

 Posted: Wed Aug 29, 2007 10:38 am    Post subject: Reply to: Query on Array Hi Aji, Thanks alot for the reply.. and i modified the code in the following way perform varying i from 1 to 1 until i > 10 if a(i) NE a (i+1) add b(i) to ws-add move a(i) to ws-comp move ws-add to ws-add1 move zeroes to ws-add else add B(i) to ws-add end-if end-perform. thanks, sree
agkshirsagar

Active Member

Joined: 27 Feb 2007
Posts: 686
Location: Earth

 Posted: Wed Aug 29, 2007 10:55 am    Post subject: SREE, Are you able to understand the implications of the code you have written? Are you getting o/p as mentioned in the first post.. I don't think so... What does ws-add1 and ws-comp doing in your code?
agkshirsagar

Active Member

Joined: 27 Feb 2007
Posts: 686
Location: Earth

 Posted: Wed Aug 29, 2007 11:01 am    Post subject: Is your array always in sorted order? (I can see that but just for the sake of asking.. ) If 'yes' then with some modifications you can use logic posted by Aji. Waiting for more inputs from you..
sreekusr
Warnings : 1

New User

Joined: 28 Aug 2006
Posts: 54