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密 ...
随机推荐
- 序列化反序列化api(入门级)
定义: java序列化是指把Java对象转换为字节序列的过程:而Java反序列化是指把字节序列恢复为Java对象的过程. 为什么字符串通常也会进行序列化? 对象需要进行序列化的原因:保证对象的状态不变 ...
- Android中实现圆角矩形及半透明效果。
注:本文由Colin撰写,版权所有!转载请注明原文地址,谢谢合作! 在做Android开发时,我们为了美观,有时候需要使用圆角矩形,或半透明之类的效果,在网页设计中很容易实现.但在Android开发中 ...
- tyvj1614 魔塔魔塔!
描述 百度noip贴吧管理组开发了一个小游戏,叫魔塔魔塔.虽然把魔塔重复了两次,但其实还只是个魔塔而已,还是简化版的.游戏在一个N*M大小的地图中进行,每一格都是正方形.对于某一格,有若干种可能的状态 ...
- HDOJ 4734 F(x)
数位DP.... F(x) Time Limit: 1000/500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- eclipse无法自动识别出svn项目
因为重新安装了svn插件,重启后发现原来的svn项目无法自动识别出来,连Team->Share Project都没有,而本地用tortoiseSvn是可以正常操作的. 后来我把项目删除然后重新导 ...
- thinkphp中的自动验证
array(验证字段,验证规则,错误提示,[验证条件,附加规则,验证时间]) 1.验证字段 需要验证的表单字段名称,这个字段不一定是数据库字段,也可以是表单的一些辅助字段,例如确认密码和验证码等等.有 ...
- 更新引用google的cdn外部jQuery核心库JS文件
jquery-2.0.3 注!不再支持IE 6/7/8 直接引用地址: <script src="http://ajax.googleapis.com/ajax/libs/jque ...
- Linux新手应掌握的10个基本命令
导读 Linux对我们的生活有着很大的影响.然而在Linux上,你通常应该使用终端命令,而不是只要点击启动器图像(就像你在Windows上操作那样).这10个基本的Linux命令和重要命令会帮助你尽快 ...
- Android学习笔记(三)——初探Intent
//此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! Intent 是 Android 程序中各组件之间进行交互的一种重要方式,它不仅可以指明当前组件想要执行的动作 ...
- php写入txt换行符
1.问题 写入txt文件想换行,老是直接输出了\r\n. 2.解决 要用双引号对\r\n进行解释,否则php会直接当字符输出. 3.例子 要求:往test.txt文本每一行后面加abc $a=file ...