Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

One perform with different internal table structure to 1 function module

HI all,

I am downloading an internal table in to excel using function EXCEL_OLE_STANDARD_DAT'”

Here’s 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

Tags:
replied

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?

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question