Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

'Paste' method of OLE2_OBJECT not working

VishwanathV
Participant
0 Kudos
2,595

Hello,

While trying to adopt below logic for my requirement, I am facing SY-SUBRC issue for 'Paste' command. SY-SUBRC shows a value '2' after the execution of the command. Can anyone please offer some advice as to what is missing here? My code is running on NW7.4 with HANA DB.

*&---------------------------------------------------------------------*
*& Report  ZKRIS_OLE_DL_CLIPBOARD
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zkris_ole_dl_clipboard.

INCLUDE ole2incl.
.
DATA: w_cell1 TYPE ole2_object,
w_cell2 TYPE ole2_object.

*--- Ole data Declarations
DATA: h_excel TYPE ole2_object, " Excel object
h_mapl TYPE ole2_object, " list of workbooks
h_map TYPE ole2_object, " workbook
h_zl TYPE ole2_object, " cell
h_f TYPE ole2_object, " font
gs_interior TYPE ole2_object, " Pattern
worksheet TYPE ole2_object,
h_cell TYPE ole2_object,
h_cell1 TYPE ole2_object,
range TYPE ole2_object,
h_sheet2 TYPE ole2_object,
h_sheet3 TYPE ole2_object,
gs_font TYPE ole2_object,
flg_stop(1) TYPE c.

*********************************************************************
** Internal table Declaration
*********************************************************************

DATA: BEGIN OF t_excel OCCURS 0,

vkorg(20) TYPE c, "Sales Org

vbtyp(20) TYPE c, "Document Category

auart(20) TYPE c, "Document Type

ernam(20) TYPE c, "Created By

vbeln(20) TYPE c, "Document Number

posnr(20) TYPE c, "Item Number

erdat(20) TYPE c, "Created Date

vdatu(20) TYPE c, "Header Requested Delivery Date

reqdat(20) TYPE c, "Request date

condat(20) TYPE c, "Confirm date

lifsk(20) TYPE c, "Header Block

txt30(30) TYPE c, "Order User Status Description

lifsp(20) TYPE c, "Line Block

dispo(20) TYPE c, "MRP Controller

dsnam(20) TYPE c, "MRP Controller Description

vmsta(20) TYPE c, "Material Sales Status

kunnr(20) TYPE c, "Sold To

cname(35) TYPE c, "Sold To Name

regio(20) TYPE c, "State

cufd(10) TYPE c, "CUD

bstnk(20) TYPE c, "PO#

bsark(20) TYPE c, "Ordering Method

matnr(20) TYPE c, "Material

maktx(35) TYPE c, "Material Description

t200(20) TYPE c,                                            "T200

vtext(20) TYPE c, "T200 Description

matkl(20) TYPE c, "Material Group

zzbomind(7) TYPE c, "BOM Indicator

ostat(20) TYPE c, "Order Status

cmgst(20) TYPE c, "CRD

inco1(20) TYPE c, "Incoterms

oqty(20) TYPE c, "Order Quantity

pqty(20) TYPE c, "Open Quantity

unit(20) TYPE c, "UOM

onet(20) TYPE c, "Order Value

pnet(20) TYPE c, "Open Value

curr(20) TYPE c, "Currency key

so_bezei LIKE tvkbt-bezei,"Sales Office

sg_bezei LIKE tvgrt-bezei,"Sales Group

bname(20) TYPE c, "Ordering Party

contact(20) TYPE c, "Contact Name

telf1(20) TYPE c, "Contact telf1

reqqty(20) TYPE c, "Item Request qty

reqval(20) TYPE c, "Item Request value

conqty(20) TYPE c, "Item Confirm qty

conval(20) TYPE c, "Item Confirm value

zzrev(02) TYPE c, "Revenue recognition acceptance

bezei(20) TYPE c, "Revenue recognition text

vgbel(20) TYPE c, "Reference Order for RETURNS

0008text(255) TYPE c, "Internal Order Comment Text

