MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to sum and order items read from a TS

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> CICS and Middleware
View previous topic :: View next topic  
Author Message
mly
Beginner


Joined: 26 Dec 2002
Posts: 7
Topics: 3

PostPosted: Thu Dec 26, 2002 7:26 pm    Post subject: How to sum and order items read from a TS Reply with quote

Hi,
I have to do an online Cics-Cobol/Mvs program where I link a program which gives me a TS; then I read this TS and write another TS, with the total values for each product, like this:

Input TS:
Product..... Value
pic x(3).....pic 9(6)

ABC......... 001000
XYZ......... 005000
KLM......... 002000
ABC......... 001500
KLM......... 003000
CDX......... 003500
CDX......... 001000
PQR......... 000500

Output TS: (in product ascending order)
Product..... Value
pic x(3)..... pic 9(6)

ABC......... 002500
CDX......... 004500
KLM......... 005000
PQR......... 000500
XYZ......... 005000

The number of items in input TS is between 1 and 3000, and output TS can contain from 1 to 20 items.
Any ideas/suggestions how could it be done in an efficient way?
Thanks,
mly
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Dec 26, 2002 9:00 pm    Post subject: Reply with quote

Mly,

Well sorting in CICS program is not advisable, but it can be done.check if your system has a product CICS/QSORT from Mackinney Systems, that imnplements the Shell sort using TS queues.

If you don't have it then you can read TSQ into a working storage table, and write your own procedure division logic to sort them.However I haven't tried this option, but I think it can be done.

Since TSQ'S are flatfiles,you can sort the file using sort products ( DFSORT ,SYNCSORT). you can submit the job to the INTRDR.check this link for CICS interface to JES


Hope this helps...

cheers

kolusu

Ps: I am moving this topic to CICS AND MIDDLEWARE forum as it is the approriate forum for this question.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
RonB
Beginner


Joined: 02 Dec 2002
Posts: 93
Topics: 0
Location: Orlando, FL

PostPosted: Thu Dec 26, 2002 11:42 pm    Post subject: Reply with quote

MLY,
Since the number of OUTPUT items is so small ( you say from 1 to 20 items ), I would not bother sorting the INPUT TSQ, or READING it into an internal array ( of some 3000 entries ) and then sorting it - instead I would build the internal array to resemble the OUTPUT TSQ by adding new item entries only when needed. For example, in your example I would add items ABC, XYZ, KLM, CDX, and PQR, in that order. Of course, I would keep the item array in sorted order and 'bubble sort' it as each new item is added - that is as each input TSQ record is read, do a SEARCH ALL on the item array, and if found, add its value to the existing item total; if not found, add the new item with its initial value, and re-sort the array. At end of input, write the output TSQ from the array. I would probably allow for twice as many entries as the maximum expected, and initialize it to high-values to insure that the SEARCH ALL functions properly.

Ron
Back to top
View user's profile Send private message
mly
Beginner


Joined: 26 Dec 2002
Posts: 7
Topics: 3

PostPosted: Fri Dec 27, 2002 4:36 pm    Post subject: Reply with quote

Kolusu and Ronb

Thanks a lot for your prompt suggestions. I don't have Cics/Qsort in my shop. Ronb, I followed your instructions and it worked fine.

Regards,
Mly
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Sat Dec 28, 2002 1:36 am    Post subject: Reply with quote

Kolusu,
I had always wanted to ask this.
Quote:
you can submit the job to the INTRDR.check this link for CICS interface to JES


After, the EXEC CICS statement to write SPOOLFILE, the job gets submitted. Now, won't this job be independent of the CICS program? For example, the input TSQ is sent for sorting via DFSORT via a batch job. To process the output TSQ, do I have to wait until the batch job is over? If yes, then how does one "wait"?
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Sat Dec 28, 2002 6:48 am    Post subject: Reply with quote

cogito,

You can code a DELAY in cics until the sort job completes.

Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Mon Dec 30, 2002 3:02 pm    Post subject: Reply with quote

Hi Kolusu,

The DELAY command will only suspend the task for a specified interval or until a specified time. How do we know that the batch job has ended sorting the records? Is there a way (through an input extra partitioned TDQ perhaps) by which the batch job can interact with the CICS application program?. Have never tried anything like this. Just wondering if it can be done.

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> CICS and Middleware All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group