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密 ...
随机推荐
- 发布自己的包到Nuget上
1.首先下载Nuget.exe https://dist.nuget.org/index.html 2.设置环境变量 设置apikey nuget setApiKey <my_api_key& ...
- mouse scrollings and zooming operations in linux & windows are opposite
mouse scrollings and zooming operations in linux & windows are opposite. windows中, 鼠标滚动的方向是: 查看页 ...
- linux socket
linux 的 C 库路径为 /usr/include,可以直接查看源码,也可以通过 "man 头文件名" 来学习,需要查看某个函数如 bind() ,则只需要 man 2 bi ...
- [歪谈]拽一个贵人出来给你"当炮架子"
我们在古装神话剧中经常会听到某个“先知”对前来算命的人说:你会在某某时刻遇到你的贵人.而这个贵人会在事业上助你一臂之力. 这里有个问题:贵人到底是什么?我们怎样去寻找我们的贵人. 前几天有个网友来咨询 ...
- 【Bootstrap】Bootstrap和Java分页-第二篇
目录 关于此文 配置xml-pager.tld 分页控件-Pager 分页action集成类-BaseController 实例-Dao 实例-service 实例-action 实例-JSP 实例- ...
- URL、Session、Cookies、Server.Transfer、Application和跨页面传送,利弊比较
URL.Session.Cookies.Server.Transfer.Application和跨页面传送.-本题考查面试者对ASP.NET中多页面传值的理解是否全面.因为ASP.NET的页面表单提交 ...
- PHP基础封装简单的MysqliHelper类
MysqliHelper.class.php 1: <?php 2: 3: /** 4: * MysqliHelper 5: * [面向对象的MysqliHelper的简单封装] 6: */ ...
- eclipse工具背景色模板-程序员保护好自己的眼睛
做为coder,要保护好自己的眼睛,eclipse 强烈推荐 Eclipse Color Theme插件,该插件包含多种当前流行的主题选择. 安装方法: 安装方法:1.先安装一个Eclipse Col ...
- Swift实战之2048小游戏
上周在图书馆借了一本Swift语言实战入门,入个门玩一玩^_^正好这本书的后面有一个2048小游戏的实例,笔者跟着实战了一把. 差不多一周的时间,到今天,游戏的基本功能已基本实现,细节我已不打算继续完 ...
- hibernate之persistence错误
错误码: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityM ...