ABAP DEMO ole示例程序

*&---------------------------------------------------------------------*
*& Report YCX_021
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT YCX_021.
INCLUDE OLE2INCL .

*-----------------------------------------------------------------------

*     Global GUI Controls Variables / Structures

*-----------------------------------------------------------------------

*--Data Definition of OLE

DATA: GS_EXCEL          TYPE OLE2_OBJECT ,

      GS_WBOOKLIST      TYPE OLE2_OBJECT ,

      GS_APPLICATION    TYPE OLE2_OBJECT ,

      GS_WBOOK          TYPE OLE2_OBJECT ,

      GS_ACTIVESHEET    TYPE OLE2_OBJECT ,

      GS_SHEETS         TYPE OLE2_OBJECT ,

      GS_NEWSHEET       TYPE OLE2_OBJECT ,

      GS_CELL1          TYPE OLE2_OBJECT ,

      GS_CELL2          TYPE OLE2_OBJECT ,

      GS_CELLS          TYPE OLE2_OBJECT ,

      GS_RANGE          TYPE OLE2_OBJECT ,

      GS_FONT           TYPE OLE2_OBJECT ,

      GS_INTERIOR       TYPE OLE2_OBJECT ,

      GS_COLUMNS        TYPE OLE2_OBJECT ,

      GS_CHARTS         TYPE OLE2_OBJECT ,

      GS_CHART          TYPE OLE2_OBJECT ,

      GS_CHARTTITLE     TYPE OLE2_OBJECT ,

      GS_CHARTTITLECHAR TYPE OLE2_OBJECT ,

      GS_CHARTOBJECTS   TYPE OLE2_OBJECT .

DATA GV_SHEET_NAME(20) TYPE C .

DATA GV_OUTER_INDEX LIKE SY-INDEX .

DATA GV_INTEX(2) TYPE C .

DATA GV_LINE_CNTR TYPE I . "line counter

DATA GV_LINNO TYPE I . "line number

DATA GV_COLNO TYPE I . "column number

DATA GV_VALUE TYPE I . "data

*$*$----------------------------------------------------------------$*$*

*$*$                      Selection Screen                          $*$*

*$*$----------------------------------------------------------------$*$*

*-----------------------------------------------------------------------

*                   Selection Screen

*-----------------------------------------------------------------------

PARAMETERS: P_SHEETS TYPE I .

*$*$----------------------------------------------------------------$*$*

*$*$                          Main Program                          $*$*

*$*$----------------------------------------------------------------$*$*

*--------- START-OF-SELECTION ----------

START-OF-SELECTION .

  DO P_SHEETS TIMES .

*--Forming sheet name

    GV_INTEX = SY-INDEX .

    GV_OUTER_INDEX = SY-INDEX .

    CONCATENATE ‘Excel Sheet #‘ GV_INTEX INTO GV_SHEET_NAME .

*--For the first loop, Excel is initiated and one new sheet is added

    IF SY-INDEX = 1 .

      CREATE OBJECT GS_EXCEL ‘EXCEL.APPLICATION‘ .

      SET PROPERTY OF GS_EXCEL ‘Visible‘ = 1 .

      GET PROPERTY OF GS_EXCEL ‘Workbooks‘ = GS_WBOOKLIST .

      GET PROPERTY OF GS_WBOOKLIST ‘Application‘ = GS_APPLICATION .

      SET PROPERTY OF GS_APPLICATION ‘SheetsInNewWorkbook‘ = 1 .

      CALL METHOD OF
          GS_WBOOKLIST
          ‘Add‘        = GS_WBOOK.

      GET PROPERTY OF GS_APPLICATION ‘ActiveSheet‘ = GS_ACTIVESHEET .

      SET PROPERTY OF GS_ACTIVESHEET ‘Name‘ = GV_SHEET_NAME .

*--For the rest of loops, other sheets are added

    ELSE .

      GET PROPERTY OF GS_WBOOK ‘Sheets‘ = GS_SHEETS .

      CALL METHOD OF
          GS_SHEETS
          ‘Add‘     = GS_NEWSHEET.

      SET PROPERTY OF GS_NEWSHEET ‘Name‘ = GV_SHEET_NAME .

    ENDIF .

    GV_LINE_CNTR = 1 . "line counter

*--Title

*--Selecting cell area to be merged.

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL1
      EXPORTING
        #1       = 1
        #2       = 1.

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL2
      EXPORTING
        #1       = 1
        #2       = 4.

    CALL METHOD OF
        GS_EXCEL
        ‘Range‘  = GS_CELLS
      EXPORTING
        #1       = GS_CELL1
        #2       = GS_CELL2.

    CALL METHOD OF
        GS_CELLS
        ‘Select‘.

