Smartforms打印
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Smartforms打印相关的知识,希望对你有一定的参考价值。
1代码实现
将要打印的内表抛到内存
打开smarforms
生成调用smartforms的链接。此处的内表已经抛到内存了,此处并不是真正的传值。
关闭打印
2 smartforms
定义全局变量
在类型中定义ZSSD014_ALV的类型
接收抛到内存中的内表,计算内表行数(可当做总页数或行数),并清理内存中的数据
定义循环,循环打印内表中的数据
计算当前页码
有的类型并不能展示在smartforms,因此需要将其转换为string类型
强制换页
定义换页条件
3程序源码
DATA: lw_outopt TYPE ssfcompop,
lw_control TYPE ssfctrlop,
lw_sjob TYPE ssfcresop,
l_xs TYPE char5,
l_zbs TYPE char5,
l_num TYPE char5,
lw_job TYPE ssfcrescl,
l_sm_name TYPE tdsfname,
l_fm_name TYPE rs38l_fnam,
l_check TYPE char2,
lv_fcode TYPE char5.
DATA:lt_prt_tag TYPE STANDARD TABLE OF zssd014_alv.
lv_fcode = BQ.
PERFORM frm_check_data USING lv_fcode CHANGING l_check.
CHECK l_check <> X."检查数据无误
CLEAR:l_sm_name.
IF g_fcode = ZTAG_ZB_PRT.
l_sm_name = ZSD005."
ELSEIF g_fcode = ZTAG_XX_PRT.
l_sm_name = ZSD006."
ENDIF.
lt_prt_tag = gt_prt_tag.
EXPORT lt_prt_tag TO MEMORY ID ZSD003."内存抛到smartforms
lw_control-no_open = X.
lw_control-no_close = X.
lw_outopt-tdiexit = X."预览打印时,点打印后立即退出预览界面
*打开Smartform
CALL FUNCTION SSF_OPEN
EXPORTING
output_options = lw_outopt
control_parameters = lw_control
* IMPORTING
* JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE 用户已取消输出! TYPE S DISPLAY LIKE E.
EXIT.
ELSE.
CALL FUNCTION SSF_FUNCTION_MODULE_NAME
EXPORTING
formname = l_sm_name
IMPORTING
fm_name = l_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
CALL FUNCTION l_fm_name
EXPORTING
control_parameters = lw_control
TABLES
* CONTROL_PARAMETERS = L_CONTROL
gt_head = lt_prt_tag. "表数据通过内存抛过去,这里并不真的传值
* gt_item = gt_item.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
*关闭Smartform,此时会弹出一个选择打印机选项
CLEAR lw_job.
CALL FUNCTION SSF_CLOSE
IMPORTING
job_output_info = lw_job
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE S NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 DISPLAY LIKE E.
EXIT.
ENDIF.
IF lw_job-outputdone = X."打印成功
MESSAGE 打印成功! TYPE S .
zob_alv_9001->alv_refresh( ).
ELSE.
MESSAGE 打印未完成! TYPE S DISPLAY LIKE W.
ENDIF.
ENDIF.
以上是关于Smartforms打印的主要内容,如果未能解决你的问题,请参考以下文章