SAP ALV显示并打印(非OO方式)
*&---------------------------------------------------------------------*
*& Report Z_SD_CPFHTZD
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z_SD_CPFHTZD.
INCLUDE ZDDALV007_INC.
TYPE-POOLS: slis.
TABLES:VTTP,LIPS,LIKP,KNA1,VTTK.
TYPES:BEGIN OF TY_ALL,
TKNUM LIKE VTTK-TKNUM ,"运单号
TPLST LIKE VTTK-TPLST ,"装运点
ERDAT LIKE VTTK-ERDAT ,"装运日期
TDLNR LIKE VTTK-TDLNR ,"物流公司
ROUTE LIKE VTTK-ROUTE ,"线路
DISTZ LIKE VTTK-DISTZ ,"里程
ADD01 LIKE VTTK-ADD01 ,"车主
EXTI1 LIKE VTTK-EXTI1 ,"卸货点
ADD02 LIKE VTTK-ADD02 ,"司机
BFART LIKE VTTK-BFART ,"车厢类型
MATNR LIKE LIPS-MATNR,"物料编码
ARKTX LIKE LIPS-ARKTX,"物料描述
BRGEW LIKE LIPS-BRGEW,"交货数量
GEWEI LIKE LIPS-GEWEI,"重量单位
END OF TY_ALL.
TYPES:BEGIN OF TY_HEADER,
TKNUM LIKE VTTK-TKNUM,"运单号
TPLST LIKE VTTK-TPLST ,"装运点
ERDAT LIKE VTTK-ERDAT ,"装运日期
TDLNR LIKE VTTK-TDLNR ,"物流公司
ROUTE LIKE VTTK-ROUTE ,"线路
DISTZ LIKE VTTK-DISTZ ,"里程
ADD01 LIKE VTTK-ADD01 ,"车主
EXTI1 LIKE VTTK-EXTI1 ,"卸货点
ADD02 LIKE VTTK-ADD02 ,"司机
BFART LIKE VTTK-BFART ,"车厢类型
COUNT LIKE LIPS-BRGEW,"一个运单需要打印的交货数量
END OF TY_HEADER.
*单据抬头结束
*单据明细开始
TYPES:BEGIN OF TY_ITEMS,
* GV_NAME LIKE KNA1-NAME1,"客户名称
* GV_KUNAG LIKE LIKP-KUNAG,"客户编号(售达方)
ZSEL TYPE C, "选中标识
MATNR LIKE LIPS-MATNR,"物料编码
ARKTX LIKE LIPS-ARKTX,"物料描述
BRGEW LIKE LIPS-BRGEW,"交货数量
GEWEI LIKE LIPS-GEWEI,"重量单位
BEIZHU(20) TYPE C,"备注
* style TYPE lvc_t_styl,
END OF TY_ITEMS.
*单据明细结束
*定义传入到smartforms的变量开始
DATA:fm_name TYPE rs38l_fnam.
DATA:itemsname(32) TYPE c.
DATA:headername(32) TYPE c.
*定义传入到smartforms的变量结束
DATA:GT_ALL TYPE TY_ALL OCCURS 0.
DATA:WA_ALL TYPE TY_ALL.
*定义表单头内表和工作区开始
DATA:GT_HEADER TYPE TY_HEADER OCCURS 0.
DATA:WA_HEADER TYPE TY_HEADER.
*定义表单头内表和工作区结束
*定义表单详细内容内表和工作区开始
DATA:GT_ITEMS TYPE TY_ITEMS OCCURS 0.
DATA:WA_ITEMS TYPE TY_ITEMS.
*定义表单详细内容内表和工作区结束
*定义存储ALV向smartforms传入数据的内表开始
DATA:GT_HEADER_TEMP TYPE TY_HEADER OCCURS 0.
DATA:GT_ITEMS_TEMP TYPE TY_ITEMS OCCURS 0.
*定义存储ALV向smartforms传入数据的内表结束
DATA: gs_fcat TYPE lvc_s_fcat,
gt_fcat TYPE lvc_t_fcat,
gs_layo TYPE lvc_s_layo,
gs_grid TYPE lvc_s_glay.
DATA: gt_event TYPE slis_t_event WITH HEADER LINE,
gt_event_exit TYPE slis_t_event_exit WITH HEADER LINE.
DATA: ref_grid TYPE REF TO cl_gui_alv_grid .
*DATA: BEGIN OF gt_itab OCCURS 0,
* aa(10) TYPE c,
* bb TYPE i,
* cc TYPE p,
* style TYPE lvc_t_styl,
* END OF gt_itab.
*DATA: wa_itab LIKE gt_itab.
START-OF-SELECTION.
SELECT-OPTIONS: P_ERDAT FOR VTTK-ERDAT ,
P_TKNUM FOR VTTK-TKNUM ,
P_TDLNR FOR VTTK-TDLNR ,
P_TPLST FOR VTTK-TPLST ,
P_ERNAM FOR VTTK-ERNAM ,
P_ROUTE FOR VTTK-ROUTE .
PERFORM FRM_GET_DATA.
PERFORM display_data .
END-OF-SELECTION.
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS handle_modify
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified et_good_cells.
ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_modify.
* PERFORM refresh.
DATA stbl TYPE lvc_s_stbl.
LOOP AT GT_ITEMS INTO WA_ITEMS.
* wa_itab-cc = wa_itab-bb * 2 .
MODIFY GT_ITEMS FROM WA_ITEMS.
ENDLOOP.
* 稳定刷新
stbl-row = 'X'." 基于行的稳定刷新
stbl-col = 'X'." 基于列稳定刷新
CALL METHOD ref_grid->refresh_table_display
EXPORTING
is_stable = stbl.
ENDMETHOD. "HANDLE_MODIFY
ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION
DATA gt_event_receiver TYPE REF TO lcl_event_receiver .
FORM FRM_PRINT_DATA.
DATA:PTR_COUNT(10) TYPE C.
call function 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSDSF001' "smartforms名"
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
CONCATENATE 'ZDDITEMMM' SY-UZEIT INTO itemsname.
CONCATENATE 'ZDDHEADER' SY-UZEIT INTO headername.
savebuffer GT_ITEMS_TEMP itemsname.
savebuffer GT_HEADER headername.
* PTR_COUNT = GV_COUNT .
*调用 smartForms
call function fm_name
EXPORTING
PTR_ITEMS = itemsname
PTR_HEADER = headername
* PTR_TOTAL = GV_COUNT
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4.
clearbuffer itemsname.
clearbuffer headername.
* CLEAR GV_COUNT.
* CLEAR PTR_COUNT.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM display_data .
PERFORM set_fcat.
PERFORM set_layout.
* gt_event-form = 'DATA_CHANGED'.
* gt_event-name = slis_ev_data_changed.
* APPEND gt_event.
* gt_event_exit-ucomm = 'ENTR'. "Enter = 'ENTR' & '/00' & ' '
* APPEND gt_event_exit.
* gt_event_exit-ucomm = '/00'.
* APPEND gt_event_exit.
*
* gt_event_exit-ucomm = ' '.
* APPEND gt_event_exit.
*
* gt_event_exit-ucomm = '&DATA_SAVE'.
* APPEND gt_event_exit.
*
* gt_event_exit-ucomm = '&F03'. "Back
* APPEND gt_event_exit.
* gt_event_exit-ucomm = '&F15'.
* APPEND gt_event_exit.
* gt_event_exit-ucomm = '&F12'.
* APPEND gt_event_exit .
PERFORM show_alv TABLES gt_fcat GT_ITEMS[]
USING gs_layo.
ENDFORM. " DISPLAY_DATA
*&---------------------------------------------------------------------*
FORM set_fcat .
PERFORM csalv_set_fcat USING:
" 'Field' 'Text' 'Edit' 'Zero' 'Type' 'Qfieldname' 'Key' 'Hostspot' 'Emphasize' 'Checkbox'
'MATNR' '物料编码' '' '' '' '' '' '' '' '',
'ARKTX' '物流描述' '' '' '' '' '' '' '' '',
'BRGEW' '交货数量' '' '' '' '' '' '' '' '',
'GEWEI' '重量单位' '' '' '' '' '' '' '' '',
'BEIZHU' '备注' 'X' '' '' '' '' '' '' '' ,
'zsel' '是否打印 ' 'X' '' '' '' '' '' '' 'X'.
ENDFORM. " SET_FCAT
*&---------------------------------------------------------------------*
FORM set_layout .
gs_layo
-zebra = 'X'.
* gs_layout-stylefname = 'FIELD_STYLE'.
* gs_layo-CWIDTH_OPT = 'X'.
ENDFORM. " SET_LAYOUT
*&---------------------------------------------------------------------*
FORM csalv_set_fcat USING
p_name
p_text
p_edit
p_zero
p_type
p_qfieldname
p_key
p_hotspot
p_emphasize
p_checkbox
.
gs_fcat-fieldname = p_name.
* gs_fcat-reptext_l =
* gs_fcat-selddictxt =
gs_fcat-reptext = p_text.
gs_fcat-edit = p_edit.
gs_fcat-no_zero = p_zero.
gs_fcat-datatype = p_type.
gs_fcat-qfieldname = p_qfieldname.
gs_fcat-key = p_key.
gs_fcat-hotspot = p_hotspot.
gs_fcat-emphasize = p_emphasize.
gs_fcat-checkbox = p_checkbox.
APPEND gs_fcat TO gt_fcat.
ENDFORM. "csalv_set_fcat
*&---------------------------------------------------------------------*
FORM show_alv TABLES pt_fcat pt_tab
USING ps_layout.
gs_grid-edt_cll_cb = 'X'.
gt_event-name = 'CALLER_EXIT'. "slis_ev_caller_exit_at_start事件
gt_event-FORM = 'FM_BUTTON'.
APPEND gt_event .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid i_callback_user_command = 'USER_COMMAND'
i_grid_settings
= gs_grid
i_callback_pf_status_set
= 'SET_PF_STATUS'
is_layout_lvc
= gs_layo
it_fieldcat_lvc
= pt_fcat[]
it_events
= gt_event[]
* it_event_exit = gt_event_exit[]
TABLES
t_outtab
= pt_tab
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
ENDFORM. "csalv_set_fcat
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_UCOMM text
* -->PS_SELFIELD text
*----------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield
TYPE slis_selfield.
DATA COUNT LIKE LIPS-BRGEW.
CASE r_ucomm.
WHEN '&DATA_SAVE'.
WHEN '&PRINT'.
LOOP AT GT_ITEMS INTO WA_ITEMS.
IF WA_ITEMS-ZSEL = 'X'.
APPEND WA_ITEMS TO GT_ITEMS_TEMP.
COUNT = WA_ITEMS-BRGEW + COUNT.
ENDIF.
ENDLOOP.
READ TABLE GT_HEADER INTO WA_HEADER INDEX 1.
WA_HEADER
-COUNT = COUNT.
MODIFY TABLE GT_HEADER FROM WA_HEADER.
CLEAR WA_ITEMS.
IF GT_ITEMS_TEMP IS INITIAL.
MESSAGE i000(0k) WITH '请选中要打印的内容!'.
EXIT .
ENDIF.
PERFORM FRM_PRINT_DATA.
CLEAR GT_ITEMS_TEMP.
WHEN OTHERS.
CLEAR GT_ITEMS_TEMP.
LEAVE TO SCREEN 0.
ENDCASE.
ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form SET_PF_STATUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab..
SET PF-STATUS 'STANDARD'.
ENDFORM. "SET_PF_STATUS
*&---------------------------------------------------------------------*
*& Form fm_button
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->E_GRID text
*----------------------------------------------------------------------*
FORM fm_button USING e_grid TYPE slis_data_caller_exit.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
* EXPORTING
* IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
* ET_EXCLUDING =
* E_REPID =
* E_CALLBACK_PROGRAM =
* E_CALLBACK_ROUTINE =
e_grid
= ref_grid
* ET_FIELDCAT_LVC =
* ER_TRACE =
* E_FLG_NO_HTML =
* ES_LAYOUT_KKBLO =
* ES_SEL_HIDE =
* ET_EVENT_EXIT =
* ER_FORM_TOL =
* ER_FORM_EOL =
.
* CALL METHOD ref_grid->check_changed_data.
* 设置enter事件
CALL METHOD ref_grid->register_edit_event
EXPORTING
i_event_id
= cl_gui_alv_grid=>mc_evt_enter
EXCEPTIONS
error
= 1
OTHERS = 2.
CREATE OBJECT gt_event_receiver.
SET HANDLER gt_event_receiver->handle_modify FOR ref_grid.
ENDFORM. "FM_BUTTON
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA .
SELECT *
FROM VTTK AS VK
INNER
JOIN VTTP AS VP
ON VK~TKNUM = VP~TKNUM
INNER
JOIN LIPS AS L
ON L~VBELN = VP~VBELN
INTO CORRESPONDING FIELDS OF TABLE GT_ALL
WHERE
VK
~TKNUM IN P_TKNUM AND (
VK
~ERDAT IN P_ERDAT AND
VK
~TDLNR IN P_TDLNR AND
VK
~TPLST IN P_TPLST AND
VK
~ERNAM IN P_ERNAM AND
VK
~ROUTE IN P_ROUTE ) .
MOVE-CORRESPONDING GT_ALL TO GT_HEADER.
MOVE-CORRESPONDING GT_ALL TO GT_ITEMS.
DELETE ADJACENT DUPLICATES FROM GT_HEADER.
*
* SELECT "k~NAME1 L1~KUNAG
* L2~MATNR L2~ARKTX L2~BRGEW L2~GEWEI
* FROM VTTP AS V
* INNER JOIN LIKP AS L1
* ON V~VBELN = L1~VBELN
* INNER JOIN KNA1 AS K
* ON L1~KUNAG = K~KUNNR
* INNER JOIN LIPS AS L2
* ON L2~VBELN = L1~VBELN
* INTO (" WA_ITEMS-GV_NAME,
* "WA_ITEMS-GV_KUNAG,
* WA_ALL-GV_MATNR,WA_ALL-GV_ARKTX,
* WA_ALL-GV_BRGEW ,WA_ALL-GV_GEWEI )
* WHERE V~TKNUM IN P_TKNUM.
* APPEND WA_ALL TO GT_ALL.
*
*" SORT GT_ITEMS BY GV_MATNR.
*
* ENDSELECT.
* CLEAR WA_ALL.
ENDFORM. " FRM_GET_DATA
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*MODULE STATUS_0100 OUTPUT.
* SET PF-STATUS 'STANDARD'.
** SET TITLEBAR 'xxx'.
*
*ENDMODULE. " STATUS_0100 OUTPUT
**&---------------------------------------------------------------------*
**& Module USER_COMMAND_0100 INPUT
**&---------------------------------------------------------------------*
** text
**----------------------------------------------------------------------*
*MODULE USER_COMMAND_0100 INPUT.
* DATA:OK_CODE LIKE SY-UCOMM.
* CASE OK_CODE.
* WHEN '&PRINT'.
* PERFORM FRM_PRINT_DATA.
*
* WHEN OTHERS.
*
* LEAVE TO SCREEN 0.
* ENDCASE.
*ENDMODULE. " USER_COMMAND_0100 INPUT
SAP ALV显示并打印(非OO方式)的更多相关文章
- OO方式下,ALV TREE和ALV GRID的不同之处
作为大部分报表程序的基础,ALV GRID差不多是每个ABAP开发者必须了解和掌握的内容,因此网上也不乏相关资料,而ALV TREE的应用相对较少,中文资料也就比较少见了.实际上,ALV TREE和A ...
- SAP ALV中同一列的不同行显示不同的小数位,并能够总计,小计
物料数量字段,根据物料类型的不同,来显示不同的小数位:要求有点苛刻: 首先,要能够总计和小计的话,这一列的字段类型必须是数值类型. 这样的话,就不能通过截取的方式改变不同行的小数位. 以下是两种思路: ...
- pbfunc外部函数扩展应用-直接在Datawindow中生成QR二维码,非图片方式
利用pbfunc外部函数在Datawindow中直接生成QR二维码,非图片方式.需要注意以下面几点: Datawindow的DataObject的单位必须为像素(Pixels). Datawindow ...
- Springboot使用Cookie,生成cookie,获取cookie信息(注解与非注解方式)
先 创建一个控制类吧, 其实我没有分层啊,随便做个例子: MyGetCookieController: @RestControllerpublic class MyGetCookieControlle ...
- JMeter场景运行(非GUI方式运行命令)
JMeter场景运行方式可分为两种: GUI方式运行,视窗运行,双击jmeter.bat启动运行即可以看到运行界面: 非GUI方式运行,在命令窗口中使用java –jar命名运行: 但不管是以 ...
- 利用WPF建立自己的3d gis软件(非axhost方式)(十二)SDK中的导航系统
原文:利用WPF建立自己的3d gis软件(非axhost方式)(十二)SDK中的导航系统 先下载SDK:https://pan.baidu.com/s/1M9kBS6ouUwLfrt0zV0bPew ...
- 利用WPF建立自己的3d gis软件(非axhost方式)(十三)万能的用户层接口,(强大的WPF)
原文:利用WPF建立自己的3d gis软件(非axhost方式)(十三)万能的用户层接口,(强大的WPF) 先下载SDK:https://pan.baidu.com/s/1M9kBS6ouUwLfrt ...
- 利用WPF建立自己的3d gis软件(非axhost方式)(十)SDK中一些自带的展示面板应用
原文:利用WPF建立自己的3d gis软件(非axhost方式)(十)SDK中一些自带的展示面板应用 先下载SDK:https://pan.baidu.com/s/1M9kBS6ouUwLfrt0zV ...
- 利用WPF建立自己的3d gis软件(非axhost方式)(七)实现简单的粒子效果
原文:利用WPF建立自己的3d gis软件(非axhost方式)(七)实现简单的粒子效果 先下载SDK:https://pan.baidu.com/s/1M9kBS6ouUwLfrt0zV0bPew密 ...
随机推荐
- 黄永成-thinkphp讲解-个人博客讲解25集
整个网站的根目录用blog你要跟别人说起,自己好识别的文件夹名字. 下面的项目名称 就不再重复的写了, 直接用App就好了. 网站访问: ...../index.php(入口文件)/Admin(模块名 ...
- 来自 Google 的 R 语言编码风格指南
来自 Google 的 R 语言编码风格指南R 语言是一门主要用于统计计算和绘图的高级编程语言. 这份 R 语言编码风格指南旨在让我们的 R 代码更容易阅读.分享和检查. 以下规则系与 Google ...
- Linux下更新时间
方法一.使用命令 ntpdate time-a.nist.gov 方法二.本地安装ntpdate客户端 在本地安装ntpdate客户端,更新时用 ntpdate cn.pool.ntp.org 如果你 ...
- 密码学初级教程(八)SSL/TLS-为了更安全的通信
SSL/TLS是世界上应用最广泛的密码通信方法.用到对称密码.消息认证码.公钥密码.数字签名.伪随机数生成器等密码技术. 密码套件 SSL/TLS提供了一种密码通信的框架,SSL/TLS中使用的对称密 ...
- CSS3的REM设置字体大小
在Web中使用什么单位来定义页面的字体大小,至今天为止都还在激烈的争论着,有人说PX做为单位好,有人说EM优点多,还有人在说百分比方便,以至于出现了CSS Font-Size: em vs. px v ...
- 第一个C++例子
#include <iostream> using namespace std; class Time { private: int hour; int minute; int secon ...
- C#深入浅出 修饰符(二)
1.函数参数前的修饰符 params ,ref ,out params修饰的数据类型只能数组,用于参数不固定时:且此参数位于所有形式参数的最后: public static int GetMax(pa ...
- 如何自定义wordpress登录界面的Logo
每次登录wp后台都会看到wordpress的logo,会不会有点烦呢?想不想换个新的.自己设定一个呢?那么如何自定义wordpress登录界面的Logo呢? 把代码复制到当前主题的 functions ...
- Logistic 回归(sigmoid函数,手机的评价,梯度上升,批处理梯度,随机梯度,从疝气病症预测病马的死亡率
(手机的颜色,大小,用户体验来加权统计总体的值)极大似然估计MLE 1.Logistic回归 Logistic regression (逻辑回归),是一种分类方法,用于二分类问题(即输出只有两种).如 ...
- Oracle添加数据报文字与格式字符串不匹配错误
今天在学习Oracle时碰到一个错:文字与格式字符串不匹配. 我在Oracle数据库中创建了一张表: --创建员工表employee create table employee ( empon ) n ...