应收账款账龄应该是按基准日期+现金折扣天数来计算的。
本程序同时可以按账龄周期按时间段统计金额。
agea(4) type p default -90,
ageb(4) type p default -60,
agec(4) type p default -30,
age1(4) type p default 0,
age2(4) type p default 30,
age3(4) type p default 60,
age4(4) type p default 90,
age5(4) type p default 180,
age6(4) type p default 365,
age7(4) type p default 730,
age8(4) type p default 1460.
*&-----------------------------------------------------------------*
*& Report : ZRFIAR0002 *
*& Creation Date : 2004.12.06 *
*& Created by : TianLai Liu *
*& Description : AR *
*&-----------------------------------------------------------------*
report zrfiar0002_test no standard page heading line-size 255.
type-pools : slis.
types: slis_t_fieldcat_alv type slis_fieldcat_alv occurs 1.
data : g_events_t type slis_t_event,
g_fieldcat_t type slis_t_fieldcat_alv.
data : g_layout_s type slis_layout_alv.
data: l_fieldcat_s type slis_fieldcat_alv.
define __field_tab.
l_fieldcat_s-seltext_l = &1.
l_fieldcat_s-seltext_m = &1.
l_fieldcat_s-seltext_s = &1.
l_fieldcat_s-ddictxt = ' '.
end-of-definition.
tables: bseg,bkpf,kna1,knvv,tvkbt,faede,knb1,cskt.
data: i_faede like faede.
data: e_faede like faede.
data: len type i.
data: begin of itab_kunnr occurs 1250,
kunnr like knvv-kunnr,
end of itab_kunnr.
data: begin of itab_belnr occurs 0 ,
belnr like mseg-belnr , "凭证号
"BUZEI LIKE MSEG-BUZEI , "凭证项目号
end of itab_belnr .
data: begin of bitab occurs 1250,
bukrs like bseg-bukrs, "Client
kunnr like bseg-kunnr, "客户
name1 like kna1-name1, "客户名称
name2 like kna1-name2,
vkbur like knvv-vkbur,
gjahr like bseg-gjahr, "会计年度
augbl like bseg-augbl, "清账
belnr like bseg-belnr, "凭证编号
buzei like bseg-buzei,
bschl like bseg-bschl, "记帐码
koart like bseg-koart, "帐户类型
shkzg like bseg-shkzg, "借贷
dmbtr like bseg-dmbtr, "本位币金额
budat like bkpf-budat, "记帐日期
bldat like bkpf-bldat,
zfbdt like bseg-zfbdt, "收付基准日
zterm like bseg-zterm, "付款条款
rebzg like bseg-rebzg, "发票参考号
rebzj like bseg-rebzj,
rebzz like bseg-rebzz,
rebzt like bseg-rebzt,
umskz like bseg-umskz, "特定总帐标识
zbd1t like bseg-zbd1t, "现金折扣天数 1
zbd2t like bseg-zbd2t, "现金折扣天数 2
zbd3t like bseg-zbd3t, "现金折扣天数 3
zbd2p like bseg-zbd2p,
zbd1p like bseg-zbd1p,
agzei like bseg-agzei, "清算项目
end of bitab.
data: begin of itab occurs 0,
bukrs like bseg-bukrs, "Client
kunnr like bseg-kunnr, "客户
name1 like kna1-name1, "客户名称
name2 like kna1-name2,
gjahr like bseg-gjahr, "会计年度
belnr like bseg-belnr, "凭证编号
buzei like bseg-buzei,
bschl like bseg-bschl, "记帐码
koart like bseg-koart, "帐户类型
dmbtr like bseg-dmbtr, "本位币金额
budat like bkpf-budat, "记帐日期
bldat like bkpf-bldat,
zfbdt like bseg-zfbdt, "收付基准日
rebzg like bseg-rebzg, "发票参考号
rebzj like bseg-rebzj,
zbd1t(7) type c, "天数
umskz like bseg-umskz, "特定总帐标识
end of itab.
data: begin of ageitab occurs 2000,
kunnr like bseg-kunnr, "客户
name1 like kna1-name1, "客户名称
name2 like kna1-name2,
vkorg like knvv-vkorg, "销售机构
vkbur like knvv-vkbur, "销售办事处
bezei like tvkbt-bezei, "销售办事处描述
kostl like cskt-kostl,
ktext like cskt-ktext,
dmbtr like bseg-dmbtr, "未清项总额
age0a type p decimals 2, "Age A
age0b type p decimals 2, "Age B
age0c type p decimals 2, "Age C
age01 type p decimals 2, "Age 1
age02 type p decimals 2, "Age 2
age03 type p decimals 2, "Age 3
age04 type p decimals 2, "Age 4
age05 type p decimals 2, "Age 5
age06 type p decimals 2, "Age 6
age07 type p decimals 2, "Age 7
age08 type p decimals 2, "Age 8
age09 type p decimals 2, "Age 9
age0x type p decimals 2, "Age X
age0y type p decimals 2, "Age Y
end of ageitab.
data: p_kunnr like bseg-kunnr. "客户
data: l_agea(20) type c, "ageA
l_ageb(20) type c, "ageB
l_agec(20) type c, "ageC
l_age1(10) type c, "age1
l_age2(10) type c, "age2
l_age3(10) type c, "age3
l_age4(10) type c, "age4
l_age5(10) type c, "age5
l_age6(10) type c, "age6
l_age7(10) type c, "age7
l_age8(10) type c, "age8
l_age9(10) type c, "age9
l_agex(10) type c, "age9
l_agey(12) type c. "age9
data: f_agea(10) type c, "ageA
f_ageb(10) type c, "ageB
f_agec(10) type c, "ageC
f_age1(10) type c, "age1
f_age2(10) type c, "age2
f_age3(10) type c, "age3
f_age4(10) type c, "age4
f_age5(10) type c, "age5
f_age6(10) type c, "age6
f_age7(10) type c, "age7
f_age8(10) type c, "age8
f_age9(10) type c. "age9
data: m_agea(10) type c, "ageA
m_ageb(10) type c, "ageB
m_agec(10) type c, "ageC
m_age1(10) type c, "age1
m_age2(10) type c, "age2
m_age3(10) type c, "age3
m_age4(10) type c, "age4
m_age5(10) type c, "age5
m_age6(10) type c, "age6
m_age7(10) type c, "age7
m_age8(10) type c, "age8
m_age9(10) type c. "age9
data: s_agea(10) type c, "ageA
s_ageb(10) type c, "ageB
s_agec(10) type c, "ageC
s_age1(10) type c, "age1
s_age2(10) type c, "age2
s_age3(10) type c, "age3
s_age4(10) type c, "age4
s_age5(10) type c, "age5
s_age6(10) type c, "age6
s_age7(10) type c, "age7
s_age8(10) type c, "age8
s_age9(10) type c, "age9
s_agex(10) type c, "age9
s_agey(10) type c. "age9
data: signt1(1) type c. "age1
data: refe type p.
select-options s_kunnr for bseg-kunnr.
selection-screen begin of block ba with frame. title test-a.
*PARAMETERS: R_01 RADIOBUTTON GROUP R1 ,
* R_02 RADIOBUTTON GROUP R1 ,
* R_03 RADIOBUTTON GROUP R1 ,
* R_04 RADIOBUTTON GROUP R1 ,
* R_05 RADIOBUTTON GROUP R1 ,
* R_06 RADIOBUTTON GROUP R1 DEFAULT 'X'.
select-options: s_bukrs for bseg-bukrs obligatory no intervals default '1000',"公司代码
s_vkorg for knvv-vkorg,
s_vkbur for knvv-vkbur.
selection-screen end of block ba.
selection-screen skip 1.
selection-screen begin of block b2 with frame. title test-2.
parameters: ra_01 radiobutton group ra1 ,
ra_02 radiobutton group ra1 default 'X'.
selection-screen end of block b2.
selection-screen skip 1.
selection-screen begin of block b6 with frame. title test-6.
parameters: s_bldat like bkpf-bldat default sy-datum.
selection-screen end of block b6.
selection-screen skip 1.
selection-screen begin of block b10 with frame. title test-10.
parameters: rs_01 radiobutton group rs1 default 'X',
rs_02 radiobutton group rs1,
rs_03 radiobutton group rs1,
rs_04 radiobutton group rs1,
rs_05 radiobutton group rs1,
rs_06 radiobutton group rs1,
rs_07 radiobutton group rs1,
rs_08 radiobutton group rs1.
selection-screen end of block b10.
selection-screen skip 1.
selection-screen begin of block b3 with frame. title test-3.
parameters: agea(4) type p default -90,
ageb(4) type p default -60,
agec(4) type p default -30,
age1(4) type p default 0,
age2(4) type p default 30,
age3(4) type p default 60,
age4(4) type p default 90,
age5(4) type p default 180,
age6(4) type p default 365,
age7(4) type p default 730,
age8(4) type p default 1460.
selection-screen end of block b3.
*INITIALIZATION.
clear:bitab,itab,ageitab.
refresh:bitab,itab,ageitab.
free:bitab,itab,ageitab.
perform. layout_init using g_layout_s. "ALV GRID LAYOUT
perform. eventtab_build using g_events_t[]. "ALV GRID EVENT
start-of-selection.
perform. get_data.
perform. get_age.
perform. displaycatalog_merge using g_fieldcat_t[] 'AGEITAB'.
perform. alv_display tables ageitab[].
*--------------------------------------------------------------------
* FORM. GET_AGE *
*--------------------------------------------------------------------
form. get_age.
* LOOP AT ITAB .
if ra_01 = 'X'.
else.
if rs_02 ='X'.
delete itab where umskz ne space.
endif.
if rs_03 ='X'.
delete itab where umskz ne 'A'.
endif.
if rs_04 ='X'.
delete itab where umskz ne 'B'.
endif.
if rs_05 ='X'.
delete itab where umskz ne 'L'.
endif.
if rs_06 ='X'.
delete itab where umskz ne 'X'.
endif.
if rs_07 ='X'.
delete itab where umskz ne 'Y'.
endif.
if rs_08 ='X'.
delete itab where umskz eq 'A' or umskz eq 'B' or umskz eq 'L'.
endif.
endif.
* ENDLOOP.
perform. changetitle.
sort itab by kunnr.
p_kunnr = ''.
loop at itab .
if p_kunnr <> itab-kunnr.
ageitab-kunnr = itab-kunnr.
ageitab-name1 = itab-name1.
ageitab-name2 = itab-name2.
ageitab-dmbtr = 0.
ageitab-age0a = 0.
ageitab-age0b = 0.
ageitab-age0c = 0.
ageitab-age01 = 0.
ageitab-age02 = 0.
ageitab-age03 = 0.
ageitab-age04 = 0.
ageitab-age05 = 0.
ageitab-age06 = 0.
ageitab-age07 = 0.
ageitab-age08 = 0.
ageitab-age09 = 0.
ageitab-age0x = 0.
ageitab-age0y = 0.
append ageitab.
clear ageitab.
endif.
p_kunnr = itab-kunnr.
endloop.
loop at ageitab.
loop at itab .
if ageitab-kunnr = itab-kunnr.
ageitab-dmbtr = ageitab-dmbtr + itab-dmbtr.
if itab-umskz = 'X'.
ageitab-age0x = ageitab-age0x + itab-dmbtr.
elseif itab-umskz = 'Y'.
ageitab-age0y = ageitab-age0y + itab-dmbtr.
else.
if itab-zbd1t < agea.
ageitab-age0a = ageitab-age0a + itab-dmbtr.
elseif itab-zbd1t >= agea and itab-zbd1t < ageb.
ageitab-age0b = ageitab-age0b + itab-dmbtr.
elseif itab-zbd1t >= ageb and itab-zbd1t < agec.
ageitab-age0c = ageitab-age0c + itab-dmbtr.
elseif itab-zbd1t >= agec and itab-zbd1t < age1.
ageitab-age01 = ageitab-age01 + itab-dmbtr.
elseif itab-zbd1t >= age1 and itab-zbd1t <= age2.
ageitab-age02 = ageitab-age02 + itab-dmbtr.
elseif itab-zbd1t > age2 and itab-zbd1t <= age3.
ageitab-age03 = ageitab-age03 + itab-dmbtr.
elseif itab-zbd1t > age3 and itab-zbd1t <= age4.
ageitab-age04 = ageitab-age04 + itab-dmbtr.
elseif itab-zbd1t > age4 and itab-zbd1t <= age5.
ageitab-age05 = ageitab-age05 + itab-dmbtr.
elseif itab-zbd1t > age5 and itab-zbd1t <= age6.
ageitab-age06 = ageitab-age06 + itab-dmbtr.
elseif itab-zbd1t > age6 and itab-zbd1t <= age7.
ageitab-age07 = ageitab-age07 + itab-dmbtr.
elseif itab-zbd1t > age7 and itab-zbd1t <= age8.
ageitab-age08 = ageitab-age08 + itab-dmbtr.
elseif itab-zbd1t > age8.
ageitab-age09 = ageitab-age09 + itab-dmbtr.
endif.
endif.
modify ageitab.
endif.
endloop.
clear knvv.
select single vkbur vkorg into (knvv-vkbur,knvv-vkorg)
from knvv where kunnr = ageitab-kunnr.
ageitab-vkbur = knvv-vkbur.
ageitab-vkorg = knvv-vkorg.
modify ageitab transporting vkbur vkorg.
clear tvkbt.
select single bezei into (tvkbt-bezei)
from tvkbt where vkbur = ageitab-vkbur.
ageitab-bezei = tvkbt-bezei.
modify ageitab transporting bezei.
if rs_08 = 'X'.
select single altkn into ageitab-kostl
from knb1 where kunnr = ageitab-kunnr
and bukrs = '1000'.
if not ageitab-kostl is initial.
if ageitab-kostl between 000000 and 999999.
concatenate '0000' ageitab-kostl into ageitab-kostl.
elseif ageitab-kostl between 0000000 and 9999999.
concatenate '000' ageitab-kostl into ageitab-kostl.
endif.
endif.
select single ktext into ageitab-ktext
from cskt where kostl eq ageitab-kostl
and kokrs = '1000'.
modify ageitab transporting ktext kostl.
endif.
endloop.
delete ageitab where age0a = 0
and age0b = 0
and age0c = 0
and age01 = 0
and age02 = 0
and age03 = 0
and age04 = 0
and age05 = 0
and age06 = 0
and age07 = 0
and age08 = 0
and age09 = 0
and age0x = 0
and age0y = 0.
endform. "GET_AGE
*--------------------------------------------------------------------
* FORM. GET_DATA *
*--------------------------------------------------------------------
form. get_data.
* 得到未清凭证
select bsid~bukrs bsid~kunnr bsid~gjahr bsid~augbl bsid~belnr bsid~buzei bsid~bschl
bsid~shkzg bsid~dmbtr bsid~zfbdt bsid~zterm bsid~rebzg bsid~rebzj bsid~rebzz bsid~rebzt
bsid~umskz bsid~zbd1t bsid~zbd2t bsid~zbd3t bsid~zbd2p bsid~zbd1p bsid~budat bsid~bldat kna1~name1 kna1~name2
into corresponding fields of table bitab
from bsid
inner join kna1 on kna1~kunnr = bsid~kunnr
where bsid~bukrs in s_bukrs
and bsid~kunnr in s_kunnr
and bsid~budat <= s_bldat
.
* 已清但是数据结清日期大于[到关键日未清]
select bsad~bukrs bsad~kunnr bsad~gjahr bsad~augbl bsad~belnr bsad~buzei bsad~bschl
bsad~shkzg bsad~dmbtr bsad~zfbdt bsad~zterm bsad~rebzg bsad~rebzj bsad~rebzz bsad~rebzt
bsad~umskz bsad~zbd1t bsad~zbd2t bsad~zbd3t bsad~zbd2p bsad~zbd1p bsad~budat bsad~bldat kna1~name1 kna1~name2
appending corresponding fields of table bitab
from bsad
inner join kna1 on kna1~kunnr = bsad~kunnr
where bsad~bukrs in s_bukrs
and bsad~augdt > s_bldat
and bsad~kunnr in s_kunnr
and bsad~budat <= s_bldat
.
loop at bitab .
bitab-koart = 'D' .
modify bitab .
endloop .
* SELECT BUKRS KUNNR GJAHR AUGBL BELNR BUZEI BSCHL
* KOART SHKZG DMBTR ZFBDT ZTERM REBZG REBZJ REBZZ REBZT
* UMSKZ ZBD1T ZBD2T ZBD3T AGZEI ZBD2P ZBD1P
* INTO CORRESPONDING FIELDS OF TABLE BITAB
* FROM BSEG FOR ALL ENTRIES IN ITAB_BELNR
* WHERE KOART = 'D'
* AND ( AUGBL = '' OR AUGDT > S_BLDAT )
* AND BELNR < 9000000000
* AND KUNNR in s_KUNNR
* AND BELNR = ITAB_BELNR-BELNR .
* "AND BUZEI = ITAB_BELNR-BUZEI.
if bitab[] is initial.
message 'No Data!' type 'S' display like 'E'.
leave list-processing.
endif.
loop at bitab.
clear knvv.
select single vkbur vkorg into (knvv-vkbur,knvv-vkorg)
from knvv
where kunnr = bitab-kunnr.
if knvv-vkorg in s_vkorg and knvv-vkbur in s_vkbur.
else.
delete bitab .
continue.
endif.
* CLEAR KNVV.
* SELECT SINGLE VKBUR VKORG INTO KNVV-VKBUR
* FROM KNVV
* WHERE KUNNR = bitab-KUNNR.
*
* IF R_01 = 'X' AND KNVV-VKBUR NE 10.
* DELETE BITAB .
* CONTINUE.
*
* ELSEIF R_02 = 'X' AND KNVV-VKBUR NE 20.
* DELETE BITAB.
* CONTINUE.
*
* ELSEIF R_03 = 'X' AND KNVV-VKBUR NE 30.
* DELETE BITAB.
* CONTINUE.
*
* ELSEIF R_04 = 'X' AND KNVV-VKBUR NE 40
* AND KNVV-VKBUR NE 50
* AND KNVV-VKBUR NE 60
* AND KNVV-VKBUR NE 70
* AND KNVV-VKBUR NE 12
* AND KNVV-VKBUR NE 32
* AND KNVV-VKBUR NE 42
* AND KNVV-VKBUR NE 52
* AND KNVV-VKBUR NE 100.
* DELETE BITAB.
* CONTINUE.
*
* ELSEIF R_05 = 'X' AND KNVV-VKBUR NE 80
* AND KNVV-VKBUR NE 90.
* DELETE BITAB.
* CONTINUE.
* ENDIF.
* SELECT SINGLE BUDAT BLDAT INTO (BKPF-BUDAT,BKPF-BLDAT)
* FROM BKPF WHERE BUKRS = BITAB-BUKRS
* AND BELNR = BITAB-BELNR
* AND GJAHR = BITAB-GJAHR .
* IF BKPF-BUDAT <= S_BLDAT.
* BITAB-BUDAT = BKPF-BUDAT.
* BITAB-BLDAT = BKPF-BLDAT.
* SELECT SINGLE NAME1 NAME2 INTO (BITAB-NAME1,BITAB-NAME2)
* FROM KNA1 WHERE KUNNR = BITAB-KUNNR.
* MODIFY BITAB TRANSPORTING NAME1 NAME2 BUDAT BLDAT.
* ELSE.
* DELETE BITAB.
* CONTINUE.
* ENDIF.
* ENDLOOP.
* LOOP AT BITAB.
if bitab-shkzg = 'S'. "本位币金额
itab-dmbtr = bitab-dmbtr .
else.
itab-dmbtr = bitab-dmbtr * -1.
endif.
itab-bukrs = bitab-bukrs. "Client
itab-kunnr = bitab-kunnr. "客户
itab-name1 = bitab-name1. "客户名称
itab-name2 = bitab-name2.
itab-gjahr = bitab-gjahr. "会计年度
itab-belnr = bitab-belnr. "凭证编号
itab-budat = bitab-budat. "记帐日期
itab-bldat = bitab-bldat.
if not bitab-rebzg is initial and
not bitab-rebzj is initial and
not bitab-rebzz is initial and
bitab-rebzt ne 'V'.
select single zfbdt zbd1t zbd2t zbd3t shkzg koart into
(bitab-zfbdt,bitab-zbd1t,bitab-zbd2t,bitab-zbd3t,
bitab-shkzg,bitab-koart)
from bseg where bukrs = bitab-bukrs
and belnr = bitab-rebzg
and gjahr = bitab-rebzj
and buzei = bitab-rebzz.
endif.
if not bitab-zbd3t is initial.
refe = bitab-zbd3t.
else.
if not bitab-zbd2t is initial.
if bitab-shkzg = 'S' and bitab-koart = 'D' or
( bitab-koart = 'K' and bitab-shkzg = 'H' ).
refe = bitab-zbd2t.
else.
if not bitab-zbd2p is initial.
refe = bitab-zbd2t.
endif.
endif.
else.
if not bitab-zbd1t is initial.
if bitab-shkzg = 'S' and bitab-koart = 'D'
or ( bitab-koart = 'K' and bitab-shkzg = 'H' ).
refe = bitab-zbd1t.
else.
if not bitab-zbd1p is initial.
refe = bitab-zbd1t.
endif.
endif.
endif.
endif.
endif.
if not bitab-zfbdt is initial.
itab-zfbdt = bitab-zfbdt + refe.
else.
itab-zfbdt = bitab-bldat + refe.
endif.
clear refe.
itab-umskz = bitab-umskz.
if ra_01 ='X'.
itab-zbd1t = s_bldat - itab-budat.
endif.
if ra_02 ='X'.
itab-zbd1t = s_bldat - itab-zfbdt.
endif.
append itab.
clear itab.
endloop.
if itab[] is initial.
message 'No Data!' type 'S' display like 'E'.
leave list-processing.
endif.
* LOOP AT ITAB.
* IF RA_01 ='X'.
* ITAB-ZBD1T = S_BLDAT - ITAB-BUDAT.
* ENDIF.
* IF RA_02 ='X'.
* ITAB-ZBD1T = S_BLDAT - ITAB-ZFBDT.
* ENDIF.
* MODIFY ITAB.
* ENDLOOP.
endform. "GET_DATA
*--------------------------------------------------------------------
* FORM. CHANGETITLE *
*--------------------------------------------------------------------
form. changetitle.
f_agea = 0 - agea.
f_ageb = 0 - ageb.
f_agec = 0 - agec.
f_age1 = age1.
f_age2 = age2.
f_age3 = age3.
f_age4 = age4.
f_age5 = age5.
f_age6 = age6.
f_age7 = age7.
f_age8 = age8.
condense f_agea no-gaps.
condense f_ageb no-gaps.
condense f_agec no-gaps.
condense f_age1 no-gaps.
condense f_age2 no-gaps.
condense f_age3 no-gaps.
condense f_age4 no-gaps.
condense f_age5 no-gaps.
condense f_age6 no-gaps.
condense f_age7 no-gaps.
condense f_age8 no-gaps.
condense f_age9 no-gaps.
m_agea = '未到期'.
m_ageb = '-'.
m_agec = '-'.
m_age1 = '-'.
m_age2 = '-'.
m_age3 = '-'.
m_age4 = '-'.
m_age5 = '-'.
m_age6 = '-'.
m_age7 = '-'.
m_age8 = '-'.
m_age9 = '大于'.
s_agea = '天'.
s_ageb = '天'.
s_agec = '天'.
s_age1 = '天'.
s_age2 = '天'.
s_age3 = '天'.
s_age4 = '天'.
s_age5 = '天'.
s_age6 = '天'.
s_age7 = '天'.
s_age8 = '天'.
s_age9 = '天'.
concatenate m_agea m_age9 f_agea s_agea into l_agea.
concatenate m_agea f_ageb m_ageb f_agea s_ageb into l_ageb.
concatenate m_agea f_agec m_agec f_ageb s_agec into l_agec.
concatenate m_agea f_age1 m_age1 f_agec s_agec into l_age1.
concatenate f_age1 m_age2 f_age2 s_age2 into l_age2.
concatenate f_age2 m_age3 f_age3 s_age3 into l_age3.
concatenate f_age3 m_age4 f_age4 s_age4 into l_age4.
concatenate f_age4 m_age5 f_age5 s_age5 into l_age5.
concatenate f_age5 m_age6 f_age6 s_age6 into l_age6.
concatenate f_age6 m_age7 f_age7 s_age7 into l_age7.
concatenate f_age7 m_age8 f_age8 s_age8 into l_age8.
concatenate m_age9 f_age8 s_age9 into l_age9.
l_agex = '保证金'.
l_agey = '长期备用金'.
endform. "CHANGETITLE
*********************************************************************
*--------------------------------------------------------------------
* FORM. DISPLAYCATALOG_MERGE *
*--------------------------------------------------------------------
form. displaycatalog_merge using p_g_fieldcat_t
type slis_t_fieldcat_alv
p_tabname.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'KUNNR'.
l_fieldcat_s-seltext_m = '客户编号'.
l_fieldcat_s-fix_column = 'X' .
l_fieldcat_s-emphasize = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'NAME1'.
l_fieldcat_s-seltext_m = '客户名称1'.
l_fieldcat_s-fix_column = 'X' .
l_fieldcat_s-emphasize = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'NAME2'.
l_fieldcat_s-seltext_m = '客户名称2'.
l_fieldcat_s-fix_column = 'X' .
l_fieldcat_s-emphasize = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s .
l_fieldcat_s-fieldname = 'VKORG'.
l_fieldcat_s-seltext_m = '销售组织'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'VKBUR'.
l_fieldcat_s-seltext_m = '销售办事处'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'BEZEI'.
l_fieldcat_s-seltext_m = '销售办事处描述'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'KOSTL'.
l_fieldcat_s-seltext_m = '成本中心'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'KTEXT'.
l_fieldcat_s-seltext_m = '成本中心描述'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'DMBTR'.
l_fieldcat_s-seltext_m = '本位币金额'.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE0A'.
l_fieldcat_s-seltext_m = l_agea.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE0B'.
l_fieldcat_s-seltext_m = l_ageb.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE0C'.
l_fieldcat_s-seltext_m = l_agec.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE01'.
l_fieldcat_s-seltext_m = l_age1.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE02'.
l_fieldcat_s-seltext_m = l_age2.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE03'.
l_fieldcat_s-seltext_m = l_age3.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE04'.
l_fieldcat_s-seltext_m = l_age4.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE05'.
l_fieldcat_s-seltext_m = l_age5.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE06'.
l_fieldcat_s-seltext_m = l_age6.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE07'.
l_fieldcat_s-seltext_m = l_age7.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE08'.
l_fieldcat_s-seltext_m = l_age8.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE09'.
l_fieldcat_s-seltext_m = l_age9.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE0X'.
l_fieldcat_s-seltext_m = l_agex.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
l_fieldcat_s-fieldname = 'AGE0Y'.
l_fieldcat_s-seltext_m = l_agey.
l_fieldcat_s-do_sum = 'X'.
append l_fieldcat_s to p_g_fieldcat_t.
endform. " FIELDCATALOG_MERGE
*--------------------------------------------------------------------
* FORM. LAYOUT_INIT
*--------------------------------------------------------------------
form. layout_init using p_g_layout_s type slis_layout_alv.
p_g_layout_s-detail_popup = 'X'.
p_g_layout_s-colwidth_optimize = 'X'.
endform. " LAYOUT_INIT
*--------------------------------------------------------------------
* FORM. EVENTTAB_BUILD
*--------------------------------------------------------------------
form. eventtab_build using p_g_events_t type slis_t_event.
data: l_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_g_events_t.
read table p_g_events_t with key name = slis_ev_pf_status_set
into l_event.
if sy-subrc eq 0.
move 'PF_STATUS_SET' to l_event-form.
append l_event to p_g_events_t.
endif.
endform. " EVENTTAB_BUILD
*--------------------------------------------------------------------
* FORM. ALV_DISPLAY
*--------------------------------------------------------------------
form. alv_display tables p_int_t.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = 'ZRFIAR0002' "G_REPID
is_layout = g_layout_s
it_fieldcat = g_fieldcat_t[]
i_save = 'A'
tables
t_outtab = p_int_t
exceptions
program_error = 1
others = 2.
endform. " ALV_DISPLAY