欢迎来到天天文库
浏览记录
ID:38055920
大小:15.53 KB
页数:3页
时间:2019-05-24
《ABAP-通过OLE操作OFFICE》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、ABAP--通过OLE操作OFFICE(代码)本代码是通过OLE技术操作EXCEL,将SAP的数据填写到本地EXCEL中,Office运行在SAP的GUI界面外,注意红色代码。REPORTZRSDEMO01NOSTANDARDPAGEHEADING.*thisreportdemonstrateshowtosendsomeABAPdatatoan*EXCELsheetusingOLEautomation.*必须包含INCLUDEOLE2INCL.*handlesforOLEobjects*申明相关的OFF
2、ICE的OLE对象DATA:H_EXCELTYPEOLE2_OBJECT, "Excelobject H_MAPLTYPEOLE2_OBJECT, "listofworkbooks H_MAPTYPEOLE2_OBJECT, "workbook H_ZLTYPEOLE2_OBJECT, "cell H_FTYPEOLE2_OBJECT. "fontTABLES:SPFLI.DATA HTYPE
3、I.*tableofflightsDATA:IT_SPFLILIKESPFLIOCCURS10WITHHEADERLINE.*&---------------------------------------------------------------------**& EventSTART-OF-SELECTION*&---------------------------------------------------------------------*START-OF-SELECTION.*r
4、eadflights SELECT*FROMSPFLIINTOTABLEIT_SPFLIUPTO10ROWS.*telluserwhatisgoingon CALLFUNCTION'SAPGUI_PROGRESS_INDICATOR' EXPORTING* PERCENTAGE=0 TEXT =TEXT-007 EXCEPTIONS OTHERS =1.*startExcel(创建对象) CREATEOBJECTH_
5、EXCEL'EXCEL.APPLICATION'. PERFORMERR_HDL.*设置office对象是否显示 SETPROPERTYOFH_EXCEL 'Visible'=1. PERFORMERR_HDL.*telluserwhatisgoingon CALLFUNCTION'SAPGUI_PROGRESS_INDICATOR' EXPORTING* PERCENTAGE=0 TEXT =TEXT-008 EXCEPTIONS
6、 OTHERS =1.*getlistofworkbooks,initiallyempty CALLMETHODOFH_EXCEL'Workbooks'=H_MAPL. PERFORMERR_HDL.*addanewworkbook CALLMETHODOFH_MAPL'Add'=H_MAP. PERFORMERR_HDL.*telluserwhatisgoingon CALLFUNCTION'SAPGUI_PROGRESS_INDICATOR' EXPORTING*
7、 PERCENTAGE=0 TEXT =TEXT-009 EXCEPTIONS OTHERS =1.*outputcolumnheadingstoactiveExcelsheet PERFORMFILL_CELLUSING111'Flug'(001). PERFORMFILL_CELLUSING121'Nr'(002). PERFORMFILL_CELLUSING131'Von'(003). PERFORMFILL_CELLUSING1
8、41'Nach'(004). PERFORMFILL_CELLUSING151'Zeit'(005). LOOPATIT_SPFLI.*copyflightstoactiveEXCELsheet H=SY-TABIX+1. PERFORMFILL_CELLUSINGH10IT_SPFLI-CARRID. PERFORMFILL_CELLUSINGH20IT_SPFLI-CONNID. PERFORMFILL_CELLUSIN
此文档下载收益归作者所有