*&---------------------------------------------------------------------*
*& Report ZMM_CGDDFXB
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zmmr068.

TABLES: ekpo,lfa1,ekbe,ztmm_insp_key,rseg,ekko,t001w.

"声明上半部分内表
TYPES: BEGIN OF itaa,
ebeln TYPE ebeln, "采购凭证号
lifnr TYPE lifnr, "供应商
name1 TYPE name1, "供应商描述
ebelp TYPE ebelp, "行项目号
matnr TYPE matnr, "物料编码
maktx TYPE maktx, "物料描述
werks TYPE werks,
lgort LIKE ekpo-lgort,
menge LIKE ekpo-menge,
bewtp LIKE ekbe-bewtp,
menge_sh LIKE ekbe-menge, "收货数量
menge_yk LIKE ekbe-menge, "已开发票数量
menge_xk LIKE ekbe-menge, "需开发票数量 = 收货数量 - 已开发票数量
menge_fh LIKE ekbe-menge, "发货数量
menge_yz LIKE ekbe-menge, "预制发票数量
dmbtr_yz LIKE ekbe-wrbtr, "预制发票金额
dmbtr_sh TYPE ekbe-dmbtr, "收货金额
dmbtr_yk TYPE ekbe-dmbtr, "已开发票金额
dmbtr_xk TYPE ekbe-dmbtr, "需开发票金额 = 收货金额 - 已开发票金额
dmbtr_fh TYPE ekbe-dmbtr, "发货金额
zzfhl LIKE ztmm_insp_key-zzfhl,
zzdbz LIKE ztmm_insp_key-zzdbz,
zzbd LIKE ztmm_insp_key-zzbd,
zzwsw LIKE ztmm_insp_key-zzwsw,
zzgls LIKE ztmm_insp_key-zzgls,
zztxb LIKE ztmm_insp_key-zztxb,
zzgm LIKE ztmm_insp_key-zzgm,
belnr LIKE ekbe-belnr,
buzei LIKE ekbe-buzei,
matnr_re LIKE rseg-matnr,
maktx_re LIKE makt-maktx,
menge_ee LIKE ekbe-menge,
dmbtr LIKE ekbe-dmbtr,
belnr_fp LIKE rseg-belnr,
buzei_fp LIKE rseg-buzei,
menge_fp LIKE rseg-menge,
wrbtr LIKE rseg-wrbtr,
gjahr LIKE rseg-gjahr,
mwskz LIKE rseg-mwskz,
bwkey LIKE rseg-bwkey,
bukrs LIKE rseg-bukrs,
shkzg LIKE rseg-shkzg,
reslo LIKE ekpo-reslo, "发货库存地
budat LIKE ekbe-budat, "过账日期

zzzgxw LIKE ztmm003-zzzgxw,

END OF itaa,
BEGIN OF ty_ztmm003,
ebeln LIKE ztmm003-ebeln,
ebelp LIKE ztmm003-ebelp,
zzzgxw LIKE ztmm003-zzzgxw,
END OF ty_ztmm003.
DATA: gs_itaa TYPE itaa,
gt_itaa TYPE TABLE OF itaa WITH HEADER LINE,
gs_itab TYPE itaa,
gt_itab TYPE TABLE OF itaa WITH HEADER LINE,
gs_itac TYPE itaa,
gt_itac TYPE TABLE OF itaa WITH HEADER LINE.
DATA:gs_ztmm003 TYPE ty_ztmm003,
gt_ztmm003 TYPE TABLE OF ty_ztmm003.

DATA: fm_name TYPE rs38l_fnam.
DATA: i_fields TYPE lvc_t_fcat. "清单观察器控制的字段目录
DATA: i_grid_settings TYPE lvc_s_glay.
FIELD-SYMBOLS: <wa_fields> TYPE lvc_s_fcat. "ALV 控制: 字段目录
DATA:gt_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE, "通用类型
gt_fieldgroups_tab TYPE slis_t_sp_group_alv, "通用类型
gs_layout TYPE slis_layout_alv,
gs_sortfields_tab TYPE slis_t_sortinfo_alv WITH HEADER LINE,
gt_events TYPE slis_t_event,
gs_settings TYPE lvc_s_glay,
i_list_comments TYPE slis_t_listheader. "用来填充表单标题区域的数据类型
DATA:
cellcolor TYPE lvc_s_scol,
wa_fieldcat TYPE lvc_s_fcat,
wa_layout TYPE lvc_s_layo,
wa_layout1 TYPE lvc_s_layo,
t_fieldcat TYPE lvc_t_fcat,
t_fieldcat1 TYPE lvc_t_fcat,
gs_variant TYPE disvariant.
DATA:l_temp_head TYPE string.
DATA:l_temp_head1 TYPE string.
DATA: ebeln_e LIKE ekbe-ebeln,
ebelp_e LIKE ekbe-ebelp.

