通常用户在遇到问题后,经常会问某个单据的变更记录,很多模块中在前台的操作界面中都根据对应的菜单栏中可以找到对应的变更记录,像销售订单、交货单、采购申请、采购订单都在菜单栏位中都可以查询到对应的修改记录,但是对于想批量查询一些单据的变更记录就要涉及自定义的开发了。
SAP 变更记录基本都会存在两张表中
更改凭证抬头—CDHDR
更改凭证项目—CDPOS
更改文档创建的对象—TCDOB
我们以销售订单的变更记录和交货单的变更记录进行演示
我们在查询表CDHDR的时候,首先就需要知道文档对象,不同的业务场景存在不同的文档对象
我们可以通过表TCDOB查询到对应业务场景中的文档对象,输入对应的后台表名称,如下图我们填写VBAP销售订单的后台表名称,然后执行
可以查询到销售订单的文档对象就是VERKBELEG
同理:
交货单的文档对象就是:LIEFERUNG
采购申请:BANF
采购订单:EINKBELEG
然后我们在查询的时候就可以通过对象类型进行取值
如下图
对象值的位置填写的就是交货单的单号
然后就可以查到这个交货单的变更记录
我们可以根据 表+字段名来确定我们更改的是什么内容
以下代码是用于查询销售订单交货单变更记录查询的代码:
*&---------------------------------------------------------------------*
*& Report ZSDR027
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZSDR027.
TABLES:vbak,cdhdr,cdpos,likp.
TYPES:BEGIN OF ty_cdhp,
objectclas TYPE cdhdr-objectclas , " 更改文档对象
objectid TYPE cdhdr-objectid , " 对象值
changenr TYPE cdhdr-changenr , " 文档编号
username TYPE cdhdr-username , " 用户
udate TYPE cdhdr-udate , " 日期
utime TYPE cdhdr-utime , " 时间
tcode TYPE cdhdr-tcode , " 事务
planchngnr TYPE cdhdr-planchngnr , " 更改号
act_chngno TYPE cdhdr-act_chngno , " 文档编号
was_plannd TYPE cdhdr-was_plannd , " 已创建
change_ind TYPE cdhdr-change_ind , " 应用对象变更
langu TYPE cdhdr-langu , " 语言
version TYPE cdhdr-version , " 三字节字段
tabname TYPE cdpos-tabname , " 表名
tabkey TYPE cdpos-tabkey , " 表键
fname TYPE cdpos-fname , " 字段名
chngind TYPE cdpos-chngind , " 更改标识符
text_case TYPE cdpos-text_case , " 文本标志
unit_old TYPE cdpos-unit_old , " 单位
unit_new TYPE cdpos-unit_new , " 单位
cuky_old TYPE cdpos-cuky_old , " 货币代码
cuky_new TYPE cdpos-cuky_new , " 货币代码
value_new TYPE cdpos-value_new , " 新值
value_old TYPE cdpos-value_old , " 旧值
END OF ty_cdhp.
DATA: gt_cdhp TYPE TABLE OF ty_cdhp WITH HEADER LINE .
DATA: gt_likp TYPE TABLE OF ty_cdhp WITH HEADER LINE .
TYPES: BEGIN OF gy_show,
objectclas TYPE cdhdr-objectclas , " 更改文档对象
objectid TYPE cdhdr-objectid , " 对象值
changenr TYPE cdhdr-changenr , " 文档编号
username TYPE cdhdr-username , " 用户
udate TYPE cdhdr-udate , " 日期
utime TYPE cdhdr-utime , " 时间
tcode TYPE cdhdr-tcode , " 事务
tabname TYPE cdpos-tabname , " 表名
tabkey TYPE cdpos-tabkey , " 表键
fname TYPE string , " 字段名
chngind TYPE cdpos-chngind , " 更改标识符
text_case TYPE cdpos-text_case , " 文本标志
unit_old TYPE cdpos-unit_old , " 单位
unit_new TYPE cdpos-unit_new , " 单位
cuky_old TYPE cdpos-cuky_old , " 货币代码
cuky_new TYPE cdpos-cuky_new , " 货币代码
value_new TYPE cdpos-value_new , " 新值
value_old TYPE cdpos-value_old , " 旧值
box TYPE c,
name_text(25) ,
posnr TYPE vbep-posnr,
etenr TYPE vbep-etenr,
matnr TYPE mara-matnr, "物料
maktx TYPE makt-maktx, "物料描述
KUNNR TYPE KNA1-KUNNR, "客户
NAME1 TYPE KNA1-NAME1, "客户描述
VKBUR TYPE VBAK-VKBUR, "销售办公室
BEZEI1 TYPE TVKBT-BEZEI, "销售办公室描述
VKGRP TYPE VBAK-VKGRP, "销售组
BEZEI TYPE TVGRT-BEZEI, "销售组描述
NETWR TYPE VBAP-NETWR, "订单未税金额
WAERK TYPE vbap-WAERK, "币别
LFIMG TYPE lips-LFIMG, "交货单数量
VBELN TYPE VBAP-VBELN,
POSNR1 TYPE VBAP-POSNR,
END OF gy_show.
DATA gt_show TYPE TABLE OF gy_show WITH HEADER LINE.
DATA it_show TYPE TABLE OF gy_show WITH HEADER LINE.
DATA: gs_layout TYPE lvc_s_layo,
gt_fcat_lvc TYPE lvc_t_fcat,
gs_fcat_lvc TYPE lvc_s_fcat.
TYPES:BEGIN OF ty_user,
bname TYPE usr21-bname,
persnumber TYPE usr21-persnumber,
name_first TYPE adrp-name_first,
name_last TYPE adrp-name_last,
name_text TYPE string,
END OF ty_user.
DATA:it_user TYPE TABLE OF ty_user WITH HEADER LINE.
DATA:it_user1 TYPE TABLE OF ty_user WITH HEADER LINE.
DEFINE set_fieldcat.
CLEAR gs_fcat_lvc .
gs_fcat_lvc-fieldname = &1."内表的字段
gs_fcat_lvc-outputlen = &2."输出长度
gs_fcat_lvc-scrtext_l = &3."在ALV里面显示的名字
gs_fcat_lvc-just = &4."水平对齐方式,L左对齐,R右对齐。
gs_fcat_lvc-no_zero = &5."去除前导零
gs_fcat_lvc-checkbox = &6."checkbox
gs_fcat_lvc-edit = &7.
APPEND gs_fcat_lvc TO gt_fcat_lvc .
END-OF-DEFINITION.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS:
r1 RADIOBUTTON GROUP g1 DEFAULT 'X' USER-COMMAND ucom,
r2 RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln MODIF ID p1,
s_uname FOR gt_show-name_text LOWER CASE MODIF ID p1,
s_datum FOR cdhdr-udate MODIF ID p1.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE TEXT-003.
SELECT-OPTIONS:
S_VBELN1 for LIKP-VBELN MODIF ID p0,
s_uname1 FOR gt_show-name_text LOWER CASE MODIF ID p0,
s_datum1 FOR cdhdr-udate MODIF ID p0.
SELECTION-SCREEN END OF BLOCK b3.
INITIALIZATION.
AT SELECTION-SCREEN OUTPUT.
"修改屏幕
PERFORM frm_modify_screen.
START-OF-SELECTION.
FORM frm_modify_screen.
LOOP AT SCREEN.
IF r1 = 'X'.
IF screen-group1 = 'P0'.
screen-active = '0'.
ENDIF.
IF screen-name = 'S_IDNRK-LOW'.
screen-required = '2'.
ENDIF.
ELSEIF r2 = 'X'.
IF screen-group1 = 'P1'.
screen-active = '0'.
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDFORM.
START-OF-SELECTION.
CASE 'X'.
WHEN r1.
PERFORM fvm_uname .
PERFORM fvm_getdata.
PERFORM fvm_alv.
WHEN r2.
PERFORM fvm_uname1 .
PERFORM fvm_getlikp.
PERFORM fvm_alv1.
WHEN OTHERS.
ENDCASE.
END-OF-SELECTION.
FORM fvm_getdata.
SELECT
cdhdr~objectclas
cdhdr~objectid
cdhdr~changenr
cdhdr~username
cdhdr~udate
cdhdr~utime
cdhdr~tcode
cdhdr~planchngnr
cdhdr~act_chngno
cdhdr~was_plannd
cdhdr~change_ind
cdhdr~langu
cdhdr~version
cdpos~tabname
cdpos~tabkey
cdpos~fname
cdpos~chngind
cdpos~text_case
cdpos~unit_old
cdpos~unit_new
cdpos~cuky_old
cdpos~cuky_new
cdpos~value_new
cdpos~value_old
INTO CORRESPONDING FIELDS OF TABLE gt_cdhp
FROM cdhdr
INNER JOIN cdpos ON cdpos~objectclas = cdhdr~objectclas
AND cdpos~objectid = cdhdr~objectid
AND cdpos~changenr = cdhdr~changenr
WHERE cdhdr~objectid IN s_vbeln
AND cdhdr~udate IN s_datum
AND cdhdr~objectclas = 'VERKBELEG' "销售订单
AND cdhdr~langu = sy-langu
AND cdpos~fname IN ('CMWAE','FKDAT','ZTERM','KUNNR','MATNR','KDMAT','WMENG','CMPRE','EDATU').
SORT gt_cdhp BY objectid tabkey udate utime.
SELECT VKGRP , BEZEI
INTO TABLE @DATA(LT_TVGRT)
FROM TVGRT
WHERE SPRAS = '1'.
SELECT VKBUR , BEZEI
INTO TABLE @DATA(LT_TVKBT)
FROM TVKBT
WHERE SPRAS = '1'.
SELECT
VKBUR_ANA ,"销售办事处
VKGRP_ANA ,
VBELN , "销售凭证
POSNR , "凭证项目
MATNR , "物料编号
ARKTX , "物料描述
NETWR , "订单未税金额
WAERK , "币别
KUNNR_ANA
INTO TABLE @DATA(LT_ZVBAP)
FROM VBAP
* INNER JOIN TVGRT on TVGRT~VKGRP = vbap~VKGRP_ANA
WHERE
VBAP~VBELN in @s_vbeln
.
sort LT_ZVBAP by VBELN POSNR.
SELECT KUNNR , NAME1
INTO TABLE @DATA(LT_KNA1)
FROM KNA1
FOR ALL ENTRIES IN @LT_ZVBAP
WHERE
KNA1~KUNNR = @LT_ZVBAP-KUNNR_ANA .
SORT LT_KNA1 by kunnr.
LOOP AT gt_cdhp .
MOVE-CORRESPONDING gt_cdhp TO gt_show.
READ TABLE it_user WITH KEY bname = gt_cdhp-username BINARY SEARCH.
IF sy-subrc = 0.
gt_show-name_text = it_user-name_text.
ENDIF.
IF gt_show-name_text NOT IN s_uname[] AND gt_cdhp-username NOT IN s_uname[].
CLEAR gt_cdhp.
CONTINUE.
ENDIF.
CASE gt_cdhp-fname.
WHEN 'CMWAE' .
gt_show-fname = '货币'.
WHEN 'BSTKD' .
gt_show-fname = '客户参考'.
WHEN 'ZTERM' .
gt_show-fname = '付款方式'.
WHEN 'KUNNR' .
IF gt_cdhp-tabname = 'VBAK'.
gt_show-fname = '售达方'.
ELSEIF gt_cdhp-tabname = 'VBPA'..
gt_show-fname = '送达方'.
ENDIF.
WHEN 'MATNR' .
gt_show-fname = '物料'.
WHEN 'KDMAT' .
gt_show-fname = '客户物料编号'.
WHEN 'WMENG' .
gt_show-fname = '订单数量'.
WHEN 'CMPRE' .
gt_show-fname = '金额'.
WHEN 'EDATU' .
gt_show-fname = '首个交货日期'.
WHEN OTHERS.
gt_show-fname = ''.
ENDCASE.
IF gt_show-fname = ''.
CONTINUE.
ENDIF.
gt_show-posnr = gt_show-tabkey+13(6).
gt_show-etenr = gt_show-tabkey+19(4).
APPEND gt_show.
CLEAR:gt_cdhp, gt_show .
ENDLOOP.
LOOP at gt_show.
READ TABLE LT_ZVBAP INTO DATA(LS_ZVBAP) WITH KEY VBELN = gt_show-objectid
POSNR = gt_show-POSNR BINARY SEARCH.
IF sy-subrc = 0.
gt_show-MATNR = LS_ZVBAP-matnr.
gt_show-MAKTX = LS_ZVBAP-ARKTX.
gt_show-NETWR = LS_ZVBAP-NETWR.
gt_show-WAERK = LS_ZVBAP-WAERK.
gt_show-VKBUR = LS_ZVBAP-VKBUR_ANA.
gt_show-VKGRP = LS_ZVBAP-VKGRP_ANA.
ENDIF.
READ TABLE LT_ZVBAP INTO DATA(LS_ZVBAP1) WITH KEY VBELN = gt_show-objectid BINARY SEARCH.
IF sy-subrc = 0.
gt_show-KUNNR = LS_ZVBAP1-KUNNR_ANA.
endif.
MODIFY gt_show.
endloop.
LOOP at gt_show.
READ TABLE LT_TVGRT INTO DATA(LS_TVGRT) WITH KEY VKGRP = gt_show-VKGRP
BINARY SEARCH.
IF sy-subrc = 0.
gt_show-BEZEI1 = LS_TVGRT-BEZEI.
ENDIF.
READ TABLE LT_TVKBT INTO DATA(LS_TVKBT) WITH KEY VKBUR = gt_show-VKBUR
BINARY SEARCH.
IF sy-subrc = 0.
gt_show-BEZEI = LS_TVKBT-BEZEI.
ENDIF.
READ TABLE LT_KNA1 INTO DATA(LS_KNA1) WITH KEY KUNNR = gt_show-KUNNR
BINARY SEARCH.
IF sy-subrc = 0.
gt_show-name1 = LS_KNA1-name1.
ENDIF.
MODIFY gt_show.
endloop.
ENDFORM.
FORM fvm_alv .
PERFORM set_layout.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SET_LAYOUT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM set_layout .
gs_layout-no_toolbar = 'X'.
gs_layout-cwidth_opt = 'X'.
gs_layout-zebra = 'X'.
gs_layout-box_fname = 'BOX'.
REFRESH gt_fcat_lvc .
set_fieldcat:
'KUNNR' '' '客户' '' 'X' '' '',
'NAME1' '' '客户名称' '' 'X' '' '',
'OBJECTID' '' '销售订单' '' 'X' '' '',
* 'OBJECTCLAS' '' '更改文档对象' '' 'X' '' '',
* 'CHANGENR' '' '文档编号' '' 'X' '' '',
* 'TABKEY' '' '表键' '' 'X' '' '',
'POSNR' '' '项目' '' 'X' '' '',
'VKBUR' '' '销售办公室' '' 'X' '' '',
'BEZEI' '' '销售办公室描述' '' 'X' '' '',
'VKGRP' '' '销售组' '' 'X' '' '',
'BEZEI1' '' '销售组描述' '' 'X' '' '',
'MATNR' '' '物料' '' 'X' '' '',
'MAKTX' '' '物料描述' '' 'X' '' '',
'NETWR' '' '订单未税金额' '' 'X' '' '',
'WAERK' '' '币别' '' 'X' '' '',
'USERNAME' '' '用户' '' 'X' '' '',
'NAME_TEXT' '' '用户名' '' 'X' '' '',
'UDATE' '' '日期' '' 'X' '' '',
'UTIME' '' '时间' '' 'X' '' '',
'TCODE' '' '事务码' '' 'X' '' '',
'TABNAME' '' '表名' '' 'X' '' '',
'FNAME' '' '字段名' '' 'X' '' '',
* 'CHNGIND' '' '更改标志' '' 'X' '' '',
'VALUE_NEW' '' '新值' '' 'X' '' '',
'VALUE_OLD' '' '旧值' '' 'X' '' '' .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
* i_callback_pf_status_set = 'FRM_PF_STATUS'
* i_callback_user_command = 'FRM_USER_COMMAND'
is_layout_lvc = gs_layout
it_fieldcat_lvc = gt_fcat_lvc
i_save = 'A'
TABLES
t_outtab = gt_show
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FVM_UNAME
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM fvm_uname .
DATA gc_string TYPE string .
RANGES: gs_uname FOR gt_show-name_text.
LOOP AT s_uname . "大小写
gc_string = s_uname-low .
TRANSLATE gc_string TO UPPER CASE .
IF gc_string <> s_uname-low .
gs_uname-sign = 'I'.
gs_uname-option = 'EQ'.
gs_uname-low = gc_string. "大写的
APPEND gs_uname .
ENDIF.
ENDLOOP.
LOOP AT gs_uname.
APPEND gs_uname TO s_uname .
ENDLOOP.
SELECT usr21~bname
usr21~persnumber
adrp~name_first
adrp~name_last
INTO CORRESPONDING FIELDS OF TABLE it_user
FROM usr21
INNER JOIN adrp
ON usr21~persnumber = adrp~persnumber .
SORT it_user BY bname .
LOOP AT it_user .
CONCATENATE it_user-name_last it_user-name_first INTO it_user-name_text.
MODIFY it_user.
ENDLOOP .
ENDFORM.
FORM fvm_getlikp.
SELECT
cdhdr~objectclas
cdhdr~objectid
cdhdr~changenr
cdhdr~username
cdhdr~udate
cdhdr~utime
cdhdr~tcode
cdhdr~planchngnr
cdhdr~act_chngno
cdhdr~was_plannd
cdhdr~change_ind
cdhdr~langu
cdhdr~version
cdpos~tabname
cdpos~tabkey
cdpos~fname
cdpos~chngind
cdpos~text_case
cdpos~unit_old
cdpos~unit_new
cdpos~cuky_old
cdpos~cuky_new
cdpos~value_new
cdpos~value_old
INTO CORRESPONDING FIELDS OF TABLE gt_LIKP
FROM cdhdr
INNER JOIN cdpos ON cdpos~objectclas = cdhdr~objectclas
AND cdpos~objectid = cdhdr~objectid
AND cdpos~changenr = cdhdr~changenr
WHERE cdhdr~objectid IN s_vbeln1
AND cdhdr~udate IN s_datum1
AND cdhdr~objectclas = 'LIEFERUNG' "交货单
AND cdhdr~langu = sy-langu
AND cdpos~fname IN ('CMNGV','LFIMG','KUNNR','WADAT_IST','LGORT','WBSTK','SPE_WAUHR_IST','AMTBL','CMGST').
SORT gt_cdhp BY objectid tabkey udate utime.
* SELECT
* VKBUR_ANA ,"销售办事处
* VKGRP_ANA ,
* VBELN , "销售凭证
* POSNR , "凭证项目
* MATNR , "物料编号
* ARKTX , "物料描述
* NETWR , "订单未税金额
* WAERK , "币别
* KUNNR_ANA
*
* INTO TABLE @DATA(LT_ZVBAP1)
* FROM VBAP
** INNER JOIN TVGRT on TVGRT~VKGRP = vbap~VKGRP_ANA
* WHERE
* VBAP~VBELN in @s_vbeln1.
*
* sort LT_ZVBAP1 by VBELN POSNR.
SELECT
VBELN,
KUNNR
INTO TABLE @DATA(LT_LIKP)
FROM LIKP
WHERE
LIKP~VBELN in @S_VBELN1.
SELECT KUNNR , NAME1
INTO TABLE @DATA(LT_ZKNA1)
FROM KNA1
FOR ALL ENTRIES IN @LT_LIKP
WHERE
KNA1~KUNNR = @LT_LIKP-KUNNR .
SORT LT_ZKNA1 by kunnr.
SELECT
VBELN ,
POSNR,
matnr,
ARKTX ,
LFIMG
INTO TABLE @DATA(LT_LIPS)
FROM LIPS
WHERE
LIPS~VBELN in @s_vbeln1.
sort LT_LIPS by VBELN POSNR..
LOOP AT gt_LIKP .
MOVE-CORRESPONDING gt_LIKP TO it_show.
READ TABLE it_user1 WITH KEY bname = gt_LIKP-username BINARY SEARCH.
IF sy-subrc = 0.
it_show-name_text = it_user1-name_text.
ENDIF.
IF it_show-name_text NOT IN s_uname1[] AND gt_LIKP-username NOT IN s_uname1[].
CLEAR gt_LIKP.
CONTINUE.
ENDIF.
CASE gt_LIKP-fname.
WHEN 'CMNGV' .
it_show-fname = '计划交货日期'.
WHEN 'WADAT_IST' .
it_show-fname = '实际发货日期'.
WHEN 'LFIMG' .
it_show-fname = '交货数量'.
WHEN 'KUNNR' .
IF gt_LIKP-tabname = 'VBAK'.
it_show-fname = '售达方'.
ELSEIF gt_LIKP-tabname = 'VBPA'..
it_show-fname = '送达方'.
ENDIF.
WHEN 'LGORT' .
it_show-fname = '库存地点'.
WHEN 'WBSTK' .
it_show-fname = '货物移动状态'.
WHEN 'SPE_WAUHR_IST' .
it_show-fname = '发货时间'.
WHEN 'AMTBL' .
it_show-fname = '已批准凭证信贷值'.
WHEN 'CMGST' .
it_show-fname = '信用检查的总体状态'.
WHEN OTHERS.
it_show-fname = ''.
ENDCASE.
IF it_show-fname = ''.
CONTINUE.
ENDIF.
it_show-posnr = it_show-tabkey+13(6).
it_show-etenr = it_show-tabkey+19(4).
APPEND it_show.
CLEAR:gt_likp, it_show .
ENDLOOP.
LOOP at it_show.
READ TABLE LT_LIPS INTO DATA(LS_LIPS) WITH KEY VBELN = it_show-objectid
POSNR = it_show-POSNR .
IF sy-subrc = 0.
it_show-MATNR = LS_LIPS-MATNR.
it_show-MAKTX = LS_LIPS-ARKTX.
it_show-LFIMG = LS_LIPS-LFIMG.
ENDIF.
READ TABLE LT_LIKP INTO DATA(LS_LIKP) WITH KEY VBELN = it_show-objectid.
IF sy-subrc = 0.
it_show-KUNNR = LS_LIKP-KUNNR.
ENDIF.
MODIFY it_show.
READ TABLE LT_ZKNA1 INTO DATA(LS_ZKNA1) WITH KEY KUNNR = it_show-KUNNR.
IF sy-subrc = 0.
it_show-NAME1 = LS_ZKNA1-NAME1.
ENDIF.
MODIFY it_show.
ENDLOOP.
ENDFORM.
FORM fvm_uname1 .
DATA gc_string1 TYPE string .
RANGES: gs_uname1 FOR it_show-name_text.
LOOP AT s_uname1 . "大小写
gc_string1 = s_uname1-low .
TRANSLATE gc_string1 TO UPPER CASE .
IF gc_string1 <> s_uname1-low .
gs_uname1-sign = 'I'.
gs_uname1-option = 'EQ'.
gs_uname1-low = gc_string1. "大写的
APPEND gs_uname1 .
ENDIF.
ENDLOOP.
LOOP AT gs_uname1.
APPEND gs_uname1 TO s_uname1 .
ENDLOOP.
SELECT usr21~bname
usr21~persnumber
adrp~name_first
adrp~name_last
INTO CORRESPONDING FIELDS OF TABLE it_user1
FROM usr21
INNER JOIN adrp
ON usr21~persnumber = adrp~persnumber .
SORT it_user1 BY bname .
LOOP AT it_user1 .
CONCATENATE it_user1-name_last it_user1-name_first INTO it_user1-name_text.
MODIFY it_user1.
ENDLOOP .
ENDFORM.
FORM fvm_alv1 .
gs_layout-no_toolbar = 'X'.
gs_layout-cwidth_opt = 'X'.
gs_layout-zebra = 'X'.
gs_layout-box_fname = 'BOX'.
REFRESH gt_fcat_lvc .
set_fieldcat:
'KUNNR' '' '送达方' '' 'X' '' '',
'NAME1' '' '送达方名称' '' 'X' '' '',
'OBJECTID' '' '交货单' '' 'X' '' '',
'POSNR' '' '项目' '' 'X' '' '',
'LFIMG' '' '交货数量' '' 'X' '' '',
'MATNR' '' '物料' '' 'X' '' '',
'MAKTX' '' '物料描述' '' 'X' '' '',
'USERNAME' '' '用户' '' 'X' '' '',
'NAME_TEXT' '' '用户名' '' 'X' '' '',
'UDATE' '' '日期' '' 'X' '' '',
'UTIME' '' '时间' '' 'X' '' '',
'TCODE' '' '事务码' '' 'X' '' '',
'TABNAME' '' '表名' '' 'X' '' '',
'FNAME' '' '字段名' '' 'X' '' '',
* 'CHNGIND' '' '更改标志' '' 'X' '' '',
'VALUE_NEW' '' '新值' '' 'X' '' '',
'VALUE_OLD' '' '旧值' '' 'X' '' '' .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
* i_callback_pf_status_set = 'FRM_PF_STATUS'
* i_callback_user_command = 'FRM_USER_COMMAND'
is_layout_lvc = gs_layout
it_fieldcat_lvc = gt_fcat_lvc
i_save = 'A'
TABLES
t_outtab = it_show
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
更多SAP文章请点击
更多SAP文章更新,大家一起学习进步!
文章中如有错误处。敬请指正!
搜索公众号:SAP资料文库
微信号:SPRO_PP
写于:深圳福田
时间:2024-04-24