************************************************************************
* All Rights Reserved *
*----------------------------------------------------------------------*
* Program Name : ZFIR0039 *
* Program Title: 分期收款發出商品物料資料
* Created by : DEV01 *
* Created on : 2006/08/02 *
* Version : 1.0 *
*----------------------------------------------------------------------*
* Function Description: *
* 分期收款發出商品物料資料
*----------------------------------------------------------------------*
* Data Table List: *
* bkpf:
* bseg:
* mkpf:
* mseg:
* vbrk:
* vbap:
* konv:
*----------------------------------------------------------------------*
* Refrence Table List: *
*
*----------------------------------------------------------------------*
* Modification Log: *
* Date Programmer Correction Number *
*2006-08-10 dev01 增加控制零值是否顯示控制引數
************************************************************************
report zFIR0039 .
*----------------------------------------------------------------------*
* TABLES *
*----------------------------------------------------------------------*
tables: bkpf,
bseg.
*----------------------------------------------------------------------*
* TYPES OR TYPE-POOLS *
*----------------------------------------------------------------------*
type-pools: slis.
*----------------------------------------------------------------------*
* INTERNAL TABLES AND WORK AREAS *
*----------------------------------------------------------------------*
* 查詢結果輸出內表
data: gt_result like zfico0001 occurs 0 with header line.
*WL/WA憑證對應物料憑證查詢結果
data: begin of gt_mkpf occurs 100,
matnr like vbrp-matnr, "物料代號
shkzg like zfico0001-shkzg, "借貸
blart like bkpf-blart, "憑證型別
hkont like bseg-hkont, "科目
vbeln like mkpf-mblnr, "物料單號
posnr like mseg-zeile, "行號
belnr like bkpf-belnr, "會計憑證號
fkart like mseg-bwart, "移動型別型別
fkimg like vbrp-fkimg, "數量
kwert like konv-kwert, "成本
bualt like mseg-bualt,
dmbtr like mseg-dmbtr, "成本
end of gt_mkpf.
data gt_mkpf_s like table of gt_mkpf.
*RV憑證對應發票查詢結果
data: begin of gt_vbrk occurs 100,
matnr like vbrp-matnr, "物料代號
shkzg like zfico0001-shkzg, "借貸
vbeln like vbrk-vbeln, "單號
posnr like vbrp-posnr, "行號
belnr like bkpf-awkey, "會計憑證號
fkart like vbrk-fkart, "型別
fkimg like vbrp-fkimg, "數量
kwert like konv-kwert, "成本
end of gt_vbrk.
data gt_vbrk_s like table of gt_vbrk.
*總表和明細表格式內表
data: gt_field type slis_t_fieldcat_alv,
gt_sort type slis_t_sortinfo_alv,
gt_sortvbrk type slis_t_sortinfo_alv,
gt_fieldvbrk type slis_t_fieldcat_alv,
gt_sortmkpf type slis_t_sortinfo_alv,
gt_fieldmkpf type slis_t_fieldcat_alv.
*----------------------------------------------------------------------*
* GLOBAL VARIABLES *
*----------------------------------------------------------------------*
data: g_repid like sy-repid,
g_dynnum like sy-dynnr.
*定義查詢螢幕
selection-screen begin of block s_1 with frame title text-001.
parameters: p_bukrs like bkpf-bukrs obligatory . "公司程式碼
parameters: p_dates like sy-datum obligatory default sy-datum."會計日期
parameters: p_datee like sy-datum obligatory default sy-datum."會計日期
selection-screen end of block s_1.
selection-screen begin of block s_2 with frame title text-002.
parameters: p_wl as checkbox default 'X'. "是否檢查WA
parameters: p_rv as checkbox default 'X'. "是否檢查RV
selection-screen end of block s_2.
include zformatgridfield.
************************************************************************
* MAIN PROCESS *
************************************************************************
*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
initialization.
g_repid = sy-repid.
g_dynnum = sy-dynnr.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*----------------------------------------------------------------------*
at selection-screen.
if p_dates+0(6) <> p_datee+0(6).
message '日期必須為同個期間' type 'E'.
endif.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
start-of-selection.
*----------------------------------------------------------------------*
* END-OF-SELECTION *
*----------------------------------------------------------------------*
end-of-selection.
*顯示結果
perform sub_select_data.
perform sub_create_field_cat.
perform sub_create_sort_cat.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = gt_field[]
it_sort = gt_sort[]
tables
t_outtab = gt_result[].
************************************************************************
*&Form Name : SUB_CREATE_FIELD_CAT
* Created by : DEV01 *
* Created on : 2006/07/31 *
*----------------------------------------------------------------------*
* Function Description: *
* 欄位格式定義
*----------------------------------------------------------------------*
*引數說明 *
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
* Date Programmer Description *
************************************************************************
form sub_create_field_cat.
refresh gt_field.
perform sub_field_des using :
'' '' 'BUKRS' '' 'X' '' '' '公司程式碼' '8' '' '' gt_field[],
'' '' 'GJAHR' '' 'X' '' '' '會計年度' '8' '' '' gt_field[],
'' '' 'MONAT' '' 'X' '' '' '會計期間' '8' '' '' gt_field[],
'' '' 'BLART' '' 'X' '' '' '憑證型別' '8' '' '' gt_field[],
'' '' 'HKONT' '' 'X' '' '' '會計科目' '10' '' '' gt_field[],
'' '' 'SHKZG' '' 'X' '' '' '借貸' '4' '' '' gt_field[],
'' '' 'MATNR' '' 'X' '' '' '物料程式碼' '18' '' '' gt_field[],
'' '' 'FKIMG' '' '' '' 'X' '數量' '15' '' '' gt_field[],
'' '' 'WRBTR' '' '' '' 'X' '成本' '15' '' '' gt_field[].
endform. " SUB_CREATE_FIELD_CAT
************************************************************************
*&Form Name : SUB_CREATE_SORT_CAT
* Created by : DEV01 *
* Created on : 2006/07/31 *
*----------------------------------------------------------------------*
* Function Description: *
* 欄位排序定義
*----------------------------------------------------------------------*
*引數說明 *
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
* Date Programmer Description *
* YYYY/MM/DD XXXXXXXX *
************************************************************************
form sub_create_sort_cat.
refresh gt_sort.
perform sub_field_sort using:
'BUKRS' '' '1' 'X' 'X' gt_sort[],
'GJAHR' '' '2' 'X' '' gt_sort[],
'MONAT' '' '3' 'X' '' gt_sort[].
endform. " SUB_CREATE_SORT_CAT
************************************************************************
*&Form Name : sub_select_data
* Created by : DEV01 *
* Created on : 2006/07/31 *
*----------------------------------------------------------------------*
* Function Description: *
* 欄位排序定義
*----------------------------------------------------------------------*
*引數說明 *
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
* Date Programmer Description *
* YYYY/MM/DD XXXXXXXX *
************************************************************************
form sub_select_data .
* 匯入資料來源庫(文字型)
data: begin of wa_bkpf ,
belnr like bkpf-belnr, "憑證號
awtyp like bkpf-awtyp, "參考過程
awkey like bkpf-awkey, "物件關鍵字
blart like bkpf-blart, "憑證型別
hkont like bseg-hkont, "會計科目
end of wa_bkpf.
*取物料憑證明細
data: begin of wa_mseg ,
matnr like mseg-matnr, "物料代號
zeile like mseg-zeile, "專案號
bwart like mseg-bwart, "移動型別
menge like mseg-menge, "數量
dmbtr like mseg-dmbtr, "成本
bualt like mseg-bualt,
smbln like mseg-smbln,
sjahr like mseg-sjahr,
smblp like mseg-smblp,
end of wa_mseg.
*取RV憑證明細
data: begin of wa_vbrk ,
matnr like vbrp-matnr, "物料代號
posnr like vbrp-posnr, "
knumv like vbrk-knumv, "
fkart like vbrk-fkart, "移動型別
fkimg like vbrp-fkimg, "數量
kwert like konv-kwert, "成本
sfakn like vbrk-sfakn, "已取消的出具發票憑證編號
end of wa_vbrk.
data: l_fkart like vbrk-fkart.
*計算‘WA’,‘WL’ 會計憑證
if p_wl = 'X'.
select bkpf~belnr bkpf~awtyp bkpf~awkey bkpf~blart
into corresponding fields of wa_bkpf
from bkpf
where bkpf~bukrs = p_bukrs
and bkpf~gjahr = p_dates+0(4)
and bkpf~blart in ('WA','WL')
and bkpf~budat between p_dates and p_datee.
*提取明細
select single bseg~hkont
into (wa_bkpf-hkont)
from bseg
where bukrs = p_bukrs
and belnr = wa_bkpf-belnr
and gjahr = p_dates+0(4)
and hkont in ('1291000000','1291040000','1291050000','1291010000').
if sy-subrc = 0."取物料憑證
select mseg~matnr mseg~zeile mseg~bwart mseg~menge
mseg~dmbtr mseg~bualt
mseg~smbln mseg~sjahr mseg~smblp
into wa_mseg
from mseg
where mblnr = wa_bkpf-awkey+0(10)
and mjahr = wa_bkpf-awkey+10(4).
gt_result-bukrs = p_bukrs.
gt_result-gjahr = p_dates+0(4).
gt_result-monat = p_dates+4(2).
gt_result-blart = wa_bkpf-blart.
gt_result-hkont = wa_bkpf-hkont.
gt_result-matnr = wa_mseg-matnr.
if wa_mseg-smbln ne space.
select single mseg~dmbtr
into (wa_mseg-dmbtr)
from mseg
where mblnr = wa_mseg-smbln
and mjahr = wa_mseg-sjahr
and zeile = wa_mseg-smblp.
endif.
if wa_bkpf-blart = 'WA'."計算WA憑證
case wa_mseg-bwart ."根據移動型別計借貸方
when '291' or '261' or '522' or '454'.
gt_result-shkzg = 'S'.
gt_result-fkimg = wa_mseg-menge.
gt_result-wrbtr = wa_mseg-dmbtr.
collect gt_result.
gt_mkpf-matnr = wa_mseg-matnr.
gt_mkpf-shkzg = gt_result-shkzg.
gt_mkpf-vbeln = wa_bkpf-awkey.
gt_mkpf-posnr = wa_mseg-zeile.
gt_mkpf-fkart = wa_mseg-bwart.
gt_mkpf-fkimg = wa_mseg-menge.
gt_mkpf-kwert = wa_mseg-dmbtr.
gt_mkpf-dmbtr = wa_mseg-dmbtr.
gt_mkpf-bualt = wa_mseg-bualt.
gt_mkpf-belnr = wa_bkpf-belnr.
gt_mkpf-blart = wa_bkpf-blart.
gt_mkpf-hkont = wa_bkpf-hkont.
append gt_mkpf.
when '292' or '262' or '521' or '453'.
gt_result-shkzg = 'H'.
gt_result-fkimg = - wa_mseg-menge.
* IF wa_mseg-smbln NE space.
* gt_result-wrbtr = - wa_mseg-bualt.
* ELSE.
gt_result-wrbtr = - wa_mseg-dmbtr.
* ENDIF.
collect gt_result.
gt_mkpf-matnr = wa_mseg-matnr.
gt_mkpf-shkzg = gt_result-shkzg.
gt_mkpf-vbeln = wa_bkpf-awkey.
gt_mkpf-posnr = wa_mseg-zeile.
gt_mkpf-fkart = wa_mseg-bwart.
gt_mkpf-fkimg = wa_mseg-menge.
gt_mkpf-kwert = - wa_mseg-dmbtr.
gt_mkpf-dmbtr = - wa_mseg-dmbtr.
gt_mkpf-bualt = - wa_mseg-bualt.
gt_mkpf-belnr = wa_bkpf-belnr.
gt_mkpf-blart = wa_bkpf-blart.
gt_mkpf-hkont = wa_bkpf-hkont.
append gt_mkpf.
endcase.
else."計算WL憑證
case wa_mseg-bwart ."根據移動型別計借貸方
when '601' or '654' or '954' or '643' or '674'
or '645' or '676' or '903' or '633'.
gt_result-shkzg = 'S'.
gt_result-fkimg = wa_mseg-menge.
gt_result-wrbtr = wa_mseg-dmbtr.
collect gt_result.
gt_mkpf-matnr = wa_mseg-matnr.
gt_mkpf-shkzg = gt_result-shkzg.
gt_mkpf-vbeln = wa_bkpf-awkey.
gt_mkpf-posnr = wa_mseg-zeile.
gt_mkpf-fkart = wa_mseg-bwart.
gt_mkpf-fkimg = wa_mseg-menge.
* IF wa_mseg-smbln NE space.
* gt_mkpf-kwert = wa_mseg-bualt.
* ELSE.
gt_mkpf-kwert = wa_mseg-dmbtr.
* ENDIF.
gt_mkpf-dmbtr = wa_mseg-dmbtr.
gt_mkpf-bualt = wa_mseg-bualt.
gt_mkpf-belnr = wa_bkpf-belnr.
gt_mkpf-blart = wa_bkpf-blart.
gt_mkpf-hkont = wa_bkpf-hkont.
append gt_mkpf.
when '602' or '653' or '953' or '644' or '673'
or '646' or '675' or '904' or '634'.
gt_result-shkzg = 'H'.
gt_result-fkimg = - wa_mseg-menge.
* IF wa_mseg-smbln NE space.
* gt_result-wrbtr = - wa_mseg-bualt.
* ELSE.
gt_result-wrbtr = - wa_mseg-dmbtr.
* ENDIF.
collect gt_result.
gt_mkpf-matnr = wa_mseg-matnr.
gt_mkpf-shkzg = gt_result-shkzg.
gt_mkpf-vbeln = wa_bkpf-awkey.
gt_mkpf-posnr = wa_mseg-zeile.
gt_mkpf-fkart = wa_mseg-bwart.
gt_mkpf-fkimg = wa_mseg-menge.
* IF wa_mseg-smbln NE space.
* gt_mkpf-kwert = - wa_mseg-bualt.
* ELSE.
gt_mkpf-kwert = - wa_mseg-dmbtr.
* ENDIF.
gt_mkpf-dmbtr = - wa_mseg-dmbtr.
gt_mkpf-bualt = - wa_mseg-bualt.
gt_mkpf-belnr = wa_bkpf-belnr.
gt_mkpf-blart = wa_bkpf-blart.
gt_mkpf-hkont = wa_bkpf-hkont.
append gt_mkpf.
endcase.
endif.
endselect.
endif.
endselect.
endif.
*計算‘RV’ 會計憑證
if p_rv = 'X'.
select bkpf~belnr bkpf~awtyp bkpf~awkey bkpf~blart
into corresponding fields of wa_bkpf
from bkpf
where bkpf~bukrs = p_bukrs
and bkpf~blart in ('RV')
and gjahr = p_dates+0(4)
and bkpf~budat between p_dates and p_datee.
*提取明細
select single bseg~hkont
into (wa_bkpf-hkont)
from bseg
where bukrs = p_bukrs
and belnr = wa_bkpf-belnr
and gjahr = p_dates+0(4)
and hkont = '1291000000'.
if sy-subrc = 0."取發票
select vbrk~fkart vbrp~posnr vbrk~sfakn vbrk~knumv vbrp~matnr vbrp~fkimg
into corresponding fields of wa_vbrk
from vbrk
inner join vbrp on vbrk~vbeln = vbrp~vbeln
where vbrk~vbeln = wa_bkpf-awkey+0(10).
if sy-subrc = 0.
select single kwert into (wa_vbrk-kwert)
from konv
where knumv = wa_vbrk-knumv
and kposn = wa_vbrk-posnr and kschl = 'ZPRS'."'VPRS'.
gt_result-bukrs = p_bukrs.
gt_result-gjahr = p_dates+0(4).
gt_result-monat = p_dates+4(2).
gt_result-blart = wa_bkpf-blart.
gt_result-hkont = wa_bkpf-hkont.
gt_result-matnr = wa_vbrk-matnr.
case wa_vbrk-fkart ."根據發票型別計借貸方
when 'ZC01' or 'ZC07' or 'ZC10' or 'ZC11' or 'ZC14'.
gt_result-shkzg = 'H'.
gt_result-fkimg = - wa_vbrk-fkimg.
gt_result-wrbtr = - wa_vbrk-kwert.
gt_vbrk-matnr = wa_vbrk-matnr.
gt_vbrk-shkzg = gt_result-shkzg.
gt_vbrk-vbeln = wa_bkpf-awkey+0(10).
gt_vbrk-posnr = wa_vbrk-posnr.
gt_vbrk-fkart = wa_vbrk-fkart.
gt_vbrk-fkimg = wa_vbrk-fkimg.
gt_vbrk-kwert = wa_vbrk-kwert.
gt_vbrk-belnr = wa_bkpf-belnr.
collect gt_result.
append gt_vbrk.
when 'ZC02' or 'ZC08' or 'ZC09' or 'ZC12' or 'ZC13'.
gt_result-shkzg = 'S'.
gt_result-fkimg = wa_vbrk-fkimg.
gt_result-wrbtr = wa_vbrk-kwert.
gt_vbrk-matnr = wa_vbrk-matnr.
gt_vbrk-shkzg = gt_result-shkzg.
gt_vbrk-vbeln = wa_bkpf-awkey+0(10).
gt_vbrk-posnr = wa_vbrk-posnr.
gt_vbrk-fkart = wa_vbrk-fkart.
gt_vbrk-fkimg = wa_vbrk-fkimg.
gt_vbrk-kwert = wa_vbrk-kwert.
gt_vbrk-belnr = wa_bkpf-belnr.
collect gt_result.
append gt_vbrk.
when 'ZC05'.
if wa_vbrk-sfakn <> space.
select single fkart into (l_fkart) from vbrk
where vbeln = wa_vbrk-sfakn.
if ( sy-subrc = 0 ) and ( l_fkart = 'ZC01').
gt_result-shkzg = 'S'.
gt_result-fkimg = wa_vbrk-fkimg.
gt_result-wrbtr = wa_vbrk-kwert.
gt_vbrk-matnr = wa_vbrk-matnr.
gt_vbrk-shkzg = gt_result-shkzg.
gt_vbrk-vbeln = wa_bkpf-awkey+0(10).
gt_vbrk-posnr = wa_vbrk-posnr.
gt_vbrk-fkart = wa_vbrk-fkart.
gt_vbrk-fkimg = wa_vbrk-fkimg.
gt_vbrk-kwert = wa_vbrk-kwert.
gt_vbrk-belnr = wa_bkpf-belnr.
collect gt_result.
append gt_vbrk.
endif.
endif.
when 'ZC06'.
if wa_vbrk-sfakn <> space.
select single fkart into (l_fkart) from vbrk
where vbeln = wa_vbrk-sfakn.
if ( sy-subrc = 0 ) and ( l_fkart = 'ZC02').
gt_result-shkzg = 'H'.
gt_result-fkimg = - wa_vbrk-fkimg.
gt_result-wrbtr = - wa_vbrk-kwert.
gt_vbrk-matnr = wa_vbrk-matnr.
gt_vbrk-shkzg = gt_result-shkzg.
gt_vbrk-vbeln = wa_bkpf-awkey+0(10).
gt_vbrk-posnr = wa_vbrk-posnr.
gt_vbrk-fkart = wa_vbrk-fkart.
gt_vbrk-fkimg = wa_vbrk-fkimg.
gt_vbrk-kwert = wa_vbrk-kwert.
gt_vbrk-belnr = wa_bkpf-belnr.
collect gt_result.
append gt_vbrk.
endif.
endif.
endcase.
endif.
endselect.
endif.
endselect.
endif.
endform. " sub_select_data
************************************************************************
*&Form Name : user_command
* Created by : DEV01 *
* Created on : 2006/07/31 *
*----------------------------------------------------------------------*
* Function Description: *
* 處理Grid雙擊事件
*----------------------------------------------------------------------*
*引數說明 *
*----------------------------------------------------------------------*
*-->im_ucomm: 螢幕功能碼
*-->im_selfield: 螢幕相關資訊
*----------------------------------------------------------------------*
* Date Programmer Description *
************************************************************************
form user_command using im_ucomm like sy-ucomm
im_selfield type slis_selfield.
case im_ucomm.
when '&IC1'. "doubleclick
read table gt_result index im_selfield-tabindex.
if ( sy-subrc = 0 ).
if gt_result-blart = 'RV' .
perform sub_create_fieldvbrk.
perform sub_create_sortvbrk.
perform sub_get_vbrk using gt_result-matnr gt_result-shkzg.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
it_fieldcat = gt_fieldvbrk[]
it_sort = gt_sortvbrk[]
tables
t_outtab = gt_vbrk_s[].
else.
perform sub_create_fieldmkpf.
perform sub_create_sortmkpf.
perform sub_get_mkpf using gt_result-matnr.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
it_fieldcat = gt_fieldmkpf[]
it_sort = gt_sortmkpf[]
tables
t_outtab = gt_mkpf_s[].
endif.
clear im_ucomm.
endif.
endcase.
endform. "USER_COMMAND
************************************************************************
*&Form Name : sub_create_fieldvbrk
* Created by : DEV01 *
* Created on : 2006/07/31 *
*----------------------------------------------------------------------*
* Function Description: *
* 明細欄位格式定義
*----------------------------------------------------------------------*
*引數說明 *
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
* Date Programmer Description *
************************************************************************
form sub_create_fieldvbrk.
refresh gt_fieldvbrk.
perform sub_field_des using :
'' '' 'MATNR' '' 'X' '' '' '物料程式碼' '18' '' '' gt_fieldvbrk[],
'' '' 'VBELN' '' 'X' '' '' '單據號' '10' '' '' gt_fieldvbrk[],
'' '' 'POSNR' '' 'X' '' '' '專案號' '4' '' '' gt_fieldvbrk[],
'' '' 'FKART' '' 'X' '' '' '憑證型別' '8' '' '' gt_fieldvbrk[],
'' '' 'BELNR' '' 'X' '' '' '會計憑證' '10' '' '' gt_fieldvbrk[],
'' '' 'FKIMG' '' '' '' '' '數量' '15' '' '' gt_fieldvbrk[],
'' '' 'KWERT' '' '' '' 'X' '成本' '15' '' '' gt_fieldvbrk[].
endform. " SUB_CREATE_FIELD_CAT
************************************************************************
*&Form Name : SUB_CREATE_SORTvbrk
* Created by : DEV01 *
* Created on : 2006/07/31 *
*----------------------------------------------------------------------*
* Function Description: *
* 明細欄位排序定義
*----------------------------------------------------------------------*
*引數說明 *
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
* Date Programmer Description *
* YYYY/MM/DD XXXXXXXX *
************************************************************************
form sub_create_sortvbrk.
refresh gt_sortvbrk.
perform sub_field_sort using:
'MATNR' '' '1' 'X' 'X' gt_sortvbrk[].
endform. " SUB_CREATE_SORTvbrk
************************************************************************
*&Form Name : sub_get_vbrk
* Created by : DEV01 *
* Created on : 2006/07/31 *
*----------------------------------------------------------------------*
* Function Description: *
* 明細欄位排序定義
*----------------------------------------------------------------------*
*引數說明 *
*----------------------------------------------------------------------*
* -->IM_MATNR 物料程式碼
* -->IM_SHKZG 借貸
*----------------------------------------------------------------------*
form sub_get_vbrk using im_matnr
im_shkzg.
clear gt_vbrk_s.
refresh gt_vbrk_s.
loop at gt_vbrk where matnr = im_matnr and shkzg = im_shkzg.
append gt_vbrk to gt_vbrk_s.
endloop.
endform. " sub_get_vbrk
************************************************************************
*&Form Name : sub_create_fieldvbrk
* Created by : DEV01 *
* Created on : 2006/07/31 *
*----------------------------------------------------------------------*
* Function Description: *
* 明細欄位格式定義
*----------------------------------------------------------------------*
*引數說明 *
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
* Date Programmer Description *
*2006-08-10 dev01 增加控制零值是否顯示控制引數
*2006-08-12 dev01 增加控制是否顯示控制引數
************************************************************************
form sub_create_fieldmkpf.
refresh gt_fieldmkpf.
perform sub_field_des using :
'' '' 'MATNR' '' 'X' '' '' '物料程式碼' '18' '' '' gt_fieldmkpf[],
'' '' 'BLART' '' 'X' '' '' '憑證型別' '8' '' '' gt_fieldmkpf[],
'' '' 'HKONT' '' 'X' '' '' '科目' '10' '' '' gt_fieldmkpf[],
'' '' 'SHKZG' '' 'X' '' '' '借貸' '10' '' '' gt_fieldmkpf[],
'' '' 'VBELN' '' 'X' '' '' '物料單號' '20' '' '' gt_fieldmkpf[],
'' '' 'POSNR' '' 'X' '' '' '專案號' '8' '' '' gt_fieldmkpf[],
'' '' 'FKART' '' 'X' '' '' '移動型別' '8' '' '' gt_fieldmkpf[],
'' '' 'BELNR' '' 'X' '' '' '會計憑證' '10' '' '' gt_fieldmkpf[],
'' '' 'FKIMG' '' '' '' '' '數量' '15' '' '' gt_fieldmkpf[],
'' '' 'KWERT' '' '' '' 'X' '成本' '15' '' '' gt_fieldmkpf[],
'' '' 'BUALT' '' '' '' 'X' 'BUALT' '15' '' '' gt_fieldmkpf[],
'' '' 'DMBTR' '' '' '' 'X' 'DMBTR' '15' '' '' gt_fieldmkpf[].
endform. " SUB_CREATE_FIELDmkpf
************************************************************************
*&Form Name : SUB_CREATE_SORTmkpf
* Created by : DEV01 *
* Created on : 2006/07/31 *
*----------------------------------------------------------------------*
* Function Description: *
* 明細欄位排序定義
*----------------------------------------------------------------------*
*引數說明 *
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
* Date Programmer Description *
* YYYY/MM/DD XXXXXXXX *
************************************************************************
form sub_create_sortmkpf.
refresh gt_sortmkpf.
perform sub_field_sort using:
'MATNR' '' '1' 'X' 'X' gt_sortmkpf[].
endform. " SUB_CREATE_SORTmkpf
************************************************************************
*&Form Name : sub_get_mkpf
* Created by : DEV01 *
* Created on : 2006/07/31 *
*----------------------------------------------------------------------*
* Function Description: *
* 明細欄位排序定義
*----------------------------------------------------------------------*
*引數說明 *
*----------------------------------------------------------------------*
* -->IM_MATNR 物料程式碼
*----------------------------------------------------------------------*
form sub_get_mkpf using im_matnr.
clear gt_mkpf_s.
refresh gt_mkpf_s.
loop at gt_mkpf where matnr = im_matnr.
append gt_mkpf to gt_mkpf_s.
endloop.
endform. " sub_get_bkpf
×ZFORMATGRIDFIELD
*----------------------------------------------------------------------*
* Form : SUB_FIELD_DES
* Created by : DEV01 *
* Created on : 2006/03/17 *
*----------------------------------------------------------------------*
* Description: Set the fields which will be displayed
*----------------------------------------------------------------------*
*引數說明 *
*---------------------------------------------------------------------*
* im_ref_FIELD---must upper case *
* im_ref_TABLE---internal table name *
* im_FIELDname---must upper case *
* im_TABname ---internal table name *
* im_KEY ---column with key-color AND frozen *
* im_CHECKBOX ---the column is checkbox *
* im_dosum ---total,if total, the field must be sumed *
* im_SELTEX_L ---column Long description of title *
* im_outputlen---column output length
* re_field : 欄位格式定義內表
*----------------------------------------------------------------------*
* Modification Log: *
* Date Programmer Correction Number *
*2006-08-10 dev01 增加控制零值是否顯示控制引數
*2006-08-12 dev01 增加控制是否顯示控制引數
*----------------------------------------------------------------------*
form sub_field_des using im_ref_field type c
im_ref_table type c
im_fieldname type c
im_tabname type c
im_key type c
im_checkbox type c
im_dosum type c
im_seltex_l type c
im_outputlen type i
im_zero type c
im_out type c
re_field type slis_t_fieldcat_alv.
data: wa_fieldcat type slis_fieldcat_alv.
clear wa_fieldcat.
wa_fieldcat-ref_fieldname = im_ref_field.
wa_fieldcat-ref_tabname = im_ref_table.
wa_fieldcat-fieldname = im_fieldname.
wa_fieldcat-tabname = im_tabname.
wa_fieldcat-key = im_key.
wa_fieldcat-checkbox = im_checkbox.
wa_fieldcat-do_sum = im_dosum.
wa_fieldcat-no_zero = im_zero.
wa_fieldcat-no_out = im_out.
wa_fieldcat-seltext_l = im_seltex_l.
wa_fieldcat-seltext_m = im_seltex_l.
wa_fieldcat-seltext_s = im_seltex_l.
wa_fieldcat-outputlen = im_outputlen.
* wa_fieldcat-col_pos = IM_colpos.
append wa_fieldcat to re_field.
endform. "SUB_FIELD_DES
*----------------------------------------------------------------------*
* Form : SUB_FIELD_DES_D
* Created by : DEV01 *
* Created on : 2006/10/18 *
*----------------------------------------------------------------------*
* Description: Set the fields which will be displayed
*----------------------------------------------------------------------*
*引數說明 *
*---------------------------------------------------------------------*
* im_ref_FIELD---must upper case *
* im_ref_TABLE---internal table name *
* im_FIELDname---must upper case *
* im_TABname ---internal table name *
* im_KEY ---column with key-color AND frozen *
* im_CHECKBOX ---the column is checkbox *
* im_dosum ---total,if total, the field must be sumed *
* im_SELTEX_L ---column Long description of title *
* im_outputlen---column output length
* IM_dec--小數點位數
* re_field : 欄位格式定義內表
*----------------------------------------------------------------------*
* Modification Log: *
* Date Programmer Correction Number *
*----------------------------------------------------------------------*
form sub_field_des_d using im_ref_field type c
im_ref_table type c
im_fieldname type c
im_tabname type c
im_key type c
im_checkbox type c
im_dosum type c
im_seltex_l type c
im_outputlen type i
im_zero type c
im_out type c
im_dec type c
re_field type slis_t_fieldcat_alv.
data: wa_fieldcat type slis_fieldcat_alv.
clear wa_fieldcat.
wa_fieldcat-ref_fieldname = im_ref_field.
wa_fieldcat-ref_tabname = im_ref_table.
wa_fieldcat-fieldname = im_fieldname.
wa_fieldcat-tabname = im_tabname.
wa_fieldcat-key = im_key.
wa_fieldcat-checkbox = im_checkbox.
wa_fieldcat-do_sum = im_dosum.
wa_fieldcat-no_zero = im_zero.
wa_fieldcat-no_out = im_out.
wa_fieldcat-seltext_l = im_seltex_l.
wa_fieldcat-seltext_m = im_seltex_l.
wa_fieldcat-seltext_s = im_seltex_l.
wa_fieldcat-outputlen = im_outputlen.
wa_fieldcat-decimals_out = im_dec.
* wa_fieldcat-col_pos = IM_colpos.
append wa_fieldcat to re_field.
endform. "SUB_FIELD_DES
*----------------------------------------------------------------------*
* Form : SUB_FIELD_DES_D
* Created by : DEV01 *
* Created on : 2006/10/18 *
*----------------------------------------------------------------------*
* Description: Set the fields which will be displayed
*----------------------------------------------------------------------*
*引數說明 *
*---------------------------------------------------------------------*
* im_ref_FIELD---must upper case *
* im_ref_TABLE---internal table name *
* im_FIELDname---must upper case *
* im_TABname ---internal table name *
* im_KEY ---column with key-color AND frozen *
* im_CHECKBOX ---the column is checkbox *
* im_dosum ---total,if total, the field must be sumed *
* im_SELTEX_L ---column Long description of title *
* im_outputlen---column output length
* im_chk --display check box
* re_field : 欄位格式定義內表
*----------------------------------------------------------------------*
* Modification Log: *
* Date Programmer Correction Number *
*----------------------------------------------------------------------*
form sub_field_des_chk using im_ref_field type c
im_ref_table type c
im_fieldname type c
im_tabname type c
im_key type c
im_checkbox type c
im_dosum type c
im_seltex_l type c
im_outputlen type i
im_zero type c
im_out type c
im_chk type c
re_field type slis_t_fieldcat_alv.
data: wa_fieldcat type slis_fieldcat_alv.
clear wa_fieldcat.
wa_fieldcat-ref_fieldname = im_ref_field.
wa_fieldcat-ref_tabname = im_ref_table.
wa_fieldcat-fieldname = im_fieldname.
wa_fieldcat-tabname = im_tabname.
wa_fieldcat-key = im_key.
wa_fieldcat-checkbox = im_checkbox.
wa_fieldcat-do_sum = im_dosum.
wa_fieldcat-no_zero = im_zero.
wa_fieldcat-no_out = im_out.
wa_fieldcat-seltext_l = im_seltex_l.
wa_fieldcat-seltext_m = im_seltex_l.
wa_fieldcat-seltext_s = im_seltex_l.
wa_fieldcat-outputlen = im_outputlen.
wa_fieldcat-checkbox = im_chk.
* wa_fieldcat-col_pos = IM_colpos.
append wa_fieldcat to re_field.
endform. "SUB_FIELD_DES
*&--------------------------------------------------------------------*
* Form : SUB_FIELD_SORT
* Created by : DEV01 *
* Created on : 2006/03/17 *
*&--------------------------------------------------------------------*
* Function Description: *
* Set the sorted fields
*----------------------------------------------------------------------*
*引數說明 *
*---------------------------------------------------------------------*
* IM_FIELDNAME---The field will be sorted *
* IM_TABNAME ---internal table name *
* IM_SPOS ---Sort sequence *
* IM_UP ---Ascending,down-Descending *
* IM_subtot ---sub total,if subtotal, the field must be sumed *
* rt_sort --排序內表
*&--------------------------------------------------------------------*
form sub_field_sort using im_fieldname type c
im_tabname type c
im_spos type i
im_up type c
im_subtot type c
re_sort type slis_t_sortinfo_alv.
data: wa_sort type slis_sortinfo_alv.
clear wa_sort .
wa_sort-fieldname = im_fieldname. "The field will be sorted
wa_sort-tabname = im_tabname. "internal table name
wa_sort-spos = im_spos. "Sort sequence
wa_sort-up = im_up. "Ascending,down-Descending
wa_sort-subtot = im_subtot.
append wa_sort to re_sort.
endform. "SUB_FIELD_SORT