DATA: gt_structure TYPE lvc_t_fcat,
gt_structure1 TYPE lvc_t_fcat,
wa_structure TYPE lvc_s_fcat.

DATA:
* User Command
ok_code TYPE sy-ucomm,
* Reference Variable for Docking Container
r_dock_container TYPE REF TO cl_gui_docking_container,
r_dock_container1 TYPE REF TO cl_gui_docking_container,
* Reference Variable for alv grid
r_grid TYPE REF TO cl_gui_alv_grid,
r_grid1 TYPE REF TO cl_gui_alv_grid.
SELECTION-SCREEN BEGIN OF BLOCK aaa WITH FRAME TITLE text-001.
SELECT-OPTIONS s_bedat FOR ekko-bedat."采购订单凭证日期
SELECT-OPTIONS s_aedat FOR ekko-aedat."订单创建日期
SELECT-OPTIONS s_bukrs FOR rseg-bukrs."公司
SELECT-OPTIONS s_ebeln FOR ekbe-ebeln."采购凭证号
SELECT-OPTIONS s_bsart FOR ekko-bsart."凭证类型
SELECT-OPTIONS s_lifnr FOR ekko-lifnr."供应商
SELECT-OPTIONS s_werks FOR t001w-werks OBLIGATORY."工厂
SELECT-OPTIONS s_matnr FOR ekpo-matnr."物料
SELECT-OPTIONS s_lgort FOR ekpo-lgort."收货库存地
SELECT-OPTIONS s_reslo FOR ekpo-reslo."发货库存地
SELECT-OPTIONS s_gjahr FOR ekbe-gjahr NO-EXTENSION NO INTERVALS."凭证年度
SELECT-OPTIONS s_budat FOR ekbe-budat."过账日期
SELECTION-SCREEN END OF BLOCK aaa.

INITIALIZATION.

AT SELECTION-SCREEN.
DATA : l_message(20).
DATA: BEGIN OF lt_werks OCCURS 0,
werks TYPE werks_d,
END OF lt_werks.
CLEAR: lt_werks,lt_werks[].
SELECT werks
FROM t001w
INTO TABLE lt_werks
WHERE werks IN s_werks.
IF lt_werks[] IS INITIAL.
MESSAGE '没有符合条件的数据' TYPE 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
LOOP AT lt_werks.
AUTHORITY-CHECK OBJECT 'M_BEST_WRK'
ID 'WERKS' FIELD lt_werks-werks
ID 'ACTVT' DUMMY.
IF sy-subrc <> 0.
CLEAR l_message.
CONCATENATE '工厂:' lt_werks-werks ',访问权限不足!' INTO l_message.
MESSAGE l_message TYPE 'E'.
ENDIF.
* AUTHORITY-CHECK OBJECT 'M_RECH_WRK'
* ID 'WERKS' FIELD lt_werks-werks
* ID 'ACTVT' DUMMY.
* IF sy-subrc <> 0.
* CLEAR l_message.
* CONCATENATE '工厂:' lt_werks-werks ',访问权限不足!' INTO l_message.
* MESSAGE l_message TYPE 'E'.
* ENDIF.
ENDLOOP.

*开始事件
START-OF-SELECTION.
PERFORM get_data.
* PERFORM define_data.
PERFORM display_data.

END-OF-SELECTION.
CLASS cl_event_receiver DEFINITION.
PUBLIC SECTION.

