研发管理

img pafa

first report

发表于2004/9/29 17:14:00  1319人阅读

*&---------------------------------------------------------------------*
*& Report  ZSDRP_ORD_LIST_PF1
*
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZSDRP_ORD_LIST_PF1
        no standard page heading
        line-size 255 line-count 65(2).

***********************************************************************
* Title           : ZSDRP_ORD_LIST_PF                                 *
* Application     : SD                                                *
* Subject         : PR Report                                         *
* Author          : PF 2004/09/29                                     *
***********************************************************************
* 为了销售订单管理的目的,需要跟踪销售订单的净单价,同时也需  *
* 要跟踪销售订单的毛单价。                                            *
*
***********************************************************************
* MODIFICATIONS (latest entry at the top)                             *
* -------------                                                       *
* REL  DATE    NAME (COMPANY)     DESCRIPTION               TASK-NO   *
* ---  ----    ---- ---------     -----------               -------   *
***********************************************************************


tables: VBAK,    "销售凭证 : 抬头数据
        KNA1,    "客户主文件的一般数据
        VBAP.    "销售凭证:项目数据

*内部表定义
data: begin of it_vbak occurs 0,
        VBELN    like VBAK-VBELN,  "销售凭证号
        KUNNR    like VBAK-KUNNR,  "售达方(客户代码)
        AUDAT    like VBAK-AUDAT,  "定单日期
      end of it_vbak.

data: begin of it_kna1 occurs 0,
        KUNNR    like KNA1-KUNNR,  "客户编号
        NAME1    like KNA1-NAME1,  "名称
      end of it_kna1.

data: begin of it_vbap occurs 0,
        VBELN    like  VBAP-VBELN,   "销售凭证号
        POSNR    like  VBAP-POSNR,   "销售凭证项目
        MATNR    like  VBAP-MATNR,   "物料号
        KWMENG   like  VBAP-KWMENG,  "以销售单位表示的累计订购数量
        VRKME    like  VBAP-VRKME,   "销售单位
        MEINS    like  VBAP-MEINS,   "基本计量单位
        CMPRE    like  VBAP-CMPRE,   "毛单价
        NETPR    like  VBAP-NETPR,   "净单价
        WAERK    like  VBAP-WAERK,   "SD 凭证货币
      end of it_vbap.

* for final output
data: begin of it_output occurs 0,
         KUNNR   like  VBAK-KUNNR,   "客户编号
         NAME1   like  KNA1-NAME1,   "名称
         VBELN   like  VBAK-VBELN,   "销售凭证号
         AUDAT   like  VBAK-AUDAT,   "定单日期
         POSNR   like  VBAP-POSNR,   "销售凭证项目
         MATNR   like  VBAP-MATNR,   "物料号
         KWMENG  like  VBAP-KWMENG,  "以销售单位表示的累计订购数量
         VRKME   like  VBAP-VRKME,   "销售单位
         MEINS   like  VBAP-MEINS,   "基本计量单位
         CMPRE   like  VBAP-CMPRE,   "毛单价
         NETPR   like  VBAP-NETPR,   "净单价
         WAERK   like  VBAP-WAERK,   "SD 凭证货币
      end of it_output.


*---------------------------------------------------------------------*
* INITIALIZATION
*---------------------------------------------------------------------*
initialization.

*---------------------------------------------------------------------*
* AT SELECTION-SCREEN
*---------------------------------------------------------------------*


select-options:
  S_AUDAT for VBAK-AUDAT,               "订单日期
  S_KUNNR for vbak-KUNNR.               "客户代码


*---------------------------------------------------------------------*
* start-of-selection
*---------------------------------------------------------------------*
start-of-selection.

  select vbeln
         kunnr
         audat
    from vbak
    into table it_vbak
   where audat in s_audat and  kunnr in  s_kunnr.

  if sy-subrc <> 0.
    write: '没有记录显示'.
  endif.

  select kunnr
         name1
    from kna1
    into table it_kna1
    for all entries in it_vbak
    where kunnr = it_vbak-kunnr.

  if sy-subrc <> 0.
    write: / '没有相应的记录在客户主数据中'.
  endif.

  select vbeln
         posnr
         matnr
         kwmeng
         vrkme
         meins
         cmpre
         netpr
         waerk
    from vbap
    into table it_vbap
    for all entries in it_vbak
    where vbeln = it_vbak-vbeln.

  if sy-subrc <> 0.
    write: / '没有相应的记录在销售凭证的项目数据中'.
  endif.

