report z. data: w_options type itcpo, w_result type itcpp, w_otf like itcoo occurs 0 with header line, w_ascii like tline occurs 0 with header line, w_device(40) type c, w_num like sy-tabix. parameters: printer like tsp03-padest lower case default 'locl', layoutst like rsscf-tdform default 'MEDRUCK'. selection-screen: begin of line. parameters p_prn radiobutton group rad0. selection-screen: comment 4(60) cmt_prn for field p_prn, end of line. selection-screen: begin of line. parameters p_pre radiobutton group rad0. selection-screen: comment 4(60) cmt_pre for field p_pre, end of line. selection-screen: begin of line. parameters p_mem radiobutton group rad0. selection-screen: comment 4(60) cmt_mem for field p_mem, end of line. selection-screen: begin of line. parameters p_otf radiobutton group rad0. selection-screen: comment 4(60) cmt_otf for field p_otf, end of line. initialization. cmt_prn = 'Print to spool'. cmt_pre = 'Only create form and preview, no print'. cmt_mem = 'Output OTF to memory buffer and convert to ASCII'. cmt_otf = 'Only get OTF data'. start-of-selection. perform: form_open, print_item, form_close. case 'X'. when p_prn. write: / 'See Spool#', w_result-tdspoolid, '(', w_result-tdpages, ' pages )'. when p_pre. when p_otf. loop at w_otf. write / w_otf. endloop. when p_mem. perform get_ascii. endcase. *---------------------------------------------------------------------* * FORM FORM_OPEN * *---------------------------------------------------------------------* * Start of printing the form * *---------------------------------------------------------------------* form form_open. w_options-tddest = printer. w_device = 'PRINTER'. "default case 'X'. when p_pre. w_options-tdpreview = 'X'. w_options-tdnoprint = 'X'. when p_prn. when p_mem. w_device = 'OTF_MEM'. when others. w_options-tdgetotf = 'X'. endcase. call function 'OPEN_FORM' exporting device = w_device dialog = ' ' form = layoutst options = w_options exceptions canceled = 1 device = 2 form = 3 options = 4 unclosed = 5 mail_options = 6 archive_error = 7 invalid_fax_number = 8 more_params_needed_in_batch = 9 spool_error = 10 others = 11. write: / 'Form open. Return code =', sy-subrc. if sy-subrc <> 0. message id sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif. endform. *&---------------------------------------------------------------------* *& Form PRINT_ITEM *&---------------------------------------------------------------------* * Print form item * *----------------------------------------------------------------------* form print_item. call function 'WRITE_FORM' exceptions element = 1 function = 2 type = 3 unopened = 4 unstarted = 5 window = 6 bad_pageformat_for_print = 7 spool_error = 8 others = 9. write: / 'Form print. Return code =', sy-subrc. if sy-subrc <> 0. message id sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif. endform. " PRINT_ITEM *---------------------------------------------------------------------* * FORM FORM_CLOSE * *---------------------------------------------------------------------* * End of printing the form * *---------------------------------------------------------------------* form form_close. call function 'CLOSE_FORM' importing result = w_result tables otfdata = w_otf exceptions unopened = 1 bad_pageformat_for_print = 2 send_error = 3 spool_error = 4 others = 5. write: / 'Form close. Return code =', sy-subrc, 'Spool#', w_result-tdspoolid. if sy-subrc <> 0. message id sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. else. describe table w_otf lines w_num. write: / 'OTF has', w_num, 'lines.'. endif. endform. *&---------------------------------------------------------------------* *& Form get_ascii *&---------------------------------------------------------------------* * convert OTF from memory to ASCII text *----------------------------------------------------------------------* form get_ascii. call function 'CONVERT_OTF_MEMORY' tables lines = w_ascii exceptions memory_empty = 1 err_max_linewidth = 2 err_format = 3 err_conv_not_possible = 4 others = 5. write: / 'Convert OTF memory. Return code =', sy-subrc. if sy-subrc <> 0. message id sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. else. describe table w_ascii lines w_num. write: / 'OTF has', w_num, 'lines.'. loop at w_ascii. write: / w_ascii. endloop. endif. endform. " get_ascii ******************************