Skip to Content
0

How to change tab name of attached excel file in abap

Apr 25, 2017 at 10:17 AM

109

avatar image

Hello Experts,

I have a requirement to send a mail with attached excel file ,for this i have used cL_bcs class. Here we can send the attached file name from the input screen.

Now here one issue is the tab name of the attached excel file is taking the name of the file. Which i dont want. I want the tab name should be 'Sheet1'.

I have attached screenshot for this. (file name and Tab name are same)

Can you please help me on this? how i should change the tab name of excel file. I have used CL_DOCUMENT_BCS class for create document.

file-name.jpg (8.2 kB)
tab-name.jpg (110.8 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Sandra Rossi Apr 25, 2017 at 06:50 PM
1

BCS classes are for building (body, attachments, receivers) and sending emails, not for creating the attached files!

What you did is probably the attachment of a text .CSV file. You can only get very simple behavior with that.

If you really want to change the tab name, you'll to rewrite your program: the easiest way is to download the abap2xlsx tool (contains API classes) to build an .XLSX file. You'll have to search the forum for any question and to reuse the examples provided in the download. You could also use OLE (or even the DOI wrapper) but it works only in dialog mode and is slower.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Apr 25, 2017 at 12:06 PM
-1

hii sarkar,

here is sample code which i had done.

DATA:gv_stras TYPE string,gv_stras1 TYPE string,gv_stras2 TYPE string,gv_stras3 TYPE string,gv_stras4 TYPE string,gv_stras5 TYPE string,gv_stras6 TYPE string. DATA:gv_locat TYPE string,gv_locat1 TYPE string,gv_locat2 TYPE string,gv_locat3 TYPE string,gv_locat4 TYPE string . DATA : value(13) TYPE c, net(13) TYPE c, htab(1) TYPE c, lv_fname TYPE string, lv_pernr TYPE pa0001-pernr.

lv_pernr = pa0001-pernr.

FIELD-SYMBOLS : <ks> TYPE any.

this is 1 box heading

gt_down-persg = 'STATUS'.

gt_down-lv_pernr = 'USERID'.

gt_down-pernr1 = 'USERNAME'.

gt_down-vorna = 'FIRSTNAME'.

gt_down-nachn2 = 'LASTNAME'.

gt_down-midnm = 'MI'.

P'. gt_down-land1 = 'COUNTRY'.

gt_down-mmanager = 'MATRIX MANAGER'.

APPEND gt_down.

this is which u have show that box :::::::

2.this is 2 output fields

gt_down-persg = 'STATUS'.

gt_down-lv_pernr = 'USERID'.

gt_down-pernr1 = 'User Name'.

gt_down-vorna = 'First Name'.

gt_down-nachn2 = 'Last Name'.

gt_down-midnm = 'Middle Name'.

gt_down-land1 = 'Country'.

gt_down-mmanager = 'Matrix Manager'.

LOOP AT gt_final INTO gs_final. MOVE gs_final-persg TO gt_down-persg . MOVE gs_final-pernr TO gt_down-lv_pernr . MOVE gs_final-pernr1 TO gt_down-pernr1 . MOVE gs_final-vorna TO gt_down-vorna . MOVE gs_final-nachn2 TO gt_down-nachn2 .

CLASS cl_abap_char_utilities DEFINITION LOAD. htab = cl_abap_char_utilities=>horizontal_tab. OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. LOOP AT gt_down. TRANSFER gt_down TO file. ENDLOOP.

this is sample code for reference take INTERNAL TABLE I DATA DECLARATION SEPERATLY AND APPEND ALL THE OUTPUT TAB TO NEW INTENAL TABLE.

IT WORKS!!!!!

ALL THE BEST

Share
10 |10000 characters needed characters left characters exceeded