END OF t_excel.

DATA: t_excel_bckord LIKE t_excel OCCURS 0 WITH HEADER LINE,
t_excel_bcklog LIKE t_excel OCCURS 0 WITH HEADER LINE,
t_excel_blkord LIKE t_excel OCCURS 0 WITH HEADER LINE.

TYPES: data1(1500) TYPE c,
ty TYPE TABLE OF data1.

DATA: it TYPE ty WITH HEADER LINE,
it_2 TYPE ty WITH HEADER LINE,
it_3 TYPE ty WITH HEADER LINE,

rec TYPE sy-tfill,
deli(1) TYPE c,
l_amt(18) TYPE c.
DATA: BEGIN OF hex,
tab TYPE x,
END OF hex.

FIELD-SYMBOLS: <fs> .

CONSTANTS cns_09(2) TYPE n VALUE 09.

ASSIGN deli TO <fs> TYPE 'X'.
hex-tab = cns_09.
<fs> = hex-tab.

DATA gv_sheet_name(20) TYPE c .

*----------------------------------------------------------------------*
* M A C R O Declaration
*----------------------------------------------------------------------*
DEFINE ole_check_error.
  if &1 ne 0.
    message e001(zz) with &1.
    exit.
  endif.
END-OF-DEFINITION.

t_excel_bckord-vkorg = 'ABC'.
t_excel_bckord-vbtyp = 'DEF'.
t_excel_bckord-auart = 'GHI'.
t_excel_bckord-ernam = 'JKL'.
t_excel_bckord-vbeln = 'MNO'.
t_excel_bckord-0008text = 'XYZ'.
APPEND t_excel_bckord.

t_excel_bckord-vkorg = 'ABC1'.
t_excel_bckord-vbtyp = 'DEF1'.
t_excel_bckord-auart = 'GHI1'.
t_excel_bckord-ernam = 'JKL1'.
t_excel_bckord-vbeln = 'MNO1'.
t_excel_bckord-0008text = 'XYZ1'.
APPEND t_excel_bckord.

t_excel_bckord-vkorg = 'ABC2'.
t_excel_bckord-vbtyp = 'DEF2'.
t_excel_bckord-auart = 'GHI2'.
t_excel_bckord-ernam = 'JKL2'.
t_excel_bckord-vbeln = 'MNO2'.
t_excel_bckord-0008text = 'XYZ2'.
APPEND t_excel_bckord.



t_excel_bcklog-vkorg = 'ABC'.
t_excel_bcklog-vbtyp = 'DEF'.
t_excel_bcklog-auart = 'GHI'.
t_excel_bcklog-ernam = 'JKL'.
t_excel_bcklog-vbeln = 'MNO'.
t_excel_bcklog-0008text = 'XYZ'.
APPEND t_excel_bcklog.

t_excel_bcklog-vkorg = 'ABC1'.
t_excel_bcklog-vbtyp = 'DEF1'.
t_excel_bcklog-auart = 'GHI1'.
t_excel_bcklog-ernam = 'JKL1'.
t_excel_bcklog-vbeln = 'MNO1'.
t_excel_bcklog-0008text = 'XYZ1'.
APPEND t_excel_bcklog.

t_excel_bcklog-vkorg = 'ABC2'.
t_excel_bcklog-vbtyp = 'DEF2'.
t_excel_bcklog-auart = 'GHI2'.
t_excel_bcklog-ernam = 'JKL2'.
t_excel_bcklog-vbeln = 'MNO2'.
t_excel_bcklog-0008text = 'XYZ2'.
APPEND t_excel_bcklog.

t_excel_bcklog-vkorg = 'ABC3'.
t_excel_bcklog-vbtyp = 'DEF3'..
t_excel_bcklog-auart = 'GHI3'.
t_excel_bcklog-ernam = 'JKL3'.
t_excel_bcklog-vbeln = 'MNO3'.
t_excel_bcklog-0008text = 'XYZ3'.
APPEND t_excel_bcklog.