*--Merging

    CALL METHOD OF
        GS_CELLS
        ‘Merge‘.

*--Setting title data

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL1
      EXPORTING
        #1       = GV_LINE_CNTR
        #2       = 1.

    SET PROPERTY OF GS_CELL1 ‘Value‘ = ‘TITLE‘ .

*--Formatting the title

    GET PROPERTY OF GS_CELL1 ‘Font‘ = GS_FONT .

    SET PROPERTY OF GS_FONT ‘Underline‘ = 2 .

    SET PROPERTY OF GS_FONT ‘Bold‘ = 1 .

    SET PROPERTY OF GS_CELL1 ‘HorizontalAlignment‘ = -4108 .

    GET PROPERTY OF GS_CELL1 ‘Interior‘ = GS_INTERIOR .

    SET PROPERTY OF GS_INTERIOR ‘ColorIndex‘ = 15 .

    SET PROPERTY OF GS_INTERIOR ‘Pattern‘ = -4124 .

    SET PROPERTY OF GS_INTERIOR ‘PatternColorIndex‘ = -4105 .

    GV_LINE_CNTR = GV_LINE_CNTR + 1 .

*--Writing some additional data for the title

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL1
      EXPORTING
        #1       = GV_LINE_CNTR
        #2       = 1.

    SET PROPERTY OF GS_CELL1 ‘Value‘ = ‘Sheet No‘ .

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL1
      EXPORTING
        #1       = GV_LINE_CNTR
        #2       = 5.

    SET PROPERTY OF GS_CELL1 ‘Value‘ = ‘:‘ .

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL1
      EXPORTING
        #1       = GV_LINE_CNTR
        #2       = 6.

    SET PROPERTY OF GS_CELL1 ‘Value‘ = GV_INTEX .

*--Formatting the area of additional data 1

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL1
      EXPORTING
        #1       = 1
        #2       = 1.

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL2
      EXPORTING
        #1       = GV_LINE_CNTR
        #2       = 5.

    CALL METHOD OF
        GS_EXCEL
        ‘Range‘  = GS_CELLS
      EXPORTING
        #1       = GS_CELL1
        #2       = GS_CELL2.

    CALL METHOD OF
        GS_CELLS
        ‘Select‘.

    GET PROPERTY OF GS_CELLS ‘Font‘ = GS_FONT .

    SET PROPERTY OF GS_FONT ‘Bold‘ = 1 .

*--Formatting the area of additional data 2

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL1
      EXPORTING
        #1       = 1
        #2       = 5.

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL2
      EXPORTING
        #1       = GV_LINE_CNTR
        #2       = 5.

    CALL METHOD OF
        GS_EXCEL
        ‘Range‘  = GS_CELLS
      EXPORTING
        #1       = GS_CELL1
        #2       = GS_CELL2.

    CALL METHOD OF
        GS_CELLS
        ‘Select‘.

    GET PROPERTY OF GS_CELLS ‘Columns‘ = GS_COLUMNS .

    CALL METHOD OF
        GS_COLUMNS
        ‘AutoFit‘.

*--Bordering title data area

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL1
      EXPORTING
        #1       = 1
        #2       = 1.

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL2
      EXPORTING
        #1       = GV_LINE_CNTR
        #2       = 6.

    CALL METHOD OF
        GS_EXCEL
        ‘Range‘  = GS_CELLS
      EXPORTING
        #1       = GS_CELL1
        #2       = GS_CELL2.

    CALL METHOD OF
        GS_CELLS
        ‘Select‘.

    CALL METHOD OF
        GS_CELLS
        ‘BorderAround‘

      EXPORTING
        #1             = 1 "continuous line
        #2             = 4. "thick

*--Putting axis labels

    GV_COLNO = 2 .

    GV_LINE_CNTR = GV_LINE_CNTR + 5 .

    GV_LINNO = GV_LINE_CNTR - 1 .

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL1
      EXPORTING
        #1       = GV_LINNO
        #2       = 1.

    SET PROPERTY OF GS_CELL1 ‘Value‘ = ‘X‘ .

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL1
      EXPORTING
        #1       = GV_LINE_CNTR
        #2       = 1.

    SET PROPERTY OF GS_CELL1 ‘Value‘ = ‘Y‘ .

*--Generating some data

    DO 3 TIMES .

      GV_VALUE = GV_OUTER_INDEX * SY-INDEX * 10 .

      CALL METHOD OF
          GS_EXCEL
          ‘Cells‘  = GS_CELL1
        EXPORTING
          #1       = GV_LINNO
          #2       = GV_COLNO.

      SET PROPERTY OF GS_CELL1 ‘Value‘ = SY-INDEX .

      CALL METHOD OF
          GS_EXCEL
          ‘Cells‘  = GS_CELL1
        EXPORTING
          #1       = GV_LINE_CNTR
          #2       = GV_COLNO.

      SET PROPERTY OF GS_CELL1 ‘Value‘ = GV_VALUE .

      GV_COLNO = GV_COLNO + 1 .

    ENDDO .

