- 浏览: 406100 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
yiming163:
thank you!
eCATT, LSMW in detail -
泡泡蓝:
把WITH INCLUDES.改成 WITH ANALYSI ...
User Exits,Customer Exits,BAdI and BTE -
泡泡蓝:
王弈争 写道泡泡蓝 写道SCAN ABAP-SOURCE SO ...
User Exits,Customer Exits,BAdI and BTE -
王弈争:
泡泡蓝 写道SCAN ABAP-SOURCE SOURCETA ...
User Exits,Customer Exits,BAdI and BTE -
jgtang82:
泡泡,我没遇到你所说的问题呀
User Exits,Customer Exits,BAdI and BTE
Desktop Office Integration (online help document): http://help.sap.com/saphelp_nw04/helpdata/en/e9/0be775408e11d1893b0000e8323c4f/frameset.htm
Cite from: http://www.itpub.net/thread-925318-1-1.html
Example:
*&---------------------------------------------------------------------*
*& Report Z_Rocky_TEST
*&
*&---------------------------------------------------------------------*
*& Rocky Wang
*& RockyTech (AT) 126.com
*& RockTech.yculblog.com
*&---------------------------------------------------------------------*
REPORT Z_ROCKY_TEST.
TABLES: MAKT.
***-----------------------------------***
*** excel related declaring
***-----------------------------------***
TYPE-POOLS: SLIS,VRM, SBDST, SOI.
CONSTANTS DOCUMENT_NAME(30) VALUE 'TEST'.
CONSTANTS INPLACE VALUE 'X'.
DATA: FLAG .
DATA: CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
CONTROL TYPE REF TO I_OI_CONTAINER_CONTROL,
DOCUMENT TYPE REF TO I_OI_DOCUMENT_PROXY,
SPREADSHEET TYPE REF TO I_OI_SPREADSHEET,
ERROR TYPE REF TO I_OI_ERROR,
ERRORS TYPE REF TO I_OI_ERROR OCCURS 0 WITH HEADER LINE.
CONTROLS: EXCELDATA TYPE TABLEVIEW USING SCREEN 0100.
DATA: TABLENAME(10), OKCODE(15),
ROW(4), COLUMN(4), DATA(39).
* spreadsheet interface structures for Excel data input
DATA: RANGEITEM TYPE SOI_RANGE_ITEM.
DATA: RANGES TYPE SOI_RANGE_LIST.
DATA: EXCEL_INPUT TYPE SOI_GENERIC_TABLE.
DATA: EXCEL_INPUT_WA TYPE SOI_GENERIC_ITEM.
DATA: INITIALIZED(1), RETCODE TYPE SOI_RET_STRING.
DATA: ITEM_URL(256), ALREADY_DONE, NEWNAME(40).
DATA DOCUMENT_TYPE(80).
DATA: APP TYPE VRM_ID, APPLIST TYPE VRM_VALUES.
DATA: EXCEL(80) VALUE 'Excel.Sheet'.
DATA: LINE_COUNT TYPE I,
COLUMN_COUNT TYPE I.
DATA: OK_CODE TYPE SY-UCOMM,
SAVE_OK TYPE SY-UCOMM.
CLASS C_OI_ERRORS DEFINITION LOAD.
DATA: BEGIN OF ITAB OCCURS 0.
INCLUDE STRUCTURE MAKT.
DATA: END OF ITAB.
SELECT-OPTIONS MATNR FOR MAKT-MATNR.
START-OF-SELECTION.
PERFORM GETDATA.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Form getdata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GETDATA .
SELECT *
FROM MAKT
INTO TABLE ITAB
WHERE MAKT~MATNR IN MATNR.
ENDFORM. " getdata
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'SA1'.
IF FLAG = SPACE .
PERFORM CREATE_BASIC_OBJECTS USING '' '' '' '' DOCUMENT_NAME.
PERFORM OUTPUT_TO_EXCEL.
ENDIF.
ENDMODULE. "STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
FLAG = 'X'.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'STOP' .
IF NOT DOCUMENT IS INITIAL.
CALL METHOD DOCUMENT->CLOSE_DOCUMENT.
FREE DOCUMENT.
ENDIF.
IF NOT CONTROL IS INITIAL.
CALL METHOD CONTROL->DESTROY_CONTROL.
FREE CONTROL.
ENDIF.
LEAVE PROGRAM.
WHEN 'BACK' .
IF NOT DOCUMENT IS INITIAL.
CALL METHOD DOCUMENT->CLOSE_DOCUMENT.
FREE DOCUMENT.
ENDIF.
IF NOT CONTROL IS INITIAL.
CALL METHOD CONTROL->DESTROY_CONTROL.
FREE CONTROL.
ENDIF.
SET SCREEN 0. " quit the program
"set screen 1000.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form CREATE_BASIC_OBJECTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_APP_NAME text
* -->P_CLASSNAME text
* -->P_CLASSTYPE text
* -->P_OBJ_KEY text
* -->P_DOCNAME text
*----------------------------------------------------------------------*
FORM CREATE_BASIC_OBJECTS USING P_APP_NAME
P_CLASSNAME
P_CLASSTYPE
P_OBJ_KEY
P_DOCNAME.
CHECK INITIALIZED IS INITIAL.
* first get the SAP DOI i_oi_container_control interface
CALL METHOD
C_OI_CONTAINER_CONTROL_CREATOR=>GET_CONTAINER_CONTROL
IMPORTING
CONTROL = CONTROL
ERROR = ERROR.
* check no errors occured
CALL METHOD ERROR->RAISE_MESSAGE
EXPORTING
TYPE = 'E'.
CREATE OBJECT CONTAINER
EXPORTING CONTAINER_NAME = 'CONTAINER'.
DATA L_APP_NAME(200).
IF P_APP_NAME IS INITIAL.
L_APP_NAME = 'TEST'.
ELSE.
L_APP_NAME = P_APP_NAME.
ENDIF.
CALL METHOD CONTROL->INIT_CONTROL
EXPORTING
R3_APPLICATION_NAME = L_APP_NAME
INPLACE_ENABLED = INPLACE
INPLACE_SCROLL_DOCUMENTS = 'X'
PARENT = CONTAINER
REGISTER_ON_CLOSE_EVENT = 'X'
REGISTER_ON_CUSTOM_EVENT = 'X'
NO_FLUSH = 'X'
IMPORTING
ERROR = ERRORS.
* save error object in collection
APPEND ERRORS.
CLEAR ITEM_URL.
DATA: BDS_INSTANCE TYPE REF TO CL_BDS_DOCUMENT_SET.
DATA: DOC_SIGNATURE TYPE SBDST_SIGNATURE,
WA_DOC_SIGNATURE LIKE LINE OF DOC_SIGNATURE,
DOC_COMPONENTS TYPE SBDST_COMPONENTS,
DOC_URIS TYPE SBDST_URI,
WA_DOC_URIS LIKE LINE OF DOC_URIS.
*以下三个值为Tcode:OAOR里面新建模板文件的参数
DATA: DOC_CLASSNAME TYPE SBDST_CLASSNAME VALUE 'PICTURES',
DOC_CLASSTYPE TYPE SBDST_CLASSTYPE VALUE 'OT',
DOC_OBJECT_KEY TYPE SBDST_OBJECT_KEY VALUE 'ZEXCEL'.
WA_DOC_SIGNATURE-PROP_NAME = 'DESCRIPTION'.
APP = 'excel'.
IF APP = 'excel'.
DOCUMENT_TYPE = EXCEL.
WA_DOC_SIGNATURE-PROP_VALUE = P_DOCNAME.
ELSE.
ENDIF.
APPEND WA_DOC_SIGNATURE TO DOC_SIGNATURE.
CREATE OBJECT BDS_INSTANCE.
CALL METHOD BDS_INSTANCE->GET_INFO
EXPORTING
CLASSNAME = DOC_CLASSNAME
CLASSTYPE = DOC_CLASSTYPE
OBJECT_KEY = DOC_OBJECT_KEY
CHANGING
COMPONENTS = DOC_COMPONENTS
SIGNATURE = DOC_SIGNATURE.
CALL METHOD BDS_INSTANCE->GET_WITH_URL
EXPORTING
CLASSNAME = DOC_CLASSNAME
CLASSTYPE = DOC_CLASSTYPE
OBJECT_KEY = DOC_OBJECT_KEY
CHANGING
URIS = DOC_URIS
SIGNATURE = DOC_SIGNATURE.
FREE BDS_INSTANCE.
READ TABLE DOC_URIS INTO WA_DOC_URIS INDEX 1.
ITEM_URL = WA_DOC_URIS-URI.
* ask the SAP DOI container for a i_oi_document_proxy for Excel
CALL METHOD CONTROL->GET_DOCUMENT_PROXY
EXPORTING
DOCUMENT_TYPE = 'Excel.Sheet'
NO_FLUSH = 'X'
IMPORTING
DOCUMENT_PROXY = DOCUMENT
ERROR = ERRORS.
APPEND ERRORS.
* open a document saved in business document service.
CALL METHOD DOCUMENT->OPEN_DOCUMENT
EXPORTING
OPEN_INPLACE = INPLACE
DOCUMENT_URL = ITEM_URL.
DATA: HAS TYPE I.
CALL METHOD DOCUMENT->HAS_SPREADSHEET_INTERFACE
EXPORTING
NO_FLUSH = ''
IMPORTING
IS_AVAILABLE = HAS
ERROR = ERRORS.
APPEND ERRORS.
CALL METHOD DOCUMENT->GET_SPREADSHEET_INTERFACE
EXPORTING
NO_FLUSH = ' '
IMPORTING
SHEET_INTERFACE = SPREADSHEET
ERROR = ERRORS.
APPEND ERRORS.
* Activate sheet 1
CALL METHOD SPREADSHEET->SELECT_SHEET
EXPORTING
NAME = '???'
* NO_FLUSH = ' '
IMPORTING
ERROR = ERRORS.
* RETCODE =
.
APPEND ERRORS.
LOOP AT ERRORS.
CALL METHOD ERRORS->RAISE_MESSAGE
EXPORTING
TYPE = 'E'.
ENDLOOP.
FREE ERRORS.
INITIALIZED = 'X'.
ENDFORM. "CREATE_BASIC_OBJECTS
*&---------------------------------------------------------------------*
*& Form output_to_excel
*&---------------------------------------------------------------------*
* fill the EXCEL sheet
*----------------------------------------------------------------------*
FORM OUTPUT_TO_EXCEL.
DATA NUM TYPE I VALUE 1.
LOOP AT ITAB.
NUM = NUM + SY-TABIX.
PERFORM FILL_CELL USING NUM 1 ITAB-MATNR.
PERFORM FILL_CELL USING NUM 2 ITAB-SPRAS.
PERFORM FILL_CELL USING NUM 3 ITAB-MAKTX.
PERFORM FILL_CELL USING NUM 4 ITAB-MAKTG.
NUM = 1.
ENDLOOP.
ENDFORM. "output_to_excel
*&---------------------------------------------------------------------*
*& Form FILL_CELL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->I text
* -->J text
* -->VAL text
*----------------------------------------------------------------------*
FORM FILL_CELL USING I J VAL.
DATA: COLUMNS_NUMBER TYPE I,
ROWS_NUMBER TYPE I.
COLUMNS_NUMBER = 1.
ROWS_NUMBER = 1.
CALL METHOD SPREADSHEET->INSERT_RANGE_DIM
EXPORTING
NAME = 'cell'
NO_FLUSH = 'X'
TOP = I
LEFT = J
ROWS = ROWS_NUMBER
COLUMNS = COLUMNS_NUMBER
IMPORTING
ERROR = ERRORS.
APPEND ERRORS.
REFRESH: RANGES, EXCEL_INPUT.
RANGEITEM-NAME = 'cell'.
RANGEITEM-COLUMNS = 1.
RANGEITEM-ROWS = 1.
APPEND RANGEITEM TO RANGES.
EXCEL_INPUT_WA-COLUMN = 1.
EXCEL_INPUT_WA-ROW = 1.
EXCEL_INPUT_WA-VALUE = VAL.
APPEND EXCEL_INPUT_WA TO EXCEL_INPUT.
* set data
CALL METHOD SPREADSHEET->SET_RANGES_DATA
EXPORTING
RANGES = RANGES
CONTENTS = EXCEL_INPUT
NO_FLUSH = 'X'
IMPORTING
ERROR = ERRORS.
APPEND ERRORS.
CALL METHOD SPREADSHEET->FIT_WIDEST
EXPORTING
NAME = SPACE
NO_FLUSH = 'X'.
REFRESH: RANGES, EXCEL_INPUT.
ENDFORM. "fill_cell
发表评论
-
Sap Number Range Object (SNRO)
2010-12-21 16:11 1828Brief Example http://www.sapte ... -
SAP R/3 Security Tables
2010-12-09 15:27 1616Below the list of SAP R/3 Sec ... -
Class def & impl, Inherit & overwriting, interface & using it, event & handler
2010-12-08 10:05 1148Below codes is a simply and rou ... -
IDOC_INPUT_ORDERS with error msg RV45A-VBAP_SELKZ (2) is not input field
2010-11-08 14:51 2403[Issue] Hi I am creating a mul ... -
SAP ALV Trees
2010-11-05 14:07 2151BCALV_GRID_DND_TREE ALV Grid: D ... -
Creating a SAP shortcut for any transaction and sending it by mail
2010-11-02 11:12 2004Refer to SAP wiki: http://wiki. ... -
Note 573128 - Debugging programs in the background
2010-11-01 20:13 1176Note 573128 - Debugging program ... -
Function Module related on Date calculations (ZT)
2010-07-20 17:00 1691http://wiki.sdn.sap.com/wiki/di ... -
SAP SDN Interesting Topics
2010-06-29 09:48 984Web Dynpro ABAP Performance Too ... -
SE16N &SAP_EDIT, ICON at Selection Screen
2010-06-12 17:35 1732摘录From blog of 翱翔云天 1. SE16N & ... -
Debug background processes, update/system code,model dialog...
2009-12-18 13:55 1197How do I debug running backgrou ... -
ABAP character variables vs. string variables
2009-11-16 11:23 2947Chinese Version: http://blog.cs ... -
ECC6 ALV Dump
2009-10-21 15:20 1032[Dump] 1. Use system reserved ... -
Simple Transfermation Program
2009-08-07 23:42 1994Have you been requested to gene ... -
eCATT, LSMW in detail
2009-02-15 10:14 3452eCATT : http://sap.iteye.com/bl ... -
Trigger ABAP program using UNIX script
2009-01-09 13:27 22421. Create a batch job in SM37 f ... -
How to cancel active job, del/change schedule job
2008-12-26 09:56 2305if the job is active and you wa ... -
How to Run UNIX script from ABAP?
2008-12-19 12:52 2526Look at SM69, SM49 and Functio ... -
REUSE_ALV_GRID_DISPLAY事件子过程和cl_gui_grid类的事件对应关系
2008-12-04 18:46 3855一、SLIS定义的ALV的事件名称* Eventsslis_e ... -
DDIC info related tables
2008-12-03 09:58 1943Data elementsDD04L Data elem ...
相关推荐
为了更好地理解这一过程,你可以参考提供的文档:《用OLE DOI 实现ABAP导出EXCEL表格.docx》和《ABAP-透過OLE操作OFFICE.docx》。同时,《OLE.pdf》可能包含更深入的OLE和DOI技术细节,这对于优化和调试代码会非常有...
在SAP ABAP环境中,DOI(Data Output Interface)和OLE(Object Linking and Embedding)是两种常用的工具,用于与外部系统交互,特别是在处理数据导出到如Microsoft Excel这样的应用程序时。下面将详细介绍这两个...
ABAP DOI,全称为Desktop Office Integration,是SAP提供的一种技术,用于解决与Microsoft Office集成时的开发需求。在早期,SAP采用OLE(Object Linking and Embedding)技术来实现这一功能,但OLE存在两个主要缺点...
FOR i FROM 1 TO 3 DO. lo_excel_writer->set_cell_value( iv_column = 'A' iv_row = i + 4 iv_text = some_data[i] ). ENDFOR. ``` 3. 在原来的模板上删除若干行: 删除行的需求可以通过`DELETE_ROWS`...
本主题将深入探讨“ABAP EXCEL通用类”——ZCL_EXCEL,它是SAP ABAP开发者用于处理Excel文件的一个强大工具。ZCL_EXCEL类允许程序员在后台生成、读取和修改Excel文件,从而实现与Microsoft Excel的数据交互。 首先...
在SAP ABAP环境中,与Excel进行交互是常见的任务,特别是在数据导入导出、报告生成或用户自定义数据处理场景中。"abap与excel接口统一方法"主要涉及如何在ABAP程序中创建一个标准、可复用的接口来读取、写入Excel...
ABAP ole下载到多个excel 上和一个excel上新增多个sheet 页 ;ABAP ole下载到多个exce PERFORM 注释了,和一个excel上新增多个sheet 页 ,注 是ABAP 代码 OLE
在ABAP中处理Excel文件是一项常见的任务,这通常涉及到数据的导入导出,例如从SAP系统中获取数据并生成报表,或者将外部Excel数据整合到系统中。"ABAP-EXCEL编程"的主题旨在教授如何使用ABAP与Microsoft Excel进行...
ABAP与Excel接口的统一方法主要涉及在SAP ABAP编程中如何通过OLE Automation技术与Microsoft Excel进行交互,实现数据的读取和写入。以下将详细解释这个过程的关键步骤和所需的知识点。 1. **基本介绍** - **单字...
ABAP 的EXCEL综合程序组,有大部分ABAP开发时调用EXCEL用到的方法,有一个可以直接把ALV数据输出...
在企业信息化管理中,ABAP(Advanced Business Application Programming)是SAP系统的一种编程语言,而Excel作为Microsoft Office套件中的电子表格程序,被广泛用于数据分析和报表制作。将ABAP与Excel结合,可以实现...
标题与描述均提及了“ABAP OLE开发EXCEL”,这明确指出了本文将探讨的主题:如何使用ABAP(一种由SAP开发的高级商务应用编程语言)通过OLE(对象链接与嵌入)技术来自动化操作Excel。在企业级应用程序中,尤其是SAP...
ABAP_Excel_处理总结
### ABAP 读取Excel到内表的函数与自编程序详解 #### 一、引言 在SAP系统开发中,经常需要处理Excel数据,尤其是将Excel中的数据导入到SAP系统的内表中。然而,在这个过程中会遇到一些限制,比如单元格内容长度的...
ABAP编程实现Excel操作可以实现各种Excel操作,包括创建Excel、插入行、填充单元格、调整列宽、创建Sheet、复制Sheet、复制单元格、边框粗细、行颜色、预览、释放对象、关闭Excel、从服务器下载Excel模板、隐蔽打开...
ABAP数据快速填充EXCEL,比传统的OLE方式要运行速度快。
根据给定文件内容,主要介绍了两种将ABAP数据导出至Excel的方式:OLE方式和DOI方式。其中,DOI方式被认为更为强大。 ##### 1. OLE方式 OLE(Object Linking and Embedding)即对象链接与嵌入,是一种用于Windows...
在ABAP编程中,处理Excel文件常常涉及到与Excel对象模型的交互,这通常通过OLE Automation技术实现。在本文中,我们将探讨如何使用ABAP-Excel编程的统一接口来满足三种常见的Excel输出需求:在特定位置输出单字段、...
ABAP-EXCEL 编程的统一接口使用方法 ABAP-EXCEL 是一种使用 ABAP 编程语言与 Excel 应用程序集成的技术,它允许开发者使用 ABAP 语言编写程序来操作 Excel 文件。本文将介绍 ABAP-EXCEL 编程的统一接口使用方法,...