t_excel_blkord-vkorg = 'ABC'.
t_excel_blkord-vbtyp = 'DEF'.
t_excel_blkord-auart = 'GHI'.
t_excel_blkord-ernam = 'JKL'.
t_excel_blkord-vbeln = 'MNO'.
t_excel_blkord-0008text = 'XYZ'.
APPEND t_excel_blkord.

t_excel_blkord-vkorg = 'ABC1'.
t_excel_blkord-vbtyp = 'DEF1'.
t_excel_blkord-auart = 'GHI1'.
t_excel_blkord-ernam = 'JKL1'.
t_excel_blkord-vbeln = 'MNO1'.
t_excel_blkord-0008text = 'XYZ1'.
APPEND t_excel_blkord.

t_excel_blkord-vkorg = 'ABC2'.
t_excel_blkord-vbtyp = 'DEF2'.
t_excel_blkord-auart = 'GHI2'.
t_excel_blkord-ernam = 'JKL2'.
t_excel_blkord-vbeln = 'MNO2'.
t_excel_blkord-0008text = 'XYZ2'.
APPEND t_excel_blkord.

t_excel_blkord-vkorg = 'ABC3'.
t_excel_blkord-vbtyp = 'DEF3'..
t_excel_blkord-auart = 'GHI3'.
t_excel_blkord-ernam = 'JKL3'.
t_excel_blkord-vbeln = 'MNO3'.
t_excel_blkord-0008text = 'XYZ3'.
APPEND t_excel_blkord.

t_excel_blkord-vkorg = 'ABC4'.
t_excel_blkord-vbtyp = 'DEF4'..
t_excel_blkord-auart = 'GHI4'.
t_excel_blkord-ernam = 'JKL4'.
t_excel_blkord-vbeln = 'MNO4'.
t_excel_blkord-0008text = 'XYZ4'.
APPEND t_excel_blkord.


LOOP AT t_excel_bckord.
  CONCATENATE
  t_excel_bckord-vkorg

  t_excel_bckord-vbtyp

  t_excel_bckord-auart

  t_excel_bckord-ernam

  t_excel_bckord-vbeln

  t_excel_bckord-posnr

  t_excel_bckord-erdat

  t_excel_bckord-vdatu

  t_excel_bckord-reqdat

  t_excel_bckord-condat

  t_excel_bckord-lifsk

  t_excel_bckord-txt30

  t_excel_bckord-lifsp

  t_excel_bckord-dispo

  t_excel_bckord-dsnam

  t_excel_bckord-vmsta

  t_excel_bckord-kunnr

  t_excel_bckord-cname

  t_excel_bckord-regio

  t_excel_bckord-cufd

  t_excel_bckord-bstnk

  t_excel_bckord-bsark

  t_excel_bckord-matnr

  t_excel_bckord-maktx

  t_excel_bckord-t200

  t_excel_bckord-vtext

  t_excel_bckord-matkl

  t_excel_bckord-zzbomind

  t_excel_bckord-ostat

  t_excel_bckord-cmgst

  t_excel_bckord-inco1

  t_excel_bckord-oqty

  t_excel_bckord-pqty

  t_excel_bckord-unit

  t_excel_bckord-onet

  t_excel_bckord-pnet

  t_excel_bckord-curr

  t_excel_bckord-so_bezei

  t_excel_bckord-sg_bezei

  t_excel_bckord-bname

  t_excel_bckord-contact

  t_excel_bckord-telf1

  t_excel_bckord-reqqty

  t_excel_bckord-reqval

  t_excel_bckord-conqty

  t_excel_bckord-conval

  t_excel_bckord-zzrev

  t_excel_bckord-bezei

  t_excel_bckord-vgbel

  t_excel_bckord-0008text

  INTO it
  SEPARATED BY deli.

  APPEND it.
  CLEAR it.
