SAPSMARTFORMS凭证连续打印设置操作计算很好.docx
- 文档编号:29005318
- 上传时间:2023-07-20
- 格式:DOCX
- 页数:18
- 大小:326.71KB
SAPSMARTFORMS凭证连续打印设置操作计算很好.docx
《SAPSMARTFORMS凭证连续打印设置操作计算很好.docx》由会员分享,可在线阅读,更多相关《SAPSMARTFORMS凭证连续打印设置操作计算很好.docx(18页珍藏版)》请在冰豆网上搜索。
SAPSMARTFORMS凭证连续打印设置操作计算很好
SAPSMARTFORMS凭证连续打印设置操作之三
利用ALV显示,并进行手动选择打印
在SAP系统中,凭证经常需要连续打印,如从凭证号100,打印至120;要求系统在打印的时候自动按凭证号进行分页处理。
下面的例子是利用内表传递数据至SMARTFORMS中,并且利用打印程序中的内表循环来实现凭证的自动分页打印处理;而SMARTFORMS的设置则非常的简单,按一张凭证号来进行设置即可。
下面进行具体的操作讲解。
打印效果显示,如下图所示:
运行报表程序:
运行后,出现下面的界面,这时我们就可以选择需要打印的单据号,然后再点击工具栏中的“打印”按钮,即可进行选择性的连续打印,如下图:
上面为显示连续打印三张销售凭证,运行后如下图所示:
数据结构体的定义zwyvbap;TCODE:
SE11,此结构体在后面的程序中也要用到,是传递数据的接口。
定义如下图所示:
SMARTFORMSFORM界面设置
1、表格接口的数据,如下图所示:
2、表格接口表的数据如下图所示:
3、全局定义中的数据定义如下图所示:
SMARTFORMS页和窗口的操作:
1、页头显示内容。
下面的操作都只进行截图显示。
如下图所示:
2、MAIN主窗口的设置:
打印表体的表头显示,如下图所示:
表体循环显示:
新程序行的设置:
选择MainWindow->Create->FlowLogic->ProgramLines 计算
统计区域的设置:
页尾的设置:
REPORT完整代码清单,如下图所示(TCODE:
SE38):
*&---------------------------------------------------------------------*
*& Report ZTEST1000012
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST.
REPORT ZP_SD_007.
INCLUDE ZP_SD_007_VARL.
INCLUDE ZP_SD_007_FORM.
INCLUDE ZP_SD_007_ALV.
START-OF-SELECTION.
PERFORM GET_DATA_ALV.
PERFORM SHOW_ALV TABLES GT_VBAK_ALV.
*&---------------------------------------------------------------------*
*& 包含 ZP_SD_007_VARL
*&---------------------------------------------------------------------*
TABLES:
VBAK.
DATA:
FORMNAME TYPE TDSFNAME,
FM_NAME TYPE RS38L_FNAM,
CONTROL TYPE SSFCTRLOP,
ERRTAB TYPE TSFERROR.
DATA:
BEGIN OF GT_VBAK OCCURS 0. "定义内表
INCLUDE TYPE ZWYVBAP.
DATA:
END OF GT_VBAK.
DATA:
BEGIN OF GT_VBAP OCCURS 0, "定义内表
VBELN LIKE VBAK-VBELN.
DATA:
END OF GT_VBAP.
DATA:
P_VBELN TYPE VBAK-VBELN.
* 定义传递到FORM中的页头数据
DATA:
VKORG TYPE VBAK-VKORG, "销售组织
VTWEG TYPE VBAK-VTWEG, "分销渠道
VKBUR TYPE VBAK-VKBUR, "销售办事处
VKGRP TYPE VBAK-VKGRP, "销售组
KUNNR TYPE VBAK-KUNNR, "供应商代码
NAME1 TYPE KNA1-NAME1, "供应商名称
VBELN TYPE VBAK-VBELN, "订单号码
AUDAT TYPE VBAK-AUDAT. "过账日期
* 定义显示在ALV界面上的内表
DATA:
BEGIN OF GT_VBAK_ALV OCCURS 0,
VKORG TYPE VBAK-VKORG, "销售组织
VTWEG TYPE VBAK-VTWEG, "分销渠道
VKBUR TYPE VBAK-VKBUR, "销售办事处
VKGRP TYPE VBAK-VKGRP, "销售组
KUNNR TYPE VBAK-KUNNR, "供应商代码
NAME1 TYPE KNA1-NAME1, "供应商名称
VBELN TYPE VBAK-VBELN, "订单号码
AUDAT TYPE VBAK-AUDAT, "过账日期
SELE TYPE CHAR1. "定义选中栏,边上的
DATA:
END OF GT_VBAK_ALV.
SELECTION-SCREEN BEGIN OF BLOCK 100 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
S_VBELN FOR VBAK-VBELN DEFAULT '4970' TO '4990'. "定义需要打印的凭证号码
SELECTION-SCREEN END OF BLOCK 100.
*&---------------------------------------------------------------------*
*& 包含 ZP_SD_007_FORM
*$ 显示在界面上的数据
*&---------------------------------------------------------------------*
FORM GET_DATA_ALV.
SELECT
VKORG
VTWEG
VKBUR
VKGRP
KUNNR
VBELN
AUDAT
INTO CORRESPONDING FIELDS OF TABLE GT_VBAK_ALV
FROM VBAK
WHERE VBELN IN S_VBELN.
ENDFORM. "get_data_alv
*&---------------------------------------------------------------------*
*& Form print_so
*&---------------------------------------------------------------------*
* text 设置打印的程序
*----------------------------------------------------------------------*
FORM PRINT_SO.
CLEAR GT_VBAP[].
* 获取选中的数据,并把选中的数据传递至 内表中。
LOOP AT GT_VBAK_ALV WHERE SELE = 'X'.
GT_VBAP-VBELN = GT_VBAK_ALV-VBELN.
APPEND GT_VBAP.
ENDLOOP.
FORMNAME = 'ZSD_PRINT_001'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = FORMNAME
IMPORTING
FM_NAME = FM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FOUNCTION_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.
ENDIF.
CONTROL-NO_DIALOG = 'X'.
CONTROL-PREVIEW = 'X'.
CONTROL-NO_OPEN = 'X'.
CONTROL-NO_CLOSE = 'X'.
CALL FUNCTION 'SSF_OPEN'
EXPORTING
* ARCHIVE_PARAMETERS =
* USER_SETTINGS = 'X'
* MAIL_SENDER =
* MAIL_RECIPIENT =
* MAIL_APPL_OBJ =
* OUTPUT_OPTIONS =
CONTROL_PARAMETERS = CONTROL
* IMPORTING
* JOB_OUTPUT_OPTIONS =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
* error handling
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
EXIT.
ENDIF.
LOOP AT GT_VBAP. "对凭证号进行循环处理,即在程序中进行分页的设置
P_VBELN = GT_VBAP-VBELN.
* 获取打印的表头数据
SELECT SINGLE
VKORG
VTWEG
VKBUR
VKGRP
KUNNR
VBELN
AUDAT
INTO (VKORG,VTWEG,VKBUR,VKGRP,KUNNR,VBELN,AUDAT)
FROM VBAK
WHERE VBELN = P_VBELN.
* 获取打印的表体数据
CLEAR GT_VBAK[]. "清空内表
SELECT
VBELN
POSNR
MATNR
ARKTX
KWMENG
NETWR
NETPR
MEINS
INTO CORRESPONDING FIELDS OF TABLE GT_VBAK
FROM VBAP
WHERE VBELN = P_VBELN.
CALL FUNCTION FM_NAME
EXPORTING
CONTROL_PARAMETERS = CONTROL
VKORG = VKORG
VTWEG = VTWEG
VKBUR = VKBUR
VKGRP = VKGRP
KUNNR = KUNNR
VBELN = VBELN
AUDAT = AUDAT
NAME1 = NAME1
TABLES
GT_VBAK = GT_VBAK "传递内表数据到SMARTFORMS中
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 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.
ENDLOOP.
CALL FUNCTION 'SSF_CLOSE'
* IMPORTING
* JOB_OUTPUT_INFO =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* analyse internal error table of Smart Forms
CALL FUNCTION 'SSF_READ_ERRORS'
IMPORTING
ERRORTAB = ERRTAB.
IF NOT ERRTAB IS INITIAL.
* add your handling
ENDIF.
ENDFORM. "print_so
*&---------------------------------------------------------------------*
*& 包含 ZP_SD_007_ALV
*&---------------------------------------------------------------------*
TYPE-POOLS:
slis.
*-----------------------------------------------------------*
*ALV相关内表和结构 *
*-----------------------------------------------------------*
DATA:
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
WA_STATUS TYPE SLIS_FORMNAME VALUE 'SUB_SET_PF_STATUS',
WA_COMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',
IT_EVENTS TYPE SLIS_T_EVENT.
DATA:
G_LAYOUT TYPE LVC_S_LAYO,
FIELDCAT TYPE LINE OF LVC_T_FCAT,
GT_FIELDCAT TYPE LVC_T_FCAT.
*&---------------------------------------------------------------------*
*& 显示ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_TAB text
*----------------------------------------------------------------------*
FORM SHOW_ALV TABLES TABLE.
*ALV表格显示样式
PERFORM ALV_LIST_LAYOUT.
*ALV报表的字段设置
PERFORM PF_ALV_LIST_FCAT USING IT_FIELDCAT.
*ALV报表显示
PERFORM PF_ALV_LIST_DISPLY TABLES TABLE.
ENDFORM. " SHOW_ALV
*&---------------------------------------------------------------------*
*& Form ALV_LIST_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_LIST_LAYOUT.
WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
WA_LAYOUT-DETAIL_INITIAL_LINES = 'X'.
WA_LAYOUT-BOX_FIELDNAME = 'SELE'. "定义边框选中栏
ENDFORM. " ALV_LIST_LAYOUT
*&---------------------------------------------------------------------*
*& Form PF_ALV_LIST_FCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_FIELDCAT text
*----------------------------------------------------------------------*
FORM PF_ALV_LIST_FCAT USING P_IT_FIELDCAT.
DATA:
LW_AFIELDCAT TYPE SLIS_FIELDCAT_ALV,
LW_POS TYPE I.
DEFINE D_FIELD.
CLEAR LW_AFIELDCAT.
LW_POS = LW_POS + 1.
LW_AFIELDCAT-COL_POS = LW_POS.
LW_AFIELDCAT-FIELDNAME = &1.
LW_AFIELDCAT-SELTEXT_L = &2.
LW_AFIELDCAT-REF_FIELDNAME = &4.
LW_AFIELDCAT-REF_TABNAME = &3.
LW_AFIELDCAT-NO_ZERO = &5.
LW_AFIELDCAT-HOTSPOT = &6.
LW_AFIELDCAT-OUTPUTLEN = &7.
LW_AFIELDCAT-EDIT = &8.
LW_AFIELDCAT-KEY = &9.
APPEND LW_AFIELDCAT TO IT_FIELDCAT.
END-OF-DEFINITION.
D_FIELD:
'VBELN' '销售单号' SPACE SPACE 'X' SPACE '10' SPACE SPACE,"销售凭证
'VKORG' '销售组织' SPACE SPACE SPACE SPACE '5' SPACE SPACE,"销售凭证类
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- SAPSMARTFORMS 凭证 连续 打印 设置 操作 计算 很好