1000220130320
20 21400 PUNE
20 21500 MUMBAI
20 21600 PUNE
90
1000120130320
20 21700 PUNE
20 21800 MUMBAI
20 21900 PUNE
20 22000 PUNE
20 23000 PUNE
20 24000 PUNE
90
Here I want count total total number of detail records, and want to write in trailer record from 3rd position as below -
Required file output data -
1000220130320
20 21400 PUNE
20 21500 MUMBAI
20 21600 PUNE
90000000003
1000120130320
20 21700 PUNE
20 21800 MUMBAI
20 21900 PUNE
20 22000 PUNE
20 23000 PUNE
20 24000 PUNE
90000000006
I am trying below condition but it is not giving expected results -
Above SORT is giving as below result, but is is not expected -
1000220130320
20 21400 PUNE
20 21500 MUMBAI
20 21600 PUNE
90000000005
1000120130320
20 21700 PUNE
20 21800 MUMBAI
20 21900 PUNE
20 22000 PUNE
20 23000 PUNE
20 24000 PUNE
90000000012
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Try with IFTHEN=(WHEN=GROUP, with the 10 marking the start of the group and the 90 the end. PUSH a SEQ after the "end" of your fixed records.
Then IFTHEN=(WHEN=(logexp to identify the "trailer" and OVERLAY the count, modified appropriately, from the extension to where you want it on the trailer.
You can use IFOUTLEN=1300 to ensure that the extension is not actually written. IFOUTLEN is not a condition, it means "set the output length to <value> after all the IFTHENs are completed.
Thanks for your help, Could you please explain 1st line, I got meaning of 2nd line but, about first line I am not clear, I am not aware
how to make a group.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
There are examples in the DFSORT manuals, and many here.
Code:
10
20
20
20
20
90
10
20
20
90
10
90
You have "groups" of records, with 10 defining the "start" and 90 defining the "end". PUSH, which is used with WHEN=GROUP, can be used to "overlay" a sequence within the group. When you later identify the 90 record, the sequence on that record includes the count for 10, any/all 20s and 90. So you can put a count onto the 90, using OVERLAY to where you want, and in the form that you want, from where you PUSHED the sequence number and subtracting 2.
I am not able to find out what length should I provide in PUSH and OVERLAY, I know that it is causing out of range issue in PUSH=(3:1301,9) & OVERLAY=(3:1301,9).
Can you please suggest what value should I provide ?
1000220130320
20 21400 PUNE
20 21500 MUMBAI
20 21600 PUNE
90000000003
1000120130320
20 21700 PUNE
20 21800 MUMBAI
20 21900 PUNE
20 22000 PUNE
20 23000 PUNE
20 24000 PUNE
90000000006