Using Existing OLE Excel Object
Hi
I have created an ole excel object to download my report data.
My requirement is to use an existing excel object.
Existing OLE object would act like a template with the Header Information and my company's logo in it.
Can anyone suggest suitable procedures for the same.
AK
I dont know more about it.
Just have look below function module.
<b>EXCEL_OLE_STANDARD_DAT</b> Just calls MS_EXCEL_OLE_STANDARD_DAT
<b>MS_EXCEL_OLE_STANDARD</b>_DATDownloads internal table and opens it in MS Excel
<b>KCD_EXCEL_OLE_TO_INT_CONVERT</b> Uploads an *.xls file to internal table (max cell length = 32).
<b>ALSM_EXCEL_TO_INTERNAL_TABLE</b> the same as KCD_EXCEL_OLE_TO_INT_CONVERT but max cell length = 50
<b>FTBU_START_EXCEL</b> just [download internal table to file and] start Excel (w/o OLE).
regards
vinod
Similar Messages
-
Dump while running a program with OLE Excel download facility in ITS
Hi,
Because of some complex requirment, I had created a report program which will download the data to an Excel sheet using SAP OLE Automation Controller. For this report i had created a tcode too.
The report which i developed is perfectly working fine in SAPGUI. But if i access the same report throught SAP ITS serice. I am getting a dump. Please find below the dump details. I am not able to figure it out why the dump is not coming in SAPGUI.
Runtime Errors MESSAGE_TYPE_X
Date and Time 09.03.2010 05:35:41
Short text
The current application triggered a termination with a short dump.
What happened?
The current application program detected a situation which really
should not occur. Therefore, a termination with a short dump was
triggered on purpose by the key word MESSAGE (type X).
|
Error analysis
Short text of error message:
Control Framework : Error processing control
Long text of error message:
Diagnosis
An error occurred when the system tried to process the commands
from the Automation Queue on the presentation server.
There are several possible reasons for this:
- The installation of the SAP GUI on the presentation server is
faulty or obsolete.
- There is an error in the application program
- There is an error in the SAPGUI or an integrated control
Procedure
1. Make sure that you have imported the appropriate Support
Package, the current kernel, and GUI patch for the release of your
system
2. Check whether the error occurs locally on one or a few PCs, or
generally on all PCs. Note whether the error only occurs for some
users, for example because of a specific Customizing setting.
If it only occurs locally, this suggests an installation problem
with the PC. Check the installation; if necessary, reinstall the
software. In the dump, search for the SY-MSGLI field, since it may
point to the cause of the error.
3. Activate the Automation Trace (in accordance with SAP Note
158985).
4.Start the transaction and continue until the screen immediately
before the dump.
5. From the System -> Utilities menu, choose Autom. Queue,
Synchronous Processing.
The status bar of the GUI displays the text:
"Automation synchron flush mode on"
6. If you now proceed with the application, the short dump will
display the ABAP call that caused the error; the Automation Trace
will contain the error on the presentation server.
7. If necessary, load the short dump and trace files on to
sapservX, so that SAP can analyze them.
Technical information about the message:
Message class....... "CNDP"
Number.............. 006
Variable 1.......... " "
Variable 2.......... " "
Variable 3.......... " "
Variable 4.......... " "
How to correct the error
Probably the only way to eliminate the error is to correct the program.
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"MESSAGE_TYPE_X" " "
"SAPLOLEA" or "LOLEAU02"
"AC_SYSTEM_FLUSH"
If you cannot solve the problem yourself and want to send an error
notification to SAP, include the following information:
1. The description of the current problem (short dump)
To save the description, choose "System->List->Save->Local File
(Unconverted)".
2. Corresponding system log
Display the system log by calling transaction SM21.
Restrict the time interval to 10 minutes before and five minutes
after the short dump. Then choose "System->List->Save->Local File
(Unconverted)".
3. If the problem occurs in a problem of your own or a modified SAP
program: The source code of the program
In the editor, choose "Utilities->More
Utilities->Upload/Download->Download".
4. Details about the conditions under which the error occurred or which
actions and input led to the error.
User and Transaction
Client.............. 120
User................ "XXXXXX"
Language Key........ "E"
Transaction......... "ZGA_BEACON_SOX_RPT "
Transactions ID..... "4B95E2560EB62F9AE10000000A241C33"
Program............. "SAPLOLEA"
Screen.............. "ZGA_REP_BEACON_SOX_REPORT 9000"
Screen Line......... 0
Information on Caller ofr "HTTP" Connection:
Plug-in Type.......... "HTTP"
Caller IP............. "10.36.28.52"
Caller Port........... 8000
Universal Resource Id. "/sap/bc/gui/sap/its/webgui/~flNUQVRFPTIzNzIxLjAxNC4wNC4
wNA=="Hi All,
FYI.....
As I said because of my complex requirement, i am using OLE excel download facilities to download the data. ITS wont support this OLE download facility. This can be done only through local SAP GUI.
The reason for this is that, when i am using this download facility through SAP GUI, OLE object thats used in my report program will directly talk to the Local OLE excel objects (i.e. the local installed Excell application) and download the data. But if it's through ITS, my program wont be able to communicate with the local excel OLE objects because of this i am getting a DUMP.
Thank You all for the support. All the best in future.
Regards
Maneesh Chandran -
Unable to add reference for Excel Object Library for use within Script Task
I have a requirement to use a Script Tax that needs to reference the Excel Object Model. There are numerous articles on using this such as
http://www.databasejournal.com/features/mssql/article.php/3921141/SSIS-Script-Task-and-Microsoft-Office-Automation.htm.
Simply, I need to add a reference to the Microsoft Excel 12.0 Object Library.
I have selected this from the Object List on the COM tab and when this adds the reference it states 'The System cannot find the reference specified', even though the referenced file for this Object is C:\Program Files(x86)\Microsoft Office\Office12\Excel.exe
and this file location exists on my local machine ?Please search where "Microsoft.Office.Interop.Excel.dll" exist in your system and try adding the reference.
If you don't find the dll there then there might be problem while installing.
To install the PIAs by using the redistributable package
http://www.microsoft.com/en-us/download/details.aspx?id=3508
http://www.microsoft.com/en-us/download/details.aspx?id=18346
Regards, RSingh -
Errors in excel using SAP OLE DB connection
I'm trying to use the OLE DB connector in excel and keep getting the following error when I try to connect to our BW system:
u201CCannot process Unicode RFC in non-Unicode systemu201D
Has anyone else encountered this problem, and gotten around it? We are not unicode yet, is this a requirement for using this connector and if so is there a non-unicode equivalent? Appreciate any help. Thank you.
Ivano
PS- Here's a couple of the articles I've been trying to follow:
http://www.bi-expertonline.com/article.cfm?id=5048&s=4717b805-004b-4f5d-b703-3b414486e53f
http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1031a475-a633-2a10-f4b4-ccfe615c0517bumpity bump bump
-
Handle a non existance of report object while using find_report_object ?
How to handle a non existance of report object while using find_report_object?
HOW CAN I HANDLE THE ERROR FRM-41219 PROGRAMATICALLY.
SINCE ID_NULL IS NOT SUPPORTING FOR REPORT OBJECT.
1) Message level for FRM-41219 is 20, even if i set the message level to 20, it's not getting suppresed.
As per my follwoing code, error is rasing once immidiatlly after the find_report_object.
DECLARE
REPID REPORT_OBJECT;
BEGIN
REPID := FIND_REPORT_OBJECT('REP_OBJECT');
--NOTE 'REP_OBJECT' DOES NOT EXIST, IT'S NOT GOING TO THE EXCEPTION
--SECTION AND RASING THE ERROR 41219 CANNOT FIND REPORT : INVALID ID.
--QUESTION : HOW CAN I HANDLE THIS ERROR?
EXCEPTION
WHEN OTHERS THEN
MESSAGE('INSIDE EXCEPTION');
MESSAGE('INSIDE EXCEPTION');
END;This is really more of a Forms issue since these are Forms built-ins. However, check out note 209513.1 in Metalink. It describes how to check if the report objects exists and how to trap the error.
Hope that helps,
Toby -
hello everybody,
i am trying to format an already existing excel-file with ole-technique.
this works fine so far, but (of course) there is one very important step i can't handle.
i need to make subtotals and after 2 days of trying and searching the net i have no more ideas how it could work.
to make it easier to understand i have made a simple excerpt which everyone should be able to use as local report by copy/paste or you can download the coding as txt-file from here:
txt-file
Report ZVEXCELOLE_TMP
Author: Matthias Leitner
REPORT zvexcelole_tmp NO STANDARD PAGE HEADING LINE-SIZE 132.
datendeklaration *
DATA: it_filetable TYPE filetable.
DATA: wa_filetable TYPE file_table.
DATA: wa_filename TYPE string,
wa_upload TYPE string,
wa_download TYPE string,
wa_file(255) TYPE c,
wa_rc TYPE i.
OLE-Definitionen
INCLUDE ole2incl.
DATA: wa_loesch type i,
o_excel TYPE ole2_object,
o_workbook TYPE ole2_object,
o_columns TYPE ole2_object,
o_autofit TYPE ole2_object,
o_blatt TYPE ole2_object.
selection-screen *
SELECTION-SCREEN BEGIN OF BLOCK z3 WITH FRAME.
PARAMETERS: pa_dir(255) TYPE c LOWER CASE .
SELECTION-SCREEN END OF BLOCK z3.
initialization *
INITIALIZATION.
standardmässiges download-verzeichnis holen
CALL METHOD cl_gui_frontend_services=>get_upload_download_path
CHANGING
upload_path = wa_upload
download_path = wa_download
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
gui_upload_download_path = 4
upload_download_path_failed = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
MOVE wa_download TO pa_dir.
ENDIF.
at selection-screen *
AT SELECTION-SCREEN.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_dir.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION =
DEFAULT_FILENAME =
FILE_FILTER =
INITIAL_DIRECTORY =
MULTISELECTION =
WITH_ENCODING =
CHANGING
file_table = it_filetable
rc = wa_rc
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 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.
ELSE.
READ TABLE it_filetable INTO wa_filetable INDEX 1.
MOVE wa_filetable-filename TO pa_dir.
ENDIF.
start-of-selection *
START-OF-SELECTION.
PERFORM excel_format.
MOVE pa_dir TO wa_file.
FORMAT HOTSPOT ON.
WRITE: wa_file+0(132).
FORMAT HOTSPOT OFF.
HIDE wa_file.
CLEAR wa_file.
at line-selection *
AT LINE-SELECTION.
CLEAR wa_file.
READ CURRENT LINE.
IF NOT wa_file IS INITIAL.
MOVE wa_file TO wa_filename.
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
document = wa_filename
application =
PARAMETER =
DEFAULT_DIRECTORY =
MAXIMIZED =
MINIMIZED =
SYNCHRONOUS =
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
bad_parameter = 3
file_not_found = 4
path_not_found = 5
file_extension_unknown = 6
error_execute_failed = 7
OTHERS = 8
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.
form excel_format *
FORM excel_format.
start excel
CREATE OBJECT o_excel 'EXCEL.APPLICATION'.
IF sy-subrc NE 0.
WRITE: / 'OLE-Fehler. EXCEL.APPLICATION'.
ENDIF.
excel -> not visible
SET PROPERTY OF o_excel 'Visible' = 0. "visible = 1
IF sy-subrc NE 0.
WRITE: / 'OLE-Fehler. Visible'.
ENDIF.
Arbeitsblatt auswählen
CALL METHOD OF o_excel 'Workbooks' = o_workbook.
IF sy-subrc NE 0.
WRITE: / 'OLE-Fehler. Workbooks'.
ENDIF.
open existing file
CALL METHOD OF o_workbook 'OPEN'
EXPORTING
#1 = pa_dir.
IF sy-subrc NE 0.
WRITE: / 'OLE-Fehler. OPEN'.
ENDIF.
SUBTOTALS!!!
bei allen spalten auf optimale breite setzen
CALL METHOD OF o_excel 'Columns' = o_columns.
IF sy-subrc NE 0.
WRITE: / 'OLE-Fehler. Columns'.
ENDIF.
CALL METHOD OF o_columns 'Autofit' = o_autofit.
IF sy-subrc NE 0.
WRITE: / 'OLE-Fehler. Autofit'.
ENDIF.
save and close excel
CALL METHOD OF o_excel 'Worksheets' = o_blatt
EXPORTING
#1 = 1.
IF sy-subrc NE 0.
WRITE: / 'OLE-Fehler. Worksheets'.
ENDIF.
CALL METHOD OF o_blatt 'SaveAs'
EXPORTING
#1 = pa_dir
#2 = 1. "fileFormat
IF sy-subrc NE 0.
WRITE: / 'OLE-Fehler. SaveAs'.
ELSE.
ENDIF.
CALL METHOD OF o_workbook 'CLOSE'.
IF sy-subrc NE 0.
WRITE: / 'OLE-Fehler. CLOSE'.
ENDIF.
CALL METHOD OF o_excel 'QUIT'.
IF sy-subrc NE 0.
WRITE: / 'OLE-Fehler. QUIT'.
ENDIF.
FREE o_excel.
ENDFORM. "FORM excel_format
the excel-file should be grouped by column 6 and sum column 4.
you can download an example of the excel-sheet (already including the subtotals as i need them):
xls-file
i hope my question is clear. if i have forgotten anything important - please ask.
our system:
SAP_BASIS 620
excel 2002 - service pack 3
thanks in advance!
matthias
Message was edited by: Matthias Leitnerhi vinod,
thank you very much for the reply.
if i get it right the first two function modules don't have any functionallity for making subtotals. the next two just put excel-data into internal format.
the last may be a possibility to use an external excel makro .
but i think it must be possible to do this by OLE.
best regards,
matthias -
Failed to Run OLE Excel program in background JOB (SM36)
Please help.
I have write a program to use OLE to create a Excel file.
The program can run successful in front end workstation. However, when I run the program in background job by SM36.
The statement "CREATE OBJECT EXCEL 'EXCEL.APPLICATION'" return with error "SY-SUBRC = 2".
How can I solve it ?
Can OLE Excel be run on background job ?
Thanks so much,
MarkHi Mark:
Your need is a very common one. I also was asked to generate an Excel in Background.
It is not possible to work with OLE in background mode.
The reason is: In background mode there is no presentation server. OLE is executed in presentation server.
Below I paste the code I wrote to solve my problem.
This class sends a mail with an excel attached. The Excel content will be the internal table you pass to the class. But the Excel is not binary, it is a plain text file, separated by tabulators. Anyway, when you open it with Excel, the columns are properly shown.
Sorry. Comments are in spanish, I don't have time to translate it.
I kindly ask to everybody which want to use it to keep my name in the code.
* Autor: Jordi Escoda, 30/10/2008.
* Descripción: Esta clase genera un correo electrónico destinado a
* una persona, adjuntando el contenido de una tabla interna como
* Excel (campos separados por tabuladores).
* La virtud de esta clase es su sencillez de utilización. Para lanzar
* el mail con el excel adjunto basta con declarar la tabla interna,
* llenarla, colocar el asunto del mensaje, el destinatario, el nombre
* del excel adjunto, y pasar la tabla interna.
* Ejemplo de utilización:
* DATA: lc_mail TYPE REF TO cl_mail_builder_xls_attach.
* DATA: lt_anla TYPE STANDARD TABLE OF anla.
* SELECT * INTO TABLE lt_anla FROM anla.
* CREATE OBJECT lc_mail.
* CALL METHOD lc_mail->set_subject( 'Excel adjunto' ).
* CALL METHOD lc_mail->set_recipient( 'XXX@XXXDOTCOM' ).
* CALL METHOD lc_mail->set_attach_filename( 'ANLA' ).
* APPEND 'Cuerpo del mensaje' TO lt_body.
* APPEND 'Saludos cordiales' TO lt_body.
* CALL METHOD lc_mail->set_bodytext( lt_body ).
* CALL METHOD lc_mail->set_attach_table( lt_anla ).
* CALL METHOD lc_mail->send( ).
* CLASS cl_mail_builder_xls_attach DEFINITION
CLASS cl_mail_builder_xls_attach DEFINITION.
PUBLIC SECTION.
METHODS: set_subject
IMPORTING im_subject TYPE so_obj_des,
set_bodytext
IMPORTING im_body TYPE bcsy_text,
set_recipient
IMPORTING im_recipient TYPE ad_smtpadr,
set_attach_table
IMPORTING im_table TYPE ANY TABLE,
set_attach_filename
IMPORTING im_attach_name TYPE sood-objdes,
send.
PRIVATE SECTION.
CONSTANTS:
c_tab TYPE c VALUE cl_bcs_convert=>gc_tab,
c_crlf TYPE c VALUE cl_bcs_convert=>gc_crlf,
c_singlequote TYPE c VALUE '.
DATA: l_recipient_addr TYPE ad_smtpadr.
DATA: send_request TYPE REF TO cl_bcs,
document TYPE REF TO cl_document_bcs,
recipient TYPE REF TO if_recipient_bcs,
bcs_exception TYPE REF TO cx_bcs.
DATA: binary_content TYPE solix_tab,
size TYPE so_obj_len.
DATA: l_string TYPE string,
l_body_text TYPE bcsy_text,
l_subject TYPE so_obj_des,
l_attach_name TYPE sood-objdes.
METHODS: create_binary_content,
get_dataelement_medium_text
IMPORTING im_table_name TYPE tabname
im_field_name TYPE fieldname
EXPORTING ex_medium_text TYPE scrtext_m.
ENDCLASS. "cl_mail_builder_xls_attach DEFINITION
* CLASS cl_mail_builder_xls_attach IMPLEMENTATION
CLASS cl_mail_builder_xls_attach IMPLEMENTATION.
METHOD set_bodytext.
l_body_text[] = im_body[].
ENDMETHOD. "add_bodytext
METHOD set_subject.
l_subject = im_subject.
ENDMETHOD. "add_subject
METHOD set_attach_filename.
l_attach_name = im_attach_name.
ENDMETHOD. "add_subject
METHOD set_recipient.
l_recipient_addr = im_recipient.
ENDMETHOD. "add_subject
METHOD set_attach_table.
* Rellena en un string el contenido de la tabla interna recibida
DATA: ref_to_struct TYPE REF TO cl_abap_structdescr.
DATA: my_like TYPE fieldname,
nombretabla TYPE tabname,
nombrecampo TYPE fieldname,
texto_mediano TYPE scrtext_m.
DATA: l_idx TYPE i,
l_valorcampo(16) TYPE c,
l_long TYPE i.
FIELD-SYMBOLS: <fs_linea> TYPE ANY,
<fs_campo> TYPE ANY.
FIELD-SYMBOLS: <comp_descr> TYPE abap_compdescr.
CHECK NOT im_table[] IS INITIAL.
* Línea con los nombres de las columnas.
CLEAR l_string.
LOOP AT im_table ASSIGNING <fs_linea>.
* Toma los atributos del componente
ref_to_struct =
cl_abap_structdescr=>describe_by_data( <fs_linea> ).
LOOP AT ref_to_struct->components ASSIGNING <comp_descr>.
ASSIGN COMPONENT <comp_descr>-name
OF STRUCTURE <fs_linea> TO <fs_campo>.
* Obtenemos el origen de donde proviene (like). Ej:BKPF-BUDAT
DESCRIBE FIELD <fs_campo> HELP-ID my_like.
SPLIT my_like AT '-' INTO nombretabla nombrecampo.
CALL METHOD get_dataelement_medium_text
EXPORTING
im_table_name = nombretabla
im_field_name = nombrecampo
IMPORTING
ex_medium_text = texto_mediano.
IF texto_mediano IS INITIAL.
CONCATENATE l_string <comp_descr>-name INTO l_string.
ELSE.
CONCATENATE l_string texto_mediano INTO l_string.
ENDIF.
AT LAST.
CONCATENATE l_string c_crlf INTO l_string.
EXIT.
ENDAT.
CONCATENATE l_string c_tab INTO l_string.
ENDLOOP.
EXIT.
ENDLOOP.
* Contenido de la tabla
LOOP AT im_table ASSIGNING <fs_linea>.
* Toma los atributos del componente
ref_to_struct =
cl_abap_structdescr=>describe_by_data( <fs_linea> ).
LOOP AT ref_to_struct->components ASSIGNING <comp_descr>.
* Asignamos el componente ue tratamos, para obtener
* el valor del mismo
ASSIGN COMPONENT <comp_descr>-name OF STRUCTURE <fs_linea>
TO <fs_campo>.
CASE <comp_descr>-type_kind.
WHEN 'P'. "Packed Number
* Convierte a caracter
WRITE <fs_campo> TO l_valorcampo.
CONCATENATE l_string l_valorcampo INTO l_string.
WHEN OTHERS.
l_long = STRLEN( <fs_campo> ).
IF l_long > 11 AND <fs_campo> CO ' 0123456789'.
* El Excel muestra un número tal como 190000000006
* en formato 1,9E+11.
* Para eviarlo, los números de más de 11 dígitos los
* concatenamos con comillas simples.
CONCATENATE l_string c_singlequote
<fs_campo> c_singlequote INTO l_string.
ELSE.
CONCATENATE l_string <fs_campo> INTO l_string.
ENDIF.
ENDCASE.
AT LAST.
* Añade CRLF
CONCATENATE l_string c_crlf INTO l_string.
EXIT.
ENDAT.
* Añade tabulador
CONCATENATE l_string c_tab INTO l_string.
ENDLOOP.
ENDLOOP.
create_binary_content( ).
ENDMETHOD. "set_attach_table
METHOD create_binary_content.
DATA: l_size TYPE so_obj_len.
* convert the text string into UTF-16LE binary data including
* byte-order-mark. Mircosoft Excel prefers these settings
* all this is done by new class cl_bcs_convert (see note 1151257)
TRY.
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = l_string
iv_codepage = '4103' "suitable for MS Excel, leave empty
iv_add_bom = 'X' "for other doc types
IMPORTING
et_solix = binary_content
ev_size = size ).
CATCH cx_bcs.
MESSAGE e445(so).
ENDTRY.
ENDMETHOD. "create_binary_content
METHOD send.
DATA: l_sent_to_all TYPE os_boolean.
TRY.
* create persistent send request
send_request = cl_bcs=>create_persistent( ).
* create and set document with attachment
* create document object
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = l_body_text
i_subject = l_subject ).
* add the spread sheet as attachment to document object
document->add_attachment(
i_attachment_type = 'xls'
i_attachment_subject = l_attach_name
i_attachment_size = size
i_att_content_hex = binary_content ).
* add document object to send request
send_request->set_document( document ).
* add recipient (e-mail address)
recipient =
cl_cam_address_bcs=>create_internet_address(
l_recipient_addr ).
* add recipient object to send request
send_request->add_recipient( recipient ).
* send document
l_sent_to_all = send_request->send(
i_with_error_screen = 'X' ).
COMMIT WORK.
IF l_sent_to_all IS INITIAL.
MESSAGE i500(sbcoms) WITH l_recipient_addr.
ELSE.
MESSAGE s022(so).
ENDIF.
CATCH cx_bcs INTO bcs_exception.
MESSAGE i865(so) WITH bcs_exception->error_type.
ENDTRY.
ENDMETHOD. "lcl_mail_xls_attachment
METHOD get_dataelement_medium_text.
DATA: lt_fld_info TYPE STANDARD TABLE OF dfies,
wa_fld_info TYPE dfies.
* Busca en el diccionario los datos del campo
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = im_table_name
fieldname = im_field_name
langu = sy-langu
TABLES
dfies_tab = lt_fld_info
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
CLEAR ex_medium_text.
IF sy-subrc = 0.
READ TABLE lt_fld_info INDEX 1 INTO wa_fld_info.
* Si lo ha podido tomar del diccionario...
IF NOT wa_fld_info-scrtext_m IS INITIAL.
* Toma el nombre del nombre de campo del diccionario
ex_medium_text = wa_fld_info-scrtext_m.
ENDIF.
ENDIF.
ENDMETHOD. "get_dataelement_medium_text
ENDCLASS. "cl_mail_builder_xls_attach IMPLEMENTATION -
Problem in running a ABAP OLE Excel program in Web Portal
Hi,
Do anyone know how to solve the following problem ?
I have write a ABAP program in R/3 to use OLE to create a Excel file.
The program can run successful in front end workstation through SAPGUI.
However, when I run this ABAP program through the Web Portal by "Workset"
After I input the selection criteria and execute the program:
The statement "CREATE OBJECT EXCEL 'EXCEL.APPLICATION'" return with error "SY-SUBRC = 2".
How can I solve it ?
Can OLE Excel Abap Program can run on Web Portal through the "Workset" ?
Thanks so much,
MarkHi
check this might help
Re: Displaying Error while uploading Excel Sheets
jo -
When try to call Sub in Excel Objects > SheetXX after the original xlsm is modified and saved by another user in diff machine, getting an error below and seems Excel cannot identify any subs exists in Sheet.
Compile error:
Object library invalid or contains references to object definitions that could not be found
Note: it seems that this problem has been occurring After December 2014 update and still exists even after applying the fix:
http://blogs.technet.com/b/the_microsoft_excel_support_team_blog/archive/2014/12/11/forms-controls-stop-working-after-december-2014-updates-.aspx)Hi Kwlee324,
Thanks for sharing the workaround with us. It would be very helpful for others who have the same issue.
Also I found a two useful links about the error message "Object library invalid or contains references to object definitions that could not be found":
https://support.microsoft.com/kb/2703186
http://blogs.msdn.com/b/vsod/archive/2009/06/05/visual-basic-6-controls-stop-working-after-security-advisory-960715.aspx
Hope it is helpful.
Regards & Fei
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Hello all,
1.
I shoud output a excel file using ABAP development. And my excel file is very complex, it have some fixed headers. i am new to ole excel, so who can give me some examples or some useful website. then i can learn how to do it ?
2.
anther question: in which situation, i can't output a excel file? pls tell me asap.
Thanks in advance.Hello Ming,
Try this program... i have used lots of excel formatting in it.. revert back incase you need help
*& Report ZKRIS_OLE2
REPORT zkris_ole2.
TYPE-POOLS ole2 .
DATA: count TYPE i,
application TYPE ole2_object,
workbook TYPE ole2_object,
excel TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object.
CONSTANTS: row_max TYPE i VALUE 256.
DATA index TYPE i.
DATA:
h_cell TYPE ole2_object, " cell
h_f TYPE ole2_object, " font
h_range TYPE ole2_object,
h_range2 TYPE ole2_object,
h_merge TYPE ole2_object,
h_int TYPE ole2_object,
h_int2 TYPE ole2_object,
h_width TYPE ole2_object,
h_columns TYPE ole2_object,
h_rows TYPE ole2_object,
h_actwindow TYPE ole2_object,
h_select TYPE ole2_object,
h_select2 TYPE ole2_object,
h_hyperlink TYPE ole2_object,
h_addhyper TYPE ole2_object,
h_borderstop TYPE ole2_object,
h_entirecol TYPE ole2_object.
CREATE OBJECT excel 'EXCEL.APPLICATION'.
IF sy-subrc NE 0.
WRITE: / 'No EXCEL creation possible'.
STOP.
ENDIF.
SET PROPERTY OF excel 'DisplayAlerts' = 0.
CALL METHOD OF excel 'WORKBOOKS' = workbook .
SET PROPERTY OF excel 'VISIBLE' = 1.
* creating workbook
SET PROPERTY OF excel 'SheetsInNewWorkbook' = 1.
CALL METHOD OF workbook 'ADD'.
CALL METHOD OF excel 'WORKSHEETS' = sheet.
CALL METHOD OF sheet 'ADD'.
FREE OBJECT sheet.
CALL METHOD OF excel 'WORKSHEETS' = sheet
EXPORTING
#1 = 1.
SET PROPERTY OF sheet 'NAME' = 'Company Codes'.
CALL METHOD OF sheet 'ACTIVATE'.
DATA: col TYPE i VALUE 1,
row TYPE i VALUE 2,
col1 TYPE i VALUE 2,
col_real TYPE i VALUE 1.
index = row_max * ( row - 2 ) + 1.
CALL METHOD OF sheet 'Cells' = cells
EXPORTING
#1 = index.
SET PROPERTY OF cells 'Value' = 'thsi is some larger amount of data blahhhh'.
CALL METHOD OF excel 'Rows' = h_rows
EXPORTING
#1 = '1:1'.
SET PROPERTY OF h_rows 'WrapText' = 1.
DO 5 TIMES.
index = row_max * ( row - 1 ) + col.
CALL METHOD OF sheet 'Cells' = cells
EXPORTING
#1 = index.
* SET PROPERTY OF cells 'Value' = '=TRIM("1234 2")'.
SET PROPERTY OF cells 'Value' = 'thsi is some large data'.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Align' = 'Center'.
GET PROPERTY OF h_cell 'Interior' = h_int.
* SET PROPERTY OF h_int 'ColorIndex' = col_real .
GET PROPERTY OF h_cell 'Font' = h_f.
* SET PROPERTY OF h_f 'ColorIndex' = 1.
get property of h_cell 'Borders' = h_borderstop.
set property of h_borderstop 'LineStyle' = 1.
set property of h_borderstop 'Weight' = 2.
SET PROPERTY OF h_f 'Bold' = 1. "bold
SET PROPERTY OF h_cell 'HorizontalAlignment' = 2. "left align
SET PROPERTY OF h_cell 'Orientation' = 45. "angled
col = col + 1.
col_real = col_real + 1.
IF col = 16.
col = 1.
row = row + 1.
ENDIF.
col1 = col_real + 1.
ENDDO.
index = row_max * ( 10 - 1 ) + 1.
CALL METHOD OF sheet 'Cells' = cells
EXPORTING
#1 = index.
SET PROPERTY OF cells 'Value' = '123'.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = 10
#2 = 1.
GET PROPERTY OF h_cell 'Interior' = h_int.
SET PROPERTY OF h_int 'ColorIndex' = 4 .
*range
CALL METHOD OF excel 'Range' = h_range
EXPORTING
#1 = 'A10'
#2 = 'K10'.
CALL METHOD OF h_range 'Merge' = h_merge .
* width or autofit
CALL METHOD OF excel 'Columns' = h_columns
EXPORTING
#1 = 'A:E'.
*SET PROPERTY OF h_columns 'ColumnWidth' = 17.
GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
set property of h_entirecol 'Autofit' = 1.
* hyperlink
** simple method
*get property of sheet 'Hyperlinks' = h_hyperlink.
*call method of h_hyperlink 'Add' = h_addhyper
* exporting
* #1 = h_range
* #3 = '#Sheet1!A1'.
index = row_max * ( 12 ) + 1.
CALL METHOD OF sheet 'Cells' = cells
EXPORTING
#1 = index.
SET PROPERTY OF cells 'Value' = 'test data'.
GET PROPERTY OF sheet 'Hyperlinks' = h_hyperlink.
CALL METHOD OF h_hyperlink 'Add' = h_addhyper
EXPORTING
#1 = cells
#3 = '#Sheet1!A1'.
* borders
CALL METHOD OF excel 'Range' = h_range2
EXPORTING
#1 = 'A5'
#2 = 'L28'.
GET PROPERTY OF h_range2 'Select' = h_select2.
*CALL METHOD OF h_hyperlink 'Add' = h_addhyper
* EXPORTING
* #1 = h_range2
* #3 = '#Sheet1!A1'.
GET PROPERTY OF h_select2 'Interior' = h_int2.
SET PROPERTY OF h_int2 'ColorIndex' = 6 .
get property of h_range2 'Borders' = h_borderstop.
set property of h_borderstop 'LineStyle' = 1.
set property of h_borderstop 'Weight' = 2.
* freeze panes
CALL METHOD OF excel 'Rows' = h_rows
EXPORTING
#1 = '3:3'.
GET PROPERTY OF h_rows 'Select' = h_select.
GET PROPERTY OF excel 'ActiveWindow' = h_actwindow.
SET PROPERTY OF h_actwindow 'FreezePanes' = 1. -
Guys,
I am working on OLE excel to download data from SAP.I have few basic questions for OLE excel
1. I want to merge Cells in EXCEL , how can i do it?
2. I want to make alignment right in some Cell,how can i do it?
3. I have been reading post in SDN for OLE ,so in that one i notice different numbers for colors like
SET PROPERTY OF O_INTERIOR 'Color' = '10092543'.
.how can i know the code for color. as well as for alignment of text in cell .
SET PROPERTY OF O_CELL 'HorizontalAlignment' = -4108 .
..so from where do you know -4180 is for center alignment
4. How can i know different methods and properties of excel cell as well as workbook.
I know these are lot of questions,but basic ones i guess.If someone can give me guidance that would be helpful and points will be given.Suppose EXCEL is your EXCEL.APPLICATION handler
All H_ objects are of TYPE OLE2_OBJECT type
1. for merging
data:
H_RANGE TYPE OLE2_OBJECT,
H_MERGE TYPE OLE2_OBJECT.
CALL METHOD OF EXCEL 'Range' = H_RANGE
EXPORTING
#1 = 'A10'
#2 = 'K10'.
CALL METHOD OF H_RANGE 'Merge' = H_MERGE .
2. for aligning, row and col are of type i.. referring to the cell you wish to change
1 = default
2 = left
3 = center
4 = right
5 = justify
CALL METHOD OF EXCEL 'Cells' = H_CELL
EXPORTING
#1 = ROW
#2 = COL.
SET PROPERTY OF h_cell 'HorizontalAlignment' = 3.
3. For color coding see this program
*& Report ZKRIS_OLE3_PALETTE
*& Displays the full OLE color range in excel
REPORT ZKRIS_OLE3_PALETTE.
TYPE-POOLS ole2 .
DATA: count TYPE i,
count_real TYPE i,
application TYPE ole2_object,
workbook TYPE ole2_object,
excel TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object.
CONSTANTS: row_max TYPE i VALUE 256.
DATA index TYPE i.
DATA:
h_cell TYPE ole2_object, " cell
h_f TYPE ole2_object, " font
h_int TYPE ole2_object,
h_width TYPE ole2_object,
h_columns TYPE ole2_object,
h_rows TYPE ole2_object,
h_font TYPE ole2_object,
h_entirecol TYPE ole2_object.
DATA: h_range TYPE ole2_object.
DATA: h_merge TYPE ole2_object.
CREATE OBJECT excel 'EXCEL.APPLICATION'.
IF sy-subrc NE 0.
WRITE: / 'No EXCEL creation possible'.
STOP.
ENDIF.
SET PROPERTY OF excel 'DisplayAlerts' = 0.
CALL METHOD OF excel 'WORKBOOKS' = workbook .
SET PROPERTY OF excel 'VISIBLE' = 1.
* creating workbook
SET PROPERTY OF excel 'SheetsInNewWorkbook' = 1.
CALL METHOD OF workbook 'ADD'.
CALL METHOD OF excel 'WORKSHEETS' = sheet
EXPORTING
#1 = 1.
SET PROPERTY OF sheet 'NAME' = 'Color Palette'.
CALL METHOD OF sheet 'ACTIVATE'.
DATA: col TYPE i VALUE 1,
row TYPE i VALUE 2,
col1 TYPE i VALUE 2,
col_real TYPE i VALUE 1.
row = 1.
col = 3.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'No.'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Background'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'.
CALL METHOD OF excel 'Rows' = h_rows
EXPORTING
#1 = '2:2'.
SET PROPERTY OF h_rows 'WrapText' = 1.
col = 9.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'No.'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Background'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
SET PROPERTY OF h_cell 'Bold' = 1.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'.
CALL METHOD OF excel 'Rows' = h_rows
EXPORTING
#1 = '1:1'.
SET PROPERTY OF h_rows 'WrapText' = 1.
GET PROPERTY OF h_rows 'Font' = h_font.
SET PROPERTY OF h_font 'Bold' = 1.
count = 1.
count_real = count.
row = 2.
col = 3.
DO 56 TIMES.
PERFORM write_num_and_color.
ENDDO.
* autofit
CALL METHOD OF excel 'Columns' = h_columns
EXPORTING
#1 = 'C:L'.
GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
SET PROPERTY OF h_entirecol 'Autofit' = 1.
* write palette on lhs
*range
CALL METHOD OF excel 'Range' = h_range
EXPORTING
#1 = 'A2'
#2 = 'A20'.
CALL METHOD OF h_range 'Merge' = h_merge .
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = 2
#2 = 1.
SET PROPERTY OF h_cell 'Value' = 'Palette'.
SET PROPERTY OF h_cell 'Orientation' = 90. "angled.
SET PROPERTY OF h_cell 'HorizontalAlignment' = 3. "center align
GET PROPERTY OF h_cell 'Font' = h_f.
SET PROPERTY OF h_f 'Bold' = 1. "bold
SET PROPERTY OF h_f 'Name' = 'Comic Sans MS'.
SET PROPERTY OF h_f 'Size' = '14'.
SET PROPERTY OF h_cell 'VerticalAlignment' = 2. "center align
* autofit
CALL METHOD OF excel 'Columns' = h_columns
EXPORTING
#1 = 'A:A'.
GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
SET PROPERTY OF h_columns 'ColumnWidth' = 4.
*& Form write_num_and_color
* text
FORM write_num_and_color.
index = row_max * ( row - 1 ) + col.
CALL METHOD OF sheet 'Cells' = cells
EXPORTING
#1 = index.
SET PROPERTY OF cells 'Value' = count_real.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
GET PROPERTY OF h_cell 'Interior' = h_int.
SET PROPERTY OF h_int 'ColorIndex' = count_real.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
GET PROPERTY OF h_cell 'Font' = h_f.
SET PROPERTY OF h_f 'ColorIndex' = count_real.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
GET PROPERTY OF h_cell 'Interior' = h_int.
SET PROPERTY OF h_int 'ColorIndex' = 1.
SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
GET PROPERTY OF h_cell 'Font' = h_f.
SET PROPERTY OF h_f 'ColorIndex' = count_real.
row = row + 1.
col = col - 3.
count = count + 1.
IF count = 29.
count = 1.
row = 2.
col = col + 6.
ENDIF.
count_real = count_real + 1.
ENDFORM. "write_num_and_color
4. To know the different OLE properties, you need to examine the macros in excel and then use a bit of trial and error at first -
The program used to create this object is acrobat. that program is either not installed or its nor responding.
to edit this object, install Acrobat or ensure that any dialog boxes in Acrobat are closed.
I have just installed acrobat Pro XI . when inserting an existing adove file as an object this happens. any ideas?OLE Embedded Objects seem to have problems with PDF files. I am not sure if it's OLE or if it's the OLE server (Acrobat/Reader) installed on the machine in this case. Does this file work on another machine with Acrobat/Reader installed.
-
Unable to click on excel object within a word 2010 document
Whenever a user tries to click an Excel Object within a Word 2010 document, the error "Microsoft Word can't start the application required to open this object. An error occured and this feature is no longer functioning properly. Would you
like to repair this feature now?". Clicking YES runs a repair on Office 2010, which does not resolve the issue. Clicking No gets you the following prompt: "The program used to create this object is Excel. That program is either not installed on your
computer or it is not responding. To edit this object, install Excel or ensure that any dialog boxes in Excel are closed."
Operating System: Windows 7, Office Version: 2010
I've tried the following to resolve the issue, without success:
Running the Office Repair as suggested in the prompt
There are no open dialog boxes in Excel
There are no COM add-ins or Excel add-ins active in Excel
Starting Word in Safe Mode (clicking CTRL on open) does not resolve the issue.
"Ignore other applications that use Dynamic Data Exchange (DDE)" is unchecked in Excel.
I am able to edit this document with no problem on a machine running Windows 7 with Office 2007 or even office 2013.Hi,
Do you see this problem if you start Windows in Safe Mode? You might want to have a try and verify result, some outside application may be preventing the OLE server/client connection.
Have you ever checked your anti virus? Try to disable it and check again.
Please make sure to install any updates to your system or Office products. It's important to make it up to date.
Try to go to your task manager to kill any excel process and then try again.
I have seen a case that user finally fixed this with a clean uninstallation and reinstallation, if issue presists with all above steps, you might want to do a completely reinstallation and then try again.
Thanks, -
How to add OLE wordpad objects to a crystal report through VB program
Can we programmatically add OLE wordpad objects to a crystal report XI r 2. through VB.NET or VB6?
And is there a way of treating a database binary/blob field as an ole object in CR?Hi Mohan,
Try it in the Designer first. If it works in the designer then it will work in our SDK's but you'll have to use RAS. So when you post your question to the .NET Development - Crystal Reports Forum be sure to specify what version you are using and anything else as far as versions go.
It may be easier to simply link the OLE Object in the designer, check the help file out on how to.
Thank you
Don -
Error in using ABAP OLE wrong cell value
Dear All..
I'm facing a problem while using ABAP OLE..
the problem is the ABAP OLE writes the wrong value in Excel file
the value is 121.000 but it written in Excel file : 121
the weird thing is .. other value of 9.000.000 written correctly in Excel File .. and also lots of other values..
i've trace the value until it goes to the method of :
CALL METHOD OF h_excel 'Cells' = h_zl
EXPORTING
#1 = i_row
#2 = i_col.
SET PROPERTY OF h_zl 'Value' = i_value.
GET PROPERTY OF h_zl 'Font' = h_f.
IF i_bold = 'X'.
SET PROPERTY OF h_f 'Bold' = 1.
ENDIF.
and the values of variable i_value is still correct which is : 121.000 but after writing in excel it becomes 121
i believe it will become faulty at the specific amount with format of XXX.000 because if I changed the value to 121.001 it displays correctly in Excel file..
i_value is a pass value from variable ld_val with data type of is --> ld_val(20) type n.
is this are originally bugs from the OLE ? how to solved it ?
please advice ..yes it is clear, but how excel manage the passed data is unclear.
However, to solve you can try this:
DATA : ld_val(20).
WRITE value1 TO ld_val CURRENCY CURR.
REPLACE ALL OCCURRENCES OF '.' IN ld_val WITH space.
CALL METHOD OF h_excel 'Cells' = h_zl
EXPORTING
#1 = i_row
#2 = i_col.
SET PROPERTY OF h_zl 'Value' = ld_val.
GET PROPERTY OF h_zl 'Font' = h_f.
IF i_bold = 'X'.
SET PROPERTY OF h_f 'Bold' = 1.
ENDIF.
Regards,
Angelo.
Maybe you are looking for
-
How do I cancel a download so it won't start again, when I am in itunes it starts automatically to download Modern Combat 4, I don't want it, don't know how it got started?
-
How can I get reminders in chronological order?
Is there a way to get reminders to appear in chronological order?
-
Bridge CC 64bit is not working
I have Bridge CC 64 bit installed and it suddenly stopped working. I have windows 7 and I can see information in the windows event log that the application is crashed. I have tried to run it using "run as administrator" but no hope. does anyone have
-
10GB of used space that I have no idea what it is!
ipod Summary says Audio 7.32GB Other 10.88GB Free 370MB But I have NO podcasts, Contacts or even Windows files stored on my ipod! it is purely music. Not even ANY videos. How do I get to a list of what's on there? How do I then get rid of it!?! How d
-
PC won't boot with CDRom Drives hooked up after iTunes install
Hello All, After installing iTunes (initial, first time install on this machine) the computer would not fully boot. It would get to the Windows starting screen and the indicator bar would reach about 2/3 of the way complete and sit there. I tried reb