ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Sorting program-decribed file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sorting program-decribed file

    I have a program-described order entry file with three records types, H, D and T. This file is sorted daily, as show below. 8-12 is the order number.

    Code:
    // LOAD #GSORT
    // FILE NAME-INPUT,LABEL-OEMST,DISP-SHR
    // FILE NAME-OUTPUT,LABEL-OESRT,RECORDS-99999,RETAIN-J,EXTEND-10,DFILE-YES
    // RUN
    HSORTRE 14D 3X 500
    I
    FNC 8 12
    FDC 1 250
    FDC 251 500
    // END
    Somehow, the records for an order lost their H/D/T sequence. There is an alternate index based on order number. When a chain is made using this file, the program expects to receive the H record for that order. But the record returned is a D record, because its RRN is less than that of the H record.

    I would like to know how this happened, but I am most interested in learning how to get the sequence back to where it should be.

    Thanks in advance,

    Leo


  • #2
    Wow. I haven't seen the "good old" #GSORT for 30 years or so.

    I searched for a manual for the equivalent for #GSORT that is the FMTDTA command.


    In the H-card you have written "SORTRE" in position 7-12.

    According to the manual the only valid values are
    Code:
    SORTR    Input records are to be sorted in a regular manner.
    SORTRS  Input records are to be sorted and summed.
    SORTA    Output file is to contain only the relative record numbers of the sorted records (record address (RA) sort).
    So I think that it should be "SORTR" instead.

    Comment


    • #3
      What's in positions 8 thru 12 of the record? That is the only sort field. Is that just the order number? What position is the H/D/T code in?

      I left my last S/34/36 job in 1988 and have had very little to do with S/36 in the meantime, so I'm rusty. I think there's a way to use an alternate collating sequence to make H come before D, but I don't remember how to do that.

      Is there another field, such as a sequence number, perhaps, that you could sort on? It wouldn't be hard to add a second control (sort) field.

      As for what could have changed the behavior, I have no idea.

      Comment


      • #4
        Per Peder's comment, I don't know about the SORTRE. I don't remember ever using the E.

        I found a S/34 sort manual. Maybe it will help.

        Comment


        • #5
          Bad link to the manual. Let me try again.

          Here's the URL as text, just in case:



          Comment


          • #6
            Ted,
            I think you have found the cause to the problems.
            For me it looks like the sort only sorts on the order number.
            By change the sequence of the H/D/T records are kept. But there is no guarantee that this will be kept.
            So this field must be included and sorted in an alternative sequence.


            @LBurkett99
            I would suggest that you eliminate the old #GSORT and replaces it with a logical file over the physical.
            If you specify 3 record formats in the logical - 1. selecting the "H" record, 2. selecting the "D" record and 3. selecting the "T" record
            and all given a key defined buy the order number -- then you can read the records in the logical file sequentially by order number.

            The record type and order number can be found using the SST ( substring ) keyword for logical files. Take a look in the manual "Programming DDS for physical and logical files".
            There are good examples in there too.

            Comment


            • #7
              I don't think eliminating the #GSORT is a viable option. What I am trying is to use an alternate sequence on the record type.

              Position 1 is the record type; H, D, or T. Positions 8-14 are the order number.

              Here are my sort specifications. I want the output in order number sequence, with the header first, followed by the detail and trailer records.

              HSORTR 8A F X
              ALTSEQ C8C1C4C2E3C3
              *
              FNC 8 14
              FNC 1 1 A
              *
              FDC 1 500

              The FMTDTA command returns FMT6010, 1 error(s) found in source file QFMTSRC; that's all. Can anyone spot the error?

              Thanks,
              Leo

              Comment


              • #8
                The error was a comment on the ALTSEQ line. Sort gave me just what I wanted.

                Thanks for all you comments and suggestions.
                Leo

                Comment

                Working...
                X