" 声明单击事件的方法
METHODS handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id.
" 声明双击事件方法
METHODS handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
" 声明Toolbar事件方法
METHODS handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive.
" 声明USER-COMMAND 事件方法
METHODS handle_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS.
CLASS cl_event_receiver IMPLEMENTATION.

" 单击事件方法的实现
METHOD handle_hotspot_click.
CONDENSE e_row_id NO-GAPS.
CONDENSE e_column_id NO-GAPS.
MESSAGE i001(00) WITH '单击事件->行号:' e_row_id '、列名:' e_column_id.
ENDMETHOD. "handle_HOTSPOT_CLICK
" 双击事件方法的实现
METHOD handle_double_click.

CONDENSE e_row NO-GAPS.
CONDENSE e_column NO-GAPS.
IF e_column EQ 'EBELN'.
* CLEAR GS_ITAC-EBELN.
READ TABLE gt_itaa INTO gs_itaa INDEX e_row.
IF sy-subrc EQ 0.
CLEAR: ebeln_e, ebelp_e.
ebeln_e = gs_itaa-ebeln.
ebelp_e = gs_itaa-ebelp.
ENDIF.
PERFORM show_detail.
ENDIF.
ENDMETHOD. "handle_double_click
" 实现Toolbar事件方法
METHOD handle_toolbar.
DATA: ls_toolbar TYPE stb_button.
CLEAR: ls_toolbar.
ls_toolbar-butn_type = 3. " 分隔符
APPEND ls_toolbar TO e_object->mt_toolbar.
* CLEAR: ls_toolbar.
* ls_toolbar-function = 'DISP'. " 功能码
* ls_toolbar-icon = icon_display. " 图标名称
* ls_toolbar-quickinfo = '显示'. " 图标的提示信息
* ls_toolbar-butn_type = 0. " 0表示正常按钮
* ls_toolbar-disabled = ''. " X表示灰色,不可用
* ls_toolbar-text = '按钮1'. " 按钮上显示的文本
* APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
" 实现USER-COMMAND 事件方法
METHOD handle_command.
* CASE e_ucomm.
* WHEN '&DETA'.
* PERFORM show_detail." TABLES gt_itaa.
* ENDCASE.
ENDMETHOD. "HANDLE_COMMAND

ENDCLASS. "cl_event_receiver IMPLEMENTATION
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data .

* matnr_re LIKE rseg-matnr,
* maktx_re LIKE makt-maktx,
* menge_ee LIKE ekbe-menge,

SELECT ep~ebeln ek~lifnr ep~ebelp ep~matnr ep~werks ep~lgort ep~menge ep~reslo
ee~belnr ee~buzei ee~budat ee~bewtp ee~menge AS menge_ee ee~dmbtr ee~gjahr
FROM ekko AS ek
INNER JOIN ekpo AS ep
ON ek~ebeln = ep~ebeln
INNER JOIN ekbe AS ee
ON ep~ebeln = ee~ebeln AND ep~ebelp = ee~ebelp
INTO CORRESPONDING FIELDS OF TABLE gt_itaa
WHERE ek~bedat IN s_bedat AND ek~aedat IN s_aedat AND ek~bukrs IN s_bukrs
AND ee~ebeln IN s_ebeln AND ek~bsart IN s_bsart AND ek~lifnr IN s_lifnr
AND ep~werks IN s_werks AND ep~matnr IN s_matnr AND ee~gjahr IN s_gjahr
AND ee~budat IN s_budat AND ep~lgort IN s_lgort AND ep~reslo IN s_reslo.

SELECT ebeln ebelp zzzgxw
INTO CORRESPONDING FIELDS OF TABLE gt_ztmm003
FROM ztmm003.
SORT gt_itaa BY ebeln ebelp.
LOOP AT gt_itaa INTO gs_itaa.
READ TABLE gt_ztmm003 INTO gs_ztmm003 WITH KEY ebeln = gs_itaa-ebeln ebelp = gs_itaa-ebelp.
IF sy-subrc = 0.
gs_itaa-zzzgxw = gs_ztmm003-zzzgxw.
ENDIF.

