What is a control break? (COBOL)

后端 未结 1 720
深忆病人
深忆病人 2021-01-26 19:12

OK so I\'m taking an online COBOL class now and this week the content is control break and control field... For previous lectures I can understand easily but I have no idea what

相关标签:
1条回答
  • 2021-01-26 19:45

    A Control Field is a field which indicates how data is grouped. All Control Field values which are the same, "belong together". No "other values" for a Control Field value belong with it.

    A typical example might be a Customer Number. Data for the same Customer Number can be logically grouped together for some purpose (total number of outstanding orders, anything).

    It would not be logical to include data for another customer within the customer that you are currently processing.

    When the Control Field value changes, this is a "Control Break". In a report, this is the time to do something to differentiate from the other customers, in this example: print a total, indicate some different line/page spacing to make it easy for a user to "see" the "break".

    You can have multiple Control Fields. When a higher Control Field changes (say, Company) then there is a "break" in every control field below that, from the lowest-level Control Field first, "upwards" in order.

    Data will typically be sorted on Control Fields (indeed, you'll see SORT keys called Control Fields), but this is not necessary, as long as all the data for the same control value is consecutive.

    Files can have Control Fields and Control Breaks, which may be represented by different record types containing summary information for that "level" of break.

    Reports will very often have Control Fields with specific actions to be carried out on a Control Break.

    01. 1111
    02. 1111
    03. 1111
    04. 1111
    05. 2222
    

    In the above, record number 05 "causes" the Control Break. Processing for Control Value 1111 needs to be carried out before record number 05 can be processed.

    Control processing requires at the very least the Control Field (often also called "the Key") of the previous record to be stored. Often other data has to be stored or accumulated.

    On occasion you don't know how to process a record until you read the next record, so the entire input (or all required fields from it) is stored, and the records are processed "one behind".

    One thing to always remember is that "end of file" causes the final Control Break, and it is the highest of all, and all Control Break processing from the lowest on upwards must be done at that point.

    0 讨论(0)
提交回复
热议问题