Declare Array in OLE Excel
Dear all,
How can I declare a variable type Array in Excel Ole ABAP ??
Dim a As Variant
a = Array(11, 12)
How can I declare in ABAP ??
Thank you
Note 633105 - OLE automation: ABAP type for OLE array parameters
Symptom
If the method of an OLE object contains an array parameter, there is no suitable ABAP data type for the parameter.
Reason and Prerequisites
Array is not supported as a data type for OLE parameters in ABAP.
Solution
None
Similar Messages
-
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 -
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 -
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 -
A number in a CHAR in OLE excel
Hi,
I've got a problem with and OLE Excel.
I must pass to the excel file a numeric value written in a char variables (es: '01111') and, in the excel file, it is written like '111111'.
I try to convert it with this:
GET PROPERTY OF g_cell1 'SET_FORMAT' = g_text.
SET PROPERTY OF g_text 'CATEGORY' = 4.
but it doesn't work.
Please, help me.
ThanksHi,
I think the value is passed correctly but this is excel's output format.
When you open the file, right click on cell -> Format Cells -> Custom -> enter 5 zeros '00000' (exact number of places which should be displayed). Now the value will come as '01111'.
Regards
Marcin -
Hi gurus,
I am creating Excel file passing values to different sheets A,B,C from internal table.
But when my program is under execution, if i try open new excel sheet then datas are getting written into new sheet. so the out put of real excel sheet is different from as expected.
Do i have to maintain any property in OLE excel to avoid this situation. because i want to open some other excel file, while my program is executing with OLE excel creation.
Regards
AmbichanINCLUDE ole2incl.
DATA: application TYPE ole2_object,
workbook TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object,
gs_chart TYPE ole2_object.
CONSTANTS: row_max TYPE i VALUE 256.
DATA index TYPE i.
CREATE OBJECT application 'excel.application'.
SET PROPERTY OF application 'visible' = 1.
CALL METHOD OF application 'Workbooks' = workbook.
*CALL METHOD OF workbook 'Add'. "if you want to create a file
CALL METHOD OF workbook 'Open'
EXPORTING
#1 = p_file.
#1 = 'C:\Temp\XXX0099_Support_20XX.xls'. "your excel file
name here
Create second Excel sheet "Timesheets
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING
#1 = 2.
SET PROPERTY OF sheet 'Name' = 'Timesheets'.
CALL METHOD OF sheet 'Activate'.
CLEAR: w_index.
SORT itab BY budat hiden.
LOOP AT itab.
w_index = sy-tabix + w_lin.
CALL METHOD OF application 'Cells' = cells
EXPORTING
#1 = w_index " line
#2 = 1. " column
SET PROPERTY OF cells 'Value' = itab-hiden . "need to be changed
Save excel spreadsheet to particular filename
CALL METHOD OF sheet 'Save' "'Save'
EXPORTING
#1 = p_file
#1 = p_file
#2 = 1."filename
"fileFormat
Closes excel window, data is lost if not saved
SET PROPERTY OF application 'visible' = 0.
reward points if its helpful -
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.
AKI 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 -
How to lookup a value in a 2D array from an Excel file - Dasylab version 12 Pro
Hi, I am new to this forum and am looking for some advice on a worksheet I'm trying to construct. I have an Excel spreadsheet that is basically a 2D array, and I want to use Dasylab v12 Pro to be able to import a value from this array based on user selections from within the Dasylab worksheet.
Column A lists 200+ diesel engine models. I've shown 9 in my Excel attachment...one model per row (shaded in yellow), and each engine model can be run at several speeds (shaded green in columns B thru F). For an engine in a given row, combined with a chosen operating speed gives you a corresponding horsepower (blue shading).
I have this Excel sheet saved somewhere on my C:/ drive, and what I want to do is when the user starts the Dasylab worksheet he will select from a drop drown menu to choose the engine model (ie A, B, C, etc) and another drop down menu to choose the speed (ie 1470, 1760, etc). I know that I can make a drop down menu with a Coded Switch within Dasylab, however it seems only 16 choices can be made from each switch, so for my 200 engine models I will need 13 switches! I know I can assign a text description like "Engine A" to a numerical value within that coded switch. Somehow I need to take those two selections made within the Dasylab experiment, and read this Excel file (ie my database of all of these 200 diesel engine models) as a 2 dimensional array by row and column to spit out the data value (the blue numbers) back into Dasylab.
The goal is to take the engine model, speed, and the horsepower obtained from the array search and write these to an .asc file that I will create a running log of this data. So, after the test page is run 50 times it will have 50 rows of data containing these 3 parameters. There is some other test data taken from my data acquisition that goes along with this, however that's not part of my 2D array predicament.
I'm taking a guess that I need to do something with global strings & variables, and some how import them and export them with an ODBC in/out module. This is something I've just never worked with before so I am a bit lost. Obviously I can just make the user type in the engine model and speed as a startup parameter at the start of the test and save that to a variable or string, but I want to make it idiot proof so that the two selections (ie row and column) can be chosen from a pre-set list and will yield my data value. Everything else related to Dasylab I am pretty proficient with.
Thanks,
Mike
Attachments:
engine 2D array.xlsx 10 KBThis would be the best way.
Also, with version 13 they started using Phyton to create custom modules that can be programmed in DASYLab.
We arte learning this right now and I know that you can use standard message dialogs with that as well.
I would suggest to you to download a demo of V13 and take a look at the Pyton module.
Also, usually DASYLab system intgretors like us, can provide services also on things like this including Excel programming for pre and post analisys
Tom Rizzo
InSyS Corp.
www.insyscorp.com
Your DASYLab integrator -
Dump while executing a OLE Excel download report feature 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=="Check the following example to download in excel
INCLUDE ole2incl.
*& TYPES *
TYPES: BEGIN OF ty_spfli,
kunnr TYPE kna1-kunnr,
land1 TYPE kna1-land1,
NAME1 TYPE KNA1-NAME1,
ORT01 TYPE KNA1-ORT01,
REGIO TYPE KNA1-REGIO,
ADRNR TYPE KNA1-ADRNR,
END OF ty_spfli.
TYPES: BEGIN OF ty_titles,
title(20) TYPE c,
field(20) TYPE c,
END OF ty_titles.
*& INTERNAL TABLES *
DATA: t_spfli TYPE STANDARD TABLE OF ty_spfli,
t_titles TYPE STANDARD TABLE OF ty_titles.
*& FIELD-SYMBOLS *
FIELD-SYMBOLS: <fs_spfli> LIKE LINE OF t_spfli,
<fs_titles> LIKE LINE OF t_titles,
<fs> TYPE ANY.
*& VARIABLES *
DATA: w_tabix TYPE sy-tabix,
w_titles TYPE sy-tabix,
w_line TYPE sy-tabix,
w_field TYPE string,
filename TYPE string,
path TYPE string,
fullpath TYPE string.
DATA: data_titles TYPE REF TO data.
DATA: e_sheet TYPE ole2_object,
e_activesheet TYPE ole2_object,
e_newsheet TYPE ole2_object,
e_appl TYPE ole2_object,
e_work TYPE ole2_object,
e_cell TYPE ole2_object,
e_color TYPE ole2_object,
e_bold TYPE ole2_object.
*& SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS: p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK b1.
*& START-OF-SELECTION *
START-OF-SELECTION.
PERFORM get_titles.
PERFORM get_data.
PERFORM create_excel. -
How to Declare Arrays in bpel and use them as acollection
Hi,
I Am new to Bpel, I had created an empty Bpel Process and configured file adapter to a directory, In my text file i have 3 records with four columns, each column seperated by ',' and each record seperated by "EOL(end of line)", Below is the xsd file generated by the native format xsd builder, taken a recieve activity to recieve the contents of file from file adapter.
So all the data which is in the file will be there in recieve activity.
FileContents
55555,rgfdgsd,gfdgfdg,23
66666,retretret,trtertg,21
77777,rtrttreter,trtter,23
My Question is
I want to compare whether value of C1 = '55555' and if the value is equal to 55555 then that record with c1=55555 has to be inserted into database by using Arrays
How to compare the value of c1 through bpel functions.
with java i have to use the logic similar to this by using Xpath
getElement by tagname(c1);- it will give all the elements with tagname c1, three records are there with tagname c1 (c1=55555,c1=66666,c1=77777), we have to iterate through the elemnts and check whether the value iof c1='55555' and get the whole parent block which contains values of c1,c2,c3,c4 and insert that to database
What variables we have to use to get the Similar logic in bpel
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
targetNamespace="http://TargetNamespace.com/FileAdapter"
xmlns:tns="http://TargetNamespace.com/FileAdapter"
elementFormDefault="qualified"
attributeFormDefault="unqualified" nxsd:encoding="ASCII" nxsd:stream="chars" nxsd:version="NXSD">
<xsd:element name="Associates">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Associate" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C1" type="xsd:double" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C2" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C3" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C4" type="xsd:double" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy=""">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
I want to do it by using Arrays,
Please post the step by step procedure like
How to declare an Array?
How to iterate the results in recieve acticity of file adapter and put them to array?
How to compare the values in array with our desired value?
Please Look into this and suggest me the solution.
RegardsI think it is a good option to use transformations. Do you have any critical reason why you want to do this using array?
Little explanation below for your questions.
As per my understanding from variable is the recieve activity variable and to variable is the Array variable is it right?
Yes. Here I was try to build my array from the different source system data. This will append data to the array variable.
How can we declare an array variable in bpel(to variable) with name as Variable_Array, part as payload and query as ArrayList?
*Any element that can hold another element can be a array.
For example if element A is declared as sequence of element B type, then A acts as a array for B*
Could you please explain this also, what is from variable? and what is to variable?
+<assign name="Assign_XPath_For_Array">+
+<copy><from expression="concat('/ns1:ArrayList/ns2:ArrayElem') "/><to variable="Variable_Xpath"/></copy>+
+</assign>+
what is the type of to variable "Variable_Xpath"(String or int etc)?
This creates a dynamic Xpath and store in some variable here. Here the variable is called Variable_Xpath which is a string
similarly what is the type of to variable?
+<assign name="Assign_Read_Array">+
+<copy>+
+<from expression="bpws:getVariableData('Variable_Array','payload',bpws:getVariableData('Variable_Xpath'))"/>+
+<to variable="Variable_Read_Array_Element" query="/ns1: ABC"/>+
+</copy>+
+</assign>+
To variable type is the variable that I read from the Array.
*For example if A is the array holding B, then the to variable is B and from is doing A[counter]*
Every Little Helps
Kalidass Mookkaiah
http://oraclebpelindepth.blogspot.com/ -
How to export an array to an excel-sheet
Hallo,
does somebody knows how i can write an String[][]-Array in an simple Excel-Table, or knows someone a source where i can find information about the xls-fileformat?POI has, however, a programming interface. Relying on the file format alone, you are reinventing the wheel.
In a production environment I use the comma-separated-value file format to "mock" Excel files and this works.
Good luck anyway! -
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 -
Hi,
i use in abap EXCEL with OLE and visible mode. Every thing works like i want, but
when excel starts, it's allways behind the SAP Window.
Is there any way to start the excel allways in foreground?
Regards, Dieter
Moved to GUI - Forum
Edited by: Dieter Gröhn on Feb 7, 2011 12:58 PMHi,
this has been discussed 1000 times.
OLE is not available in background. Full Stop.
You can create tab-delimited text files that can be opened by excel: No formatting, one unnamed sheet in workbook.
XLSX formatted excel-compatible files with all excel features can be created in background. Check out the XLSX code project her or in google code. It will perfectly do what you want but you have to do some work.
I do not give the link here because if you really want to do you can find it.
Regards,
Clemens
Maybe you are looking for
-
I am about to spend some more money and get a remote for my Vision:M. I am pretty sure this one is compatible with it, but I am not sure as no where does it mention that it is compatible with it. This one! I remember reading that the remote from the
-
ADF Tree row selection and af:commandLink
Hello, I'm quite new to JDeveloper and ADF. I'm using JDev 11.1.1 and get some issues while trying to set up a "qualifications" selection tree. Here is a summary : I'm dealing with "Qualification" objects. A qualification has an id,name and 'selected
-
When I try to oen i-tunes I get tne message "This version of I-tunes has not been correctly localized for this lanauge. Please run the English version . It will not open. One proposed fis was to uninstall it and reinstall it. If I uninstall it and r
-
Supplier Qualification with ERP
Dear experts, I've set up the supplier qualification process. So fas so good. I'm able to accept a supplier in "Supplier Preselection" I want to transfer this supplier to the ECC system next but the transaction to do so is not there. I have assigned
-
F4 help-only posted values-Bex variable input
Hi I have one hierarchy node variable on an infoobject.This infoobject is authorisation-relevent.The infoobjects hierarchy is activated in query designer.We have many hierarchies for this infoobject,one for every year.Recently,we chose new hierarchy