* SELECT SINGLE matnr belnr buzei menge gjahr mwskz bwkey bukrs shkzg wrbtr
* FROM rseg
* INTO ( gs_itaa-matnr_re,gs_itaa-belnr_fp,gs_itaa-buzei_fp,gs_itaa-menge_fp
* ,gs_itaa-gjahr,gs_itaa-mwskz,gs_itaa-bwkey,gs_itaa-bukrs,
* gs_itaa-shkzg,gs_itaa-wrbtr )
* WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp.
SELECT SINGLE zzfhl zzdbz zzbd zzwsw zzgls zztxb zzgm
FROM ztmm_insp_key
INTO ( gs_itaa-zzfhl,gs_itaa-zzdbz,gs_itaa-zzbd,gs_itaa-zzwsw,gs_itaa-zzgls,gs_itaa-zztxb,gs_itaa-zzgm )
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp.
SELECT SINGLE name1
FROM lfa1
INTO gs_itaa-name1
WHERE lifnr = gs_itaa-lifnr.
SELECT SINGLE maktx
FROM makt
INTO gs_itaa-maktx_re
WHERE matnr = gs_itaa-matnr.
SELECT SINGLE maktx
FROM makt
INTO gs_itaa-maktx
WHERE matnr = gs_itaa-matnr.
"收货数量 汇总
DATA: menge_sh_s LIKE ekbe-menge,
menge_sh_h LIKE ekbe-menge.
SELECT SINGLE SUM( menge ) INTO menge_sh_s
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'E' AND shkzg EQ 'S'.
SELECT SINGLE SUM( menge ) INTO menge_sh_h
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'E' AND shkzg EQ 'H'.
gs_itaa-menge_sh = gs_itaa-menge_sh + menge_sh_s - menge_sh_h.
"已开发票数量 汇总
DATA: menge_yk_s LIKE ekbe-menge,
menge_yk_h LIKE ekbe-menge.
SELECT SINGLE SUM( menge ) INTO menge_yk_s
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'Q' AND shkzg EQ 'S'.
SELECT SINGLE SUM( menge ) INTO menge_yk_h
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'Q' AND shkzg EQ 'H'.
gs_itaa-menge_yk = gs_itaa-menge_yk + menge_yk_s - menge_yk_h.
"需开发票数量 = 收货数量 - 已开发票数量
gs_itaa-menge_xk = gs_itaa-menge_sh - gs_itaa-menge_yk.

"收货金额 汇总
DATA: dmbtr_sh_s LIKE ekbe-dmbtr,
dmbtr_sh_h LIKE ekbe-dmbtr.
SELECT SINGLE SUM( dmbtr ) INTO dmbtr_sh_s
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'E' AND shkzg EQ 'S'.
SELECT SINGLE SUM( dmbtr ) INTO dmbtr_sh_h
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'E' AND shkzg EQ 'H'.
gs_itaa-dmbtr_sh = gs_itaa-dmbtr_sh + dmbtr_sh_s - dmbtr_sh_h.
"已开发票金额汇总
DATA: dmbtr_yk_s LIKE ekbe-dmbtr,
dmbtr_yk_h LIKE ekbe-dmbtr.
SELECT SINGLE SUM( dmbtr ) INTO dmbtr_yk_s
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'Q' AND shkzg EQ 'S'.
SELECT SINGLE SUM( dmbtr ) INTO dmbtr_yk_h
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'Q' AND shkzg EQ 'H'.
gs_itaa-dmbtr_yk = gs_itaa-dmbtr_yk + dmbtr_yk_s - dmbtr_yk_h.
"需开发票金额
gs_itaa-dmbtr_xk = gs_itaa-dmbtr_sh - gs_itaa-dmbtr_yk.
"发货数量汇总
DATA: menge_fh_s LIKE ekbe-menge,
menge_fh_h LIKE ekbe-menge.
SELECT SINGLE SUM( menge ) INTO menge_fh_s
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'U' AND shkzg EQ 'S'.
SELECT SINGLE SUM( menge ) INTO menge_fh_h
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'U' AND shkzg EQ 'H'.
gs_itaa-menge_fh = gs_itaa-menge_fh + menge_fh_s - menge_fh_h.
"发货金额汇总
DATA: dmbtr_fh_s LIKE ekbe-dmbtr,
dmbtr_fh_h LIKE ekbe-dmbtr.
SELECT SINGLE SUM( dmbtr ) INTO dmbtr_fh_s
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'U' AND shkzg EQ 'S'.
SELECT SINGLE SUM( dmbtr ) INTO dmbtr_fh_h
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'U' AND shkzg EQ 'H'.
gs_itaa-dmbtr_fh = gs_itaa-dmbtr_fh + dmbtr_fh_s - dmbtr_fh_h.
"预制发票数量
DATA: menge_yz_s LIKE ekbe-menge,
menge_yz_h LIKE ekbe-menge.
SELECT SINGLE SUM( menge ) INTO menge_yz_s
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'T' AND shkzg EQ 'S'.
SELECT SINGLE SUM( menge ) INTO menge_yz_h
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'T' AND shkzg EQ 'H'.
gs_itaa-menge_yz = gs_itaa-menge_yz + menge_yz_s - menge_yz_h.
"预制发票金额
DATA: dmbtr_yz_s LIKE ekbe-dmbtr,
dmbtr_yz_h LIKE ekbe-dmbtr.
SELECT SINGLE SUM( wrbtr ) INTO dmbtr_yz_s
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'T' AND shkzg EQ 'S'.
SELECT SINGLE SUM( wrbtr ) INTO dmbtr_yz_h
FROM ekbe
WHERE ebeln = gs_itaa-ebeln AND ebelp = gs_itaa-ebelp
AND bewtp EQ 'T' AND shkzg EQ 'H'.
gs_itaa-dmbtr_yz = gs_itaa-dmbtr_yz + dmbtr_yz_s - dmbtr_yz_h.

