Skip to Content

Export xlsx from Alv Report

Hi guys, i have little problem from my report. I want to export to excel from alv report, the header have be export, but the conatin is no like this

from alv report this

And why always there is a checkbox? even though i didnot make the checkbox.

this my code

*Declare for ALV

type-pools : slis.

*declare for internal table type

types: begin of t_gb,

sel,

no(3) type i,

matnr type afpo-matnr,

aufnr type afpo-aufnr,

maktx type makt-maktx,

erfmg type resb-erfmg,

erfme type resb-erfme,

mtart type mara-mtart,

lgort type resb-lgort,

end of t_gb.

*Work area ALV

data: wa_tgb type t_gb,

i_wa_tgb type standard table of t_gb.

*ALV report

data: tgb_f type slis_fieldcat_alv,

wa_tgb_f type slis_t_fieldcat_alv,

wa_gb_layout type slis_layout_alv,

r_ucomm type sy-ucomm,

rs_selfield type slis_selfield,

f_selfield type slis_selfield-value,

f_program type sy-repid.

*decare list dropdown

DATA :

name type vrm_id,

list type vrm_values,

value type vrm_value,

xlow_aufnr TYPE afko-aufnr,

xhigh_aufnr TYPE afko-aufnr,

qtyerfmg TYPE resb-erfmg,

no(3) type i.

*initialixation

initialization.

f_program = sy-repid.


clear:tgb_f, wa_tgb_f.

data lv_col type i value 0.


lv_col = 1 + lv_col.

tgb_f-col_pos = lv_col.

tgb_f-fieldname = 'no'.

tgb_f-tabname = 'i_wa_tgb'.

tgb_f-seltext_l = 'No'.

append tgb_f to wa_tgb_f.

clear tgb_f.

lv_col = 1 + lv_col.

tgb_f-col_pos = lv_col.

tgb_f-fieldname = 'matnr'.

tgb_f-tabname = 'i_wa_tgb'.

tgb_f-seltext_l = 'Component'.

append tgb_f to wa_tgb_f.

clear tgb_f.

lv_col = 1 + lv_col.

tgb_f-col_pos = lv_col.

tgb_f-fieldname = 'maktx'.

tgb_f-tabname = 'i_wa_tgb'.

tgb_f-seltext_l = 'Description'.

append tgb_f to wa_tgb_f.

clear tgb_f.

lv_col = 1 + lv_col.

tgb_f-col_pos = lv_col.

tgb_f-fieldname = 'erfmg'.

tgb_f-tabname = 'i_wa_tgb'.

tgb_f-seltext_l = 'Qty'.

append tgb_f to wa_tgb_f.

clear tgb_f.

lv_col = 1 + lv_col.

tgb_f-col_pos = lv_col.

tgb_f-fieldname = 'erfme'.

tgb_f-tabname = 'i_wa_tgb'.

tgb_f-seltext_l = 'UoM'.

append tgb_f to wa_tgb_f.

clear tgb_f.

lv_col = 1 + lv_col.

tgb_f-col_pos = lv_col.

tgb_f-fieldname = 'lgort'.

tgb_f-tabname = 'i_wa_tgb'.

tgb_f-seltext_l = 'Sloc'.

append tgb_f to wa_tgb_f.

clear tgb_f.

lv_col = 1 + lv_col.

tgb_f-col_pos = lv_col.

tgb_f-fieldname = 'mtart'.

tgb_f-tabname = 'i_wa_tgb'.

tgb_f-seltext_l = 'Mat Type'.

append tgb_f to wa_tgb_f.

clear tgb_f.

wa_gb_layout-zebra = 'X'.

wa_gb_layout-colwidth_optimize = 'X'.

wa_gb_layout-box_fieldname = 'SEL'.

if i_wa_tgb is not initial and wa_tgb_f is not initial.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

* I_INTERFACE_CHECK = ' '

* I_BYPASSING_BUFFER =

* I_BUFFER_ACTIVE = ' '

i_callback_program = f_program

* i_callback_pf_status_set = ' '

* i_callback_user_command = 'UCOMM_EKKO'

* I_STRUCTURE_NAME =

is_layout = wa_gb_layout

it_fieldcat = wa_tgb_f

* IT_EXCLUDING =

* IT_SPECIAL_GROUPS =

* IT_SORT =

* IT_FILTER =

* IS_SEL_HIDE =

* I_DEFAULT = 'X'

* I_SAVE = ' '

* IS_VARIANT =

* it_events = it_event_ekko

* IT_EVENT_EXIT =

* IS_PRINT =

* IS_REPREP_ID =

* I_SCREEN_START_COLUMN = 0

* I_SCREEN_START_LINE = 0

* I_SCREEN_END_COLUMN = 0

* I_SCREEN_END_LINE = 0

* IR_SALV_LIST_ADAPTER =

* IT_EXCEPT_QINFO =

* I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

* IMPORTING

* E_EXIT_CAUSED_BY_CALLER =

* ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = i_wa_tgb

exceptions

program_error = 1

others = 2.

endif.

thank you guys

ab.jpg (27.5 kB)
aa.jpg (35.6 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Dec 03, 2015 at 04:58 AM

    Hi Afif,

    Which icon you use for excel download ?


    aa.jpg (35.5 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 03, 2015 at 06:23 AM

    You wrote

    And why always there is a checkbox? even though i didnot make the checkbox.

    But also

    wa_gb_layout-box_fieldname = 'SEL'.

    Else did you try the multiple option for Excel export/inplace, read 358644 - ALV Export Excel: Recommendations and known errors. Which format did you select at popup (I prefer MHTML)

    Regards,

    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 11, 2015 at 08:14 AM

    Hei guys how can i fix it? Can any one help me to solve this?

    Cause this important in my jobdesk

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.