*--Source data area

    GV_COLNO = GV_COLNO - 1 .

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL1
      EXPORTING
        #1       = GV_LINNO
        #2       = 1.

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL2
      EXPORTING
        #1       = GV_LINE_CNTR
        #2       = GV_COLNO.

    CALL METHOD OF
        GS_EXCEL
        ‘Range‘  = GS_CELLS
      EXPORTING
        #1       = GS_CELL1
        #2       = GS_CELL2.

    CALL METHOD OF
        GS_CELLS
        ‘Select‘.

    GET PROPERTY OF GS_APPLICATION ‘Charts‘ = GS_CHARTS .

    CALL METHOD OF
        GS_CHARTS
        ‘Add‘     = GS_CHART.

    CALL METHOD OF
        GS_CHART
        ‘Activate‘.

    SET PROPERTY OF GS_CHART ‘ChartType‘ = ‘51‘ . "Vertical bar graph

    CALL METHOD OF
        GS_CHART
        ‘SetSourceData‘

      EXPORTING
        #1              = GS_CELLS
        #2              = 1.

    SET PROPERTY OF GS_CHART ‘HasTitle‘ = 1 .

    GET PROPERTY OF GS_CHART ‘ChartTitle‘ = GS_CHARTTITLE .

    GET PROPERTY OF GS_CHARTTITLE ‘Characters‘ = GS_CHARTTITLECHAR .

    SET PROPERTY OF GS_CHARTTITLECHAR ‘Text‘ = ‘Sample Graph‘ .

*--Locate the chart onto the current worksheet

*--Activate current sheet

    CALL METHOD OF
        GS_EXCEL
        ‘WorkSheets‘ = GS_ACTIVESHEET
      EXPORTING
        #1           = GV_SHEET_NAME.

    CALL METHOD OF
        GS_ACTIVESHEET
        ‘Activate‘.

    CALL METHOD OF
        GS_CHART
        ‘Location‘

      EXPORTING
        #1         = 2
        #2         = GV_SHEET_NAME.

*--Reposition the chart on the worksheet (cut&paste)

    CALL METHOD OF
        GS_ACTIVESHEET
        ‘ChartObjects‘ = GS_CHARTOBJECTS.

    CALL METHOD OF
        GS_CHARTOBJECTS
        ‘Select‘.

    CALL METHOD OF
        GS_CHARTOBJECTS
        ‘Cut‘.

*--Select new area
    GV_LINE_CNTR = GV_LINE_CNTR + 2 .

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL1
      EXPORTING
        #1       = GV_LINE_CNTR
        #2       = 1.

    CALL METHOD OF
        GS_EXCEL
        ‘Cells‘  = GS_CELL2
      EXPORTING
        #1       = GV_LINE_CNTR
        #2       = 1.

    CALL METHOD OF
        GS_EXCEL
        ‘Range‘  = GS_CELLS
      EXPORTING
        #1       = GS_CELL1
        #2       = GS_CELL2.

    CALL METHOD OF
        GS_CELLS
        ‘Select‘.

    CALL METHOD OF
        GS_ACTIVESHEET
        ‘Paste‘.
  ENDDO.

*--Deallocating memory
  FREE:
  GS_EXCEL, GS_WBOOKLIST, GS_APPLICATION, GS_WBOOK,
  GS_ACTIVESHEET,GS_SHEETS, GS_NEWSHEET, GS_CELL1,
  GS_CELL2, GS_CELLS, GS_RANGE, GS_FONT, GS_INTERIOR,
  GS_COLUMNS, GS_CHARTS, GS_CHART, GS_CHARTTITLE,
  GS_CHARTTITLECHAR, GS_CHARTOBJECTS .

原文地址:https://www.cnblogs.com/rainysblog/p/11980416.html

时间: 2024-11-05 19:40:09

ABAP DEMO ole示例程序的相关文章

abap如何查找SAP示例程序

SAP提供了大量示例程序,可供ABAPER学习,可以直接COPY过来用,对提升Coding质量及编程能力很有帮助,下面是几种查找方法: 1.tcode:SE38  输入'DEMO*'后按F4,可以查到SAP所有的DEMO示例程序,能学到很多ABAP功能的实现方法. 2.tcode:"ABAPDOCU",可以找到很多ABAP DOCUMENT及示例程序. 3.tcode:se38 输入'BCALV*'后按F4,可以查到很多ALV示例程序.

