代码语言:javascript复制
REPORT z_alv_manual_set_header .
TABLES:afko,afru,afpo,pbim,pbed,makt,mard .
*************ALV
TYPE-POOLS slis.
DATA:l_events TYPE slis_t_event,
gs_layout TYPE slis_layout_alv,
fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
eventcat TYPE slis_t_event WITH HEADER LINE.
DATA:l_variant TYPE TABLE OF disvariant WITH HEADER LINE,
prg LIKE sy-repid.
**************
DATA:bedat LIKE pbed-pdatu,"当月月初
eddat LIKE pbed-pdatu."当月月末
DATA yesterday LIKE sy-datum.
DATA: lcm LIKE makt-matnr, " 冷藏门
ldm LIKE makt-matnr, " 冷冻门
bwm LIKE makt-matnr, "变温门
czhxt LIKE makt-matnr," 初装后箱体
zzhxt LIKE makt-matnr." 总装后箱体
DATA:gmnga_buf LIKE afru-gmnga. "计算当月计划
DATA:BEGIN OF itb_list_fert OCCURS 0, "当天有生产的整机清单
stlbez LIKE afko-stlbez, "物料号
stlal LIKEafko-stlal, "可选BOM
stlan LIKEafko-stlan, "BOM 用途
END OF itb_list_fert.
DATA: maktx LIKE makt-maktx ,
maktx1 LIKE makt-maktx ,
f1 LIKE makt-maktx ,
f2 LIKE makt-maktx ,
f3 LIKE makt-maktx ,
dot VALUE '.',
dot1 VALUE ','.
DATA:BEGIN OF itb_output OCCURS 0,"输出表格
maktx LIKEmakt-maktx, "产品型号
plnmg_f_m LIKE pbed-plnmg, "当月计划
czhxt LIKEmakt-matnr," 初装后箱体
gmnga_lcm LIKEafru-gmnga, "冷藏门 当日完成
gmnga_lcm_lj LIKE afru-gmnga,"冷藏门 累计完成
labst_lcm LIKEmard-labst, "冷藏门 结存
gmnga_ldm LIKEafru-gmnga, "冷冻门 当日完成
gmnga_ldm_lj LIKE afru-gmnga,"冷冻门 累计完成
labst_ldm LIKEmard-labst, "冷冻门 结存
gmnga_bwm LIKEafru-gmnga, "变温门 当日完成
gmnga_bwm_lj LIKE afru-gmnga,"变温门 累计完成
labst_bwm LIKEmard-labst, "变温门 结存
gmnga_czhxt LIKEafru-gmnga, "初装上楼 当日完成
gmnga_czhxt_lj LIKEafru-gmnga,"初装上楼 累计完成
labst_czhxt LIKEmard-labst, "初装上楼 结存
gmnga_zzhxt LIKEafru-gmnga, "总装完成 当日完成
gmnga_zzhxt_lj LIKEafru-gmnga,"总装完成 累计完成
labst_zzhxt LIKEmard-labst, "总装完成 结存
gmnga_zj LIKEafru-gmnga, "成品入库 当日完成 "生产计划已完成数
gmnga_zj_lj LIKE afru-gmnga,"成品入库 累计完成
labst_zj LIKEmard-labst, "成品入库 结存
sljhc LIKE afru-gmnga, "上楼冰箱与计划差
bzjhc LIKE afru-gmnga, "包装入库冰箱与计划差
gmnga_zj1 LIKEafru-gmnga, "生产计划已完成数
END OF itb_output.
DATA itb_stpox LIKE STANDARD TABLE OF stpox WITH HEADERLINE.
DATA:BEGIN OF itb_bom_maktx OCCURS 0,"BOM展开后的物料描述
idnrk LIKE stpox-idnrk,
maktx LIKE makt-maktx,
END OF itb_bom_maktx.
INITIALIZATION.
l_variant-report = sy-repid.
*******************************************START-OF-SELECTION
START-OF-SELECTION.
PERFORM eventtab_build CHANGING l_events.
PERFORM input_data.
PERFORM write_data.
*&---------------------------------------------------------------------*
*& Form write_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM write_data .
PERFORM get_fieldcat.
gs_layout-zebra = 'X' .
prg = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = prg
is_layout = gs_layout
is_variant = l_variant
it_fieldcat = fieldcat[]
it_events = eventcat[]
TABLES
t_outtab =itb_output[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " write_data
*&---------------------------------------------------------------------*
*& Form GET_FIELDCAT
*&---------------------------------------------------------------------*
* 因为ALV表头是手工调整输出的,所以必须在这里输入每个列的宽度
* fieldcat-outputlen .
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'MAKTX'.
fieldcat-col_pos =1. " Position on screen
fieldcat-seltext_l = '产品型号'.
fieldcat-key = 'X'.
fieldcat-outputlen = 11.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'PLNMG_F_M'.
fieldcat-col_pos =2. " Position on screen
fieldcat-seltext_l = '月计划合计'.
fieldcat-key = 'X'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'GMNGA_LCM'.
fieldcat-col_pos =3. " Position on screen
fieldcat-seltext_l = '冷藏门当日完成'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'GMNGA_LCM_LJ'.
fieldcat-col_pos =4. " Position on screen
fieldcat-seltext_l = '冷藏门累计完成'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'LABST_LCM'.
fieldcat-col_pos =5. " Position on screen
fieldcat-seltext_l = '冷藏门结存'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'GMNGA_LDM'.
fieldcat-col_pos =6. " Position on screen
fieldcat-seltext_l = '冷冻门当日完成'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'GMNGA_LDM_LJ'.
fieldcat-col_pos =7. " Position on screen
fieldcat-seltext_l = '冷冻门累计完成'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'LABST_LDM'.
fieldcat-col_pos =8. " Position on screen
fieldcat-seltext_l = '冷冻门结存'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'GMNGA_BWM'.
fieldcat-col_pos =9. " Position on screen
fieldcat-seltext_l = '变温室当日完成'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'GMNGA_BWM_LJ'.
fieldcat-col_pos =10. " Position on screen
fieldcat-seltext_l = '变温室累计完成'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'LABST_BWM'.
fieldcat-col_pos =11. " Position on screen
fieldcat-seltext_l = '变温室结存'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'GMNGA_CZHXT'.
fieldcat-col_pos =12. " Position on screen
fieldcat-seltext_l = '初装上楼当日完成'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'GMNGA_CZHXT_LJ'.
fieldcat-col_pos =13. " Position on screen
fieldcat-seltext_l = '初装上楼累计完成'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'LABST_CZHXT'.
fieldcat-col_pos =14. " Position on screen
fieldcat-seltext_l = '初装上楼结存'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'GMNGA_ZZHXT'.
fieldcat-col_pos =15. " Position on screen
fieldcat-seltext_l = '总装当日完成'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'GMNGA_ZZHXT_LJ'.
fieldcat-col_pos =16. " Position on screen
fieldcat-seltext_l = '总装累计完成'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'LABST_ZZHXT'.
fieldcat-col_pos =17. " Position on screen
fieldcat-seltext_l = '总装结存'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'GMNGA_ZJ'.
fieldcat-col_pos =18. " Position on screen
fieldcat-seltext_l = '成品入库当日完成'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'GMNGA_ZJ_LJ'.
fieldcat-col_pos =19. " Position on screen
fieldcat-seltext_l = '成品入库累计完成'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'LABST_ZJ'.
fieldcat-col_pos =20. " Position on screen
fieldcat-seltext_l = '成品入库结存'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'SLJHC'.
fieldcat-col_pos = 21. " Position on screen
fieldcat-seltext_l = '上楼冰箱与计划差'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-fieldname = 'BZJHC'.
fieldcat-col_pos =22. " Position on screen
fieldcat-seltext_l = '包装入库冰箱与计划差'.
fieldcat-outputlen = 10.
APPEND fieldcat.
CLEAR fieldcat.
fieldcat-tabname = 'ITAB_OUTPUT'.
fieldcat-col_pos =23. " Position on screen
fieldcat-fieldname = 'GMNGA_ZJ1'.
fieldcat-seltext_l = '生产计划已完成数'.
fieldcat-outputlen = 10.
APPEND fieldcat.
ENDFORM. " GET_FIELDCAT
*&---------------------------------------------------------------------*
*& Form EVENTTAB_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GT_EVENTS text
*----------------------------------------------------------------------*
FORM eventtab_build CHANGING p_events TYPE slis_t_event.
DATA l_event TYPE LINE OF slis_t_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events =p_events
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
IF sy-subrc <> 0.
* message id sy-msgid type sy-msgty number sy-msgno
* withsy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE p_events INTO l_event WITH KEY name ='AFTER_LINE_OUTPUT'.
eventcat-name = l_event-name.
eventcat-form = 'AFTER_LINE_OUTPUT'.
APPEND eventcat.
READ TABLE p_events INTO l_event WITH KEY name = 'TOP_OF_PAGE'.
eventcat-name = l_event-name.
eventcat-form = 'F_TOP_OF_PAGE'.
APPEND eventcat.
ENDFORM. " EVENTTAB_BUILD
*&--------------------------------------------------------------------*
*& Form AFTER_LINE_OUTPUT
*&--------------------------------------------------------------------*
* 输出ALV的表头,手动配置这些
*---------------------------------------------------------------------*
FORM after_line_output USING gs_lineinfo TYPE slis_lineinfo.
DATA i TYPE i.
DATA: d(394) TYPE c .
DATA: l_line(398) TYPE c.
DATA: tmp_size TYPE i.
DESCRIBE FIELD d OUTPUT-LENGTH i.
IF gs_lineinfo-tabindex = 1.
MODIFY LINE 1 LINE VALUE FROM sy-uline(gs_lineinfo-linsz).
CLEAR l_line.
WRITE sy-vline TO l_line 0.
WRITE sy-vline TO l_line 12.
WRITE sy-vline TO l_line 23.
WRITE '门体发泡完成' TO l_line 33.
WRITE sy-vline TO l_line 122.
WRITE '初装上楼完成' TO l_line 123.
WRITE sy-vline TO l_line 155.
WRITE '总装完成' TO l_line 156.
WRITE sy-vline TO l_line 188.
WRITE '成品入库' TO l_line 189.
WRITE sy-vline TO l_line 221.
WRITE sy-vline TO l_line 232.
WRITE sy-vline TO l_line 243.
WRITE sy-vline TO l_line 254.
MODIFY LINE 2 LINE VALUE FROM l_line(gs_lineinfo-linsz).
CLEAR l_line.
WRITE sy-vline TO l_line 0.
WRITE sy-vline TO l_line 12.
WRITE sy-vline TO l_line 23.
tmp_size = gs_lineinfo-linsz - 24.
WRITE sy-uline TO l_line 24(tmp_size).
WRITE '上楼冰箱' TO l_line 222.
WRITE sy-vline TO l_line 232.
WRITE '包装入库' TO l_line 233.
WRITE sy-vline TO l_line 243.
WRITE '生产计划' TO l_line 244.
WRITE sy-vline TO l_line 254.
MODIFY LINE 3 LINE VALUE FROM l_line(gs_lineinfo-linsz).
CLEAR l_line.
WRITE sy-vline TO l_line 0.
WRITE '产品型号' TO l_line 1.
WRITE sy-vline TO l_line 12.
WRITE '月计划合计' TO l_line 13.
WRITE sy-vline TO l_line 23.
WRITE '冷藏门' TO l_line 24.
WRITE sy-vline TO l_line 56.
WRITE '冷冻门' TO l_line 57.
WRITE sy-vline TO l_line 89.
WRITE '变温室' TO l_line 90.
WRITE sy-vline TO l_line 122.
WRITE sy-vline TO l_line 133.
WRITE sy-vline TO l_line 144.
WRITE sy-vline TO l_line 155.
WRITE sy-vline TO l_line 166.
WRITE sy-vline TO l_line 177.
WRITE sy-vline TO l_line 188.
WRITE sy-vline TO l_line 199.
WRITE sy-vline TO l_line 210.
WRITE sy-vline TO l_line 221.
WRITE '与计划差' TO l_line 222.
WRITE sy-vline TO l_line 232.
WRITE '冰箱与' TO l_line 233.
WRITE sy-vline TO l_line 243.
WRITE '已完成数' TO l_line 244.
WRITE sy-vline TO l_line 254.
MODIFY LINE 4 LINE VALUE FROM l_line(gs_lineinfo-linsz).
CLEAR l_line.
WRITE sy-vline TO l_line 0.
WRITE sy-vline TO l_line 12.
WRITE sy-vline TO l_line 23.
tmp_size = gs_lineinfo-linsz - 24.
WRITE sy-uline TO l_line 24(tmp_size).
WRITE '当日完成' TO l_line 123.
WRITE sy-vline TO l_line 133.
WRITE '累计完成' TO l_line 134.
WRITE sy-vline TO l_line 144.
WRITE '结存' TO l_line 145.
WRITE sy-vline TO l_line 155.
WRITE '当日完成' TO l_line 156.
WRITE sy-vline TO l_line 166.
WRITE '累计完成' TO l_line 167.
WRITE sy-vline TO l_line 177.
WRITE '结存' TO l_line 178.
WRITE sy-vline TO l_line 188.
WRITE '当日完成' TO l_line 189.
WRITE sy-vline TO l_line 199.
WRITE '累计完成' TO l_line 200.
WRITE sy-vline TO l_line 210.
WRITE '结存' TO l_line 211.
WRITE sy-vline TO l_line 221.
WRITE sy-vline TO l_line 232.
WRITE '计划差' TO l_line 233.
WRITE sy-vline TO l_line 243.
WRITE sy-vline TO l_line 254.
MODIFY LINE 5 LINE VALUE FROM l_line(gs_lineinfo-linsz).
CLEAR l_line.
WRITE sy-vline TO l_line 0.
WRITE sy-vline TO l_line 12.
WRITE sy-vline TO l_line 23.
WRITE '当日完成' TO l_line 24.
WRITE sy-vline TO l_line 34.
WRITE '累计完成' TO l_line 35.
WRITE sy-vline TO l_line 45.
WRITE '结存' TO l_line 46.
WRITE sy-vline TO l_line 56.
WRITE '当日完成' TO l_line 57.
WRITE sy-vline TO l_line 67.
WRITE '累计完成' TO l_line 68.
WRITE sy-vline TO l_line 78.
WRITE '结存' TO l_line 79.
WRITE sy-vline TO l_line 89.
WRITE '当日完成' TO l_line 90.
WRITE sy-vline TO l_line 100.
WRITE '累计完成' TO l_line 101.
WRITE sy-vline TO l_line 111.
WRITE '结存' TO l_line 112.
WRITE sy-vline TO l_line 122.
* tmp_size = gs_lineinfo-linsz - 24.
* write sy-uline to l_line 24(tmp_size).
WRITE sy-vline TO l_line 133.
WRITE sy-vline TO l_line 144.
WRITE sy-vline TO l_line 155.
WRITE sy-vline TO l_line 166.
WRITE sy-vline TO l_line 177.
WRITE sy-vline TO l_line 188.
WRITE sy-vline TO l_line 199.
WRITE sy-vline TO l_line 210.
WRITE sy-vline TO l_line 221.
WRITE sy-vline TO l_line 232.
WRITE sy-vline TO l_line 243.
WRITE sy-vline TO l_line 254.
MODIFY LINE 6 LINE VALUE FROM l_line LINE FORMAT COLOR OFF.
ENDIF.
ENDFORM. "AFTER_LINE_OUTPUT
*&--------------------------------------------------------------------*
*& Form F_TOP_OF_PAGE
*&--------------------------------------------------------------------*
* 给ALV表头输出预留行空间
*---------------------------------------------------------------------*
FORM f_top_of_page.
WRITE : / sy-uline,
/ sy-uline,
/ sy-uline,
/ sy-uline.
ENDFORM. "F_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form input_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* 测试用
*----------------------------------------------------------------------*
FORM input_data .
itb_output-maktx = 'BCD-108A' .
itb_output-plnmg_f_m = 1000 .
itb_output-gmnga_czhxt = 380 .
itb_output-gmnga_zj = 200 .
itb_output-bzjhc = '10'.
itb_output-gmnga_zj1 = '100'.
APPEND itb_output .
ENDFORM. " input_data