loop at it_vbak.
    clear it_output.
    it_output-vbeln = it_vbak-vbeln.
    it_output-kunnr = it_vbak-kunnr.
    it_output-audat = it_vbak-audat.

    read table it_kna1
    with key kunnr = it_vbak-kunnr.
    if sy-subrc = 0.
       it_output-name1 = it_kna1-name1.
    endif.

    read table it_vbap
    with key vbeln = it_vbak-vbeln.
    if sy-subrc = 0.
       it_output-posnr = it_vbap-posnr.
       it_output-matnr = it_vbap-matnr.
      it_output-kwmeng = it_vbap-kwmeng.
       it_output-vrkme = it_vbap-vrkme.
       it_output-meins = it_vbap-meins.
       it_output-cmpre = it_vbap-cmpre.
       it_output-netpr = it_vbap-netpr.
       it_output-waerk = it_vbap-waerk.
     endif.
  append it_output.
endloop.

sort it_output by kunnr.

 

*---------------------------------------------------------------------*
* end-of-selection
*---------------------------------------------------------------------*

end-of-selection.

* Output report
  perform pf_list_in_alv tables it_output.  "Write to screen


*&--------------------------------------------------------------------*
*&      Form  pf_list_in_alv
*&--------------------------------------------------------------------*
*       Output report form
*---------------------------------------------------------------------*
form pf_list_in_alv tables i_table.
  type-pools: slis.
  data: gt_fieldcat type slis_t_fieldcat_alv,
        gs_layout type slis_layout_alv,
        it_sort type slis_sortinfo_alv occurs 0.
  data: g_repid like sy-repid,
        wstr_event type slis_alv_event,
        wtbl_event type slis_t_event.
  data: begin of it_sort_row occurs 0,
           spos like alvdynp-sortpos,
           fieldname type slis_fieldname,
           tabname type slis_fieldname,
           up like alvdynp-sortup,
           down like alvdynp-sortdown,
           group like alvdynp-grouplevel,
           subtot like alvdynp-subtotals,
           comp(1) type c,
           expa(1) type c,
           obligatory(1) type c,
        end of it_sort_row.
  g_repid = sy-repid.
  gs_layout-zebra = 'X'.
  gs_layout-f2code = '&amp;ETA'.
  gs_layout-detail_popup = 'X'.
  gs_layout-colwidth_optimize = 'X'.


  perform fieldcat_init using gt_fieldcat[].

   it_sort_row-fieldname = 'KUNNR'.
  it_sort_row-spos = 2.
  it_sort_row-up = 'X'.
  it_sort_row-subtot = 'X'.
  append it_sort_row to it_sort.

  wstr_event-name = 'TOP_OF_PAGE'.
  wstr_event-form = 'TOP_OF_PAGE_CALLBACK'.
  append wstr_event to wtbl_event.

  call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
      i_callback_program = g_repid
      it_fieldcat        = gt_fieldcat[]
      is_layout          = gs_layout
      it_events          = wtbl_event
      it_sort            = it_sort
    tables
      t_outtab           = i_table.

endform.