ENDLOOP.


LOOP AT t_excel_bcklog.
  CONCATENATE
  t_excel_bcklog-vkorg

  t_excel_bcklog-vbtyp

  t_excel_bcklog-auart

  t_excel_bcklog-ernam

  t_excel_bcklog-vbeln

  t_excel_bcklog-posnr

  t_excel_bcklog-erdat

  t_excel_bcklog-vdatu

  t_excel_bcklog-reqdat

  t_excel_bcklog-condat

  t_excel_bcklog-lifsk

  t_excel_bcklog-txt30

  t_excel_bcklog-lifsp

  t_excel_bcklog-dispo

  t_excel_bcklog-dsnam

  t_excel_bcklog-vmsta

  t_excel_bcklog-kunnr

  t_excel_bcklog-cname

  t_excel_bcklog-regio

  t_excel_bcklog-cufd

  t_excel_bcklog-bstnk

  t_excel_bcklog-bsark

  t_excel_bcklog-matnr

  t_excel_bcklog-maktx

  t_excel_bcklog-t200

  t_excel_bcklog-vtext

  t_excel_bcklog-matkl

  t_excel_bcklog-zzbomind

  t_excel_bcklog-ostat

  t_excel_bcklog-cmgst

  t_excel_bcklog-inco1

  t_excel_bcklog-oqty

  t_excel_bcklog-pqty

  t_excel_bcklog-unit

  t_excel_bcklog-onet

  t_excel_bcklog-pnet

  t_excel_bcklog-curr

  t_excel_bcklog-so_bezei

  t_excel_bcklog-sg_bezei

  t_excel_bcklog-bname

  t_excel_bcklog-contact

  t_excel_bcklog-telf1

  t_excel_bcklog-reqqty

  t_excel_bcklog-reqval

  t_excel_bcklog-conqty

  t_excel_bcklog-conval

  t_excel_bcklog-zzrev

  t_excel_bcklog-bezei

  t_excel_bcklog-vgbel

  t_excel_bcklog-0008text

  INTO it_2
  SEPARATED BY deli.

  APPEND it_2.
  CLEAR it_2.
ENDLOOP.


LOOP AT t_excel_blkord.
  CONCATENATE
  t_excel_blkord-vkorg

  t_excel_blkord-vbtyp

  t_excel_blkord-auart

  t_excel_blkord-ernam

  t_excel_blkord-vbeln

  t_excel_blkord-posnr

  t_excel_blkord-erdat

  t_excel_blkord-vdatu

  t_excel_blkord-reqdat

  t_excel_blkord-condat

  t_excel_blkord-lifsk

  t_excel_blkord-txt30

  t_excel_blkord-lifsp

  t_excel_blkord-dispo

  t_excel_blkord-dsnam

  t_excel_blkord-vmsta

  t_excel_blkord-kunnr

  t_excel_blkord-cname

  t_excel_blkord-regio

  t_excel_blkord-cufd

  t_excel_blkord-bstnk

  t_excel_blkord-bsark

  t_excel_blkord-matnr

  t_excel_blkord-maktx

  t_excel_blkord-t200

  t_excel_blkord-vtext

  t_excel_blkord-matkl

  t_excel_blkord-zzbomind

  t_excel_blkord-ostat

  t_excel_blkord-cmgst

  t_excel_blkord-inco1

  t_excel_blkord-oqty

  t_excel_blkord-pqty

  t_excel_blkord-unit

  t_excel_blkord-onet

  t_excel_blkord-pnet

  t_excel_blkord-curr

  t_excel_blkord-so_bezei

  t_excel_blkord-sg_bezei

  t_excel_blkord-bname

  t_excel_blkord-contact

  t_excel_blkord-telf1

  t_excel_blkord-reqqty

  t_excel_blkord-reqval

  t_excel_blkord-conqty

  t_excel_blkord-conval

  t_excel_blkord-zzrev

  t_excel_blkord-bezei

  t_excel_blkord-vgbel

  t_excel_blkord-0008text

  INTO it_3
  SEPARATED BY deli.

  APPEND it_3.
  CLEAR it_3.
