1.自建barcode:
se73->System bar code->change->create->new input the name of the bar code you want,and the short text about this bar code.Then select the code 128 witch was supported by symbologies->normal Alignment,Then you can set the width and the height of this barcode(Mode A will be the best).
2.设置页格式(貌似对于最后没多大影响):
spad->F7 or click the full Administration->select the 'Device Types' tab,Display the page formats->change->create最后保存
创建format type,使用刚才创建的页格式,然后在Device types中将刚建的format加入进来。这样就能完全使用自己建的页格式了。
3.建立格式和表格:
1)smartforms新建格式,在字符格式中新建格式BC,在条形码处选择自己新建的条码,如果还有其他格式需要也一并建了。
2)新建表格,在全局设置的表格属性中的输出tab页中,可以将之前建的页格式选用。
3)在表格中需要的位置加上条码格式<BC>&XXXXX&</>
4)鉴于一般表的一行值为一页的打印,说一下表格的布局,因为系统是从上到下的来处理表格的,所以,主窗口需要放在其他子窗口上面,这样的话,循环操作就可以直接在主窗口的中建一个循环来实现表的循环,其他窗口中可直接使用相应的工作区。这样的话,分页和分页控制也都需要放在主窗口中来实现。
code1来实现读表累加计数,condition1来判断计数器和整个表的行数,command1中强制分页,还是使用的同样的page1。
全局定义:DESCRIBE TABLE it_tab LINES g_lines.
5)用三个窗口的原因是因为系统默认bar code占50MM,即使实际长度很短,但是还是会占用空格,这样在打印的条码中会空出一行来(如果该条码所在的text没分到50宽度的话)。三个窗口各50MM,然后窗口重叠,就能很好的解决页面布局的难题了。
6)将条码保存到本地成pdf文件:
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = 'ZLYBARTEST04' * VARIANT = ' ' * DIRECT_CALL = ' ' IMPORTING fm_name = sf_name EXCEPTIONS no_form = 1 no_function_module = 2 OTHERS = 3. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. w_cparam-no_dialog = 'X'. w_cparam-preview = space. " Suppressing the dialog box w_cparam-getotf = 'X'. " for print preview * Printer name to be used is provided in the export parameter * OUTPUT_OPTIONS w_outoptions-tddest = 'LP01'. CALL FUNCTION sf_name EXPORTING * ARCHIVE_INDEX = * ARCHIVE_PARAMETERS = control_parameters = w_cparam * MAIL_APPL_OBJ = * MAIL_RECIPIENT = * MAIL_SENDER = output_options = w_outoptions * USER_SETTINGS = 'X' IMPORTING * DOCUMENT_OUTPUT_INFO = job_output_info = t_otf_from_fm * JOB_OUTPUT_OPTIONS = TABLES it_tab = it_tab EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 OTHERS = 5. IF sy-subrc <> 0. * <error handling> ENDIF. t_otf[] = t_otf_from_fm-otfdata[]. CALL FUNCTION 'CONVERT_OTF' EXPORTING FORMAT = 'PDF' MAX_LINEWIDTH = 132 IMPORTING BIN_FILESIZE = W_BIN_FILESIZE * BIN_FILE = TABLES otf = T_OTF lines = T_PDF_TAB EXCEPTIONS ERR_MAX_LINEWIDTH = 1 ERR_FORMAT = 2 ERR_CONV_NOT_POSSIBLE = 3 ERR_BAD_OTF = 4 OTHERS = 5 . IF sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING BIN_FILESIZE = W_BIN_FILESIZE filename = 'D:CTS_program est est.pdf' FILETYPE = 'BIN' NO_AUTH_CHECK = 'X' tables DATA_TAB = T_PDF_TAB . IF sy-subrc <> 0. write sy-subrc. ENDIF.
这是固定死的文件名和路径。如果想要弹出保存对话框的话,可以在最后的FM之前加上:
CALL METHOD cl_gui_frontend_services=>file_save_dialog CHANGING filename = W_FILENAME path = W_FILE_PATH fullpath = W_FULL_PATH EXCEPTIONS CNTL_ERROR = 1 ERROR_NO_GUI = 2 NOT_SUPPORTED_BY_GUI = 3 others = 4
因为电脑是win8系统,保存的时候总是没权限,所以最后这个没有测试。