MODIFY gt_itaa FROM gs_itaa.
ENDLOOP.
APPEND LINES OF gt_itaa TO gt_itac.

DELETE ADJACENT DUPLICATES FROM gt_itaa COMPARING ebeln ebelp.
ENDFORM.

*FORM set_pf_status USING rt_extab TYPE slis_t_extab.
* SET PF-STATUS 'STANDARD'.
*ENDFORM.
*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
DEFINE fill_alv.
wa_structure-fieldname = &1.
wa_structure-coltext = &2.
WA_STRUCTURE-NO_ZERO = &3.
wa_structure-DD_OUTLEN = &4.
wa_structure-FIX_COLUMN = &5.
append wa_structure to gt_structure.
CLEAR WA_STRUCTURE.
END-OF-DEFINITION.
DEFINE fill_alb.
wa_structure-fieldname = &1.
wa_structure-coltext = &2.
WA_STRUCTURE-NO_ZERO = &3.
wa_structure-DD_OUTLEN = &4.
append wa_structure to gt_structure1.
CLEAR WA_STRUCTURE.
END-OF-DEFINITION.
FORM display_data .

fill_alv:
'EBELN' '采购凭证号' 'X' '20' 'X',
'EBELP' '项目' 'X' '20' 'X',
'LIFNR' '供应商' 'X' '20' '',
'NAME1' '供应商描述' '' '20' '',
'MATNR' '物料' 'X' '20' '',
'MAKTX' '物料描述' '' '20' '',
'WERKS' '工厂' 'X' '20' '',
'LGORT' '收货库存地点' '' '20' '',
'RESLO' '发货库存地点' '' '20' '',
'MENGE' '采购订单数量' '' '20' '',
'MENGE_SH' '收货数量' '' '20' '',
'DMBTR_SH' '收货金额' '' '20' '',
'MENGE_YK' '已开发票数量' '' '20' '',
'DMBTR_YK' '已开发票金额' '' '20' '',
'MENGE_XK' '需开发票数量' '' '20' '',
'DMBTR_XK' '需开发票金额' '' '20' '',
'MENGE_YZ' '预制发票数量' '' '20' '',
'DMBTR_YZ' '预制发票金额' '' '20' '',
'MENGE_FH' '发货数量' '' '20' '',
'DMBTR_FH' '发货金额' '' '20' '',
'ZZFHL' '脂肪含量' '' '20' '',
'ZZDBZ' '蛋白质' '' '20' '',
'ZZBD' '冰点' '' '20' '',
'ZZWSW' '微生物' '' '20' '',
'ZZGLS' '公里数' '' '20' '',
'ZZTXB' '体细胞' '' '20' '',
'ZZGM' '规模' '' '20' '',
'ZZZGXW' '总固形物' '' '20' ''.