ENDLOOP.



IF h_excel-header = space OR h_excel-handle = -1.
* start Excel
  CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
ENDIF.

* PERFORM err_hdl.

*--- get list of workbooks, initially empty
CALL METHOD OF h_excel 'Workbooks' = h_mapl.
* PERFORM err_hdl.
SET PROPERTY OF h_excel 'Visible' = 1.

* add a new workbook
CALL METHOD OF h_mapl 'Add' = h_map.
* PERFORM err_hdl.
*GV_SHEET_NAME = '1st SHEET'.

gv_sheet_name = 'Back Orders'.



GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.
SET PROPERTY OF worksheet 'Name' = gv_sheet_name .


*--Formatting the area of additional data 1 and doing the BOLD
CALL METHOD OF h_excel 'Cells' = w_cell1
  EXPORTING
    #1 = 1
    #2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
  EXPORTING
    #1 = 1
    #2 = 50.
CALL METHOD OF h_excel 'Range' = h_cell
  EXPORTING
    #1 = w_cell1
    #2 = w_cell2.
*CALL METHOD OF gs_cells 'Select' .
GET PROPERTY OF h_cell 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .


DATA l_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>clipboard_export
  IMPORTING
    data                 = it[]
  CHANGING
    rc                   = l_rc
  EXCEPTIONS
    cntl_error           = 1
    error_no_gui         = 2
    not_supported_by_gui = 3
    OTHERS               = 4.

CALL METHOD OF h_excel 'Cells' = w_cell1
  EXPORTING
    #1 = 1
    #2 = 1.

CALL METHOD OF h_excel 'Cells' = w_cell2
  EXPORTING
    #1 = 1
    #2 = 1.
* PERFORM err_hdl.

CALL METHOD OF h_excel 'Range' = range
  EXPORTING
    #1 = w_cell1
    #2 = w_cell2.

CALL METHOD OF range 'Select'.
* PERFORM err_hdl.
CALL METHOD OF worksheet 'Paste'.
* PERFORM err_hdl.

* CALL METHOD OF h_excel 'QUIT'.

*GV_SHEET_NAME = '2ND SHEET'.
gv_sheet_name = 'Backlog'.


GET PROPERTY OF h_excel 'Sheets' = h_sheet2 .

CALL METHOD OF h_sheet2 'Add' = h_map.
SET PROPERTY OF h_map 'Name' = gv_sheet_name .
GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.


*--Formatting the area of additional data 1 and doing the BOLD
CALL METHOD OF h_excel 'Cells' = w_cell1
  EXPORTING
    #1 = 1
    #2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
  EXPORTING
    #1 = 1
    #2 = 50.
CALL METHOD OF h_excel 'Range' = h_cell
  EXPORTING
    #1 = w_cell1
    #2 = w_cell2.
GET PROPERTY OF h_cell 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .

CALL METHOD cl_gui_frontend_services=>clipboard_export
  IMPORTING
    data                 = it_2[]
  CHANGING
    rc                   = l_rc
  EXCEPTIONS
    cntl_error           = 1
    error_no_gui         = 2
    not_supported_by_gui = 3
    OTHERS               = 4.

CALL METHOD OF h_excel 'Cells' = w_cell1
  EXPORTING
    #1 = 1
    #2 = 1.

CALL METHOD OF h_excel 'Cells' = w_cell2
  EXPORTING
    #1 = 1
    #2 = 1.
* PERFORM err_hdl.

CALL METHOD OF h_excel 'Range' = range
  EXPORTING
    #1 = w_cell1
    #2 = w_cell2.

CALL METHOD OF range 'Select'.
* PERFORM err_hdl.
CALL METHOD OF worksheet 'Paste'.



