供应商主数据报表
*---------------------------------------------------------*
* 程序名称:供应商主数据报表
* 程序名: ZMMR0022
*---------------------------------------------------------*
* 概要说明
*---------------------------------------------------------*
* 物料主数据报表
*---------------------------------------------------------*
REPORT zmmr0022.
TABLES:but000,
lfa1,
lfm1,
but0bk,
lfb1.
"结构
TYPES: BEGIN OF ty_data,
sel TYPE char1,
bu_group TYPE but000-bu_group,
"ktokk TYPE lfa1-ktokk , "供应商账户组
partner TYPE but000-partner , "SAP供应商编号
name_org1 TYPE but000-name_org1 , "供应商全称
name_org2 TYPE but000-name_org2 , "供应商全称
zname_org TYPE c LENGTH 80 , "供应商全称
bu_sort1_txt TYPE but000-bu_sort1 , "简称(搜索项)
loevm TYPE lfa1-loevm , "有效性
zsl TYPE but000-zsl , "税率
zgysjbm TYPE but000-zgysjbm , "旧系统编码
ztjfl TYPE but000-ztjfl , "统计分类
zlxr TYPE but000-zlxr , "联系人
zlxrdh TYPE but000-zlxrdh , "联系人电话
zlxryx TYPE but000-zlxryx , "联系人邮箱
zsmzq TYPE but000-zsmzq , "供应商生命周期
mob_number TYPE lfa1-telf1 , "公司电话
smtp_addr TYPE adr6-smtp_addr , "公司邮箱
street TYPE lfa1-stras , "供应商地址(街道)
city1 TYPE lfa1-ort01 , "城市
country TYPE lfa1-land1 , "国家
taxnumxl TYPE dfkkbptaxnum-taxnumxl, "纳税人登记号
waers TYPE lfm1-waers , "订单货币
zterm TYPE lfm1-zterm , "付款条件
title_medi TYPE but000-title , "称谓文本
langu TYPE lfa1-spras , "语言
akont TYPE lfb1-akont , "统驭科目
zuawa TYPE lfb1-zuawa , "排序码
webre TYPE lfm1-webre , "基于收货的发票校验
bkvid TYPE but0bk-bkvid , "标识
banks TYPE lfbk-banks , "国家
bankl TYPE lfbk-bankl , "银行代码
* bankn TYPE lfbk-bankn , "银行账户
bankn TYPE char38 , "银行账户
koinh TYPE lfbk-koinh , "银行户主
accname TYPE lfbk-ebpp_accname , "账户名称
bkref TYPE but0bk-bkont , "启用/禁用
bkreft TYPE but0bk-bkref , "启用/禁用
bkont TYPE but0bk-bkont , "启用/禁用
END OF ty_data.
DATA: gt_data TYPE STANDARD TABLE OF ty_data,
gs_data TYPE ty_data.
DATA: gt_data2 TYPE STANDARD TABLE OF ty_data,
gs_data2 TYPE ty_data.
DATA:gs_layout TYPE lvc_s_layo,
gs_fieldcat TYPE lvc_s_fcat,
gt_fieldcat TYPE lvc_t_fcat.
*&--------------------------------------------------------------------*
** Macro
**&-------------------------------------------------------------------*
DEFINE set_catalog.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = &1.
gs_fieldcat-outputlen = &2.
gs_fieldcat-ref_table = &3.
gs_fieldcat-ref_field = &4.
gs_fieldcat-cfieldname = &5.
gs_fieldcat-scrtext_s = gs_fieldcat-scrtext_m = gs_fieldcat-scrtext_l = &6.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
END-OF-DEFINITION.
*---------------------------------------------------------------------*
* SELECTION-SCREEN *
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: s_partn FOR but000-partner.
SELECT-OPTIONS: p_name FOR but000-name1_text NO INTERVALS .
PARAMETERS: p1 RADIOBUTTON GROUP red DEFAULT 'X',
p2 RADIOBUTTON GROUP red.
SELECTION-SCREEN END OF BLOCK bl1.
*---------------------------------------------------------------------*
* INITIALIZATION *
*---------------------------------------------------------------------*
INITIALIZATION.
PERFORM frm_initialization.
*---------------------------------------------------------------------*
* START-OF-SELECTION. *
*---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM frm_get_data.
*---------------------------------------------------------------------*
* END-OF-SELECTION. *
*---------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM frm_show_data.
*&---------------------------------------------------------------------*
*& Form frm_get_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_get_data .
SELECT
but000~partner,
concat( but000~name_org1,but000~name_org2 ) AS zname_org,
but000~bu_sort1 AS bu_sort1_txt,
but000~zsl ,
but000~zgysjbm,
but000~ztjfl ,
but000~zlxr ,
but000~zlxrdh ,
but000~zlxryx ,
but000~zsmzq ,
but000~title AS title_medi,
* but000~bkvid AS bkvid,
* but000~BKONT AS bkref,
but000~bu_group,
"lfa1~ktokk ,
lfa1~loevm ,
lfa1~telf1 AS mob_number,
lfa1~stras AS street,
lfa1~ort01 AS city1,
lfa1~land1 AS country,
lfa1~spras AS langu,
adr6~smtp_addr
FROM lfa1
INNER JOIN cvi_vend_link ON cvi_vend_link~vendor = lfa1~lifnr
INNER JOIN but000 ON but000~partner_guid = cvi_vend_link~partner_guid
LEFT JOIN adr6 ON adr6~addrnumber = lfa1~adrnr
WHERE but000~partner IN @s_partn
INTO CORRESPONDING FIELDS OF TABLE @gt_data.
SORT gt_data BY partner.
IF gt_data IS NOT INITIAL.
SELECT
lfbk~lifnr ,
lfbk~banks ,
lfbk~bankl ,
lfbk~bankn ,
lfbk~koinh ,
lfbk~BKONT
* lfbk~ebpp_accname AS accname
INTO TABLE @DATA(lt_lfbk)
FROM lfbk
FOR ALL ENTRIES IN @gt_data
WHERE lfbk~lifnr = @gt_data-partner.
SORT lt_lfbk BY lifnr.
SELECT
dfkkbptaxnum~partner,
dfkkbptaxnum~taxnumxl
INTO TABLE @DATA(lt_dfkkbptaxnum)
FROM dfkkbptaxnum
FOR ALL ENTRIES IN @gt_data
WHERE dfkkbptaxnum~partner = @gt_data-partner.
SORT lt_dfkkbptaxnum BY partner.
SELECT
lfb1~lifnr,
lfb1~akont,
lfb1~zuawa
INTO TABLE @DATA(lt_lfb1)
FROM lfb1
FOR ALL ENTRIES IN @gt_data
WHERE lfb1~lifnr = @gt_data-partner.
SORT lt_lfb1 BY lifnr.
SELECT
lfm1~lifnr,
lfm1~waers,
lfm1~webre,
lfm1~zterm
INTO TABLE @DATA(lt_lfm1)
FROM lfm1
FOR ALL ENTRIES IN @gt_data
WHERE lfm1~lifnr = @gt_data-partner.
SORT lt_lfm1 BY lifnr.
SELECT
but0bk~partner,
but0bk~bkvid,
but0bk~bkref,
but0bk~accname,
but0bk~bkont
INTO TABLE @DATA(lt_but0bk)
FROM but0bk
FOR ALL ENTRIES IN @gt_data
WHERE but0bk~partner = @gt_data-partner.
SORT lt_but0bk BY partner.
LOOP AT gt_data ASSIGNING FIELD-SYMBOL(<fs_data>).
IF <fs_data>-zname_org IN p_name.
ELSE.
DELETE gt_data.
CONTINUE.
ENDIF.
READ TABLE lt_dfkkbptaxnum INTO DATA(ls_dfkkbptaxnum) WITH KEY partner = <fs_data>-partner BINARY SEARCH.
IF sy-subrc = 0.
<fs_data>-taxnumxl = ls_dfkkbptaxnum-taxnumxl.
ENDIF.
READ TABLE lt_lfm1 INTO DATA(ls_lfm1) WITH KEY lifnr = <fs_data>-partner BINARY SEARCH.
IF sy-subrc = 0.
<fs_data>-waers = ls_lfm1-waers.
<fs_data>-webre = ls_lfm1-webre.
<fs_data>-zterm = ls_lfm1-zterm.
ENDIF.
READ TABLE lt_lfb1 INTO DATA(ls_lfb1) WITH KEY lifnr = <fs_data>-partner BINARY SEARCH.
IF sy-subrc = 0.
<fs_data>-akont = ls_lfb1-akont.
<fs_data>-zuawa = ls_lfb1-zuawa.
ENDIF.
READ TABLE lt_but0bk INTO DATA(ls_but0bk) WITH KEY partner = <fs_data>-partner BINARY SEARCH.
IF sy-subrc = 0.
<fs_data>-bkvid = ls_but0bk-bkvid.
<fs_data>-bkref = ls_but0bk-bkont.
<fs_data>-accname = ls_but0bk-accname.
* <fs_data>-bankn = <fs_data>-bankn && ls_but0bk-bkref.
ENDIF.
LOOP AT lt_lfbk INTO DATA(ls_lfbk) WHERE lifnr = <fs_data>-partner.
MOVE-CORRESPONDING <fs_data> TO gs_data2.
MOVE-CORRESPONDING ls_lfbk TO gs_data2.
READ TABLE lt_but0bk INTO ls_but0bk WITH KEY partner = <fs_data>-partner BINARY SEARCH.
IF sy-subrc = 0.
gs_data2-bankn = gs_data2-bankn && ls_but0bk-bkref.
ENDIF.
* gs_data2-accname = ls_lfbk-accname.
APPEND gs_data2 TO gt_data2.
CLEAR gs_data2.
ENDLOOP.
ENDLOOP.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_show_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_show_data .
gs_layout-zebra = 'X'.
gs_layout-cwidth_opt = 'X'.
gs_layout-box_fname = 'SEL'.
IF p1 = 'X'.
set_catalog:
'BU_GROUP ' '' 'BUT000 ' 'BU_GROUP ' '' '业务伙伴分组',
'PARTNER ' '' 'BUT000' 'PARTNER ' '' 'SAP供应商编号',
* 'NAME_ORG1 ' '' 'BUT000' 'NAME_ORG1 ' '' '供应商全称',
* 'NAME_ORG2 ' '' 'BUT000' 'NAME_ORG2 ' '' '供应商全称',
'ZNAME_ORG ' '' 'BUT000' 'NAME1_TEXT ' '' '供应商全称',
'BU_SORT1_TXT' '' 'BUT000' 'BU_SORT1 ' '' '简称(搜索项)',
'LOEVM ' '' 'LFA1 ' 'LOEVM ' '' '有效性',
'ZSL ' '' 'BUT000' 'ZSL ' '' '税率',
'ZGYSJBM ' '' 'BUT000' 'ZGYSJBM ' '' '旧系统编码',
'ZTJFL ' '' 'BUT000' 'ZTJFL ' '' '统计分类',
'ZLXR ' '' 'BUT000' 'ZLXR ' '' '联系人',
'ZLXRDH ' '' 'BUT000' 'ZLXRDH ' '' '联系人电话',
'ZLXRYX ' '' 'BUT000' 'ZLXRYX ' '' '联系人邮箱',
'ZSMZQ ' '' 'BUT000' 'ZSMZQ ' '' '供应商生命周期',
'MOB_NUMBER ' '' 'LFA1 ' 'TELF1 ' '' '公司电话',
'SMTP_ADDR ' '' 'ADR6 ' 'SMTP_ADDR ' '' '公司邮箱',
'STREET ' '' 'LFA1 ' 'STRAS ' '' '供应商地址(街道)',
'CITY1 ' '' 'LFA1 ' 'ORT01 ' '' '城市',
'COUNTRY ' '' 'LFA1 ' 'LAND1 ' '' '国家',
'TAXNUMXL ' '' 'DFKKBPTAXNUM' 'TAXNUMXL ' '' '纳税人登记号',
'WAERS ' '' 'LFM1 ' 'WAERS ' '' '订单货币',
'ZTERM ' '' 'LFM1 ' 'ZTERM ' '' '付款条件',
'TITLE_MEDI ' '' 'BUT000' 'TITLE ' '' '称谓文本',
'LANGU ' '' 'LFA1 ' 'SPRAS ' '' '语言',
'AKONT ' '' 'LFB1 ' 'AKONT ' '' '统驭科目',
'ZUAWA ' '' 'LFB1 ' 'ZUAWA ' '' '排序码',
'WEBRE ' '' 'LFM1 ' 'WEBRE ' '' '基于收货的发票校验',
'BKVID ' '' 'BUT0BK' 'BKVID ' '' '标识',
* 'BANKS ' '' 'LFBK ' 'BANKS ' '' '国家',
* 'BANKL ' '' 'LFBK ' 'BANKL ' '' '银行代码',
* 'BANKN ' '' 'LFBK ' 'BANKN ' '' '银行账户',
* 'KOINH ' '' 'LFBK ' 'KOINH ' '' '银行户主',
* 'ACCNAME ' '' 'LFBK ' 'EBPP_ACCNAME ' '' '账户名称',
'BKREF ' '' 'BUT0BK' 'BKONT ' '' '启用/禁用'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
* i_callback_pf_status_set = 'FRM_SET_STATUS'
* i_callback_user_command = 'FRM_USER_COMMAND'
is_layout_lvc = gs_layout
it_fieldcat_lvc = gt_fieldcat
i_save = 'A'
TABLES
t_outtab = gt_data
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.
ELSEIF p2 = 'X'.
set_catalog:
'PARTNER ' '' 'BUT000' 'PARTNER ' '' 'SAP供应商编号',
'ZNAME_ORG ' '' 'BUT000' 'NAME1_TEXT ' '' '供应商全称',
'BANKS ' '' 'LFBK ' 'BANKS ' '' '国家',
'BANKL ' '' 'LFBK ' 'BANKL ' '' '银行代码',
'BANKN ' '' 'LFBK ' 'BANKN ' '' '银行账户',
'KOINH ' '' 'LFBK ' 'KOINH ' '' '银行户主',
* 'BKREFT ' '' 'BUT0BK' 'BKREF ' '' '参考明细',
'ACCNAME ' '' 'LFBK ' 'EBPP_ACCNAME ' '' '账户名称',
'BKONT ' '' 'BUT0BK' 'BKONT ' '' '启用/禁用'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'FRM_SET_STATUS'
i_callback_user_command = 'FRM_USER_COMMAND'
is_layout_lvc = gs_layout
it_fieldcat_lvc = gt_fieldcat
i_save = 'A'
TABLES
t_outtab = gt_data2
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.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_initialization
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_initialization .
CLEAR:gs_layout,gt_fieldcat[],gt_data[].
ENDFORM.
FORM frm_set_status USING extab TYPE slis_t_extab.
DATA:rs_extab TYPE slis_extab.
SET PF-STATUS 'S1000' EXCLUDING extab...
* SET TITLEBAR 'S1000'.
ENDFORM.
FORM frm_user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
DATA rs_selfield TYPE slis_selfield.
DATA: ls_stbl TYPE lvc_s_stbl.
*获取屏幕修改后的值
DATA: lr_grid TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lr_grid.
CALL METHOD lr_grid->check_changed_data.
* CASE ucomm.
* WHEN 'CXTS'. "数据推送
* CLEAR gt_alv1[].
* gt_alv1[] = gt_alv[].
* DELETE gt_alv1 WHERE box = ''." OR zfhzt = 'S'.
*
* IF gt_alv1[] IS INITIAL.
* MESSAGE '请选择推送数据' TYPE 'S' DISPLAY LIKE 'E'.
* EXIT.
* ELSE.
* PERFORM frm_send USING ''.
* ENDIF.
* WHEN '&IC1'. "双击事件
* WHEN OTHERS.
* ENDCASE.
rs_selfield-refresh = 'X'.
rs_selfield-col_stable = 'X'.
rs_selfield-row_stable = 'X'.
ls_stbl-row = 'X'." 基于行的稳定刷新
ls_stbl-col = 'X'." 基于列稳定刷新
CALL METHOD lr_grid->refresh_table_display
EXPORTING
is_stable = ls_stbl.
ENDFORM.
原文地址:https://blog.csdn.net/twins622/article/details/145163386
免责声明:本站文章内容转载自网络资源,如侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!