04-21-2006 9:44 PM
HI all,
I am downloading an internal table in to excel using function EXCEL_OLE_STANDARD_DAT'
Heres my code ..
PERFORM sub_excel_download2..
form sub_excel_download2
FM ::: call function 'MS_EXCEL_OLE_STANDARD_DAT'
exporting
file_name = 'C:\TEMP\file'
CREATE_PIVOT = 0
DATA_SHEET_NAME = ' '
PIVOT_SHEET_NAME = ' '
PASSWORD = ' '
PASSWORD_OPTION = 0
tables
PIVOT_FIELD_TAB =
data_tab = it_excel_tab2
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
others = 9.
if sy-subrc <> 0.
write: / 'Error downloading to Excel'.
endif.
endform.
I have 3 internal tables which I want to download , but user has to select check box on selection screen . Remember my internal tables structures are different .
Q: Is there any way I can <b>pass internal table dynamically to my perform as well as to call function 'MS_EXCEL_OLE_STANDARD_DAT' on the basis of user selection, using one perform ?</b>
I want something like
Perform excel_download using dynamic table . ( <b>where my excel table structures are different</b> )
Form excel_download using <b>dynamic table</b> .
call function 'MS_EXCEL_OLE_STANDARD_DAT'
exporting
file_name = 'C:\TEMP\file'
CREATE_PIVOT = 0
DATA_SHEET_NAME = ' '
PIVOT_SHEET_NAME = ' '
PASSWORD = ' '
PASSWORD_OPTION = 0
tables
PIVOT_FIELD_TAB =
data_tab = <b>dynamic_table</b>
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
others = 9.
if sy-subrc <> 0.
write: / 'Error downloading to Excel'.
endif.
Endform
Waiting for your input/suggestion.
Thanks
Saquib khan
04-21-2006 9:53 PM
You can do this by using Field symbols.
Define
field-symbols <FS> type any table.
and assign you structure to <FS> and pass <FS> to the FM.
04-21-2006 9:52 PM
May be I am missing something but did you try
"Form excel_download <u>tables</u> dynamic_table"?
04-21-2006 9:53 PM
You can do this by using Field symbols.
Define
field-symbols <FS> type any table.
and assign you structure to <FS> and pass <FS> to the FM.
04-21-2006 9:56 PM
Sri,
I want a Dynamic internal table in Perform .
Perform excel_download using <b><dynamic table:Structure like my 3 tables which change on the basis of user selection ></b>
Thanks Amandeep for your valuable inputs .Can you please post some example of code. So I can give it a shot.
Thanks Once again!!
Message was edited by: Saquib Khan
04-21-2006 10:02 PM
True, you have your dynamic internal table defined, filled and then this form is called. So I see it like this.
fill itab1.
perform download_table_to_excel tables itab1.
fill itab2.
perform download_table_to_excel tables itab2.
fill itab3.
perform download_table_to_excel tables itab3.
form download_table_to_excel tables itab.
call function ....
endform.
Isn't this your flow?
Srinivas
04-21-2006 10:07 PM
Do you mean that the name of the table should be dynamically determined or that the structure of the table itself is dynamic (or both)?
Rob
04-21-2006 10:08 PM
NO Sri, I have already 3 internal tables Itab1, itab2, itab3 .. which has different structures OK ..
Now I dont want to write perform 3 times as well as I dont want to call FM 3 times .
I am looking for that I write perform in which I pass internal table ( Itab1,itab2,itab3 ) dynamically as well as pass the IT structure to FM dynamically .
In this way my One perform can out put Itab,itab2 and itab3 when user select the different check box.
I hope I make my self clear .
Thanks
Message was edited by: Saquib Khan
04-21-2006 10:09 PM
You don't have to specify the type of the tables parameter in your FORM definition.
04-21-2006 10:16 PM
Ok I think I understand it now. So you have one perform within which you want to dynamically download different itabs based on the checkboxes user selected.
FORM download_itabs_to_excel.
FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE.
IF p_chkbx1 = 'X'.
ASSIGN itab1[] TO <itab>.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = p_file
* CREATE_PIVOT = 0
* DATA_SHEET_NAME = ' '
* PIVOT_SHEET_NAME = ' '
* PASSWORD = ' '
* PASSWORD_OPTION = 0
TABLES
* PIVOT_FIELD_TAB =
data_tab = <itab>
* FIELDNAMES =
* EXCEPTIONS
* FILE_NOT_EXIST = 1
* FILENAME_EXPECTED = 2
* COMMUNICATION_ERROR = 3
* OLE_OBJECT_METHOD_ERROR = 4
* OLE_OBJECT_PROPERTY_ERROR = 5
* INVALID_PIVOT_FIELDS = 6
* DOWNLOAD_PROBLEM = 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.
ENDFORM. "download_to_excel
You have to repeat the IF P_CHKBX1 = 'X' for each of the checkboxes selected.
Hope I got it correct this time.
Srinivas
04-21-2006 10:24 PM
Yes you understand the one part of story. Now like you are passing internal table to FM in the above code.
Can I also pass internal table to
PERFORM download_itabs_to_excel using <b><dynamic table >?</b>.
FORM download_itabs_to_excel using <b><dynamic_table>?</b>.
Thanks a lot for your input and time ..
Saquib
04-21-2006 10:33 PM
Let us say we can do this, what do you want to do with the <dynamic_table> inside the form? Just pass it to the function call? In that case you can put the function call in a form and don't use any parameters. Just make the previous field-symbol definition global. So now the flow more or less will be
form download_based_on_user_choice.
if p_chkbx1 = 'X'.
assign itab1[] to <itab>.
perform download_itab_to_excel.
endif.
if p_chkbx2 = 'X'.
assign itab2[] to <itab>.
perform download_itab_to_excel.
endif.
if p_chkbx3 = 'X'.
assign itab3[] to <itab>.
perform download_itab_to_excel.
endif.
endform.
form download_itab_to_excel.
call function .... table ... = <itab> ...
endform.
If this what you want?
04-21-2006 10:47 PM
No:( . never mind !!!!
Let say
itab1 "Filled with data for excel
itab2 :filld with data for excel
itab3 : filled with data for excel .
I only want <u><i><b>only one perform</b></i></u>
<u><i>I do this ... and Its working :)</i></u>
if p_chkbx1 = 'X'.
assign itab1[] to <itab>.
elseif p_chkbx2 = 'X'.
assign itab2[] to <itab>.
elseif p_chkbx3 = 'X'.
assign itab3[] to <itab>.
endif.
<b>*"Where out tab could be 1,2, or 3 on user slection</b>
<b>perform download_excel using <Itab>.</b>
form download_excel using Itab
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = p_file
CREATE_PIVOT = 0
DATA_SHEET_NAME = ' '
PIVOT_SHEET_NAME = ' '
PASSWORD = ' '
PASSWORD_OPTION = 0
TABLES
PIVOT_FIELD_TAB =
data_tab = <itab> "<b>Could be 1,2, or 3</b>
FIELDNAMES =
EXCEPTIONS
FILE_NOT_EXIST = 1
FILENAME_EXPECTED = 2
COMMUNICATION_ERROR = 3
OLE_OBJECT_METHOD_ERROR = 4
OLE_OBJECT_PROPERTY_ERROR = 5
INVALID_PIVOT_FIELDS = 6
DOWNLOAD_PROBLEM = 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.
endform
Thanks a lot !!!!
Message was edited by: Saquib Khan
04-22-2006 8:15 PM
You didn't mention that they are radiobuttons. I thought they are real checkboxes where the user can choose all or some or none of the options. Yes if they are just radiobuttons, then you can do the way you explained. I see that you figured it out already.
Regards,
Srinivas