Android cocos2dx游戏开发——示例程序HelloCpp源码分析

本文通过分析cocos2dx提供的示例程序HelloCpp来分析cocos2dx的启动过程. 我们从HelloCpp.java开始: [java] view plaincopyprint? package org.cocos2dx.hellocpp; import org.cocos2dx.lib.Cocos2dxActivity; import android.os.Bundle; public class HelloCpp extends Cocos2dxActivity{ protecte

OpenGL入门和示例程序

大家好,今天雅乐网给大家介绍一下OpenGL的一些基本语法和一个简单的示例程序. OpenGL是什么呢?说简单一点,就是一个图形软件包,它提供了许多函数供我们调用.我们看看维基百科上的说法 开放图形库(英语:Open Graphics Library,缩写为OpenGL)是个定义了一个跨编程语言.跨平台的应用程序接口(API)的规范,它用于生成二维.三维图像.这个接口由近三百五十个不同的函数调用组成,用来从简单的图形比特绘制复杂的三维景象.而另一种程序接口系统是仅用于Microsoft Wind

libvlc —— 播放器示例程序[C++代码实现攫取 RGB图像 和 PCM音频 数据功能]

在我以前的实际项目中,曾利用 libvlc 去解码音视频媒体数据(如 RTSP.本地文件 等),通过其提供的回调函数接口,攫取 RGB图像 进行图像分析,如 人脸识别.运动检测 等一类的产品应用.除此之外,只要提供适当的 MRL,配合选项参数,VLC 还可以进行屏幕录制.摄像头图像采集.麦克风音频采集 等功能. 我在网上参看过很多人提供的示例源码,实现流程都很初潜,只适合当作学习的 Demo 来看,与实际的项目应用还有很多问题要解决.为此,在这里公开我封装 libvlc 的 C++ 类,方便TA

winpcap示例程序采用VC6编译时出错error C2054: expected '(' to follow '_W64'

e:\vehiclesecurity\wpdpack_4_1_2\include\pcap-stdinc.h(80) : error C2054: expected '(' to follow '_W64' e:\vehiclesecurity\wpdpack_4_1_2\include\pcap-stdinc.h(80) : error C2085: 'uintptr_t' : not in formal parameter list e:\vehiclesecurity\wpdpack_4_

Windows Socket编程示例-TCP示例程序

前面一部分是介绍,后面有示例 1.网络中进程之间如何通信? 首要解决的问题是如何唯一标识一个进程,否则通信无从谈起!在本地可以通过进程PID来唯一标识一个进程,但是在网络中这是行不通的.其实TCP/IP协议族已经帮我们解决了这个问题,网络层的"ip地址"可以唯一标识网络中的主机,而传输层的"协议+端口"可以唯一标识主机中的应用程序(进程).这样利用三元组(ip地址,协议,端口)就可以标识网络的进程了,网络中的进程通信就可以利用这个标志与其它进程进行交互. 使用TCP

创建ArcGIS API for JavaScript的第一个示例程序

原文:创建ArcGIS API for JavaScript的第一个示例程序 在上一篇博客中已经介绍了如何搭建ArcGIS API for JavaScript开发环境,如果您还没有搭建好开发环境的话,参考博客:http://blog.csdn.net/zdw_wym/article/details/48678913. 如果开发环境搭建好了的话,那么今天我们继续来搭建我们的第一个ArcGIS API for JavaScript应用程序. 下面首先将代码贴出来,复制到VS2012中新建的html

.NET跨平台:在CentOS上编译dnx并运行ASP.NET 5示例程序

在之前的博文中我们在 Ubuntu 上成功编译出了 dnx ,并且用它成功运行了 ASP.NET 5 示例程序.在这篇博文中我们将 Ubuntu 换成 CentOS. 目前 dnx 的编译需要用到 mono,所以先要安装 mono,而且最好是用最新的 mono 源代码进行编译并安装. 我们实际成功编译的操作步骤如下(假设将 mono 安装到 /data/mono_build 目录): mkdir /data/mono_build PATH=/data/mono_build/bin:$PATH g

ABP示例程序-使用AngularJs,ASP.NET MVC,Web API和EntityFramework创建N层的单页面Web应用

本片文章翻译自ABP在CodeProject上的一个简单示例程序,网站上的程序是用ABP之前的版本创建的,模板创建界面及工程文档有所改变,本文基于最新的模板创建.通过这个简单的示例可以对ABP有个更深入的了解,每个工程里应该写什么样的代码,代码如何组织以及ABP是如何在工程中发挥作用的. 源文档地址:https://www.codeproject.com/Articles/791740/Using-AngularJs-ASP-NET-MVC-Web-API-and-EntityFram 源码可以