I stumbled on some FMTDTA which seem to be a query/sort language that predates SQL in an old RPG System. I am trying to unravel it's usage.
Example:
Physical file layout:
ORNO S 9 0 1 9 Order No
ORCSTNO A 10 10 19 Custno
ORDAT S 6 0 20 25 Order Date
ORAMT S 12 2 26 37 Order Amt
Sort Criteria in PF source member ORDSRT:
HSORTR 25A Keyfields are 25 characters long - Sort Ascending
FNC 20 25 KEY 1: ORDER DATE
FNC 1 9 KEY 2: ORDERNO
FNC 10 19 KEY 3: CUST NO
FDC 1 37 Take whole record (1-37)
Sort command
FMTDTA INFILE((MYLIB/ORDHED)) OUTFILE(QTEMP/ORDHED)
SRCFILE(MYLIB/MYSRC) SRCMBR(ORDSRT) OPTION(*NOPRT)
Result:
successfully sorts by DATE/ORD#/CUST#
However, there are a few other lines in FMTSRC that I am not sure of their purpose. Examples:
FOU
FOC
FNU
O C 1 1EQCD CANCELLED
I C 8 8EQCB CREDIT NOTE
O C 1 1EQCX OMIT CANCELLED
Here's what those six lines mean:
FOU
Col 6: F means it's a Field statement
Col 7: O means the field is an opposite control field
Col 8: U means the field contains signed decimal data in zoned format
FOC
Col 6: F means it's a Field statement
Col 7: O means the field is an opposite control field
Col 8: C means the field contains character data
FNU
Col 6: F means it's a Field statement
Col 7: N means the field is a normal control field
Col 8: U means the field contains signed decimal data in zoned format
O C 1 1EQCD CANCELLED
Col 6: O means OMIT
Col 8: C means Factor 1 and Factor 2 must contain character data
Col 9: 1 is the starting position of Factor 1
Col 13: 1 is the ending position of Factor 1
Col 17: EQ means Factor 1 must equal Factor 2
Col 19: C means Factor 2 is constant
Col 20: D is the constant or keyword against which Factor 1 is compared
Col 40: CANCELLED is a comment
I C 8 8EQCB CREDIT NOTE
Col 6: I means INCLUDE
Col 8: C means Factor 1 and Factor 2 must contain character data
Col 9: 8 is the starting position of Factor 1
Col 13: 8 is the ending position of Factor 1
Col 17: EQ means Factor 1 must equal Factor 2
Col 19: C means Factor 2 is constant
Col 20: B is the constant or keyword against which Factor 1 is compared
Col 40: CREDIT NOTE is a comment
O C 1 1EQCX OMIT CANCELLED
Col 6: O means OMIT
Col 8: C means Factor 1 and Factor 2 must contain character data
Col 9: 1 is the starting position of Factor 1
Col 13: 1 is the ending position of Factor 1
Col 17: EQ means Factor 1 must equal Factor 2
Col 19: C means Factor 2 is constant
Col 20: X is the constant or keyword against which Factor 1 is compared
Col 40: OMIT CANCELLED is a comment