How to convert a master/trailer file to a data file of trailers with a flag on the first record

Attached is a spec MASTERTRAILER_DATACONVERSION.SPX that shows how to convert a master/trailer file to a data file of trailers with a flag on the first Record. This is currently set up to run on a file with 10 master records and 2 trailer records.

In order for this to work properly:

  1. File must be sorted properly cards 1-10 then 11,12 for the first trailer, then 11,12 for the second trailer, and so on.
  2. Trailer records must follow Master Records. This can be modified with some difficulty.
  3. Card Id must match card number. This can easily be modified.
  4. Missing cards are just left blank.
  5. Duplicate records will just use the last one.

>Def @CaseID     1.5''Location of Case ID>Def @CardNum    6.2''Location of Card ID>Def @SubID      7''Location of Sub-ID (for trailers if one)>Def @NumCards   12''Total number of cards (master + trailers)>Def @TrailData  11/1.160''Location of Trailer Data in final record>Def @MasterFlag 10/78''Flag for first Master Record>Def @Input   MasterTrailer_Data^Dat''Name of Input file>Def @Inputtype  Ascii=80''Type and length of input file>Def @Output     Newfile,Ascii ''Name and type of output file >Def @Outlen     960 ''Length of output file>PurgeSame~DefCasex:      [@CaseID$]Cardnum:    [@CardNum*Z]SubID:      [@SubId*Z]Mflag:      [@MasterFlag^1]     ''This will be your master flag locationMflagsav:   [10000^1]           ''Saved flag after first master already flagged~In  @Input ,@Inputtype ,Numbuf=2,Study=Input~In $,newbuf,Study=Output,Length=10000~Output @Output,Length=@Outlen~Def Proc= Makedata:If FirstcaseChoosefile "Output"Next FirstChoosefile "Input"EndifIf Input!Cardnum = 01Blank Output![1.@Outlen]M Output!Mflagsav = FalseEndif>Repeat $a=01,...,@NumCardsIf Input!Cardnum = $aCopy Output![$a/1.80] = Input![1.80] Endif>EndrepeatIf Input!Cardnum = @NumCardsIf Output!Mflagsav = FalseM Output!Mflag = TrueM Output!Mflagsav = TrueEndifChoosefile "Output"Putid CasexWritecase M Output!Mflag = FalseBlank Output![@TrailData]Endif}~Exc Proc= Makedata on Input ~End

  • mastertrailer_data.dat
  • mastertrailer_dataconversion.spx