注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

XINBO'S SAP BLOG

你所浪费的今天,是昨天死去的人奢望的明天。你所厌恶的现在,是未来的你回不去的曾经

 
 
 

日志

 
 

ALV列头合并  

2009-05-20 11:21:14|  分类: ALV |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
ALV列头合并 - 柏拉图的永恒 - 张新波的ABAP BOLOG
源码:
*&---------------------------------------------------------------------*
*& Report  ZDEMO_ALV_MERGERHEADER                                      *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                        *
*&                                                                     *
*&---------------------------------------------------------------------*
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 LIKE afko-stlal,        "可选BOM
        stlan LIKE afko-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 LIKE makt-maktx,    "产品型号
        plnmg_f_m LIKE pbed-plnmg, "当月计划
        czhxt LIKE makt-matnr," 初装后箱体
        gmnga_lcm LIKE afru-gmnga,   "冷藏门 当日完成
        gmnga_lcm_lj LIKE afru-gmnga,"冷藏门 累计完成
        labst_lcm LIKE mard-labst,   "冷藏门 结存
        gmnga_ldm LIKE afru-gmnga,   "冷冻门 当日完成
        gmnga_ldm_lj LIKE afru-gmnga,"冷冻门 累计完成
        labst_ldm LIKE mard-labst,   "冷冻门 结存
        gmnga_bwm LIKE afru-gmnga,   "变温门 当日完成
        gmnga_bwm_lj LIKE afru-gmnga,"变温门 累计完成
        labst_bwm LIKE mard-labst,   "变温门 结存
        gmnga_czhxt LIKE afru-gmnga,   "初装上楼 当日完成
        gmnga_czhxt_lj LIKE afru-gmnga,"初装上楼 累计完成
        labst_czhxt LIKE mard-labst,   "初装上楼 结存
        gmnga_zzhxt LIKE afru-gmnga,   "总装完成 当日完成
        gmnga_zzhxt_lj LIKE afru-gmnga,"总装完成 累计完成
        labst_zzhxt LIKE mard-labst,   "总装完成 结存
        gmnga_zj LIKE afru-gmnga,   "成品入库 当日完成 "生产计划已完成数
        gmnga_zj_lj LIKE afru-gmnga,"成品入库 累计完成
        labst_zj LIKE mard-labst,   "成品入库 结存
        sljhc LIKE afru-gmnga ,      "上楼冰箱与计划差
        bzjhc LIKE afru-gmnga ,      "包装入库冰箱与计划差
        gmnga_zj1 LIKE afru-gmnga,    "生产计划已完成数
        END OF itb_output.
DATA itb_stpox LIKE STANDARD TABLE OF  stpox WITH HEADER LINE.
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
*            with sy-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
  评论这张
 
阅读(1064)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017