fill_alb:
'BELNR' '物料凭证' 'X' '20',
'BUZEI' '物料凭证项目' '' '20',
'BUDAT' '过账日期' '' '20',
'MATNR_RE' '物料编码' 'X' '20',
'MAKTX_RE' '物料描述' '' '20',
'MENGE_EE' '物料凭证数量' '' '20',
'DMBTR' '物料凭证金额' '' '20',
'BELNR_FP' '发票凭证' '' '20',
'BUZEI_FP' '发票凭证项目' '' '20',
'MENGE_FP' '发票数量' '' '20',
'WRBTR' '发票金额' '' '20',
'GJAHR' '会计年度' '' '20',
'MWSKZ' '税码' '' '20',
'BWKEY' '评估范围' '' '20',
'BUKRS' '公司代码' '' '20',
'SHKZG' '借方/贷方' '' '20'.

CALL SCREEN 100.

ENDFORM.
*&---------------------------------------------------------------------*
*& Module CREATE_OBJECTS OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'AAAAB'.
SET TITLEBAR 'AAA'.
ENDMODULE.
MODULE create_objects OUTPUT.
CHECK r_dock_container IS INITIAL.
* CHECK r_dock_container1 IS INITIAL.
DATA:gt_tools TYPE TABLE OF sy-ucomm.
DATA:event_receiver TYPE REF TO cl_event_receiver.
DATA:event_receiver1 TYPE REF TO cl_event_receiver.
CREATE OBJECT r_dock_container
EXPORTING
repid = sy-repid
dynnr = '0100'
side = cl_gui_docking_container=>dock_at_top
extension = 150
caption = '练习'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc <> 0.

* To Create the Grid Instance
CREATE OBJECT r_grid
EXPORTING
i_parent = r_dock_container
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc <> 0.

CREATE OBJECT event_receiver.
* " 注册事件handler方法
SET HANDLER event_receiver->handle_hotspot_click FOR r_grid.
SET HANDLER event_receiver->handle_double_click FOR r_grid.
SET HANDLER event_receiver->handle_toolbar FOR r_grid.
SET HANDLER event_receiver->handle_command FOR r_grid.

* DATA: l_temp TYPE string.
l_temp_head = lines( gt_itaa[] ).
*
* CLEAR l_temp.
* l_temp = lines( t_lips[] ).
CONCATENATE '采购凭证条目数:[' l_temp_head ']' INTO wa_layout-grid_title.
wa_layout-cwidth_opt = 'X'.
wa_layout-sel_mode = 'A'.
* Formatted Output Table is Sent to Control
CALL METHOD r_grid->set_table_for_first_display
EXPORTING
is_variant = gs_variant
i_default = 'X'
is_layout = wa_layout
i_save = 'A'
CHANGING
it_outtab = gt_itaa[]
it_fieldcatalog = gt_structure
* it_sort =
* it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.

CALL METHOD r_grid->set_toolbar_interactive.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc <> 0.
CLEAR wa_layout.

ENDMODULE.
*&---------------------------------------------------------------------*
*& Module CREATE_OBJECTS1 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE create_objects1 OUTPUT.
* CHECK r_dock_container1 IS INITIAL.
CHECK r_dock_container1 IS INITIAL.

CREATE OBJECT r_dock_container1
EXPORTING
repid = sy-repid
dynnr = '0100'
side = cl_gui_docking_container=>dock_at_top
extension = 150
caption = '练习1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc <> 0.

* To Create the Grid Instance
CREATE OBJECT r_grid1
EXPORTING
i_parent = r_dock_container1
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc <> 0.

CREATE OBJECT event_receiver.
" 注册事件handler方法
SET HANDLER event_receiver->handle_hotspot_click FOR r_grid1.
SET HANDLER event_receiver->handle_double_click FOR r_grid1.
SET HANDLER event_receiver->handle_toolbar FOR r_grid1.
SET HANDLER event_receiver->handle_command FOR r_grid1.

