Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Query on Array: get the unique value from Field A

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

New User


Joined: 28 Aug 2006
Posts: 54
Location: Madrid

PostPosted: Wed Aug 29, 2007 9:13 am    Post subject: Query on Array: get the unique value from Field A
Reply with quote

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

agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Wed Aug 29, 2007 9:41 am    Post subject:
Reply with quote

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..?
Back to top
View user's profile Send private message
sreekusr
Warnings : 1

New User


Joined: 28 Aug 2006
Posts: 54
Location: Madrid

PostPosted: Wed Aug 29, 2007 10:11 am    Post subject: Reply to: Query on Array
Reply with quote

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

New User


Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

PostPosted: Wed Aug 29, 2007 10:28 am    Post subject: Reply to: Query on Array
Reply with quote

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

New User


Joined: 28 Aug 2006
Posts: 54
Location: Madrid

PostPosted: Wed Aug 29, 2007 10:38 am    Post subject: Reply to: Query on Array
Reply with quote

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

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Wed Aug 29, 2007 10:55 am    Post subject:
Reply with quote

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.. icon_confused.gif I don't think so...
What does ws-add1 and ws-comp doing in your code?
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Wed Aug 29, 2007 11:01 am    Post subject:
Reply with quote

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..
Back to top
View user's profile Send private message
sreekusr
Warnings : 1

New User


Joined: 28 Aug 2006
Posts: 54
Location: Madrid

PostPosted: Wed Aug 29, 2007 11:12 am    Post subject: Reply to: Query on Array
Reply with quote

Hi agkshirsagar,

Sorry for the delay.

Yes the i/p array is in sorted order and the variable ws-add1 and ws-comp i mistakingly added.

yes as per the code we will get the desired o/p.

thanks,
sree
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 Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts JES2 job size field matching Windows ... SRICOBSAS All Other Mainframe Topics 4 Tue Sep 05, 2017 5:49 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us