On Wed, May 22, 2019 at 9:26 AM Ron Thomas <[email protected]> wrote:

> Ron
>
> what i am looking is extract from the input file 100 PO's . as i told
> first 10 bytes of the file is the PO number and each PO can contain one
> record or
> multiple records. The idea is to extract 100 PO with the all the PO
> related information which resides in multiple records.
>
> Thanks
> Ron T
>
>
I'd use three steps. The first step would sort the data by PO number which
would output the lowest 100 PO numbers. See SAMPLE= if you want to take
every "n"th record. The second step would be REXX to create the SORT
control cards for the next step. And the last step would be SORT to extract
the selected PO numbers.

Sort #1 control cards:

OPTION STOPAFT=100
SORT FIELDS=(1,11,CH,A)
SUM FIELDS=NONE
OUTFIL ENDREC=100

REXX code

/* REXX */
CARD="SORT FIELDS=NONE"
PUSH CARD
"EXECIO 1 DISKW OUTCARDS"
"EXECIO * DISKR PONUMS(STEM PONUM. FINIS"
SELECT
  WHEN PONUM.0 = 0 THEN EXIT 16 /* NO INPUT */
  WHEN PONUM.0 = 1 THEN DO
       CARD="INCLUDE COND=(1,11,CH,EQ,C'"||LEFT(PONUM.1,11)||")"
       PUSH CARD
   END
   OTHERWISE DO
       CARD="INCLUDE COND=(1,11,CH,EQ,C'"||LEFT(PONUM.1,11)||",OR,"
       PUSH CARD
       LAST=PONUM.0-1
       DO I = 2 TO LAST
          CARD="    1,11,CH,EQ,C'"||LEFT(PONUM.I,11)||",OR,"
          PUSH CARD
        END
       I=PONUM.0
       CARD="    1,11,CH,EQ,C'"||LEFT(PONUM.I,11)||")"
       PUSH CARD
       LAST=PONUM.0
       "EXECIO "LAST" DISKW OUTCARDS"
   END
END
"EXECIO 0 DISKW OUTCARDS(FINIS"


Hope this makes sense and is helpful. Although, in reality, I would most
likely use "awk" instead and not even bother with sorting.



-- 
This is clearly another case of too many mad scientists, and not enough
hunchbacks.


Maranatha! <><
John McKown

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to