* DATA: l_temp TYPE string.
l_temp_head = lines( gt_itab[] ).
*
* CLEAR l_temp.
* l_temp = lines( t_lips[] ).
CONCATENATE '物料凭证条目数:[' l_temp_head ']' INTO wa_layout1-grid_title.
wa_layout1-cwidth_opt = 'X'.
wa_layout1-sel_mode = 'A'.
* Formatted Output Table is Sent to Control
CALL METHOD r_grid1->set_table_for_first_display
EXPORTING
is_variant = gs_variant
i_default = 'X'
is_layout = wa_layout1
i_save = 'A'
CHANGING
it_outtab = gt_itab[]
it_fieldcatalog = gt_structure1
* it_sort =
* it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.

CALL METHOD r_grid1->set_toolbar_interactive.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc <> 0.
CLEAR wa_layout1.

ENDMODULE.

MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN '&F03' ."OR 'F15' OR 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Form DEFINE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
*FORM define_data .
*
*ENDFORM.
*&---------------------------------------------------------------------*
*& Form SHOW_DETAIL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM show_detail .
CLEAR: gt_itab,gt_itab[].

LOOP AT gt_itac INTO gs_itac WHERE ebeln EQ ebeln_e AND ebelp EQ ebelp_e.
IF gs_itac-bewtp EQ 'E' OR gs_itac-bewtp EQ 'U'.
CLEAR: gs_itab.
gs_itab-belnr = gs_itac-belnr.
gs_itab-buzei = gs_itac-buzei.
gs_itab-budat = gs_itac-budat.
gs_itab-matnr_re = gs_itac-matnr.
gs_itab-maktx_re = gs_itac-maktx_re.
gs_itab-menge_ee = gs_itac-menge_ee.
gs_itab-dmbtr = gs_itac-dmbtr.
* gs_itab-belnr_fp = gs_itac-belnr_fp.
* gs_itab-buzei_fp = gs_itac-buzei_fp.
* gs_itab-menge_fp = gs_itac-menge_fp.
* gs_itab-wrbtr = gs_itac-wrbtr.
* gs_itab-gjahr = gs_itac-gjahr.
* gs_itab-bwkey = gs_itac-bwkey.
* gs_itab-bukrs = gs_itac-bukrs.
* gs_itab-shkzg = gs_itac-shkzg.
SELECT SINGLE belnr buzei menge wrbtr gjahr mwskz bwkey bukrs shkzg
FROM rseg
INTO (gs_itab-belnr_fp,gs_itab-buzei_fp,gs_itab-menge_fp,gs_itab-wrbtr,gs_itab-gjahr,gs_itab-mwskz
,gs_itab-bwkey,gs_itab-bukrs,gs_itab-shkzg)
WHERE lfbnr EQ gs_itac-belnr AND lfpos EQ gs_itac-buzei AND lfgja EQ gs_itac-gjahr.

APPEND gs_itab TO gt_itab.
ENDIF.
ENDLOOP.

CALL METHOD r_dock_container1->set_visible( '1' ).

PERFORM refresh_detail_alv.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form REFRESH_DETAIL_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM refresh_detail_alv .
DATA: stbl TYPE lvc_s_stbl.
DATA: l_line TYPE i,
l_temp TYPE string.

stbl-row = 'X'." 基于行的稳定刷新
stbl-col = 'X'." 基于列的稳定刷新

l_line = lines( gt_itab[] ).
l_temp = l_line.
CONCATENATE '物料凭证条目数:[' l_temp ']' INTO wa_layout1-grid_title.
wa_layout1-cwidth_opt = 'X'.
wa_layout1-sel_mode = 'A'.
CALL METHOD r_grid1->set_frontend_layout
EXPORTING
is_layout = wa_layout1.
CALL METHOD r_grid1->refresh_table_display
EXPORTING
is_stable = stbl.
FREE: stbl,l_line,l_temp.
ENDFORM.

