码迷,mamicode.com
首页 > 其他好文 > 详细

CK13物料价格评估的数据ALV显示

时间:2016-05-10 12:30:48      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

*&---------------------------------------------------------------------*
*& Report  ZPP023
*&
*&---------------------------------------------------------------------*
*&    Author:****               DAta:****
*&    description: *****
*&---------------------------------------------------------------------*

Report  ZPP023.
tables:KEKO,KEPH,marc.



DATABEGIN OF F_KEKO_KEY.
      INCLUDE STRUCTURE CKIKEKOKEY.
DATAEND OF F_KEKO_KEY.

DATABEGIN OF F_KEKO.
      INCLUDE STRUCTURE KEKO.
DATAEND OF F_KEKO.

DATABEGIN OF GT_KEKO OCCURS 20.
      INCLUDE STRUCTURE KEKO.
DATAEND OF GT_KEKO.



DATABEGIN OF GT_EXCEL OCCURS 20.
DATA: MONTH(6type C,
      MAKTX LIKE MAKT-MAKTX,
      MTART LIKE MARA-MTART.
data: MATNR LIKE KEKO-MATNR,
      KLVAR like KEKO-KLVAR,
      LOSGR like KEKO-LOSGR.
      INCLUDE STRUCTURE KEPH.
data: KST_HJ001(16type p decimals 5,
      KST_HJ005(16type p decimals 5,
      KST_HJ007(16type p decimals 5,
      KST_HJ009(16type p decimals 5,
      KST_HJ011(16type p decimals 5,
      KST_HJ013(16type p decimals 5,
      KST_HJ(16type p decimals 5.
DATAEND OF GT_EXCEL.

DATABEGIN OF GW_EXCEL .
DATA: MONTH(6type C,
      MAKTX LIKE MAKT-MAKTX,
      MTART LIKE MARA-MTART.
DATA: MATNR LIKE KEKO-MATNR,
      KLVAR like KEKO-KLVAR,
      LOSGR like KEKO-LOSGR.
      INCLUDE STRUCTURE KEPH.
data: KST_HJ001(16type p decimals 5,
      KST_HJ005(16type p decimals 5,
      KST_HJ007(16type p decimals 5,
      KST_HJ009(16type p decimals 5,
      KST_HJ011(16type p decimals 5,
      KST_HJ013(16type p decimals 5,
      KST_HJ(16type p decimals 5.
DATAEND OF GW_EXCEL.

type-pools:slis.
data:f_pos type i,
     it_fieldcat type lvc_t_fcat,
      is_fieldcat type lvc_s_fcat,
     it_layout type lvc_s_layo.

selection-screen begin of block b1 with frame title text-001.

select-options:R_MATNR for marc-matnr.
select-options:R_KADKY for KEPH-KADKY."成本核算日期
select-options:R_DATS for KEKO-KADAT.
  selection-screen end of block b1.

 at selection-screen.
   perform get_Data.
   perform dis_alv.


*----------------------------------------------------------------------*
*       FORM get_Data.
*----------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form get_Data.
  SELECT * INTO table GT_KEKO FROM KEKO WHERE matnr in R_MATNR and KADAT in R_DATS and BIDAT in R_DATS and KADKY in R_KADKY.

  loop at GT_KEKO into F_KEKO.

    move-corresponding F_KEKO to F_KEKO_KEY.
    perform KEPH_READ using F_KEKO_KEY F_KEKO.

    clear:F_KEKO.
    endloop.

  endform.

*----------------------------------------------------------------------*
*       FORM KEPH_READ.
*----------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
 form KEPH_READ using F_KEKO_KEY  type CKIKEKOKEY  F_KEKO  type KEKO.

data:Y_X type value ‘X‘.
DATABEGIN OF T_KEPH OCCURS 20.
      INCLUDE STRUCTURE KEPH.
DATAEND OF T_KEPH.
DATABEGIN OF W_KEPH.
      INCLUDE STRUCTURE KEPH.
DATAEND OF W_KEPH.

       CALL FUNCTION ‘CK_F_KEKO_KEPH_DIRECT_READ‘
         EXPORTING
              F_KEKOKEY = F_KEKO_KEY
              READ_KEKO = Y_X
              READ_KEPH = Y_X
         IMPORTING
              F_KEKO = F_KEKO
         TABLES
              I_KEPH = T_KEPH
         EXCEPTIONS
              DATA_NOT_FOUND 01.

       loop at T_KEPH into W_KEPH where KKZST <> ‘X‘.
        move-corresponding W_KEPH to gw_excel.
        gw_excel-matnr = F_KEKO-matnr.
        gw_excel-month = F_KEKO-KADKY+0(6).
        gw_excel-losgr = F_KEKO-LOSGR.
        gw_excel-klvar = F_KEKO-klvar.
        select single mtart into gw_excel-mtart from mara where matnr = gw_excel-matnr.
        select single maktx into gw_excel-maktx from makt where matnr = gw_excel-matnr.

        "计算价格单位为1时的成本
        if  gw_excel-losgr is not initial.
        gw_excel-KST_HJ001 = gw_excel-KST001 / gw_excel-losgr.
        gw_excel-KST_HJ005 = gw_excel-KST005 / gw_excel-losgr.
        gw_excel-KST_HJ007 = gw_excel-KST007 / gw_excel-losgr.
        gw_excel-KST_HJ009 = gw_excel-KST009 / gw_excel-losgr.
        gw_excel-KST_HJ011 = gw_excel-KST011 / gw_excel-losgr.
        gw_excel-KST_HJ013 = gw_excel-KST013 / gw_excel-losgr.
        gw_excel-KST_HJ = gw_excel-KST001 + gw_excel-KST005 + gw_excel-KST007 + gw_excel-KST009 + gw_excel-KST011 + gw_excel-KST013.
        gw_excel-KST_HJ = gw_excel-KST_HJ / gw_excel-losgr.
        endif.

        shift  gw_excel-matnr left deleting leading ‘0‘.
        append gw_excel to gt_excel.
        clear:gw_excel,W_KEPH.
        endloop.

       endform.
*&---------------------------------------------------------------------*
*&      Form  DIS_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form DIS_ALV .    
perform fill_fieldcat.     
call function ‘REUSE_ALV_GRID_DISPLAY_LVC‘     
exporting       i_callback_program    
= sy-repid       

"i_callback_pf_status_set = ‘PF_status‘      
" i_callback_user_command  = ‘USER_COMMAND‘       it_fieldcat_lvc          
= it_fieldcat       
"is_layout_lvc            = it_layout       
"i_save                  = ‘A‘       
"it_sort_lvc                = it_sort_lvc      

tables        t_outtab                
= gt_excel         

exceptions       program_error            
1       
others                   2.


endform.                    " DIS_ALV
*&---------------------------------------------------------------------*
*&      Form  FILL_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form FILL_FIELDCAT .   
define add_field.      is_fieldcat
-fieldname = &1.      is_fieldcat
-tabname = &2.      is_fieldcat
-coltext  = &3.      is_fieldcat
-key = &4.      is_fieldcat
-col_pos = &5.      

append is_fieldcat to it_fieldcat.      
clear:is_fieldcat.      
end-of-definition.  add_field

:‘MONTH‘ ‘gt_excel‘ ‘月份‘ ‘X‘ ‘1‘,            
‘MATNR‘ ‘gt_excel‘ ‘物料号‘ ‘X‘ ‘2‘,            
‘MAKTX‘ ‘gt_excel‘ ‘物料描述‘ ‘X‘ ‘3‘,            
‘MTART‘ ‘gt_excel‘ ‘物料类型‘ ‘X‘ ‘4‘,            
‘KLVAR‘ ‘gt_excel‘ ‘价格类型‘ ‘X‘ ‘5‘,            
‘KST_HJ001‘ ‘gt_excel‘ ‘原材料‘ ‘‘ ‘6‘,            
‘KST_HJ005‘ ‘gt_excel‘ ‘SMT加工成本‘ ‘‘ ‘7‘,            
‘KST_HJ007‘ ‘gt_excel‘ ‘直接人工‘ ‘‘ ‘8‘,            
‘KST_HJ009‘ ‘gt_excel‘ ‘制造费用‘ ‘‘ ‘9‘,            
‘KST_HJ011‘ ‘gt_excel‘ ‘外协加工费‘ ‘‘ ‘10‘,            
‘KST_HJ013‘ ‘gt_excel‘ ‘辅助部门费用分摊‘ ‘‘ ‘11‘,            
‘KST_HJ‘ ‘gt_excel‘ ‘合计‘ ‘‘ ‘12‘.

endform.                    " FILL_FIELDCAT

CK13物料价格评估的数据ALV显示

标签:

原文地址:http://www.cnblogs.com/QIANQIANHAPPY/p/5477182.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!