SAP ALV Display Title

form frm_alv_display_w .
  data:l_fname_i type i,
       l_week(2),
       l_year(4),
       l_pos type i,
       l_txt(20),
       l_fname_txt(6),
       l_fname type lvc_fname.

  data:l_weeks type kweek,
       l_datum type scdatum,
       l_datec(10).

  define fieldcat_build.
    clear fieldcat.
    fieldcat-fieldname &1.
*    FIELDCAT-TABNAME = &2.
    fieldcat-outputlen &2.
    fieldcat-seltext_l &3.
*    FIELDCAT-REPTEXT_DDIC = &3.
*    FIELDCAT-DDICTXT = 'M'.
*    fieldcat-no_zero = 'X'.
    fieldcat-do_sum &4.
*    fieldcat-no_out = &5.
    fieldcat-fix_column &5.
    fieldcat-edit &6.
    append fieldcat .
  end-of-definition.
* col_pos fieldname tabname reptext_ddic
  clear fieldcat[].
  clear fieldcat.

  fieldcat_build :
    'WBSEM'    '20' 'WBS'                              ' ' 'X' '',
    'MATNR'    '18' 'VTN P/N '                         ' ' 'X' '',
    'MAKTX'    '20' 'Descrip.'                         ' ' 'X' '',
    'BEZEI'    '20' 'SO Type'                          ' ' 'X' '',
    'SPNAME'   '20' 'SO Status'                        ' ' 'X' '',
    'MRPIM'    '20' 'S/O # / Item / Req type'          ' ' 'X' '',
    'KUNNR'    '10' 'Customer'                         ' ' 'X' '',
    'BACK_LOG' '10' 'BACK LOG'                         'X' ''  ''.


  clear l_week.
  l_week g_weeks+4(2).
  l_year g_weeks+0(4).

  clear: l_pos,l_fname_i.
  l_fname_i g_weeks.
  do 52 times.
*    L_FNAME = L_FNAME_I.
    l_fname_txt l_fname_i.
    l_weeks l_fname_i.
    call function 'WEEK_GET_FIRST_DAY'
      exporting
        week l_weeks
      importing
        date l_datum.

    call function 'CONVERSION_EXIT_IDATE_OUTPUT'
      exporting
        input  l_datum
      importing
        output l_datec.
    condense: l_fname_txt,l_datec.
    concatenate p_space l_fname_txt into l_fname.
    concatenate l_fname_txt l_datec into l_txt separated by space.

    fieldcat_build:
       l_fname    '20'    l_txt                         'X'  '' ''.

    l_week l_week + 1.
    l_fname_i l_fname_i + 1.
    if l_week 53.
      l_year l_year + 1.
      l_week '01'.
      concatenate l_year l_week into l_fname.
      l_fname_i l_fname.
    endif.
  enddo.
  if lv_price 'X'.
    fieldcat_build :
   'KBETR' '13' 'Price'                         '' ''  '',
   'KONWA' '5' 'Currency'                         '' ''  '',
   'VERPR' '13' 'Cost/HKD'                         '' ''  ''.
  endif.

  fieldcat_build :
     'TOTAL'    '13'    'Total'                         'X' '' '',
     'ISSUE'    '20'    'Issue'                         ' ' '' '',
     'RMARK'    '40'    'Remark'                        ' ' '' 'X'.

*---SORT

  clear sort.
  sort-fieldname 'WBSEM'. "排序关键字段
  sort-spos      1. "排序顺序
  sort-up        'X'. "默认按升序排列
  sort-subtot    'X'. "输出小计
  append sort.

  clear sort.
  sort-fieldname 'MATNR'. "排序关键字段
  sort-spos      2. "排序顺序
  sort-up        'X'. "默认按升序排列
* sort-down        = 'X'. "默认按降序排列
  sort-subtot    'X'. "输出小计
  append sort.


  loop at fieldcat.
    if fieldcat-fieldname 'KUNNR'.
      fieldcat-no_zero 'X'.
    endif.

    modify fieldcat.
  endloop.

  repid sy-repid.
*---ALV
  call function 'REUSE_ALV_GRID_DISPLAY'
   exporting
     i_callback_program                repid
     i_callback_pf_status_set          'PF_STATUS_SET'
*     I_CALLBACK_USER_COMMAND           = 'FRM_UCOMM'
     i_callback_top_of_page            'ALV_TOP_OF_PAGE'
     is_layout                         layout
     it_fieldcat                       fieldcat[]
     it_sort                           sort[]
     i_default                         'X'
     i_save                            'A'
    tables
      t_outtab                          <dyn_table>
*  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.


endform.                    " FRM_ADD_ALV_FIELDS


*&---------------------------------------------------------------------*
*&      Form  ALV_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form alv_top_of_page.
  data: it_list type slis_t_listheader with header line.
  data  lw_zppt_md04_head like zppt_md04_head.
*  DATA:
*  IT_LIST-TYP = 'H'.
*  IT_LIST-KEY = ''.
*  IT_LIST-INFO = 'Header'.
*  APPEND IT_LIST.
  if not p_sel is initial.
    select single *
      into lw_zppt_md04_head
      from zppt_md04_head
      where vesnr eq p_vesnr.
    it_list-typ 'S'.
    it_list-key 'Prepared By:'.
    it_list-info lw_zppt_md04_head-ernam.
    append it_list.

    it_list-typ 'S'.
    it_list-key 'SUBJECT    :'.
    it_list-info 'Build Plan'.
    append it_list.

    it_list-typ 'S'.
    it_list-key 'Version No : '.
    it_list-info p_vesnr.

    append it_list.

    it_list-typ 'S'.
    it_list-key 'DATE       :'.
    it_list-info lw_zppt_md04_head-erdat.
    append it_list.

  else.
    it_list-typ 'S'.
    it_list-key 'Prepared By:'.
    it_list-info sy-uname.
    append it_list.

    it_list-typ 'S'.
    it_list-key 'SUBJECT    :'.
    it_list-info 'Build Plan'.
    append it_list.

    it_list-typ 'S'.
    it_list-key 'Version No : '.
    if p_vesnr is initial.
      it_list-info p_vernum.
    else.
      it_list-info p_vesnr.
    endif.
    append it_list.

    it_list-typ 'S'.
    it_list-key 'DATE       :'.
    it_list-info sy-datum.
    append it_list.
  endif.
*  IT_LIST-TYP = 'A'.
*  IT_LIST-KEY = 'Date:'.
*  IT_LIST-INFO = SY-DATUM.
*  APPEND IT_LIST.

  call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
      it_list_commentary it_list[]
      i_logo             'ENJOYSAP_LOGO'
*     I_END_OF_LIST_GRID =
*     I_ALV_FORM         =
    .
endform.                    "ALV_top_of_page
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值