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

auto save of excel file

former_member196601
Active Participant
0 Kudos

Hi Gurus,

My requirement is to save a time sheet in Excel file using ABAP reports,

I need to keep updating every day.

When i try to implement I am getting an excel pop up asking me whether i have to save changes. I don't want to display this pop up, i need to save the file with out this pop up..

Can it be done using ABAP Objects??

Can anyone help me how to sort out the prob???

Please help me....

Regards

Naveen

1 ACCEPTED SOLUTION

Former Member
0 Kudos

The easy way is as follows.

1) create ALV editable grid and enter your data.

2) add a Download to EXCEL on the ON TOOLBAR event

3) execute the following method

method DOWNLOAD_TO_EXCEL.

FIELD-SYMBOLS:

<fs0> TYPE STANDARD TABLE,

<fs1> TYPE STANDARD TABLE.

ASSIGN g_outtab1->* TO <fs0>.

ASSIGN g_fldcat1->* TO <fs1>.

CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'

EXPORTING

it_fieldcat_lvc = <fs1>

  • is_layout_lvc = m_cl_variant->ms_layout

is_tech_complete = ' '

IMPORTING

es_layout_kkblo = ls_layout

et_fieldcat_kkblo = lt_fieldcat.

LOOP AT lt_fieldcat INTO lt_fieldcat_wa.

CLEAR lt_fieldcat_wa-tech_complete.

IF lt_fieldcat_wa-tabname IS INITIAL.

lt_fieldcat_wa-tabname = '1'.

MODIFY lt_fieldcat FROM lt_fieldcat_wa.

ENDIF.

l_tabname = lt_fieldcat_wa-tabname.

ENDLOOP.

CALL FUNCTION 'ALV_XXL_CALL'

EXPORTING

i_tabname = l_tabname

is_layout = ls_layout

it_fieldcat = lt_fieldcat

i_title = sy-title

TABLES

it_outtab = <fs0>

EXCEPTIONS

fatal_error = 1

no_display_possible = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • ...

endmethod.

the toolbar

method ON_TOOLBAR.

type-pools icon.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'EXIT' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_system_end TO ls_toolbar-icon.

MOVE 'Click2Exit' TO ls_toolbar-quickinfo.

APPEND ls_toolbar TO e_object->mt_toolbar.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'SAVE' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_system_save TO ls_toolbar-icon.

MOVE 'Save data' TO ls_toolbar-quickinfo.

APPEND ls_toolbar TO e_object->mt_toolbar.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'EDIT' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_toggle_display_change TO ls_toolbar-icon.

MOVE 'Edit data' TO ls_toolbar-quickinfo.

MOVE 'EDIT' TO ls_toolbar-text.

APPEND ls_toolbar TO e_object->mt_toolbar.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'PROC' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_businav_process TO ls_toolbar-icon.

MOVE 'Process.' TO ls_toolbar-quickinfo.

MOVE 'PROC' TO ls_toolbar-text.

APPEND ls_toolbar TO e_object->mt_toolbar.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'EXCEL' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_xxl TO ls_toolbar-icon. <=====

MOVE 'Excel' TO ls_toolbar-quickinfo. <=====

MOVE 'EXCEL' TO ls_toolbar-text. <=====

APPEND ls_toolbar TO e_object->mt_toolbar. <====

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'REFR' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_refresh TO ls_toolbar-icon.

MOVE 'Refresh' TO ls_toolbar-quickinfo.

MOVE 'REFR' TO ls_toolbar-text.

APPEND ls_toolbar TO e_object->mt_toolbar.

  • ...

endmethod.

Cheers

jimbo

1 REPLY 1

Former Member
0 Kudos

The easy way is as follows.

1) create ALV editable grid and enter your data.

2) add a Download to EXCEL on the ON TOOLBAR event

3) execute the following method

method DOWNLOAD_TO_EXCEL.

FIELD-SYMBOLS:

<fs0> TYPE STANDARD TABLE,

<fs1> TYPE STANDARD TABLE.

ASSIGN g_outtab1->* TO <fs0>.

ASSIGN g_fldcat1->* TO <fs1>.

CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'

EXPORTING

it_fieldcat_lvc = <fs1>

  • is_layout_lvc = m_cl_variant->ms_layout

is_tech_complete = ' '

IMPORTING

es_layout_kkblo = ls_layout

et_fieldcat_kkblo = lt_fieldcat.

LOOP AT lt_fieldcat INTO lt_fieldcat_wa.

CLEAR lt_fieldcat_wa-tech_complete.

IF lt_fieldcat_wa-tabname IS INITIAL.

lt_fieldcat_wa-tabname = '1'.

MODIFY lt_fieldcat FROM lt_fieldcat_wa.

ENDIF.

l_tabname = lt_fieldcat_wa-tabname.

ENDLOOP.

CALL FUNCTION 'ALV_XXL_CALL'

EXPORTING

i_tabname = l_tabname

is_layout = ls_layout

it_fieldcat = lt_fieldcat

i_title = sy-title

TABLES

it_outtab = <fs0>

EXCEPTIONS

fatal_error = 1

no_display_possible = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • ...

endmethod.

the toolbar

method ON_TOOLBAR.

type-pools icon.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'EXIT' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_system_end TO ls_toolbar-icon.

MOVE 'Click2Exit' TO ls_toolbar-quickinfo.

APPEND ls_toolbar TO e_object->mt_toolbar.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'SAVE' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_system_save TO ls_toolbar-icon.

MOVE 'Save data' TO ls_toolbar-quickinfo.

APPEND ls_toolbar TO e_object->mt_toolbar.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'EDIT' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_toggle_display_change TO ls_toolbar-icon.

MOVE 'Edit data' TO ls_toolbar-quickinfo.

MOVE 'EDIT' TO ls_toolbar-text.

APPEND ls_toolbar TO e_object->mt_toolbar.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'PROC' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_businav_process TO ls_toolbar-icon.

MOVE 'Process.' TO ls_toolbar-quickinfo.

MOVE 'PROC' TO ls_toolbar-text.

APPEND ls_toolbar TO e_object->mt_toolbar.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'EXCEL' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_xxl TO ls_toolbar-icon. <=====

MOVE 'Excel' TO ls_toolbar-quickinfo. <=====

MOVE 'EXCEL' TO ls_toolbar-text. <=====

APPEND ls_toolbar TO e_object->mt_toolbar. <====

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'REFR' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_refresh TO ls_toolbar-icon.

MOVE 'Refresh' TO ls_toolbar-quickinfo.

MOVE 'REFR' TO ls_toolbar-text.

APPEND ls_toolbar TO e_object->mt_toolbar.

  • ...

endmethod.

Cheers

jimbo