View previous topic :: View next topic
|
Author |
Message |
mkk157
Active User
Joined: 17 May 2006 Posts: 310
|
|
|
|
Hi Experts,
Please help me to write the Sort card for the following requirement. We use SYNCSORT at our shop.
Attached is the screenshot of both the input and output files.
Instructions for the requirement are
Group the data based on the DATE, SEGMENT, Product and Type and then the field called "ID".
Merge the similar records in such a way that
a) Concatenate the data for the column "Description" and then sum up the "Qty".
b) Last record with Product "Onion" and Id "9999" did not club with that of the previous one as it has different ID numbers.
c) No need to worry about the Price
d) After that, each separate set should be followed by a Total "Total Sold" or "Total Packed" as highlighted in the screenshot
[img][/img] |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If you use Syncsort, you should post in the JCL forum, not the DFSORT forum. |
|
Back to top |
|
|
mkk157
Active User
Joined: 17 May 2006 Posts: 310
|
|
|
|
Hi Bill Woodger
Thanks for the alert.
Requesting moderators to move the thread to the respective section. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Have a look in your documentation for "reporting" features. HEADERn, TRAILERn etc. You should be able to find some examples by searching once you know the type of thing you want. |
|
Back to top |
|
|
mkk157
Active User
Joined: 17 May 2006 Posts: 310
|
|
|
|
Hi Bill Woodger,
From the reporting HEADERn, TRAILERn can be calculated and displayed. But the challenge is to concatenate the strings with similar key values.
As SUM is to sum up the numeric values of identity records, I want to do the same thing for character fields.
Please let me know how can we do it ? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
As SUM is to sum up the numeric values of identity records, I want to do the same thing for character fields. |
How might character fields be SUMmed?
Is this shown in your posted "output"? |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Have you looked at/tried DISPLAY? I've got a few sample reports done using this just as an educational thing. |
|
Back to top |
|
|
mkk157
Active User
Joined: 17 May 2006 Posts: 310
|
|
|
|
Hi dick scherrer,
The attached image clearly shows that, How the character fields in column "Description" are concatenated / merged / summed up. Request you not to concentrate on my terminology.
Hi Nic Clouston,
I can use DISPLAY only in a cobol program. But I like to get this done using SORT. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
Quote: |
Request you not to concentrate on my terminology. |
You are not in the position to request anything from anybody
this is a professional forum, if You do not want to express <things> in such a way that people trying to help You do not have to waste time understanding Your terminology ....
then You better stick to chatting and nothing more! |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
mkk157 wrote: |
I can use DISPLAY only in a cobol program. But I like to get this done using SORT. |
mkk157,
had you bothered to look at sort documentation,
you would find that DISPLAY is also a sort command.
Funny how those that are totally incompetent in IT,
are very familiar with the
'allow me to express myself, my way'
bullshit. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Request you not to concentrate on my terminology. |
Nothng personal, but - Ahh, Umm, request denied (at least if you want help). You nave been here 6 years and should be able (by now) to use proper terminology. Communication is at least as importent as technology.
Quote: |
The attached image clearly shows that, |
Probably completely clear to you as you wrote it, but maybe not completely clear to everyone else - especially given the terminology used.
Pretty much everyone here wants to help, but the majority of the burden to get things done is with the poster. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Probably fairly simple but as you have not bothered to explore the possibilities with sort or given any information that would allow one to help - all I can say is that it LOOKS as though it can easily be done by using the option that I mentioned before. By the way, how the heck do you think it could be done by the COBOL (or PL/1) DISPLAY statement? |
|
Back to top |
|
|
mkk157
Active User
Joined: 17 May 2006 Posts: 310
|
|
|
|
Hi dick scherrer,
I am giving the full details of the requirement along with the input, output, copybook supported by necessary explanation.
Hi Nic Clouston,
I have read the manual for DISPLAY in SORT, But, couln't find any parameter to fulfil my requirement here.
Input
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6-
***************************** Top of Data *******************
20120601 FMCG SOAP SELL CASH PURCHASE 2345 5 10 50
20120601 GROCERY ONION SELL CREDIT CARD 3456 23 12 276
20120601 FRUITS MANGO SHIPPED CREDIT CARD 1234 200 17 3400
20120601 FRUITS MANGO SHIPPED CREDIT CARD 1234 15 17 255
20120601 FRUITS MANGO SHIPPED DEBIT CARD 1234 15 17 255
20120601 GROCERY ONION SELL CASH PURCHASE 3456 25 12 300
20120601 GROCERY ONION SHIPPED CASH PURCHASE 9999 50 12 600
20120601 FMCG SOAP SELL CREDIT CARD 2345 25 10 250 |
Output
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6-
***************************** Top of Data *******************
20120601 FMCG SOAP SELL CASH PURCHASE 2345 30 10 300
CREDIT CARD
TOTAL SOLD 30
20120601 FRUITS MANGO SHIPPED DEBIT CARD 1234 230 17 3910
CREDIT CARD
TOTAL SHIPPED 230
20120601 GROCERY ONION SELL CASH PURCHASE 3456 53 12 576
CREDIT CARD
20120601 GROCERY ONION SHIPPED CASH PURCHASE 9999 50 12 600
TOTAL SOLD 53
TOTAL SHIPPED 50
**************************** Bottom of Data ***************** |
copybook of the input file
Code: |
01 WS-INFILE
05 WS-DATE PIC X(8). Input file may have data related to more than one business day.
05 FILLER PIC X(1).
05 WS-SEGMENT PIC X(7). There are limited number of segments exists as of today, and the list will be added in near future.
05 FILLER PIC X(1).
05 WS-PRODUCT PIC X(5). There are limited number of products exists as of today, and the list will be added in near future.
05 FILLER PIC X(1).
05 WS-TYPE PIC X(7). Indicates type of dispatching the Products
05 FILLER PIC X(1).
05 WS-PAMENT PIC X(13). Indicates the mode of payment. Cash / Credit card / Debit card
05 FILLER PIC X(1).
05 WS-CUST-ID PIC 9(4). Customer Identification number
05 FILLER PIC X(1).
05 WS-QTY PIC 9(3). Number of products
05 FILLER PIC X(1).
05 WS-PRICE PIC X(2). Price of each product
05 FILLER PIC X(1).
05 WS-TOT-PRICE PIC X(4). Total price of the products purchased |
* The output file should be in a sorted order of DATE, SEGMENT, Product, Type and ID.
* Group the data based on the DATE, SEGMENT, Product and Type and then the field called "ID".
* In case an identical record found (Similar DATE, SEGMENT and Type with ID), the respective, Qty and Tot Price fields should be summed up and the corresponding values in the column "Payment" should be merged and listed one after the other in different lines, here the duplicate values are to be removed in Payment field for any partcular set.
* Sample output file shows the sample input and output files.
Further details about the Output file
* Totals should be calculated after every set of DATE - SEGMANET - PRODUCT. for each value of TYPE exists in that set.
* Now, As control moves further, a new set of DATE - SEGMENT - PRODUCT - TYPE appears, the total should be calculated for number of items
* Record number 1 and 8 with identical DATE - SEGMENT - PRODUCT - TYPE - ID, were merged together and the 2 different types of payments CASH and CREDIT were listed in ascending order, "Qty" is summed up and "total price" is also calculated according to the summed up "Qty"
* Now, rest are the records 3, 4 and 5. All the three records are grouped together and the Payment values are listed with 2 different values such as DEBIT and CREDIT.
* Now, As control moves further, a new set of DATE - SEGMENT - PRODUCT - TYPE appears, the total should be calculated for number of items
* while arranging them in ascending order, Record numbers 2, 6 and 7 will come first . Out of these 3 records, 2 and 6 are identical and apply the rule above, and list the different payments CASH and CREDIT in ascending order for ID 3456. And the 7th record is non-identical as its ID is 9999. So to list it separately. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You want a key which is concatenated from two fields. So make it.
OVERLAY=(newkeystart:keypart1start,kp1length,keypart2start,kp2length)
I'm short of time, but that's what I thought last time I saw this. |
|
Back to top |
|
|
mkk157
Active User
Joined: 17 May 2006 Posts: 310
|
|
|
|
Hi Bill Woodger,
Quote: |
OVERLAY=(newkeystart:keypart1start,kp1length,keypart2start,kp2length) |
OVERLAY also does not meet my requirement.
I wrote a cobol program to achieve the desited target. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK. Thanks for letting us know.
You needed a composite key, so you had to make it. I guess that is what you are now doing in your Cobol program. |
|
Back to top |
|
|
|