首页 > 其他分享 >复制REUSE_ALV_GRID_DISPLAY_LVC,给函数添加简易的F4处理能力

复制REUSE_ALV_GRID_DISPLAY_LVC,给函数添加简易的F4处理能力

时间:2024-09-09 11:37:29浏览次数:6  
标签:gt F4 REUSE data GRID gs TYPE event f4value

翻遍REUSE_ALV_GRID_DISPLAY_LVC这个函数我们可以发现,这个函数里预定义了一些事件类型。

不过也缺少了一些类型,看看SLIS这个类型池就可以发现,ONF4事件是没有的。

为了把这个函数做出通用和简易的,复制这个函数所在的函数组SLVC_FULLSCREEN到ZSLVC_FULLSCREEN.

然后我们在这个新函数组里,定义F4事件:

LZSLVC_FULLSCREENTOP中定义grid的时候加上F4:

 LZSLVC_FULLSCREENTOP中定义本地类lcl_event_receiver的时候加上F4方法:

 

METHODS handle_onf4
                  FOR EVENT onf4 OF cl_gui_alv_grid
      IMPORTING   e_fieldname
                  e_fieldvalue
                  es_row_no
                  er_event_data
                  et_bad_cells
                  e_display.
View Code

 LZSLVC_FULLSCREENTOP中实现本地类lcl_event_receiver的时候加上F4处理:

 

FORM method_onf4 USING        pa_fieldname      TYPE  lvc_fname
                              pa_fieldvalue     TYPE  lvc_value
                              pa_row_no         TYPE  lvc_s_roid
                              pa_r_event_data   TYPE REF TO  cl_alv_event_data
                              pa_t_bad_cells    TYPE  lvc_t_modi
                              pa_display.
  IF NOT gt_grid-i_callback_onf4 IS INITIAL AND
     NOT i_callback_program IS INITIAL.
    PERFORM (gt_grid-i_callback_onf4)
      IN PROGRAM (i_callback_program) USING  pa_fieldname
           pa_fieldvalue
           pa_row_no
           pa_r_event_data
           pa_t_bad_cells
           pa_display.
  ENDIF.


ENDFORM.                               " METHOD_DATA_CHANGED
View Code

LZSLVC_FULLSCREENF02中定义grid对象注册事件里加上ONF4

 LZSLVC_FULLSCREENF01中分配回调对象:

 

 因为SLIS里没有ONF4的对象,所以event get 里只能写固定值:

 

 

基本逻辑就是:定义ONF4事件,类里实现ONF4事件,实现方法里执行回调函数对应的程序和FORM。

这样我们就可以调ALV函数的时候加上一句简单的ONF4事件和对应的处理form里可以了。

REPORT zly_f4.
TYPE-POOLS:slis.

*CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: gt_fcat   TYPE lvc_t_fcat,
      gs_fcat   TYPE lvc_s_fcat,
      gt_f4     TYPE lvc_t_f4,
      gs_f4     TYPE lvc_s_f4,
      gs_event  TYPE slis_alv_event,
      gt_event  TYPE slis_t_event,
      gs_layout TYPE lvc_s_layo,
      gs_glay   TYPE lvc_s_glay.

DATA: "event_receiver TYPE REF TO lcl_event_receiver,
      go_grid        TYPE REF TO cl_gui_alv_grid.

DATA: BEGIN OF gs_data ,
        pernr TYPE char10,
        nachn TYPE nachn,
        gesch TYPE gesch,
      END OF gs_data,
      gt_data LIKE TABLE OF gs_data.

DATA: BEGIN OF gs_f4value,
        gesch TYPE gesch,
        ztext TYPE text,
      END OF gs_f4value,
      gt_f4value LIKE TABLE OF gs_f4value.


START-OF-SELECTION.
  PERFORM f_get_data.
  PERFORM f_show_data.

FORM f_get_data .
  SELECT partner AS pernr name_last AS nachn FROM but000 INTO CORRESPONDING FIELDS OF TABLE gt_data UP TO 10 ROWS.
*    WHERE begda LE sy-datum AND endda GE sy-datum.

ENDFORM.

