【ABAP系列】SAP ABAP DOI展示EXCEL或WORD

前言部分
大家可以关注我的公众号,公众号里的排版更好,阅读更舒适。
正文部分
DOI技术算是比较老的技术了
用来直接调用office展示结果
可以是EXCEL也可以是WORD
data: begin of s_fal.
include structure faglflext.
data: end of s_fal.
data: i_fal like table of s_fal.
data: ok_code like sy-ucomm.
type-pools: soi,sbdst,abap.
class c_oi_errors definition load. data control type ref to i_oi_container_control.
data retcode type soi_ret_string. data: container type ref to cl_gui_custom_container. data: document type ref to i_oi_document_proxy.
data: error type ref to i_oi_error.
data: errors type ref to i_oi_error occurs . data spreadsheet type ref to i_oi_spreadsheet.
data sheetname() type c.
select * from faglflext into corresponding fields of table i_fal where rbukrs = '' and ryear = '' and racct = ''. call screen .
*&---------------------------------------------------------------------*
*& Module status_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0100 output.
set pf-status ''. call method c_oi_container_control_creator=>get_container_control
importing
control = control
retcode = retcode. create object container
exporting
container_name = 'DOI_PARENT'."100屏幕上的控件名. call method control->init_control
exporting
r3_application_name = 'Demo Document Container'
inplace_enabled = 'X'
parent = container
importing
retcode = retcode. call method control->get_document_proxy
exporting
document_type = 'Excel.Sheet.8'
document_format = 'OLE'
importing
document_proxy = document
retcode = retcode. call method document->create_document
exporting
create_view_data = 'X'
open_inplace = 'X'
importing
retcode = retcode.
call method document->get_spreadsheet_interface
exporting
no_flush = ' '
importing
sheet_interface = spreadsheet
error = error.
call method spreadsheet->get_active_sheet
exporting
no_flush = ''
importing
sheetname = sheetname
error = error
retcode = retcode.
call method spreadsheet->add_sheet
exporting
name = '年度报表'
no_flush = ''
importing
error = error
retcode = retcode.
call method spreadsheet->delete_sheet
exporting
name = sheetname
no_flush = ''
importing
error = error
retcode = retcode.
call method spreadsheet->select_sheet
exporting
name = '年度报表'
no_flush = ''
importing
error = error
retcode = retcode. data: rows like sy-tabix.
data: field_count type i.
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.
field-symbols: <field> type any,
<wa> type any.
field_count = .
do.
assign component field_count of structure s_fal to <field>."assign成功subrc = 0.
if sy-subrc <> .
exit.
endif.
add to field_count.
enddo.
field_count = field_count - .
describe table i_fal lines rows.
call method spreadsheet->insert_range_dim
exporting
name = 'CELL'
no_flush = 'X'
top =
left =
rows = rows
columns = field_count
importing
error = error. clear rangeitem.
refresh ranges.
rangeitem-name = 'CELL'.
rangeitem-columns = field_count.
rangeitem-rows = rows.
append rangeitem to ranges.
call method spreadsheet->set_font
exporting
rangename = 'CELL'
family = 'Times New Roman'
size =
bold =
italic =
align =
importing
error = error
retcode = retcode.
call method spreadsheet->set_format
exporting
rangename = 'CELL'
typ =
currency = 'RMB'
importing
error = error
retcode = retcode. refresh excel_input. data: field_value type string.
loop at i_fal assigning <wa>.
rows = sy-tabix.
field_count = .
do.
assign component field_count of structure <wa> to <field>."assign成功subrc = 0.
if sy-subrc <> .
exit.
endif.
clear excel_input_wa.
excel_input_wa-column = field_count.
excel_input_wa-row = rows.
field_value = <field>.
excel_input_wa-value = field_value.
append excel_input_wa to excel_input.
add to field_count.
enddo.
endloop.
* set data
call method spreadsheet->set_ranges_data
exporting
ranges = ranges
contents = excel_input
no_flush = 'X'
importing
error = error.
*get desktop directory
data: desktop_directory type string.
call method cl_gui_frontend_services=>get_sapgui_workdir
changing
sapworkdir = desktop_directory
exceptions
get_sapworkdir_failed =
cntl_error =
error_no_gui =
not_supported_by_gui =
others = .
if sy-subrc <> .
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif. if desktop_directory is initial.
desktop_directory = 'C:'.
endif.
concatenate desktop_directory '\' '年度报表.xls' into desktop_directory. data: result type abap_bool.
call method cl_gui_frontend_services=>file_exist
exporting
file = desktop_directory
receiving
result = result
exceptions
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
others = 5.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
data: rc type i.
if result = 'X'.
call method cl_gui_frontend_services=>file_delete
exporting
filename = desktop_directory
changing
rc = rc
exceptions
file_delete_failed = 1
cntl_error = 2
error_no_gui = 3
file_not_found = 4
access_denied = 5
unknown_error = 6
not_supported_by_gui = 7
wrong_parameter = 8
others = 9.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endif.
data:file_name(250) type c.
file_name = desktop_directory.
call method document->save_as
exporting
file_name = file_name
prompt_user = ''
importing
error = error
retcode = retcode.
*放到FTP
*.............................
*.............................
*在这里写放到FTP上的语句.
endmodule. " status_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module user_command_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0100 input.
case ok_code.
when 'EXIT' or 'BACK'.
leave to screen 0.
endcase.
endmodule. " user_command_0100 INPUT
【ABAP系列】SAP ABAP DOI展示EXCEL或WORD的更多相关文章
- 【ABAP系列】ABAP CL_ABAP_CONV_IN_CE
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]ABAP CL_ABAP_CON ...
- 【ABAP系列】SAP DOI技术中I_OI_SPREADSHEET接口的使用
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP DOI技术中I_OI_S ...
- 【ABAP系列】SAP ABAP下载带密码的Excel文件
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP下载带密码的Ex ...
- 【ABAP系列】【第五篇】SAP ABAP7.50 之用户接口
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列][第五篇]SAP ABAP7.5 ...
- 【ABAP系列】SAP ABAP OOALV 动态设置单元格可否编辑
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP OOALV 动 ...
- 【ABAP系列】SAP ABAP同时显示多个ALV的方法
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP同时显示多个AL ...
- 【ABAP系列】SAP ABAP常用函数总结第一篇
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP常用函数总结第一 ...
- 【ABAP系列】SAP ABAP BAPI_REQUISITION_CREATE创建采购申请
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP BAPI_RE ...
- 【ABAP系列】SAP ABAP 字符编码与解码、Unicode
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 字符编码与解码 ...
随机推荐
- Quartz--Spring 定时任务
一.quartz核心概念 先来看一张图: scheduler 任务调度器 trigger 触发器,用于定义任务调度时间规则 job 任务,即被调度的任务 misfire 错过的,指本来应该被 ...
- hdu 6377 : 度度熊看球赛
题目链接 题解: 将原问题转换为 对于全部 (2n)! 种情况,每种情况对ans的贡献为 D^k,其中k表示该情况下有k对情侣座位相邻. 预处理好共有 i (1<=i<=N)对情侣时,出现 ...
- 【shell】截取字符串前面文字
例如:有一个文件test.txt,里面有这些数据. meiguounix232 faguounix ribenunix zhongguounixtaobao hanguounixbaba 现在我想截取 ...
- MySQL自动生成序号列
select (@i:=@i+1) i,a.CITYID from basis_cityinfo a ,(select @i:=0) t2 order by a.id desc limit 220;
- 虚树总结&题单&简要题解
简介 虚树,即剔除所有无关结点,只保留询问点和询问点的相关结点(两两之间的LCA),建一棵新树,这棵新树就是虚树.通过虚树,可以有效的减小询问(甚至修改)的复杂度.设询问点的个数是\(k\),那么建虚 ...
- JS中集合对象(Array、Map、Set)及类数组对象的使用与对比(转载)
在使用js编程的时候,常常会用到集合对象,集合对象其实是一种泛型,在js中没有明确的规定其内元素的类型,但在强类型语言譬如Java中泛型强制要求指定类型. ES6引入了iterable类型,Array ...
- Java字符串的不可变性
声明一个字符串引用变量: String s = "abcd"; s是一个引用变量,指向 堆内存中的字符串常量 "abcd" 再声明一个字符串引用变量: Str ...
- centos7 yum安装jdk
安装之前先检查一下系统有没有自带open-jdk 命令: rpm -qa |grep java rpm -qa |grep jdk rpm -qa |grep gcj 如果没有输入信息表示没有安装. ...
- java生成二维码学习笔记
纠错等级: QRErrorCorrectLevel.L 7%的字码可被修正 QRErrorCorrectLevel.M 15%的字码可被修正 QRErrorCorrectLevel.Q 25%的字码可 ...
- 进程间通信(IPC)-管道、匿名管道
每个进程都有各自的地址空间,任何一个进程的全局变量在另一个进程中都看不到 所以进程之间要交换数据必须通过内核,在内核中开辟一块缓冲区,进程1把数据从用户空间拷到内核缓冲区,进程2再从内核缓冲区把数据读 ...