BILLING REPORT

report zrsd_pce_0165 no standard page heading message-id zs001.

include zrsd_pce_0165_top.
include zrsd_pce_0165_fm.

at selection-screen on value-request for filename.
  perform. choose_input_file .


*---------------------------------------------------------------------*
*                     START-OF-SELECTION                              *
*---------------------------------------------------------------------*
start-of-selection.
  repid = sy-repid.
  perform. extract_document_data.
  describe table out_tab_list_1 lines listline .
  if listline > 0.
    perform  build_field.
    perform  display_data.
  else.
    message s003 with 'NO DATA FOUND!'. "No data found.
  endif.

*----------------------------------------------------------------------*
*   INCLUDE ZRSD_PCE_0165_FM                                           *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  extract_document_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&gt  p1        text
*  *----------------------------------------------------------------------*
form. extract_document_data .

  select vbrk~vbeln vbrp~aubel as vbelna vbrp~vgbel as vbelnl
  vbrk~fkart vbrk~kunag vbrk~vkorg vbrk~vtweg vbrk~spart vbrk~erdat
  vbak~bstnk
  into corresponding fields of table out_tab_list
  from vbrk inner join vbrp
  on vbrk~vbeln = vbrp~vbeln
  inner join vbak
  on vbak~vbeln = vbrp~aubel
  where vbrk~vbeln in vbeln
    and vbrp~aubel in vbelna
    and vbrp~vgbel in vbelnl
    and vbak~bstnk in bstnk
    and vbrk~kunag in kunnr
    and vbrk~vkorg in vkorg
    and vbrk~vtweg in vtweg
    and vbrk~spart in spart
    and vbrk~fkart in fkart
    and vbrk~erdat in erdat
    and vbrk~vbeln not like '28%'.
**" 28 is cancel billing

  sort out_tab_list by  vbeln bstnk.
  loop at out_tab_list.
    clear:out_tab_list_1.
    move-corresponding out_tab_list to out_tab_list_1.
***get cancell billing number
    select single vbeln into out_tab_list_1-sfakn
    from vbrk where sfakn = out_tab_list-vbeln.
***check DN if exist.
    select single * from likp where vbeln = out_tab_list-vbelnl.
    if sy-subrc <> 0.
      if  ( out_tab_list-fkart = 'ZPLA')
         or ( out_tab_list-fkart = 'ZPLB')
         or ( out_tab_list-fkart = 'ZPLC')
         or ( out_tab_list-fkart = 'ZPLD')
         or ( out_tab_list-fkart = 'ZPLE').
        continue.
      endif.
    endif.

    append out_tab_list_1.
  endloop.
  delete adjacent duplicates from out_tab_list_1 comparing all fields.

endform.                    " extract_document_data
*&---------------------------------------------------------------------*
*&      Form  build_field
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&gt  p1        text
*  *----------------------------------------------------------------------*
form. build_field.
  perform. append_alv using:
    'SELID' 'Selid'  'X' 'X',
    'VBELN' 'Billing Document' '' '',
    'BSTNK' 'Customer PO' '' '',
    'VBELNA' 'Sales Order' '' '',
    'VBELNL' 'Delivery Notes' '' '',
    'SFAKN'  'Cancel Billing Number' '' '',
    'FKART' 'Billing type' '' '',
    'KUNAG' 'Sold to party' '' '',
    'VKORG' 'Sales Org'  '' '',
    'VTWEG' 'Sales Channel'  '' '',
    'SPART' 'Divison'  '' '',
    'ERDAT' 'Billing Create Date' '' ''.
endform.                    " build_field
*&---------------------------------------------------------------------*
*&      Form  display_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&gt  p1        text
*  *----------------------------------------------------------------------*
form. display_data.
  wa_layout-zebra = 'X'.
  wa_layout-colwidth_optimize = 'X'.
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program       = repid
            i_callback_pf_status_set = 'ZSD_165_1000'
            i_callback_user_command  = 'USER_COMMAND'
            i_grid_title             = 'EMC invoice For EPDIII'
            is_layout                = wa_layout
            it_fieldcat              = fieldcat[]
       tables
            t_outtab                 = out_tab_list_1[].

endform.                    " display_data
*&---------------------------------------------------------------------*
*&      Form  append_alv
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&gtP_1805   text
*      --&gtP_1806   text
*      --&gtP_1807   text
*      --&gtP_1808   text
*----------------------------------------------------------------------*
form. append_alv using   fieldname fieldtext checkbox edit.
  move:
      fieldname to fieldcat-fieldname,
      fieldtext to fieldcat-seltext_l,
      checkbox  to fieldcat-checkbox,
      edit      to fieldcat-edit.
  append fieldcat to fieldcat.
  clear fieldcat.
endform.                    " append_alv


*&---------------------------------------------------------------------*
*&      Form  Z165_1000
*&---------------------------------------------------------------------*
form. zsd_165_1000 using rt_extab type slis_t_extab.
  set pf-status '1000'.
endform.
*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&gt  p1        text
*  *----------------------------------------------------------------------*
form. user_command using r_ucomm type sy-ucomm
                         rs_selfield type slis_selfield.

  call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
       importing
            e_grid = gv_grid.
  call method gv_grid->check_changed_data.
  call method gv_grid->refresh_table_display.

  case r_ucomm.
    when 'BACK'.
      leave to  screen 0.
    when 'EXIT'.
      leave program.
    when 'OUTPUT' .
      perform. list_document .
    when 'EXCEL'.
      perform. excel_document .
    when 'SELALL'.
      perform  mark_all using 'X' .
    when 'DESELALL'.
      perform. mark_all using 'N' .
  endcase.
endform.
*&---------------------------------------------------------------------*
*&      Form  list_document
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&gt  p1        text
*  *----------------------------------------------------------------------*
form. list_document.
  describe table out_tab_list_1 lines listline.
  do listline times.
    out_tab_list_1-selid = space.
    clear:  out_tab_list_1 .
    read line sy-index field
         value  out_tab_list_1-selid  out_tab_list_1-vbeln.
    check sy-subrc eq 0.
    if out_tab_list_1-selid ='X'.
      modify out_tab_list_1 transporting selid
            where vbeln = out_tab_list_1-vbeln.
    elseif out_tab_list_1-selid eq ''.
      modify out_tab_list_1 transporting selid
            where vbeln = out_tab_list_1-vbeln.
    endif.

    read table out_tab_list_1 with key selid  = 'X'.
    if  out_tab_list_1-selid ='X'.
      modify  out_tab_list_1 transporting selid
            where vbeln =  out_tab_list_1-vbeln.
    elseif  out_tab_list_1-selid eq ''.
      modify  out_tab_list_1 transporting selid
            where vbeln = out_tab_list_1-vbeln.
    endif.
  enddo.
  read table  out_tab_list_1  with key selid  = 'X'.
  if sy-subrc ne 0.
    message i000 with 'Please First Choose ItemNO.'.
    exit.
  else.
    perform. output_pdf.
    perform. call_smartforms.
  endif.

endform.                    " list_document

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14397246/viewspace-666220/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/14397246/viewspace-666220/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值