FORM f_show_data .
  DEFINE %%fcat.
    CLEAR GS_FCAT.
    GS_FCAT-FIELDNAME = &1.
    GS_FCAT-SCRTEXT_L = &2.
    IF &1 = 'GESCH'.
      GS_FCAT-EDIT = 'X'.
      GS_FCAT-F4AVAILABL = 'X'.
    ENDIF.
    APPEND GS_FCAT TO GT_FCAT.
  END-OF-DEFINITION.
  %%fcat: 'PERNR' '人员编号',
          'NACHN' '姓名',
          'GESCH' '性别'.


  gs_event-name = 'ONF4'.
  gs_event-form = 'F_F4_HELP'.
  APPEND gs_event TO gt_event.
  gs_glay-edt_cll_cb = 'X'.
  CALL FUNCTION 'ZREUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
      i_callback_program       = sy-cprog
      i_callback_pf_status_set = 'PF_STATUS_SET'
      it_fieldcat_lvc          = gt_fcat
      it_events                = gt_event
      i_grid_settings          = gs_glay
    TABLES
      t_outtab                 = gt_data.
ENDFORM.


FORM f_f4_help USING e_fieldname TYPE lvc_fname
                      p_fieldvalue     TYPE  lvc_value
                       es_row_no         TYPE  lvc_s_roid
                       p_r_event_data   TYPE REF TO  cl_alv_event_data
                       p_t_bad_cells    TYPE  lvc_t_modi
                       p_display.
  DATA: lt_ddshretval TYPE STANDARD TABLE OF ddshretval,
        ls_ddshretval TYPE ddshretval.
  CLEAR gs_f4value.
  gs_f4value-gesch = 1.
  gs_f4value-ztext = '男'.
  APPEND gs_f4value TO gt_f4value.
  CLEAR gs_f4value.
  gs_f4value-gesch = 2.
  gs_f4value-ztext = '女'.
  APPEND gs_f4value TO gt_f4value.
  CLEAR gs_f4value.
  gs_f4value-gesch = 3.
  gs_f4value-ztext = '中'.
  APPEND gs_f4value TO gt_f4value.

  CHECK e_fieldname = 'GESCH'.
  REFRESH lt_ddshretval.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield         = 'GESCH'    "
      dynpprog         = sy-repid
      dynpnr           = sy-dynnr
      dynprofield      = 'GESCH'
      value_org        = 'S'
      callback_program = sy-repid
      callback_form    = 'FM_CB_FORM'
    TABLES
      value_tab        = gt_f4value
      return_tab       = lt_ddshretval
    EXCEPTIONS
      parameter_error  = 1
      no_values_found  = 2
      OTHERS           = 3.

  IF sy-subrc = 0 AND lt_ddshretval IS NOT INITIAL .
    CLEAR ls_ddshretval.
    READ TABLE lt_ddshretval INTO ls_ddshretval INDEX 1.
    IF ls_ddshretval-fieldval IS NOT INITIAL.
      CLEAR gs_data.
      READ TABLE gt_data INTO gs_data INDEX es_row_no-row_id.
      gs_data-gesch = ls_ddshretval-fieldval.
      MODIFY gt_data FROM gs_data INDEX es_row_no-row_id
                       TRANSPORTING gesch.
    ENDIF.
  ENDIF.
ENDFORM.

FORM refresh_table_alv .
  DATA: ls_stbl TYPE lvc_s_stbl.
  ls_stbl-row = 'X'."
  ls_stbl-col = 'X'.
  CALL METHOD go_grid->refresh_table_display
    EXPORTING
      is_stable = ls_stbl.
ENDFORM.

FORM pf_status_set USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'STATUS_ALV'.

  gs_f4-fieldname = 'GESCH'.
  gs_f4-register = 'X'.
  gs_f4-getbefore = 'X'.
*  gs_f4-chngeafter = 'X'.
  INSERT gs_f4 INTO TABLE gt_f4.
  CALL FUNCTION 'ZGET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
      e_grid = go_grid.
  CALL METHOD go_grid->register_edit_event
    EXPORTING
      i_event_id = cl_gui_alv_grid=>mc_evt_modified.

  CALL METHOD go_grid->register_f4_for_fields
    EXPORTING
      it_f4 = gt_f4[].
ENDFORM.
*&---------------------------------------------------------------------*
*&      FORM  FM_CB_FORM
*&---------------------------------------------------------------------*
FORM fm_cb_form TABLES record_tab STRUCTURE seahlpres
              CHANGING shlp TYPE shlp_descr_t
                       callcontrol LIKE ddshf4ctrl.
  DATA: interface LIKE LINE OF shlp-interface.
  READ TABLE shlp-interface INTO interface INDEX 1.
  interface-shlpfield+4(1) = '1'.
  interface-valfield = 'DOC_LAYOUT'.
  APPEND interface TO shlp-interface.
  DELETE shlp-interface INDEX 1.
