REPORT zhymu001.
TABLES: likp,zhymu001_t,tsege.
TYPE-POOLS: slis.
DATA: g_repid LIKE sy-repid.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv .
DATA: gs_fieldcat TYPE slis_fieldcat_alv .
DATA: gs_layout TYPE slis_layout_alv.
DATA: gs_variant LIKE disvariant.
DATA: t_cat TYPE TABLE OF lvc_s_fcat,
w_cat LIKE LINE OF t_cat.
FIELD-SYMBOLS: TYPE table,
,
.
DATA: t_ref TYPE REF TO data.
DATA: w_ref TYPE REF TO data.
DATA vbelv TYPE vbeln_von.
DATA line TYPE i.
DATA t_nei LIKE zhymu001_t OCCURS 0 WITH HEADER LINE.
DATA t_tsege LIKE tsege OCCURS 0 WITH HEADER LINE.
DATA BEGIN OF t_order OCCURS 0.
INCLUDE STRUCTURE zhymu001_s.
DATA wadat_ist LIKE likp-wadat_ist.
DATA END OF t_order.
DATA dateb TYPE d.
DATA datee TYPE d.
DATA timeb TYPE t.
DATA timee TYPE t.
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS vbeln FOR likp-vbeln obligatory.
SELECT-OPTIONS erdat FOR likp-erdat .
SELECT-OPTIONS kunnr FOR likp-kunnr .
SELECTION-SCREEN END OF BLOCK bk1.
START-OF-SELECTION.
***************获取数据
REFRESH: t_order,t_tsege,t_nei.
SELECT * INTO TABLE t_nei
FROM zhymu001_t .
SORT t_nei BY date_bn.
SELECT vbeln kunnr handle wadat_ist
INTO CORRESPONDING FIELDS OF TABLE t_order
FROM likp
WHERE vbeln IN vbeln AND erdat IN erdat
AND kunnr IN kunnr.
LOOP AT t_order.
SELECT SINGLE vbelv INTO t_order-vbelv
FROM vbfa
WHERE vbeln = t_order-vbeln.
SELECT SINGLE name1 INTO t_order-kunnr_n
FROM kna1
WHERE kunnr = t_order-kunnr .
SELECT SINGLE lifnr INTO t_order-sp_no
FROM vbpa
WHERE vbeln = t_order-vbeln AND parvw = 'SP'.
SELECT SINGLE name1 INTO t_order-sp_name
FROM lfa1
WHERE lifnr = t_order-sp_no .
MODIFY t_order. CLEAR t_order.
ENDLOOP.
SELECT * INTO TABLE t_tsege
FROM tsege
FOR ALL ENTRIES IN t_order
WHERE head_hdl = t_order-handle.
LOOP AT t_nei.
LOOP AT t_tsege WHERE even = t_nei-even
AND even_verty = t_nei-even_verty .
ENDLOOP.
IF sy-subrc <> 0 .
DELETE t_nei. CLEAR t_nei.
ENDIF.
ENDLOOP.
*****************创建内表
REFRESH t_cat .
UNASSIGN: ,.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZHYMU001_S'
CHANGING
ct_fieldcat = t_cat.
DESCRIBE TABLE t_cat LINES line .
SORT t_nei BY date_bn.
LOOP AT t_nei.
IF t_nei-date_bn IS NOT INITIAL.
line = line + 1.
w_cat-fieldname = t_nei-date_bn.
w_cat-scrtext_m = t_nei-date_bt.
w_cat-col_pos = line.
w_cat-inttype = 'D'.
w_cat-intlen = 10.
APPEND w_cat TO t_cat. CLEAR w_cat.
ENDIF.
IF t_nei-time_bn IS NOT INITIAL.
line = line + 1.
w_cat-fieldname = t_nei-time_bn.
w_cat-scrtext_m = t_nei-time_bt.
w_cat-col_pos = line.
w_cat-inttype = 'T'.
w_cat-intlen = 8.
APPEND w_cat TO t_cat. CLEAR w_cat.
ENDIF.
IF t_nei-date_en IS NOT INITIAL.
line = line + 1.
w_cat-fieldname = t_nei-date_en.
w_cat-scrtext_m = t_nei-date_et.
w_cat-col_pos = line.
w_cat-inttype = 'D'.
w_cat-intlen = 10.
APPEND w_cat TO t_cat. CLEAR w_cat.
ENDIF.
IF t_nei-time_en IS NOT INITIAL.
line = line + 1.
w_cat-fieldname = t_nei-time_en.
w_cat-scrtext_m = t_nei-time_et.
w_cat-col_pos = line.
w_cat-inttype = 'T'.
w_cat-intlen = 8.
APPEND w_cat TO t_cat. CLEAR w_cat.
ENDIF.
ENDLOOP.
line = line + 1.
w_cat-fieldname = 'WADAT_IST'.
w_cat-scrtext_m = 'Act. gds mvmt'.
w_cat-col_pos = line.
w_cat-inttype = 'D'.
w_cat-intlen = 10.
APPEND w_cat TO t_cat. CLEAR w_cat.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_cat
IMPORTING
ep_table = t_ref.
ASSIGN t_ref->* TO .
CREATE DATA w_ref LIKE LINE OF .
ASSIGN w_ref->* TO .
*************填充动态内表
LOOP AT t_order.
ASSIGN COMPONENT 'VBELV' OF STRUCTURE TO .
= t_order-vbelv.
ASSIGN COMPONENT 'VBELN' OF STRUCTURE TO .
= t_order-vbeln.
ASSIGN COMPONENT 'HANDLE' OF STRUCTURE TO .
= t_order-handle.
ASSIGN COMPONENT 'KUNNR' OF STRUCTURE TO .
= t_order-kunnr.
ASSIGN COMPONENT 'KUNNR_N' OF STRUCTURE TO .
= t_order-kunnr_n.
ASSIGN COMPONENT 'SP_NO' OF STRUCTURE TO .
= t_order-sp_no.
ASSIGN COMPONENT 'SP_NAME' OF STRUCTURE TO .
= t_order-sp_name.
ASSIGN COMPONENT 'WADAT_IST' OF STRUCTURE TO .
= t_order-wadat_ist.
LOOP AT t_nei .
LOOP AT t_tsege WHERE even = t_nei-even
AND even_verty = t_nei-even_verty .
CLEAR: dateb,timeb,datee,timee.
CONVERT TIME STAMP t_tsege-even_tstfr
TIME ZONE t_tsege-even_zonfr
INTO DATE dateb TIME timeb.
IF t_nei-date_bn IS NOT INITIAL.
ASSIGN COMPONENT t_nei-date_bn OF STRUCTURE TO .
= dateb.
ENDIF.
IF t_nei-time_bn IS NOT INITIAL.
ASSIGN COMPONENT t_nei-time_bn OF STRUCTURE TO .
= timeb.
ENDIF.
CONVERT TIME STAMP t_tsege-even_tstto
TIME ZONE t_tsege-even_zonto
INTO DATE datee TIME timee.
IF t_nei-date_en IS NOT INITIAL.
ASSIGN COMPONENT t_nei-date_en OF STRUCTURE TO .
= datee.
ENDIF.
IF t_nei-time_en IS NOT INITIAL.
ASSIGN COMPONENT t_nei-time_en OF STRUCTURE TO .
= timee.
ENDIF.
ENDLOOP.
ENDLOOP.
APPEND TO .
ENDLOOP.
END-OF-SELECTION.
***************输出
REFRESH gt_fieldcat. CLEAR gs_fieldcat.
LOOP AT t_cat INTO w_cat .
MOVE-CORRESPONDING w_cat TO gs_fieldcat.
gs_fieldcat-seltext_m = w_cat-scrtext_m.
IF w_cat-fieldname = 'VBELN'.
gs_fieldcat-hotspot = 'X'.
ENDIF.
IF w_cat-fieldname = 'HANDLE'.
gs_fieldcat-no_out = 'X'.
ENDIF.
APPEND gs_fieldcat TO gt_fieldcat .
CLEAR: w_cat,gs_fieldcat .
ENDLOOP .
gs_layout-zebra = 'X'.
gs_layout-cell_merge = 'X'.
gs_layout-colwidth_optimize = 'X'.
* gs_layout-info_fieldname = 'LINE_COLOR'.
g_repid = sy-repid.
gs_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* i_background_id = 'ALV_BACKGROUND'
i_callback_pf_status_set = 'MENU_SET'
i_callback_user_command = 'USER_COMMAND'
i_callback_program = g_repid
is_layout = gs_layout
* i_save = 'A'
* is_variant = gs_variant
it_fieldcat = gt_fieldcat[]
TABLES
t_outtab = .
*&--------------------------------------------------------------------*
*& Form menu_set
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->RT_EXTAB text
*---------------------------------------------------------------------*
FORM menu_set USING lt_extab TYPE slis_t_extab.
DATA: ls_extab TYPE slis_extab.
SET PF-STATUS '101'. "定义屏幕状态,然后在里面定义自己的按钮
ENDFORM. "menu_set
*&--------------------------------------------------------------------*
*& Form execute_command
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELDtext
*---------------------------------------------------------------------*
FORM user_command USING ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: bdcdata_wa TYPE bdcdata,
bdcdata_tab TYPE TABLE OF bdcdata.
DATA opt TYPE ctu_params.
CASE ucomm.
WHEN '&IC1'.
READ TABLE INTO
INDEX rs_selfield-tabindex .
ASSIGN COMPONENT 'VBELN' OF STRUCTURE
TO .
CLEAR bdcdata_wa.
bdcdata_wa-program = 'SAPMV50A'.
bdcdata_wa-dynpro = '4004'.
bdcdata_wa-dynbegin = 'X'.
APPEND bdcdata_wa TO bdcdata_tab. CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'LIKP-VBELN'. "输入框名称
bdcdata_wa-fval = . "传过去的值
APPEND bdcdata_wa TO bdcdata_tab. CLEAR bdcdata_wa.
bdcdata_wa-program = 'SAPMV50A'.
bdcdata_wa-dynpro = '1000'.
bdcdata_wa-dynbegin = 'X'.
APPEND bdcdata_wa TO bdcdata_tab. CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_OKCODE'. "输入框名称
bdcdata_wa-fval = '=HTER_T'. "传过去的值
APPEND bdcdata_wa TO bdcdata_tab. CLEAR bdcdata_wa.
opt-dismode = 'E'.
CALL TRANSACTION 'VL03N' USING bdcdata_tab OPTIONS FROM opt.
ENDCASE.
ENDFORM. "execute_command
- REPORT zhymu001.
- TABLES: likp,zhymu001_t,tsege.
- TYPE-POOLS: slis.
- DATA: g_repid LIKE sy-repid.
- DATA: gt_fieldcat TYPE slis_t_fieldcat_alv .
- DATA: gs_fieldcat TYPE slis_fieldcat_alv .
- DATA: gs_layout TYPE slis_layout_alv.
- DATA: gs_variant LIKE disvariant.
- DATA: t_cat TYPE TABLE OF lvc_s_fcat,
- w_cat LIKE LINE OF t_cat.
- FIELD-SYMBOLS: TYPE table,
- ,
- .
- DATA: t_ref TYPE REF TO data.
- DATA: w_ref TYPE REF TO data.
- DATA vbelv TYPE vbeln_von.
- DATA line TYPE i.
- DATA t_nei LIKE zhymu001_t OCCURS 0 WITH HEADER LINE.
- DATA t_tsege LIKE tsege OCCURS 0 WITH HEADER LINE.
- DATA BEGIN OF t_order OCCURS 0.
- INCLUDE STRUCTURE zhymu001_s.
- DATA wadat_ist LIKE likp-wadat_ist.
- DATA END OF t_order.
- DATA dateb TYPE d.
- DATA datee TYPE d.
- DATA timeb TYPE t.
- DATA timee TYPE t.
- SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
- SELECT-OPTIONS vbeln FOR likp-vbeln obligatory.
- SELECT-OPTIONS erdat FOR likp-erdat .
- SELECT-OPTIONS kunnr FOR likp-kunnr .
- SELECTION-SCREEN END OF BLOCK bk1.
- START-OF-SELECTION.
- ***************获取数据
- REFRESH: t_order,t_tsege,t_nei.
- SELECT * INTO TABLE t_nei
- FROM zhymu001_t .
- SORT t_nei BY date_bn.
- SELECT vbeln kunnr handle wadat_ist
- INTO CORRESPONDING FIELDS OF TABLE t_order
- FROM likp
- WHERE vbeln IN vbeln AND erdat IN erdat
- AND kunnr IN kunnr.
- LOOP AT t_order.
- SELECT SINGLE vbelv INTO t_order-vbelv
- FROM vbfa
- WHERE vbeln = t_order-vbeln.
- SELECT SINGLE name1 INTO t_order-kunnr_n
- FROM kna1
- WHERE kunnr = t_order-kunnr .
- SELECT SINGLE lifnr INTO t_order-sp_no
- FROM vbpa
- WHERE vbeln = t_order-vbeln AND parvw = 'SP'.
- SELECT SINGLE name1 INTO t_order-sp_name
- FROM lfa1
- WHERE lifnr = t_order-sp_no .
- MODIFY t_order. CLEAR t_order.
- ENDLOOP.
- SELECT * INTO TABLE t_tsege
- FROM tsege
- FOR ALL ENTRIES IN t_order
- WHERE head_hdl = t_order-handle.
- LOOP AT t_nei.
- LOOP AT t_tsege WHERE even = t_nei-even
- AND even_verty = t_nei-even_verty .
- ENDLOOP.
- IF sy-subrc <> 0 .
- DELETE t_nei. CLEAR t_nei.
- ENDIF.
- ENDLOOP.
- *****************创建内表
- REFRESH t_cat .
- UNASSIGN: ,.
- CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
- EXPORTING
- i_structure_name = 'ZHYMU001_S'
- CHANGING
- ct_fieldcat = t_cat.
- DESCRIBE TABLE t_cat LINES line .
- SORT t_nei BY date_bn.
- LOOP AT t_nei.
- IF t_nei-date_bn IS NOT INITIAL.
- line = line + 1.
- w_cat-fieldname = t_nei-date_bn.
- w_cat-scrtext_m = t_nei-date_bt.
- w_cat-col_pos = line.
- w_cat-inttype = 'D'.
- w_cat-intlen = 10.
- APPEND w_cat TO t_cat. CLEAR w_cat.
- ENDIF.
- IF t_nei-time_bn IS NOT INITIAL.
- line = line + 1.
- w_cat-fieldname = t_nei-time_bn.
- w_cat-scrtext_m = t_nei-time_bt.
- w_cat-col_pos = line.
- w_cat-inttype = 'T'.
- w_cat-intlen = 8.
- APPEND w_cat TO t_cat. CLEAR w_cat.
- ENDIF.
- IF t_nei-date_en IS NOT INITIAL.
- line = line + 1.
- w_cat-fieldname = t_nei-date_en.
- w_cat-scrtext_m = t_nei-date_et.
- w_cat-col_pos = line.
- w_cat-inttype = 'D'.
- w_cat-intlen = 10.
- APPEND w_cat TO t_cat. CLEAR w_cat.
- ENDIF.
- IF t_nei-time_en IS NOT INITIAL.
- line = line + 1.
- w_cat-fieldname = t_nei-time_en.
- w_cat-scrtext_m = t_nei-time_et.
- w_cat-col_pos = line.
- w_cat-inttype = 'T'.
- w_cat-intlen = 8.
- APPEND w_cat TO t_cat. CLEAR w_cat.
- ENDIF.
- ENDLOOP.
- line = line + 1.
- w_cat-fieldname = 'WADAT_IST'.
- w_cat-scrtext_m = 'Act. gds mvmt'.
- w_cat-col_pos = line.
- w_cat-inttype = 'D'.
- w_cat-intlen = 10.
- APPEND w_cat TO t_cat. CLEAR w_cat.
- CALL METHOD cl_alv_table_create=>create_dynamic_table
- EXPORTING
- it_fieldcatalog = t_cat
- IMPORTING
- ep_table = t_ref.
- ASSIGN t_ref->* TO .
- CREATE DATA w_ref LIKE LINE OF .
- ASSIGN w_ref->* TO .
- *************填充动态内表
- LOOP AT t_order.
- ASSIGN COMPONENT 'VBELV' OF STRUCTURE TO .
- = t_order-vbelv.
- ASSIGN COMPONENT 'VBELN' OF STRUCTURE TO .
- = t_order-vbeln.
- ASSIGN COMPONENT 'HANDLE' OF STRUCTURE TO .
- = t_order-handle.
- ASSIGN COMPONENT 'KUNNR' OF STRUCTURE TO .
- = t_order-kunnr.
- ASSIGN COMPONENT 'KUNNR_N' OF STRUCTURE TO .
- = t_order-kunnr_n.
- ASSIGN COMPONENT 'SP_NO' OF STRUCTURE TO .
- = t_order-sp_no.
- ASSIGN COMPONENT 'SP_NAME' OF STRUCTURE TO .
- = t_order-sp_name.
- ASSIGN COMPONENT 'WADAT_IST' OF STRUCTURE TO .
- = t_order-wadat_ist.
- LOOP AT t_nei .
- LOOP AT t_tsege WHERE even = t_nei-even
- AND even_verty = t_nei-even_verty .
- CLEAR: dateb,timeb,datee,timee.
- CONVERT TIME STAMP t_tsege-even_tstfr
- TIME ZONE t_tsege-even_zonfr
- INTO DATE dateb TIME timeb.
- IF t_nei-date_bn IS NOT INITIAL.
- ASSIGN COMPONENT t_nei-date_bn OF STRUCTURE TO .
- = dateb.
- ENDIF.
- IF t_nei-time_bn IS NOT INITIAL.
- ASSIGN COMPONENT t_nei-time_bn OF STRUCTURE TO .
- = timeb.
- ENDIF.
- CONVERT TIME STAMP t_tsege-even_tstto
- TIME ZONE t_tsege-even_zonto
- INTO DATE datee TIME timee.
- IF t_nei-date_en IS NOT INITIAL.
- ASSIGN COMPONENT t_nei-date_en OF STRUCTURE TO .
- = datee.
- ENDIF.
- IF t_nei-time_en IS NOT INITIAL.
- ASSIGN COMPONENT t_nei-time_en OF STRUCTURE TO .
- = timee.
- ENDIF.
- ENDLOOP.
- ENDLOOP.
- APPEND TO .
- ENDLOOP.
- END-OF-SELECTION.
- ***************输出
- REFRESH gt_fieldcat. CLEAR gs_fieldcat.
- LOOP AT t_cat INTO w_cat .
- MOVE-CORRESPONDING w_cat TO gs_fieldcat.
- gs_fieldcat-seltext_m = w_cat-scrtext_m.
- IF w_cat-fieldname = 'VBELN'.
- gs_fieldcat-hotspot = 'X'.
- ENDIF.
- IF w_cat-fieldname = 'HANDLE'.
- gs_fieldcat-no_out = 'X'.
- ENDIF.
- APPEND gs_fieldcat TO gt_fieldcat .
- CLEAR: w_cat,gs_fieldcat .
- ENDLOOP .
- gs_layout-zebra = 'X'.
- gs_layout-cell_merge = 'X'.
- gs_layout-colwidth_optimize = 'X'.
- * gs_layout-info_fieldname = 'LINE_COLOR'.
- g_repid = sy-repid.
- gs_variant-report = sy-repid.
- CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
- EXPORTING
- * i_background_id = 'ALV_BACKGROUND'
- i_callback_pf_status_set = 'MENU_SET'
- i_callback_user_command = 'USER_COMMAND'
- i_callback_program = g_repid
- is_layout = gs_layout
- * i_save = 'A'
- * is_variant = gs_variant
- it_fieldcat = gt_fieldcat[]
- TABLES
- t_outtab = .
- *&--------------------------------------------------------------------*
- *& Form menu_set
- *&--------------------------------------------------------------------*
- * text
- *---------------------------------------------------------------------*
- * -->RT_EXTAB text
- *---------------------------------------------------------------------*
- FORM menu_set USING lt_extab TYPE slis_t_extab.
- DATA: ls_extab TYPE slis_extab.
- SET PF-STATUS '101'. "定义屏幕状态,然后在里面定义自己的按钮
- ENDFORM. "menu_set
- *&--------------------------------------------------------------------*
- *& Form execute_command
- *&--------------------------------------------------------------------*
- * text
- *---------------------------------------------------------------------*
- * -->R_UCOMM text
- * -->RS_SELFIELDtext
- *---------------------------------------------------------------------*
- FORM user_command USING ucomm LIKE sy-ucomm
- rs_selfield TYPE slis_selfield.
- DATA: bdcdata_wa TYPE bdcdata,
- bdcdata_tab TYPE TABLE OF bdcdata.
- DATA opt TYPE ctu_params.
- CASE ucomm.
- WHEN '&IC1'.
- READ TABLE INTO
- INDEX rs_selfield-tabindex .
- ASSIGN COMPONENT 'VBELN' OF STRUCTURE
- TO .
- CLEAR bdcdata_wa.
- bdcdata_wa-program = 'SAPMV50A'.
- bdcdata_wa-dynpro = '4004'.
- bdcdata_wa-dynbegin = 'X'.
- APPEND bdcdata_wa TO bdcdata_tab. CLEAR bdcdata_wa.
- bdcdata_wa-fnam = 'LIKP-VBELN'. "输入框名称
- bdcdata_wa-fval = . "传过去的值
- APPEND bdcdata_wa TO bdcdata_tab. CLEAR bdcdata_wa.
- bdcdata_wa-program = 'SAPMV50A'.
- bdcdata_wa-dynpro = '1000'.
- bdcdata_wa-dynbegin = 'X'.
- APPEND bdcdata_wa TO bdcdata_tab. CLEAR bdcdata_wa.
- bdcdata_wa-fnam = 'BDC_OKCODE'. "输入框名称
- bdcdata_wa-fval = '=HTER_T'. "传过去的值
- APPEND bdcdata_wa TO bdcdata_tab. CLEAR bdcdata_wa.
- opt-dismode = 'E'.
- CALL TRANSACTION 'VL03N' USING bdcdata_tab OPTIONS FROM opt.
- ENDCASE.
- ENDFORM. "execute_command