首页 > 其他分享 >sap 报表 ZALV_XZH(新增报表空白行且双击字段生成一行)demo

sap 报表 ZALV_XZH(新增报表空白行且双击字段生成一行)demo

时间:2024-10-06 11:49:34浏览次数:17  
标签:报表 wa fieldcat frm 空白行 TYPE 双击 ekko &---------------------------------------

*&---------------------------------------------------------------------*
*& Report ZALV_XZH
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZALV_XZH.

TYPES:BEGIN OF ty_ekko,
ebeln TYPE ekko-ebeln,
verkf TYPE ekko-verkf,
sel TYPE c, "用来标识行选择的字段
F_STYLE TYPE LVC_T_STYL,
END OF ty_ekko.
DATA:it_ekko TYPE STANDARD TABLE OF ty_ekko,
wa_ekko TYPE ty_ekko.

DATA:lt_fieldcat TYPE lvc_t_fcat,
wa_fieldcat LIKE LINE OF lt_fieldcat,
wa_layout TYPE lvc_s_layo.
CONSTANTS: gco_callback_user_command TYPE slis_formname VALUE 'FRM_USER_COMMAND',
gco_callback_status TYPE slis_formname VALUE 'FRM_USER_STATUS'.

START-OF-SELECTION.

SELECT ebeln
verkf
INTO CORRESPONDING FIELDS OF TABLE it_ekko
FROM ekko
UP TO 10 ROWS.

APPEND INITIAL LINE TO it_ekko.

PERFORM frm_set_catalog.

PERFORM frm_loop_itdata.
* wa_layout-zebra = 'X'.
* wa_layout-box_fname = 'SEL'. "指定行选择字段
wa_layout-cwidth_opt = 'X'.
wa_layout-stylefname = 'F_STYLE'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
is_layout_lvc = wa_layout
it_fieldcat_lvc = lt_fieldcat
i_callback_pf_status_set = gco_callback_status
i_callback_user_command = gco_callback_user_command
TABLES
t_outtab = it_ekko[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc = 0.

ENDIF.

*&---------------------------------------------------------------------*
*& Form FRM_SET_PF_STATUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_user_status USING i_it_extab TYPE slis_t_extab.
* SET PF-STATUS '*******' .
ENDFORM. " FRM_SET_PF_STATUS

FORM frm_user_command USING i_ucomm TYPE sy-ucomm
i_wa_selfield TYPE slis_selfield.
CASE i_ucomm.
WHEN '&IC1'. "Double click
* if click on PO field, jump to me23n
* IF i_wa_selfield-fieldname = 'EBELN'.
* SET PARAMETER ID 'BES' FIELD i_wa_selfield-value.
* CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
* ENDIF.
PERFORM frm_loop_itdata .
APPEND INITIAL LINE TO it_ekko.
i_wa_selfield-refresh = 'X'.
WHEN OTHERS.

ENDCASE.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SET_CATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_set_catalog .

DEFINE mac_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = &1.
wa_fieldcat-reptext = &2.
wa_fieldcat-tabname = 'IT_EKKO'.
wa_fieldcat-outputlen = &3. "设置输出列宽
wa_fieldcat-edit = &4.
APPEND wa_fieldcat TO lt_fieldcat.
END-OF-DEFINITION.

clear wa_fieldcat.
wa_fieldcat-fieldname = 'SEL'.
wa_fieldcat-reptext = '选择框'.
wa_fieldcat-tabname = 'IT_EKKO'.
wa_fieldcat-edit = 'X'.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-outputlen = 5. "设置输出列宽
APPEND wa_fieldcat TO lt_fieldcat.

mac_fieldcat 'EBELN' '采购单号' 10 'X'.
mac_fieldcat 'VERKF' '销售员' 10 'X'.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_loop_itdata
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_loop_itdata .
DATA stylelin TYPE lvc_s_styl.

LOOP AT it_ekko INTO wa_ekko.
IF wa_ekko-ebeln IS NOT INITIAL.
CLEAR :wa_ekko-f_style[].
CLEAR stylelin.
stylelin-fieldname = 'EBELN'. " 需要编辑的列名
stylelin-style = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED. " 设置为不可编辑状态
APPEND stylelin TO wa_ekko-f_style.

CLEAR STYLELIN.
stylelin-fieldname = 'VERKF'.
stylelin-style = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
APPEND stylelin TO wa_ekko-f_style.

MODIFY it_ekko FROM wa_ekko.
ENDIF.
ENDLOOP.
ENDFORM.

标签:报表,wa,fieldcat,frm,空白行,TYPE,双击,ekko,&---------------------------------------
From: https://www.cnblogs.com/zsy1/p/18448956

相关文章

  • 查询结果为空时不显示报表内容
    1.1说明本文介绍了如何在帆软报表中处理查询结果为空的情况,提供了两种解决方案:通过设置条件属性使空数据行高度为0,以及添加加载结束事件用JavaScript隐藏表格。这两种方法分别适用于PC端和移动端。2.1准备数据新建普通报表,新建数据库查询ds1,SQL查询语句为:SELECT*FROM销......
  • 山海鲸可视化 VS PowerBI,中外免费报表软件对比
    在数据分析与可视化的时代,选择合适的报表工具显得尤为重要。山海鲸可视化和PowerBI是市场上颇受欢迎的两款免费报表软件,各有特色。接下来,我们将从功能、优缺点等方面进行对比,帮助你找到最适合的工具。山海鲸可视化山海鲸可视化是一款国内自主研发的报表工具,专注于用户体验和简易......
  • 报表控件DevExpress Reports v24.1 —— 拥有可调整布局选项
    DevExpressReports提供了一个可调整的布局选项,允许您以最合适的方式安排、塑造和组织数据。其中一个这样的数据塑造选项是分组,可以在表报告的详细信息带内将数据安排在嵌套的多字段组中。在v24.1版本周期中引入了几个函数,它们允许您获取不同组元素的索引,这些新功能包括:CurrentR......