IDOC stands for Intermediate Document and is used to transfer the documents/forms for printing from SAP to other system. When this output method is used, the structure of Header, Sort, Data, and Control record remains the same, however, the flags - H, S, D, and C go missing. There is a separate segment that is used for Sort, Data, and Control - E1RDI_BODY and this segment comes before the Control record.
The header segment in E1RDI_BODY doesn’t contain any document number and CLOSE_FORM function module returns the document number.
When you use function modules START_FORM and END_FORM to print multiple documents in a single request, a single IDOC is created and the status of IDOC is set to 30.