HP 3000 Manuals

Application ##3 [ HP RPG/XL Utilities-Part 1 XSORT ] MPE/iX 5.0 Documentation


HP RPG/XL Utilities-Part 1 XSORT

Application #3 

This application is in three parts.  Each part is a sample job typical of
the work XSORT was designed to address in the field.  The jobs use the
same files in a variety of ways for different sort requirements.

Each of the three sample jobs included is presented with an introduction,
XSORT specifications entered on the form, and a discussion of the
specifications.

A breakdown of the files to be sorted and their contents precedes the
discussion.

Files                     Records in File                Fields Used in Sorts 

---------------------------------------------------------------------------------------

Weekly Sales              Detail sales records.          Date, customer, product,
                                                         quantity.

Weekly Bookings           Detail booking records.        Date, customer, product,
                                                         quantity.

Sales and Bookings        Summary sales and history      Date, customer, product,
                          bookings.                      quantity.

Record Format for Weekly Sales File 

Field Names                    Contents                               Record Positions 

---------------------------------------------------------------------------------------

RECCDE                         Record "WS"                                  1 -2

INVNUM                         Invoice Number                               3 -8

INVDAY                         Invoice data - day                           9 -10

INVMON                         Invoice data - month                        11 -12

INVYR                          Invoice data - year                         13 -14

CUSTNO                         Customer number                             15 -24

CUSTTY                         Customer type                               25 -25

MRCHLN                         Merchandise line                            26 -27

PRODCO                         Product code                                28 -37

UNITS5                         Sales units                                 38 -42

STACDE                         State code                                  43 -44

SLSTER                         Sales territory                             45 -47

SLSNMl                         Sales number                                48 -49

TRANCD                         Sales type                                  50 -50

Record Format for Weekly Bookings File 

Field Names                    Contents                               Record Positions 
---------------------------------------------------------------------------------------

RECCDE                         Record code "WB"                             1 -2

CUSTNO                         Customer number                              3 -12

CUSTTY                         Customer type                               13 -13

ORDRNO                         Order number                                14 -19

ORTYCD                         Order type                                  20 -20

MRCHLN                         Merchandise line                            21 -22

PRODCO                         Product code                                23 -32

STACDE                         State code                                  33 -34

SLSTER                         Sales territory                             35 -36

SLSNM1                         Salesman number                             37 -39

CANIND                         Cancel indicator                            40 -40

DATEMM                         Date - month                                41 -42

DATEYY                         Date - year                                 43 -44

UNITS5                         Units booked                                45 -49

TRANCD                         Transaction code                            50 -50

Record Format for the Sales History File 

Field Names                    Contents                               Record Positions 

---------------------------------------------------------------------------------------

RECCDE                         Record code "SB"                             1 -2

CUSTNO                         Customer number                              3 -12

STACDE                         State code                                  13 -14

SLSTER                         Sales territory                             15 -16

SLSNM1                         Salesman number                             17 -19

PRODCD                         Product code                                20 -29

CANIND                         Cancellation indicator                      30 -30

GARTCD                         Garment type code                           31 -31

DATEMM                         Date - month                                32 -33

DATEYY                         Date - year                                 34 -35

UNITSB                         Units booked                                36 -42

UNITSHP                        Units shipped                               43 -49

UNTCAN                         Units cancelled                             50 -56
UNTRET                         Units returned                              57 -63

MRCHLN                         Merchandise line                            64 -65

DOLBOK                         Booked value                                66 -74

DOLSHP                         Shipped value                               75 -83

DOLCAN                         Cancelled value                             84 -92

DOLRET                         Returned value                              93 -101