SAP-采购订单跟踪报表的更多相关文章

  1. 【MM系列】SAP 采购订单的批量修改

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP 采购订单的批量修改   前言 ...

  2. 【MM系列】SAP 采购订单收货后不能修改价格的增强

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP 采购订单收货后不能修改价格的 ...

  3. SAP采购订单历史明细报表源代码(自己收藏)

    SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF } ...

  4. SAP采购订单入库后不允许修改单价增强

    需求:在根据采购订单做了入库凭证之后,如果用户反审批采购订单去修改单价,系统提示‘已收货,不允许修改单价’. 判断流程:是否有入库凭证 如果采购订单条件按采购信息记录定价,这个价格本来就不能修改,只能 ...

  5. SAP采购订单审批记录增强

    采购订单审核函数: BAPI_PO_RELEASE 结尾加上 ENHANCEMENT ZME28_PO. "active version DATA:LS_EKKO TYPE EKKO. DA ...

  6. SAP采购订单屏幕增强

    转自<http://blog.csdn.net/heng0757/article/details/8073875> 为采购订单增加一个页标签,在其中放入客户自定义字段, 1. CMOD 增 ...

  7. SAP 采购订单收货时报错:对于采购订单xxxx无收货可能

    因为这个问题查了挺长时间,所以写在博客里记录下. 报错详细: 每个公司的配置不同,我公司遇到的这个问题原因是这里的确认控制是从信息记录带过来的,问题解决方法是,修改下确认控制的选项: 修改确认控制的后 ...

  8. SAP 采购订单行项目中科目分配被隐藏,发现行项目设置中显示字段长度为0

    1.sm30 维护 视图 TCVIEW 修改对应字段的显示长度

  9. SAP MM 按采购订单查询付款信息的报表?

    SAP MM 按采购订单查询付款信息的报表? 上午给P3项目采购部门用户做了一个采购相关的报表的培训.培训过程中,客户的采购部门经理提出了一个问题:有没有报表能查询到各个采购订单的付款情况,显示采购订 ...

随机推荐

  1. VUE-CLI3.0脚手架安装

    文档:https://cli.vuejs.org/zh/guide/ 条件: npm 更至最新 node >=8.9 1.全局安装 npm install -g @vue/cli 或 yarn ...

  2. jdk源码--LinkedList

    本文基于jdk1.8_171 LinkedList介绍 之前看了ArrayList,内部是一个数组.这次看了LinkedList,作用和ArrayList一样,但是内部是链表形式.链表结构如下图: 数 ...

  3. SQL Server 存储过程相关语法

    一.定义变量及赋值 1.1 普通变量 --定义变量 declare @parameter_set int ) ) --set 关键字赋值 ; --select 赋值 select @parameter ...

  4. python文件下载

    1. 场景描述 刚好总结Java项目的web文件下载(附方案及源码配置),想起python项目也有用到文件下载,就也介绍下吧. 2. 解决方案 使用python的第三方组件Flask来实现文件下载功能 ...

  5. ~~Py2&Py3~~

    进击のpython python2 整型 int -- long(长整型) /获取的是整数 python3 整型 int /获取的是浮点数(小数) python2 print(range(1,10)) ...

  6. MyBatis从入门到精通:第二章数据的创建与插入文件

    数据库表的创建: create table sys_user ( id bigint not null auto_increment, ), user_password ), user_email ) ...

  7. 鸟哥的Linux私房菜笔记第六章(二)

    文件内容查询 直接查询文件内容 查阅一个文件的内容可以使用指令cat/tac/nl. # [cat|tac|nl] 文件 区别: 1.cat是直接把文件内容输出到屏幕上,并且从第一行开始输出到末行 2 ...

  8. 深入了解数据校验:Java Bean Validation 2.0(JSR380)

    每篇一句 吾皇一日不退役,尔等都是臣子 相关阅读 [小家Java]深入了解数据校验(Bean Validation):基础类打点(ValidationProvider.ConstraintDescri ...

  9. NetCore跨平台桌面框架Avalonia的OSX程序打包

    虽然工作开发语言已经转到了java,但平时仍会用netcore做一些小工具,提升工作效率,但是笔记本换成了Mac,小工具只能做成命令行形式,很是痛苦,迫切需要一个.net跨平台的桌面程序解决方案. 为 ...

  10. Android Studio项目/Flutter 案例中Gradle报错通用解决方案(包括Unable to tunnel through proxy问题)

    目录 Step 1:修改Gradle版本为本地版本 Step 2:修改classpath为Android Studio版本 Step 3:关闭代理 Step 1:修改Gradle版本为本地版本     ...