*GV_SHEET_NAME = '3rd SHEET'.
gv_sheet_name = 'Blocked Orders'.

GET PROPERTY OF h_excel 'Sheets' = h_sheet3 .

CALL METHOD OF h_sheet3 'Add' = h_map.
SET PROPERTY OF h_map 'Name' = gv_sheet_name .
GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.


*--Formatting the area of additional data 1 and doing the BOLD
CALL METHOD OF h_excel 'Cells' = w_cell1
  EXPORTING
    #1 = 1
    #2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
  EXPORTING
    #1 = 1
    #2 = 50.
CALL METHOD OF h_excel 'Range' = h_cell
  EXPORTING
    #1 = w_cell1
    #2 = w_cell2.
GET PROPERTY OF h_cell 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .

CALL METHOD cl_gui_frontend_services=>clipboard_export
  IMPORTING
    data                 = it_3[]
  CHANGING
    rc                   = l_rc
  EXCEPTIONS
    cntl_error           = 1
    error_no_gui         = 2
    not_supported_by_gui = 3
    OTHERS               = 4.

CALL METHOD OF h_excel 'Cells' = w_cell1
  EXPORTING
    #1 = 1
    #2 = 1.

CALL METHOD OF h_excel 'Cells' = w_cell2
  EXPORTING
    #1 = 1
    #2 = 1.
* PERFORM err_hdl.

CALL METHOD OF h_excel 'Range' = range
  EXPORTING
    #1 = w_cell1
    #2 = w_cell2.

CALL METHOD OF range 'Select'.
* PERFORM err_hdl.
CALL METHOD OF worksheet 'Paste'.


*--- disconnect from Excel
FREE OBJECT h_zl.
FREE OBJECT h_mapl.
FREE OBJECT h_map.
FREE OBJECT h_excel.
18 REPLIES 18

Sandra_Rossi
Active Contributor
0 Kudos
2,243

ABAP documentation of CALL METHOD - OLE :

sy-subrc  Meaning
--------  -------------------------------------
0         Method meth executed successfully.
1         Error in communication with SAP GUI.
2         Error when calling the method meth.
3         Error when setting an attribute.
4         Error when reading an attribute.

If I understand well, you are saying that you have SY-SUBRC = 2 at this line (any of the 3 occurrences):

CALL METHOD OF worksheet 'Paste'.

I guess the worksheet variable is OLE type Worksheet in Excel.

According to Excel documentation, Worksheet has a Paste method. It pastes the data of the clipboard into the active cell in this worksheet.

What contains the clipboard?

2,243

Hello Sandra,

At each CALL METHOD cl_gui_frontend_services=>clipboard_export, the clipboard will hold the internal table data from IT[], IT_2[], IT_3[] for pasting into the excel.

0 Kudos
2,243

Let's keep it simple. Does this coe work for you?

INCLUDE ole2incl.
DATA: w_cell1     TYPE ole2_object,
      h_excel     TYPE ole2_object, " Excel object
      h_mapl      TYPE ole2_object, " list of workbooks
      h_map       TYPE ole2_object, " workbook
      worksheet   TYPE ole2_object.
TYPES: data1(1500) TYPE c,
       ty          TYPE TABLE OF data1.
DATA: it      TYPE ty,
      deli(1) TYPE c.

deli = |\t|.

CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
SET PROPERTY OF h_excel 'Visible' = 1.

CALL METHOD OF h_excel 'Workbooks' = h_mapl.
CALL METHOD OF h_mapl 'Add' = h_map.

GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.
SET PROPERTY OF worksheet 'Name' = 'Back Orders'.

DATA l_rc TYPE i.
it = value #( ( |Cell 1\tCell 2| ) ( |Cell 3\tCell 4| ) ).
CALL METHOD cl_gui_frontend_services=>clipboard_export
  IMPORTING
    data                 = it[]
  CHANGING
    rc                   = l_rc
  EXCEPTIONS
    cntl_error           = 1
    error_no_gui         = 2
    not_supported_by_gui = 3
    OTHERS               = 4.