ENDFORM.                    "BO_CALLBACK_FORM

 

标签:gt,F4,REUSE,data,GRID,gs,TYPE,event,f4value
From: https://www.cnblogs.com/sapSB/p/18404242

相关文章

  • 零基础快速上手HarmonyOS ArkTS开发5---从简单的页面开始2---使用List组件构建列表、G
    接着零基础快速上手HarmonyOSArkTS开发4---从简单的页面开始继续往下学习页面布局的知识。最近发现之前学习这一章节的内容在官方已经被下了,替换成了另外一个案例了(https://developer.huawei.com/consumer/cn/training/course/slightMooc/C101717497398588123):而且整个视频的风格也......
  • 零基础快速上手HarmonyOS ArkTS开发5---从简单的页面开始2---使用List组件构建列表、G
    接着https://www.cnblogs.com/webor2006/p/18048248继续往下学习页面布局的知识。最近发现之前学习这一章节的内容在官方已经被下了,替换成了另外一个案例了(https://developer.huawei.com/consumer/cn/training/course/slightMooc/C101717497398588123):而且整个视频的风格也不一样......
  • STM32 PWM 详解(基于 STM32F429 HAL 库)
    目录前言一、PWM简介二、STM32F429的PWM功能1.定时器资源2.PWM模式3.PWM原理图三、使用HAL库配置STM32F429的PWM1.开启时钟2.配置定时器3.配置通道 4.启动定时器 5.PWM占空比的调节 四、应用实例五、总结前言        在嵌入式系统开......
  • 寄存器映射及地址计算(STM32F407)
    上篇文章介绍了存储器映射(存储器映射(STM32F407)-CSDN博客),本文介绍寄存器映射的基本概念。1、寄存器映射简介寄存器是一类特殊的存储器,它的每个位都有特定的功能,可以实现对外设/功能的控制,给寄存器的地址命名的过程就叫寄存器映射。举个简单的例子,大家家里面的纸张就好比通用......
  • STM32F4 - WDG看门狗
    WDG看门狗简介        作用:看门狗可以监控程序的运行状态,当程序因为设计漏洞、硬件故障、电磁干扰等原因,出现卡死或跑飞现象时,看门狗能及时复位程序,避免程序陷入长时间的罢工状态,保证系统的可靠性和安全性        看门狗本质上是一个定时器,当指定时间范围内,......
  • 【STM32项目设计】STM32F411健康助手--MAX30102 心率血氧传感器(5)
    硬件设计硬件连接MAX30102   STM32SDAPB7SCLPB6INTPB8GNDGND3V33V3软件设计max30102.c#include"max30102.h"#include"delay.h"u8max30102_Bus_Write(u8Register_Address,u8Word_Data){ /*采用串行EEPROM随即读取指令序列,连续读取若干字节*/ /*第1......
  • 【STM32项目设计】STM32F411健康助手--MPU6050陀螺仪驱动(6)
    硬件设计 软件设计此项目使用的是软件I2C,MPU6050的SCL连接到STM32的PB10,SDA连接到STM32的PB9mpuiic.c#include"mpuiic.h"#include"delay.h"//MPUIIC延时函数voidMPU_IIC_Delay(void){ delay_us(2);}//初始化IICvoidMPU_IIC_Init(void){ GPIO_Init......
  • CF1993E Xor-Grid Problem
    结论,异或,状压DP2300Link:https://codeforces.com/problemset/problem/1993/E。先考虑一维的情况。若只有一维,每次操作的结果和[AGC016D]XORReplace是一样的。对\(a_i\)进行一次操作相当于令\(a_i:=\oplus_{1\lei\len}a_i\),再对\(j\)进行一次操作相当于令\(a_j:=......
  • STM32F407数据手册中文版,STM32F429数据参考手册中文版
    发布一个适用STM32F405XX、STM32F407XX、STM32F415XX、STM32F417XX、STM32F427XX、STM32F437XX的中文数据手册,具体内容见下图:首页目录原文有下载地址原文链接:https://blog.csdn.net/wangshuchao0/article/details/138089438......
  • LigerUI 中的 Grid (ligerGrid) 合并单元格
    在网上搜索了很都都没有正确的方法实现合并单元格,LigerGrid不像 EasyUI 中的Grid可以直接合并单元格。我化了点时间,解决了,就分享给大家,我就不做详细的注释,只有有一定基础的都可以看懂,菜鸟就自己去补习吧。<divid="maingrid"style="margin:0;padding:0"></div......