These are the files that were created specifically for the sample sorts.
They are the Weekly Sales file (WKSALE), the Weekly Bookings file
(WKBOOK), and the Sales History file (HISTUPD), in that order.

     WB11111111119999999105ZZZ9999999CA0110110181123459
     WB21111111128999998205XXX8888888TX0120210281234568
     WB31111111137999997305LLL7777777AZ0130311280345677
     WB41111111146999996405VVV6666666NV0140411180456786
     WB51111111155999995505AAA5555555CA0150510181567895
     WB61111111164999994605DDD4444444CA0160610281678904
     WB71111111173999993709JJJ3333333CA81707N0281789013
     WB81111111182999992809GGG2222222CA91808N0181890122
     WB91111111191999991909ZZZ1111111CA11909I0181901231
     WB01111111100999990009VVV0000000CA21101N0281123450
     WB11111111119999999109ZZZ9999999CA31202N0281234561
     WB21111111128999988209XXX8888888CA41303N1280345672

     WS9000123102811111111111905ZZZ999999912345CA011019
     WS9000113002812111111112805XXX888888823456CA011028
     WS9000102901813111111113705LLL777777734567TX011037
     WS9000092801814111111114605VVV666666645678AZ011046
     WS9000082701815111111115505AAA555555556789CA011055
     WS9000072601816111111116405DDD444444467890CA011064
     WS9000062501815111111115309JJJ333333378901CA031073
     WS9000052401818111111118209GGG222222289012CA031082
     WS9000042301819111111119109ZZZ111111190123CA031091
     WS9000032201810111111110009VVV000000001234CA031100
     WS9000022101811211111112109ZZZ999999923456CA031111
     WS9000012001812311111113209XXX888888834567CA031122

     SB1111111111CA11101ZZZ9999999110281123456723456783456789123456705123456789
     SB2111111112CA01202XXX8888888120281234567834567894567890567890109234567890
     SB3111111113TX01303LLL7777777130281345678945678905678901678901209345678901
     SB4111111114CA01404VVV6666666140181444444444444446444444444444709444444440
     SB5111111115CA01505AAA5555555150281555555155555525555553555555405555555551
     SB6111111116CA01606DDD4444444160281666666166666626666663666666405666666661
     SB7111111117CA01707JJJ3333333970281777777177777727777773777777409777777771
     SB8111111118CA01808GGG2222222980281888888188888828888883888888405888888881
     SB9111111119CA02909ZZZ1111111290181999999199999929999993999999409999999991
     SB0111111110CA04101VVV0000000100281000000100000020000003000000405000000001
     SB1111111111CA01202ZZZ9999999710281111111111111121111113111111406111111111
     SB2111111112AZ01303XXX8888888120281222222122222222222223222222409222222221

Sample Sort 1 

This sort is used to select cancelled order records from the Weekly
Bookings file.  It produces a Weekly Cancellation Analysis.  The
"cancellation indicator" (in position 40), which is equal to 1, provides
selection criteria.

Output records will contain only those fields required for the report.
The output file will be sequenced by Customer Number (CUSTNO) and
subsequently by Product Code (PRODCO).

Here are the specifications as they would appear at the terminal and on
the specification form.

        HSORTR           20A                    34
        I C             40EQC1                                       SELECT CAN.ORD.
        I*                                                           IND.= 1
        FNC    3        12                                  CUSTNO  CUSTOMER #
        FNC   23        32                                  PRODCD  PRODUCT CODE
        FDC   13        13                                  CUSTTY  CUSTOMER TYPE
        FDC   20        20                                  ORDTYP  ORDER TYPE
        FDC   37        39                                  SLSNM1  SALESMAN NUMBER
        FDC   41        42                                  DATEMM  DATE MONTH
        FDC   43        44                                  DATEYY  DATE YEAR
        FDC   45        49                                  UNITS5  ORDER UNITS