CALL METHOD OF h_excel 'Cells' = w_cell1
  EXPORTING
    #1 = 1
    #2 = 1.
CALL METHOD OF w_cell1 'Select'.
CALL METHOD OF worksheet 'Paste'.

0 Kudos
2,243

I have the same problem and I tried to execute the given sample code above. But, the Paste method still doesn't work, subrc was 2. My excel version in 2209.

0 Kudos
2,243

Are you using SAP GUI or Excel in a virtual desktop?

0 Kudos
2,243

Hello Sandra,

No, I'm not using virtual desktop. The data were successfully exported into the clipboard but the method PASTE is not working. It gives subrc 2.

2,243

The code I posted works for me (animated gif):

paste-itab-into-excel.gif

Could you test on another laptop? Could you re-install Excel and latest SAP GUI version?

2,243

Hi Sandra.

I tried to execute the program using SAP GUI 760 & Excel 2209 and it worked fine. However, when I used SAP GUI 770, sy-subrc returned 2. Does it mean that there's a problem with SAP GUI 770?

0 Kudos
2,243

Thanks. Great news. My successful attempt was with SAP GUI 7.70 PL03, Excel 365, 7.52 SP 0.

7.60 went out of support on 12th of April 2022. Latest SAP GUI 7.70 is PL06. Is it the one you tried?

I couldn't find relevant SAP notes after looking at "SAP GUI MS office compatibility".

Now, the only solution left is to get some help from the SAP Support.

2,243

Hi Sandra.

It's SAP GUI 770, PL04. Excel 365 Version 2209. Thanks for your help and assistance. Will raise this to SAP support.

0 Kudos
2,243

sandra.rossi - My GUI shows

Release : 770 Final Release

File version: 7700.1.0.1161

Build: 2044469

Patch Level: 0

Does this mean, I have to go for an update?

@Rea - Once you get a response from SAP, could you please share the same here?

0 Kudos
2,243
vedvishwa

You have PL0 (Patch Level). The latest one is PL5. The one I used is PL3.

Rea is using PL04.

So, I guess the issue is not only about SAP GUI, but at least I guess SAP Support can help.

2,243

Hello,

I approached SAP for this issue and they have a very weird reply.

"

Dear Customer,

I have gone through the attached trace file. The cause of the issue is failure at Microsoft API called "PASTE".

Request you to be in touch with your Microsoft contact and get the suggestion. The Development support cannot help here for Z-reports. It is out of maintenance support scope.

Due to latest versions of EXCEL or OFFICE tools, few of the calls are failing.

"

Now, how do we get in touch with Microsoft?

0 Kudos
2,243

Thanks for the feedback. SAP support is often limited by Microsoft products and don't have power to make Microsoft change their products (it's what they say in few SAP notes after Microsoft changed something). Here, the excuse is that it's a Z program, but I think it's because they think it's too much difficult for them to contact Microsoft and no standard SAP program is implied.

I don't know how to contact Microsoft but I think it will be easier for you to change the way your solution works.

Creating an Excel file can be done without OLE, e.g. abap2xlsx, or instantiate CL_SALV_TABLE and call the method TO_XML, or create a CSV file, etc.

Sandra_Rossi
Active Contributor
0 Kudos
2,243

FYI, you could simplify:

deli = cl_abap_char_utilities=>horizontal_tab.

Sandra_Rossi
Active Contributor
0 Kudos
2,243

or even:

deli = |\t|.

VishwanathV
Participant
0 Kudos
2,243

sandra.rossi - The problem still exists even after adopting your sample code. SY-SURC is still '2' after the 'PASTE' operation. What is the gui version you're running the code on? We're on SAP GUI 770.

0 Kudos
2,243

Please use the COMMENT button for comments, questions, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.