''' Generate Hitex transmission files The AS400 essentially transmits copies of the FINMAS and FINDET files, which can be found in STMDATA, directly to the Hitex/Syn-fin/Applied. As such I used the record formats for those files to buld the MASTER and DETAIL record format strings you see below. I strongly doubt Hitex/Syn-fin/Applied require _all_ of the fields in these tables. Who requires what, though, remains a mystery. I've listed the description of the fields as they appear in the AS400 in the order they need to be passed to the format() command below. * denotes fields that are definitely expanding. FINMAS Fields, IN ORDER: Address 1 Customer Name Customer Number (4 digit bill to account) Ship to Number (2 digit shipto sub-account) * These 2 fields (6 digits) --> 10 digit account # Ship to Name Ship to Address 1 Ship to Address 2 Ship to City Ship to State Ship to Zip Ship to Country Country Code Packing List Number * 5 digit --> 10 digit Shipping Suffix (?) Box Number (?) Stain Repellent Code * 1 char --> 5 char Backing Code * 1 char --> 5 char Complete Code (?) Number of Labels Needed (?) Date yyMMdd * yyMMdd --> YYYYMMdd (Preferable, not required) Finish Code * 4 char --> 5 char FINDET Fields, IN ORDER: Packing List Number * 5 digit --> 10 digit Shipping Suffix (?) Box Number (?) Pattern Name Style 1 Style 2 Color Number Order Number * 6 character --> 10 digit P/O Number Roll Number * 5 digit --> 10 digit Stain Repellent Code * 1 char --> 5 char Backing Code * 1 char --> 5 char Complete Code (?) Cut off Yards Cut off Eights Finished Yards Finished Eights Finisher Invoice Number Finisher BOL Number Finisher Description Application Code (?) Finish Code * 4 char --> 5 char Customer Pattern Customer Color ''' MASTER_RECORD_FORMAT = '{:30s}{:30s}{:4s}{:2s}{:30s}{:30s}{:30s}{:20s}{:2s}{:05d}{:20s}{:10s}{:05d}{:1s}{:02d}{:1s}{:1s}{:1s}{:03d}{:06d}{:4s}' DETAIL_RECORD_FORMAT = '{:05d}{:1s}{:02d}{:15s}{:>4s}{:06d}{:04d}{:6s}{:15s}{:05d}{:1s}{:1s}{:1s}{:03d}{:01d}{:03d}{:01d}{:7s}{:06d}{:15s}{:2}{:4s}{:15}{:20}' if __name__ == '__main__': print MASTER_RECORD_FORMAT.format('PER ROUTING GUIDE','', '', '', 'SUNBURY TEXTILE MILLS, INC.', 'MILLER STREET', '', 'SUNBURY', 'PA', 17801, '', '', 54065, '', 0, '', '', '', 1, 160719, '') #print DETAIL_RECORD_FORMAT.format(18342, ' ', 0, 'SYNTAX', 'P', 9953, 2301, 'U51959', '729005S', 25524, '', '', '', 62, 0, 0, 0, '251348', 65, '', '54', '', '', '15310/565/STRAWBERRY')