[]
Explanation of Specifications. Header Specification. Column 6 The H entry identifies this as the Header line. Columns 7-12 SORTR identifies this as a Record-out sort. Columns 13-17 Total length of the sort control fields for this sort is 20. The total is derived from adding CUSTNO (10 characters) and PRODCO (10 characters). Column 18 The A means the output sequence will be in ascending order by CUSTNO and PRODCO. Columns 29-32 34 is the total length of output records. The control fields are not being dropped in this sort so their total (20 characters) is added to the 14 character sum derived from adding the six data fields in the sort. Record Type Specifications. Column 6 The I identifies this an an include line. Input records which match the criteria specified by this line will be used in the sort. Those which fail to meet the criteria will be omitted. Column 7 The * indicates a comment line. Column 8 Use only complete characters--one byte (eight bits)--in making comparisons. Columns 9-12 Because the input record field for factor 1 is only one character long, this entry is left blank. Columns 13-16 Input record position where factor 1 field begins and ends is position 40. Columns 17-18 EQ means factor 1 must equal factor 2. Column 19 The C means factor 2 is a constant. Column 20 This is where the value of the constant is entered. In this instance, 1 is the factor 2 constant. Field Description Specifications. Column 6 The F identifies this as a field specification line. Column 7 The N indicates that this is a normal control field. The D's in the column define the data fields. Column 8 The C tells the sort to use complete characters--1 byte (8 bits). Columns 9-12 3, 23, and the other numbers indicate record positions where field start. They are the "from" positions. Columns 13-16 These are the positions in the records where the fields end. They are the "to" positions. Here is the output of the sort. 1111111111AAA555555555505018156789 2111111112DDD444444446606028167890 2111111112XXX888888882202028123456 4111111114VVV666666664404118123457 4111111114ZZZ999999991101018112345 7111111117LLL777777773303128123456 Sample Sort 2 This sort produces a record address file for the selected records of the Sales History File. Records are selected when they contain specific combinations of Sales Territory (SLSTER) and Merchandise Line (MRCHLN). The output of this sort is a record address file containing relative record numbers for the selected records. The sequences will be Garment Type Code and Merchandise Line within the garment type. A hex dump of the output is followed by a simple RPG program which utilizes the output in a meaningful report. Two additional tasks are performed here: 1. It is desired to combine the Garment Type Codes 2 and 3 into a single category for sorting purposes. Therefore, a "3" will be substituted for a "2" wherever it is encountered in the Garment Type code field. (This is a conditional force on the control field.) 2. An opposite sort is performed on units booked (UNITSB) to put the bookings in descending sequence within Merchandise Line. Here are the specifications as they would appear at the terminal and on the specification form. HSORTA 10A I C 15 16EQC01 SELECT TERR. 01 IAC 64 65EQC05 MERCH. LINE 05 IOC 15 16EQC01 OR IAC 64 65EQC09 SELECT TERR. 01 I* MERCH. LINE 09 FNC 31 FORCE TO EQ.CD.2 FFC 3123X GARTCD AND CODE 3 FNC 64 65 MRCHLN MERCHANDISE LINE FOC 36 42 UNITSB UNITS BOOKED
[]
Explanation of Specifications. Header Specification. Column 6 The H identifies this as the Header line. Columns 7-12 SORTA identifies this as an Address-out sort. Columns 13-17 10 is the largest sum of all control field lengths. It is derived generally from adding all control fields designated with an F, N, or 0 in column 7 for each record type. This case is an exception because a forced control field is being used. It will overlay the position in the work record occupied by the character it is forcing and, therefore, will not contribute to the total control field length. Columns 18 The A indicates that the sorted records will be in ascending order by control fields. Record Type Specifications. Column 6 The I identifies this as an include line. The input records matching the criteria specified by this line will be used by the sort. Column 7 Leaving this column blank indicates that this is the first line of an I (include) set of record type lines. The * means a comment line. A identifies an AND line. It signifies that these specifications continue the definitions of the record type described in the last record type entry. O entered here stands for OR. It means that these specifications define a different type of record than the one on the previous line. Column 8 A "C" here means a character is used in comparisons. Columns 9-12 The numbers 15 and 64, entered twice here, indicate the position where the factor 1 field begins. Columns 13-16 The numbers 16 and 65 entered here indicate where the factor 1 field ends. Columns 17-18 Factor 1 will be compared with factor 2, which is a constant in all cases here. EQ means you want the two factors to be equal. Column 19 The C identifies factor 2 as a constant. Columns 20-23 The entries 01, 05, 01, and 09 are two-character constants. The zeros are entered here because the control fields are all two characters long, and constants must be the same size as control fields. (You can leave the positions presently occupied by zeros blank. It is important, however, to keep the entries right justified.) Field Description Specifications. Column 6 The F identifies this as a field description line. Column 7 The N identifies it as a normal control field. O means opposite control field. F indicates that one control field will be forced into position. In this case it will overlay the position in the work record occupied by the previous control field--if the conditions of the force operations are met. Columns 9-12 The numbers entered in this column identify the starting position of a control field in a record. Columns 13-16 These numbers identify the end position of a control field in a record. Note that 31, which is a field that is only one position in length, is only entered once, at the end position. Column 17 The 2 is the character that must be in this control field in order for a 3 (defined in column 18) to be forced into the work record. Column 18 The 3 is the character which will replace the control field in the work record if the control field equals 2 (defined in column 17). Since this is an Address-out sort, a hex dump of the output is provided. SRTUT RECORD 0 (%0, #0) 00000: 0000 0002 SRTUT RECORD 1 (%1, #1) 00000: 0000 0001 SRTUT RECORD 2 (%2, #2) 00000: 0000 000B SRTUT RECORD 3 (%3, #3) 00000: 0000 0003 SRTUT RECORD 4 (%4, #4) 00000: 0000 0004 SRTUT RECORD 5 (%5, #5) 00000: 0000 0005 SRTUT RECORD 6 (%6, #6) 00000: 0000 0006 SRTUT RECORD 7 (%7, #7) 00000: 0000 0007 A simple RPG program has been devised to make use of the output of the sort. PAGE 0001 HEWLETT PACKARD 32104A.04.07 RPG/3000 (C) HEWLETT-PACKARD CO. 1978. WED, MAR 11, 1981, 10:24 AM 0001 $CONTROL USLINIT 0002 H 1 0003 FHISTORY IP F 101R I DISK 0004 FRAF IRE F 4 4 T EDISK 0005 FREPORT 0 F 132 0V LLP 0006 E RAF HISTORY 0007 LREPORT 66FL 60OL 0008 IHISTORY NS 01 0009 I 3 12 CUSTNO 0010 I 31 31 GARTCD 0011 I 32 350DATE 0012 I 36 420UNITSB 0013 C TOTAL ADD UNITSB TOTAL 90 0014 0REPORT H 201 1P 0015 0 OR 0V 0016 0 UDATE Y 16 0017 0 51 "SALES HISTORY LISTING" 0018 0 PAGE Z 72 0019 0 70 "PAGE" 0020 0 H 1 1P 0021 0 OR 0V 0022 0 37 "GRMNT UNITS" 0023 0 58 "CUSTOMER DATE" 0024 0 H 1 1P 0025 0 OR 0V 0026 0 37 "----- -----" 0027 0 58 "---------- -----" 0028 0 D 1 01 0029 0 GARTCD 25 0030 0 UNITSBJ 38 0031 0 CUSTNO 50 0032 0 DATE Y 58 0033 0 T 1 LR 0034 0 TOTAL J 38 Here is the output of the program. You will notice that the sequence under the heading "GRMNT" (GARMENT) seems to start in descending rather than ascending order. In fact, a 3 was substituted for each 2 when encountered in the Garment Type code field, and sorting was done according to these values. 3/11/81 SALES HISTORY LISTING PAGE 1 GRMNT UNITS CUSTOMER DATE ----- ----- ---------- ----- 3 3,456,789 3111111113 2/81 2 2,345,678 2111111112 2/81 2 2,222,221 2111111112 2/81 4 4,444,444 4111111114 1/81 5 5,555,551 5111111115 2/81 6 6,666,661 6111111116 2/81 7 7,777,771 7111111117 2/81 8 8,888,881 8111111118 2/81 41,357,996 Sample Sort 3 This sample sort utilizes the multiple input file feature of XSORT. It combines the Weekly Bookings file and the Weekly Sales file. The sequence of the combined output file will be by customer number. Additionally, the Weekly Sales file is reformatted on output to the sorted file in order to match the format of the Weekly Bookings file records. The file statements required for this sort are: FILE XSORTIN1=WKBOOK FILE XSORTIN2=WKSALE FILE XSORTIN3=HISTUPD Here are the specifications as they would appear at the terminal and on the specification form. HSORTR 10A X 90 S 36 I C 1 2EQCWB SEL.WKLY.BK.REC. FNC 3 12 CUSTNO CUSTOMER NUMBER FDC 1 50 I C 1 2EQCWS SELECT WEEKLY I* SALES RECORD FNC 15 24 CUSTNO CUSTOMER NUMBER FDC 1 2 RECCDE RECORD CODE FDC 15 24 CUSTNO CUSTOMER NUMBER FDC 25 25 CUSTTY CUSTOMER TYPE FDC 3 8 INVNUM INVOICE NUMBER FDC 50 50 TRANCD SALES TYPE FDC 26 27 MRCHLN MERCHANDISE LINE FDC 28 37 PRODCD PRODUCT CODE FDC 43 44 STACDE STATE CODE FDC 45 47 SLSTER SALES TERRITORY FDC 48 49 SLSMN1 SALESMAN NUMBER FDC 50 50 TRANCD SALES TYPE FDC 11 12 INVMON INVOICEDATEMONTH FDC 13 14 INVYR INVOICEDATEYEAR FDC 38 42 UNITSF SALES UNITS
[]
[]
Explanation of Specifications. Header Specification. Column 6 The H identifies this as the Header line. Columns 7-12 SORT R identifies this as a Record-out sort. Columns 13-17 10 is the largest total of control field lengths for either of the two record sections in the sort. It is the sum derived from adding together all the control fields (fields with N, O, or F in column 7 of the Field Description specifications). In this case, control field length for the first record section is the same as that for the second section since it represents the same field, Customer Number. The field's location changes due to differences in the record formats of the two input files. Column 18 The A indicates that the records in the sorted file will be in ascending order by control field. Column 28 The X entered will cause the control fields to be dropped from the output records. Columns 29-32 90 is the length of the output records in the Record-out sort job. In this sort, control fields are being dropped so the total reflects the largest total of data fields for any single record section. If the control fields were being included in the output file, their largest total (from Header columns 13-17) would be added to that of the data fields. S Option. Column 6 The S indicates that the S Option is being used. In this case, it is required because of the multiple input files. Column 10-16 36 is the maximum number of records to be sorted. Record Type Specifications (First Record Section). Column 6 The I entry identifies this as an include line. Column 7 Leaving this blank identifies this as the first line of an include set. Column 8 C means the full character--1 byte (8 bits)--will be used in comparisons done for this sort. Columns 9-12 1 is the position in the input record where the factor 1 field begins. Columns 13-16 2 is the position in the input record where the factor 1 field ends. Columns 17-18 EQ means that factor 1 must equal factor 2 in the comparisons. Column 19 The C identifies factor 2 as a constant rather than a field. Columns 20-39 WB is the factor 2 constant. Field Description Specifications (First Record Section). Column 6 F indicates that this is a field description specification. Column 7 N identifies a normal control field. D identifies a data field. Column 8 C indicates that a full character--1 byte (8 bits)--will be used. Columns 9-12 3 is the input record position where the control field begins. 1 is the input record position where the data field begins. Columns 13-16 12 is the input record position where the control field ends. 50 is the input record position where the data field ends. Record Type Specifications (Second Record Section). Column 6 I indicates that this is an include line. Column 7 Leaving this entry blank means that this is the first line of an include set. The * means comments. Column 8 C means the full character--1 byte (8 bits)--will be used in the comparisons. Columns 9-12 A 1 entered here indicates the position in the record where the factor 1 field begins. Columns 13-16 2 entered here indicates the position in the record where the factor 1 field ends. Columns 17-18 EQ means that, in the comparisons, factor 1 must equal factor 2. Column 19 The C indicates that factor 2 is a constant, not a field. Columns 20-27 WS is the factor 2 constant. Note that this is the same length--2 characters--as the factor 1 field. Field Description Specifications (Second Record Section). Column 6 F indicates that this is a field description line. Column 7 N identifies this as a normal control field. D identifies this as a data field. Column 8 C entered here means the full character--1 byte (8 bits)--will be used in the comparisons. Column 9-12 These entries identify the position in the input records where control and data fields begin. Note that Customer Number, which is used as a control field, is entered here again as a data field. Since control fields are being dropped from output records, they must be redefined as data fields in order to be included as output. Columns 13-16 Numbers entered in these columns identify the positions in the input records where the fields end. This is the output of the sort. WS01111111100900003009VVV0000000CA031100018101234 WB11111111115999995505AAA5555555CA0150510181567895 WB11111111119999989109ZZZ9999999CA31202N0281901233 WS11111111119900012905ZZZ9999999CA011019028112345 WS12111111121900002109ZZZ9999999CA031111018123456 WB21111111128999998205XXX8888888TX0120210281234568 WB21111111124999994605DDD4444444CA0160610281678904 WB21111111120999990009XXX0000000CA21101N0281901232 WS21111111128900011805XXX8888888CA011028028123456 WS23111111132900001209XXX8888888CA031122018134567 WS31111111137900010705LLL7777777TX011037018134567 WB41111111149999999105ZZZ9999999CA0110110181123459 W841111111146999996405VVV6666666NV0140411181234570 WB41111111142999992809ZZZ2222222CA91808N0181890122 WB41111111148999988209ZZZ8888888CA41303N1281901234 WS41111111146900009605VVV6666666AZ011046018145678 WS51111111155900008505AAA5555555CA011055018156789 WS51111111153900006309JJJ3333333CA031073018178901 WS61111111164900007405DDD4444444CA011064018167890 WB71111111177999997305LLL7777777AZ0130311281234569 WB71111111173999993709LLL3333333CA81707N0281789013 WB71111111171999991909ZZZ1111111CA11909Y0181901231 WS81111111182900005209GGG2222222CA031082018189012 WS91111111191900004109ZZZ1111111CA031091018190123


MPE/iX 5.0 Documentation