函数ALV

1.定义
DATA: lt_fieldcat TYPE lvc_t_fcat,
lw_fieldcat TYPE lvc_s_fcat,
lw_layout TYPE lvc_s_layo.
2.layout赋值
lw_layout-zebra = ‘X’.
lw_layout-cwidth_opt = ‘X’.
lw_layout-sel_mode = ‘A’.
3.fieldcat赋值
FORM frm_build_fcat.

  DEFINE def_fieldcat.
    CLEAR lw_fieldcat.
    lw_fieldcat-fieldname = &1.
    lw_fieldcat-scrtext_m = &2.
    lw_fieldcat-hotspot = &3.
    lw_fieldcat-checkbox = &4.
    lw_fieldcat-edit       = &5.
    lw_fieldcat-ref_table  = &6.
    lw_fieldcat-ref_field  = &7.
    lw_fieldcat-no_zero  = &8.
    lw_fieldcat-decimals_o   = &9.
    APPEND lw_fieldcat TO lt_fieldcat.
  END-OF-DEFINITION.

  REFRESH lt_fieldcat[].

  IF pv_flag = '0'.
    def_fieldcat    'AUFNR         ' '生产订单'      ''   '' '' '' '' '' ''  .
    def_fieldcat    'MATNR         ' '物料编码'      ''   '' '' '' '' '' ''  .
    def_fieldcat    'CHARG         ' '批次'          ''   '' '' '' '' '' ''  .
    def_fieldcat    'MENGE         ' '数量'          ''   '' '' '' '' 'X' '0'  .
    def_fieldcat    'VFDAT         ' '有效期'        ''   '' '' '' '' '' ''  .
    def_fieldcat    'DATSY         ' '剩余有效期'    ''   '' '' '' '' '' ''  .
  ENDIF.

ENDFORM.
4.函数调用

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
      i_callback_program       = lv_repid
      i_callback_pf_status_set = 'FRM_SET_PF'
      i_callback_user_command  = 'FRM_USER_COMMAND'
      is_layout_lvc            = lw_layout
      it_fieldcat_lvc          = lt_fieldcat
    TABLES
      t_outtab                 = lt_charg
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.

5.GUI状态
FORM frm_set_pf USING rt_extab TYPE slis_t_extab.

  DATA: rs_extab TYPE slis_extab.
  REFRESH rt_extab.
    rs_extab-fcode = '&SAVE'.
    APPEND rs_extab TO rt_extab.
    rs_extab-fcode = '&PROC'.
    APPEND rs_extab TO rt_extab.
  SET PF-STATUS 'STATUS' EXCLUDING rt_extab.

ENDFORM.
6.user_command
FORM frm_user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.

  CASE r_ucomm.
    WHEN '&PROC'.
      PERFORM frm_proc_assign.
      PERFORM frm_dis_assign.  "显示分配结果
    WHEN '&SAVE'.
      PERFORM frm_save_data. "保存数据到后续表
    WHEN OTHERS.
  ENDCASE.

rs_selfield-refresh = ‘X’ . " 当用户在显式界面上对数据进行修改时,同时内表中的数据也随之刷新
ENDFORM.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值