SAP项目现金流量表开发源代码.docx
《SAP项目现金流量表开发源代码.docx》由会员分享,可在线阅读,更多相关《SAP项目现金流量表开发源代码.docx(49页珍藏版)》请在冰豆网上搜索。
SAP项目现金流量表开发源代码
在SAP中用承诺项目出现金流量表(报表开发源代码)
可能使用到的外部数据或SAP数据表数据的格式、字段等:
fkrs财务管理范围主记录表
fops承诺项目主记录表
fmmp现金预算管理行项目表
lfa1供应商主记录表
kna1客户主记录表
bsis总帐未清项表
t001公司代码主记录表
usr21用户主记录表
adrp用户地址表
bkpf财务凭证抬头表
bseg财务凭证行项目表
glt0总帐科目期间余额表
直接法通过分析凭证的承诺项目来取数,SAP为该项功能定义了一个逻辑数据库C1F.本程序
开始部分的逻辑数据库取数部分是SAP的标准程序,其功能是将与现金流量相关的数据装入内部表
G_T_FMMP,这部分程序禁止修改。
直接法:
1、装入金流量表定义参数(FORMfill_item_direct)
该子程序将的现金流量表项和其对应的承诺项目装入内部表INT_CASHFLOW.
2、装入与现金流量相关的数据
这部分是逻辑数据库装入,属于SAP标准程序,数据关系比较复杂,建议不要做任何改动。
3、计算现金流量
计算的基本思路是对表G_T_FMMP进行循环,查找其中每条记录的承诺项目属于INT_CASHFLOW的
表项后,把其金额累计到相应表项。
REPORTzcmrp001NOSTANDARDPAGEHEADINGLINE-SIZE220.
TABLES:
fkrs,fpos,fmmp,lfa1,kna1,bsis,
t001,usr21,adrp,bkpf,bseg,glt0.
DATA:
BEGINOFg_t_fmmpOCCURS300,
fikrsLIKEfmmp-fikrs,
bukrsLIKEfmmp-bukrs,
fiposLIKEfmmp-fipos,
wrttpLIKEfmmp-wrttp,
gjahrLIKEfmmp-gjahr,
perioLIKEfmmp-perio,
zhldtLIKEfmmp-zhldt,
budatLIKEfmmp-budat,
gsberLIKEfmmp-gsber,
vo_saknrLIKEfmmp-vo_saknr,
lifnrLIKEfmmp-lifnr,
kunnrLIKEfmmp-kunnr,
fwaerLIKEfmmp-fwaer,
fkbtrLIKEfmsu-btr001,
zbelnrLIKEcooi-refbn,
zbuzeiLIKEcooi-rfpos,
vo_bukrsLIKEfmmp-vo_bukrs,
vo_gjahrLIKEfmmp-vo_gjahr,
fitxtLIKEfkrs-fitxt,
fnameLIKEffnd-fname,
cnameLIKEfctr-cname,
pnameLIKEfpos-pname,
wtextLIKEfmmp-wtext,
ENDOFg_t_fmmp.
DATA:
BEGINOFg_t_fkrsOCCURS20,
fikrsLIKEfkrs-fikrs,
fitxtLIKEfkrs-fitxt,
ENDOFg_t_fkrs.
DATA:
BEGINOFg_t_fposOCCURS200,
fiposLIKEfpos-fipos,
pnameLIKEfpos-pname,
ENDOFg_t_fpos.
DATA:
BEGINOFg_t_lfa1OCCURS200,
lifnrLIKElfa1-lifnr,
sortlLIKElfa1-sortl,
ENDOFg_t_lfa1.
DATA:
BEGINOFg_t_kna1OCCURS200,
kunnrLIKEkna1-kunnr,
sortlLIKEkna1-sortl,
ENDOFg_t_kna1.
RANGES:
r_kunnrFORkna1-kunnr,
r_lifnrFORlfa1-lifnr,
r_fiposFORfmmp-fipos.
DATA:
BEGINOFint_cashflowOCCURS100,
desc(66)TYPEc,
r_fipos(66)TYPEc,
com_fkbtrLIKEfmmp-fkbtr,
fi_fkbtrLIKEfmmp-fkbtr,
fi_fwaerLIKEfmmp-fwaer,
ENDOFint_cashflow.
DATA:
BEGINOFg_t_t001OCCURS300,
bukrsLIKEt001-bukrs,
butxtLIKEt001-butxt,
ENDOFg_t_t001.
DATA:
posTYPEiVALUE0,
num_of_bukrsTYPEiVALUE0.
DATAcashflow_detail.
DATA:
min_budatLIKEfmmp-budat,
max_budatLIKEfmmp-budat,
z_min_budatLIKEsy-datum,
z_max_budatLIKEsy-datum,
z_bukrsLIKEfmmp-bukrs,
z_profitLIKEbseg-dmbtr,"净利润
z_bad_debitLIKEbseg-dmbtr,"坏帐准备及计提的资产减值准备
z_asset_depLIKEbseg-dmbtr,"固定资产折旧
z_intang_depLIKEbseg-dmbtr,"无形资产摊销
z_longpaid_depLIKEbseg-dmbtr,"长期待摊费用摊销
z_paid_decLIKEbseg-dmbtr,"待摊费用减少
z_accrul_incLIKEbseg-dmbtr,"预提费用增加
z_asset_proLIKEbseg-dmbtr,"固定资产,长期资产处置损失
z_asset_scrLIKEbseg-dmbtr,"固定资产报废损失
z_fi_expenLIKEbseg-dmbtr,"财务费用
z_invest_lossLIKEbseg-dmbtr,"投资损失
z_defer_taxLIKEbseg-dmbtr,"递延税款贷项
z_stockLIKEbseg-dmbtr,"存货减少
z_arLIKEbseg-dmbtr,"经营性应收减少
z_apLIKEbseg-dmbtr,"经营性应付增加
z_otherLIKEbseg-dmbtr,"其他
z_productionLIKEbseg-dmbtr,"经营活动产生的现金净额
z_lossLIKEbseg-dmbtr,"总公司下拨弥补亏损
z_asset_debitLIKEbseg-dmbtr,"以固定资产偿还债务
z_invest_debitLIKEbseg-dmbtr,"以投资偿还债务
z_asset_investLIKEbseg-dmbtr,"以固定资产投资
z_stock_debitLIKEbseg-dmbtr,"以存货偿还债务
z_asset_rentedLIKEbseg-dmbtr,"融资租赁固定资产
z_donationLIKEbseg-dmbtr,"接受捐赠非现金资产
z_debit_shortLIKEbseg-dmbtr,"偿还的经营性债务
z_debit_equitLIKEbseg-dmbtr,"债务转为资本
z_bond_dueLIKEbseg-dmbtr,"一年内到期的可转换公司债券
z_money_initLIKEbseg-dmbtr,"货币资金期初余额
z_money_endLIKEbseg-dmbtr,"货币资金期末余额
z_cashs_initLIKEbseg-dmbtr,"现金等价物期初余额
z_cashs_endLIKEbseg-dmbtr,"现金等价物期末余额
z_all_moneyLIKEbseg-dmbtr."货币资金及现金等价物净变动
DATA:
BEGINOFitb0OCCURS0,
txt(70)TYPEc,
numLIKEbseg-dmbtr,
ENDOFitb0,
mtxt(70)TYPEc.
**INITIALIZATION.
PERFORMfill_item_direct.
*START-OF-SELECTION.
GETfkrs.
g_t_fkrs-fikrs=fkrs-fikrs.
g_t_fkrs-fitxt=fkrs-fitxt.
APPENDg_t_fkrs.
GETfpos.
g_t_fpos-fipos=fpos-fipos.
g_t_fpos-pname=fpos-pname.
COLLECTg_t_fpos.
GETfmmp.
MOVE-CORRESPONDINGfmmpTOg_t_fmmp.
CASEfmmp-wrttp.
WHEN'50'OR'51'."purchaseorder
g_t_fmmp-zbelnr=fmmp-ebeln.
g_t_fmmp-zbuzei=fmmp-ebelp.
WHEN'64'."paymenttransfer
g_t_fmmp-zbelnr=fmmp-kblnr.
g_t_fmmp-zbuzei=fmmp-kblpos.
WHEN'65'."fundscommitments
g_t_fmmp-zbelnr=fmmp-kblnr.
g_t_fmmp-zbuzei=fmmp-kblpos.
WHENOTHERS."Fidocuments
g_t_fmmp-zbelnr=fmmp-vo_belnr.
g_t_fmmp-zbuzei=fmmp-vo_buzei.
ENDCASE.
APPENDg_t_fmmp.
IFNOTfmmp-kunnrISINITIAL.
r_kunnr-sign='I'.
r_kunnr-option='EQ'.
r_kunnr-low=fmmp-kunnr.
COLLECTr_kunnr.
ENDIF.
IFNOTfmmp-lifnrISINITIAL.
r_lifnr-sign='I'.
r_lifnr-option='EQ'.
r_lifnr-low=fmmp-lifnr.
COLLECTr_lifnr.
ENDIF.
END-OF-SELECTION.
SORTg_t_fmmpBYfikrsbukrsfiposwrttpgjahr
periozhldtzbelnr
zbuzeibukrsvo_saknr.
RANGES:
lr_lifnrFORlfa1-lifnr,
lr_kunnrFORkna1-kunnr.
DATA:
l_cnt_fromLIKEsy-tabixVALUE1,
l_cnt_toLIKEsy-tabixVALUE50,
l_cnt_linesLIKEsy-tabix.
*"/LesenKreditoren-TexteausStammdaten-Tabelle
IFNOTr_lifnrISINITIAL.
LOOPATr_lifnrWHERElow='*'.
DELETEr_lifnr.
ENDLOOP.
DESCRIBETABLEr_lifnrLINESl_cnt_lines."<-insert
IFl_cnt_lines<=50."<-insert
*"/Lieferanten-Kurztexteaufeinmaleinlesen"<-insert
SELECTlifnrsortlFROMlfa1
INTOCORRESPONDINGFIELDSOFTABLEg_t_lfa1
WHERElifnrINr_lifnr.
ELSE."<-insert
*"/Lieferanten-KurztexteinBloeckeneinlesen"<-insert
DO."<-insert
*"/Bloeckezuje50Leferantenbilden"<-insert
REFRESHlr_lifnr."<-insert
LOOPATr_lifnrFROMl_cnt_fromTOl_cnt_to."<-insert
lr_lifnr=r_lifnr."<-insert
APPENDlr_lifnr."<-insert
ENDLOOP."<-insert
IFsy-subrcNE0."<-insert
EXIT."<-insert
ENDIF."<-insert
l_cnt_from=l_cnt_to+1."<-insert
l_cnt_to=l_cnt_from+50."<-insert
*"/Lieferanten-Kurztextelesen"<-insert
SELECTlifnrsortlFROMlfa1"<-insert
APPENDINGCORRESPONDINGFIELDS"<-insert
OFTABLEg_t_lfa1"<-insert
WHERElifnrINlr_lifnr."<-insert
ENDDO."<-insert
ENDIF."<-insert
ENDIF.
*"/LesenDebitoren-TexteausStammdaten-Tabelle
IFNOTr_kunnrISINITIAL.
LOOPATr_kunnrWHERElow='*'.
DELETEr_kunnr.
ENDLOOP.
DESCRIBETABLEr_kunnrLINESl_cnt_lines."<-insert
IFl_cnt_lines<=50."<-insert
*"/Kunden-Kurztexteaufeinmaleinlesen"<-insert
SELECTkunnrsortlFROMkna1
INTOCORRESPONDINGFIELDSOFTABLEg_t_kna1
WHEREkunnrINr_kunnr.
ELSE."<-insert
*"/Kunden-KurztexteinBloeckeneinlesen"<-insert
DO."<-insert
*"/Bloeckezuje50Kundenbilden"<-insert
REFRESHlr_kunnr."<-insert
LOOPATr_kunnrFROMl_cnt_fromTOl_cnt_to."<-insert
lr_kunnr=r_kunnr."<-insert
APPENDlr_kunnr."<-insert
ENDLOOP."<-insert
IFsy-subrcNE0."<-insert
EXIT."<-insert
ENDIF."<-insert
l_cnt_from=l_cnt_to+1."<-insert
l_cnt_to=l_cnt_from+50."<-insert
*"/Kunden-Kurztextelesen"<-insert
SELECTkunnrsortlFROMkna1"<-insert
APPENDINGCORRESPONDINGFIELDS"<-insert
OFTABLEg_t_kna1"<-insert
WHEREkunnrINlr_kunnr."<-insert
ENDDO."<-insert
ENDIF."<-insert
ENDIF.
SELECTbukrsbutxtFROMt001
INTOCORRESPONDINGFIELDSOFTABLEg_t_t001.
DATA:
l_sav_wrttp_text(30),
l_sav_fwaerLIKEfmmp-fwaer,
l_sav_butxtLIKEt001-butxt,
l_sav_hide_row_type(4).
num_of_bukrs=0.
max_budat=0.
min_budat='99991231'.
LOOPATg_t_fmmp.
IFmin_budat>g_t_fmmp-budat.
min_budat=g_t_fmmp-budat.
ENDIF.
IFmax_budatmax_budat=g_t_fmmp-budat.
ENDIF.
l_sav_fwaer=g_t_fmmp-fwaer.
ATNEWfikrs.
LOOPATint_cashflow.
CLEARint_cashflow-fi_fkbtr.
MODIFYTABLEint_cashflow.
CLEARint_cashflow.
ENDLOOP.
ENDAT.
ATNEWbukrs.
PERFORMread_bukrs_textUSINGg_t_fmmp-bukrs
CHANGINGg_t_t001-butxt.
l_sav_butxt=g_t_t001-butxt.
LOOPATint_cashflow.
CLEARint_cashflow-com_fkbtr.
MODIFYTABLEint_cashflow.
CLEARint_cashflow.
ENDLOOP.
ENDAT.
LOOPATint_cashflow.
PERFORMinput_rangeUSINGint_cashflow-r_fipos.
LOOPATr_fipos.
IFr_fipos-option='EQ'.
IFr_fipos-low=g_t_fmmp-fipos.
int_cashflow-fi_fkbtr=int_cashflow-fi_fkbtr
+g_t_fmmp-fkbtr.
int_cashflow-com_fkbtr=int_cashflow-com_fkbtr
+g_t_fmmp-fkbtr.
ENDIF.
ENDIF.
IFr_fipos-option='BT'.
IFg_t_fmmp-fipos>=r_fipos-lowAND
g_t_fmmp-fipos<=r_fipos-high.
int_cashflow-fi_fkbtr=int_cashflow-fi_fkbtr
+g_t_fmmp-fkbtr.
int_cashflow-com_fkbtr=int_cashflow-com_fkbtr
+g_t_fmmp-fkbtr.
ENDIF.
ENDIF.
ENDLOOP.
MODIFYTABLEint_cashflow.
CLEARint_cashflow.
CLEARr_fipos.
REFRESHr_fipos.
ENDLOOP.
ATENDOFbukrs.
PERFORMcal_indirectUSINGg_t_fmmp-bukrs.
PERFORMoutput_infoUSING'COM'.
num_of_bukrs=num_of_bukrs+1.
ENDAT.
ATENDOFfikrs.
IFnum_of_bukrsNE1.
CLEARl_sav_butxt.
PERFORMoutput_infoUSING'FI'.
ENDIF.
WRITE:
/text-103.
ENDAT.
ENDLOOP.
TOP-OF-PAGE.
IFNOT(s_budat-lowISINITIAL).
min_budat=s_budat-low.
ENDIF.
IFNOT(s_budat-highISINITIAL).
max_budat=s_budat-high.
ENDIF.
SKIP2.
WRITE:
/100'现金流量表'.
WRITE:
/.
WRITE:
/210'会年企03表'.
*IFmin_budat(6)=max_budat(6).
*WRITE:
/104min_budat(4),'年',min_budat+4
(2),'月',
*202'报表编号:
会商03表'.
*ELSE.
*WRITE:
/097'日期:
',
*103min_budat,113'-',115max_budat,
*202'报表编号:
会商03表'.
*ENDIF.
*
WRITE:
/012'编制单位:
',l_sav_butxt,
10