FI--分期收款发出商品物料数据(仅供参考)
************************************************************************
* 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