Rational Developer for System z
PL/I for Windows, Version 8.0, Programming Guide

Calling PLISRTD, example 1

Figure 41. PLISRTD--Sorting input-handling routine to output-handling routine
/*******************************************************************/
/*                                                                 */
/*  DESCRIPTION                                                    */
/*    Sorting an input-handling to output-handling routine         */
/*                                                                 */
/*  Use the following statement:                                   */
/*                                                                 */
/*    set dd:sysin=ex109.dat,type(crlf),lrecl(80)                  */
/*                                                                 */
/*******************************************************************/

 ex109:  proc options(main);
     dcl Return_code fixed bin(31,0);
     call plisrtd (' SORT FIELDS=(7,74,CH,A) ',
                  ' RECORD TYPE=F,LENGTH=(80) ',
                  0,
                  Return_code,
                  e15x,
                  e35x);

     select(Return_code);
       when(0)  put skip edit
           ('Sort complete return_code 0') (a);
       when(16) put skip edit
           ('Sort failed, return_code 16') (a);
       other    put skip edit
           ('Invalid return_code = ', Return_code) (a,f(2));
       end /* select */;

      /* Set pl/i return code to reflect success of sort        */
     call pliretc(Return_code);

 e15x:   /* Input-handling routine prints input before sorting  */
       proc returns(char(80));
            dcl infield char(80);

            on endfile(sysin) begin;
               put skip(3) edit ('end of sort program input.  ',
                   'sorted output should follow')(a);
               call pliretc(8);  /* Signal end of input to sort */
               goto ende15;
            end;

            get file (sysin) edit (infield) (l);
            put skip edit (infield)(a);
            call pliretc(12);  /* Input to sort continues       */
           return(Infield);
  ende15:
            end e15x;

  e35x:   /* Output-handling routine prints the sorted records  */
       proc (Inrec);
            dcl inrec char(80);
            put skip edit (inrec) (a);
     next:  call pliretc(4); /* Request next record from sort   */
            end e35x;
 end ex109;

Contents of EX109.DAT and EX110.DAT used with Figure 41 and Figure 42

003329HOOKER S.W. RIVERDALE, SATCHWELL LANE, BACONSFIELD
002886BOOKER R.R. ROTORUA, LINKEDGE LANE, TOBLEY
003077ROOKER & SON, LITTLETON NURSERIES, SHOLTSPAR
059334HOOK E.H. 109 ELMTREE ROAD, GANNET PARK, NORTHAMPTON
073872HOME TAVERN, WESTLEIGH
000931FOREST, IVER, BUCKS
Rational Developer for System z
PL/I for Windows, Version 8.0, Programming Guide