*&--------------------------------------------------------------------*
*&      Form  fieldcat_init
*&--------------------------------------------------------------------*
* Initialization fieldcatalog   DEFINITION OF HEADING.
*      Fieldnames and ref_fieldnames MUST be UPPER CASE !!
*---------------------------------------------------------------------*
form fieldcat_init
            using rt_fieldcat type slis_t_fieldcat_alv.
  data: ls_fieldcat type slis_fieldcat_alv.
  data: pos type i value 1.
  clear ls_fieldcat.

  ls_fieldcat-col_pos   =  pos.
  ls_fieldcat-fieldname = 'KUNNR'.
  ls_fieldcat-key       = 'X'.
  ls_fieldcat-seltext_l = '客户编号'.
  ls_fieldcat-seltext_m = '客户编号'.
  ls_fieldcat-seltext_s = '客户编号'.
  ls_fieldcat-outputlen = 10.
  append ls_fieldcat to rt_fieldcat.
  clear ls_fieldcat.
  pos = pos + 1.

  ls_fieldcat-col_pos   =  pos.
  ls_fieldcat-fieldname = 'NAME1'.
  ls_fieldcat-seltext_l = '客户名称'.
  ls_fieldcat-seltext_m = '客户名称'.
  ls_fieldcat-seltext_s = '客户名称'.
  ls_fieldcat-outputlen = 12.
  append ls_fieldcat to rt_fieldcat.
  clear ls_fieldcat.
  pos = pos + 1.

  ls_fieldcat-col_pos   =  pos.
  ls_fieldcat-fieldname = 'VBELN'.
  ls_fieldcat-seltext_l = '销售订单编号'.
  ls_fieldcat-seltext_m = '销售订单编号'.
  ls_fieldcat-seltext_s = '销售订单编号'.
  ls_fieldcat-outputlen = 10.
  append ls_fieldcat to rt_fieldcat.
  clear ls_fieldcat.
  pos = pos + 1.

  ls_fieldcat-col_pos   =  pos.
  ls_fieldcat-fieldname = 'AUDAT'.
  ls_fieldcat-seltext_l = '订单日期'.
  ls_fieldcat-seltext_m = '订单日期'.
  ls_fieldcat-seltext_s = '订单日期'.
  ls_fieldcat-outputlen = 10.
  append ls_fieldcat to rt_fieldcat.
  clear ls_fieldcat.
  pos = pos + 1.

  ls_fieldcat-col_pos   =  pos.
  ls_fieldcat-fieldname = 'POSNR'.
  ls_fieldcat-seltext_l = '销售订单明细项目编号'.
  ls_fieldcat-seltext_m = '销售订单明细项目编号'.
  ls_fieldcat-seltext_s = '销售订单明细项目编号'.
  ls_fieldcat-outputlen = 30.
  append ls_fieldcat to rt_fieldcat.
  clear ls_fieldcat.
  pos = pos + 1.

  ls_fieldcat-col_pos   =  pos.
  ls_fieldcat-fieldname = 'MATNR'.
  ls_fieldcat-seltext_l = '物料编号'.
  ls_fieldcat-seltext_m = '物料编号'.
  ls_fieldcat-seltext_s = '物料编号'.
  ls_fieldcat-outputlen = 10.
  append ls_fieldcat to rt_fieldcat.
  clear ls_fieldcat.
  pos = pos + 1.

  ls_fieldcat-col_pos   =  pos.
  ls_fieldcat-fieldname = 'KWMENG'.
  ls_fieldcat-seltext_l = '订购数量'.
  ls_fieldcat-seltext_m = '订购数量'.
  ls_fieldcat-seltext_s = '订购数量'.
  ls_fieldcat-outputlen = 20.
  append ls_fieldcat to rt_fieldcat.
  clear ls_fieldcat.
  pos = pos + 1.

    ls_fieldcat-col_pos   =  pos.
  ls_fieldcat-fieldname = 'VRKME'.
  ls_fieldcat-seltext_l = '销售单位'.
  ls_fieldcat-seltext_m = '销售单位'.
  ls_fieldcat-seltext_s = '销售单位'.
  ls_fieldcat-outputlen = 20.
  append ls_fieldcat to rt_fieldcat.
  clear ls_fieldcat.
  pos = pos + 1.

  ls_fieldcat-col_pos   =  pos.
  ls_fieldcat-fieldname = 'MEINS'.
  ls_fieldcat-seltext_l = '基本单位'.
  ls_fieldcat-seltext_m = '基本单位'.
  ls_fieldcat-seltext_s = '基本单位'.
  ls_fieldcat-outputlen = 20.
  append ls_fieldcat to rt_fieldcat.
  clear ls_fieldcat.
  pos = pos + 1.

  ls_fieldcat-col_pos   =  pos.
  ls_fieldcat-fieldname = 'CMPRE'.
  ls_fieldcat-seltext_l = '毛单价'.
  ls_fieldcat-seltext_m = '毛单价'.
  ls_fieldcat-seltext_s = '毛单价'.
  ls_fieldcat-outputlen = 20.
  append ls_fieldcat to rt_fieldcat.
  clear ls_fieldcat.
  pos = pos + 1.

  ls_fieldcat-col_pos   =  pos.
  ls_fieldcat-fieldname = 'NETPR'.
  ls_fieldcat-seltext_l = '净单价'.
  ls_fieldcat-seltext_m = '净单价'.
  ls_fieldcat-seltext_s = '净单价'.
  ls_fieldcat-outputlen = 20.
  append ls_fieldcat to rt_fieldcat.
  clear ls_fieldcat.
  pos = pos + 1.

  ls_fieldcat-col_pos   =  pos.
  ls_fieldcat-fieldname = 'WEARK'.
  ls_fieldcat-seltext_l = '凭证货币'.
  ls_fieldcat-seltext_m = '凭证货币'.
  ls_fieldcat-seltext_s = '凭证货币'.
  ls_fieldcat-outputlen = 20.
  append ls_fieldcat to rt_fieldcat.
  clear ls_fieldcat.
  pos = pos + 1.

endform.

*---------------------------------------------------------------------*
*       FORM top_of_page_callback                                     *
*---------------------------------------------------------------------*
form top_of_page_callback.

  WRITE: / '销售订单列表'.
  WRITE: / 'Date', sy-datum.

endform.

阅读全文
0 0

相关文章推荐

img
取 消
img