Excel formating from ABAP

Hi,
  I am using SO_DOCUMENT_SEND_API1 function module to send excel attachment in mail. Now i want to add few feature in the excel,
1) When user opens the excel the value in the cell should be displayed as 446000018680308 now it is showing as 4.46E+14
2) Quantity column should have field seperator with comma and decimals.
3)LOGO should appear in the top.
How is it possible to add all these feature.Some sample code will help.
Regards,
Karthik.k

Hi,
You need to use the OLE concept for this one, look at the below sample code, just copy and paste the program, then you will understand it
*& Report ZETA_EXCEL_DOWNLOAD_CLIPBOARD *
report zeta_excel_download_clipboard .
include ole2incl.
data: w_cell1 type ole2_object,
w_cell2 type ole2_object.
*--- Ole data Declarations
data: h_excel type ole2_object, " Excel object
h_mapl type ole2_object, " list of workbooks
h_map type ole2_object, " workbook
h_zl type ole2_object, " cell
h_f type ole2_object, " font
gs_interior type ole2_object, " Pattern
worksheet type ole2_object,
h_cell type ole2_object,
h_cell1 type ole2_object,
range type ole2_object,
h_sheet2 type ole2_object,
h_sheet3 type ole2_object,
gs_font type ole2_object,
flg_stop(1) type c.
Internal table Declaration
data: begin of t_excel occurs 0,
vkorg(20) type c, "Sales Org
vbtyp(20) type c, "Document Category
auart(20) type c, "Document Type
ernam(20) type c, "Created By
vbeln(20) type c, "Document Number
posnr(20) type c, "Item Number
erdat(20) type c, "Created Date
vdatu(20) type c, "Header Requested Delivery Date
reqdat(20) type c, "Request date
condat(20) type c, "Confirm date
lifsk(20) type c, "Header Block
txt30(30) type c, "Order User Status Description
lifsp(20) type c, "Line Block
dispo(20) type c, "MRP Controller
dsnam(20) type c, "MRP Controller Description
vmsta(20) type c, "Material Sales Status
kunnr(20) type c, "Sold To
cname(35) type c, "Sold To Name
regio(20) type c, "State
cufd(10) type c, "CUD
bstnk(20) type c, "PO#
bsark(20) type c, "Ordering Method
matnr(20) type c, "Material
maktx(35) type c, "Material Description
t200(20) type c, "T200
vtext(20) type c, "T200 Description
matkl(20) type c, "Material Group
zzbomind(7) type c, "BOM Indicator
ostat(20) type c, "Order Status
cmgst(20) type c, "CRD
inco1(20) type c, "Incoterms
oqty(20) type c, "Order Quantity
pqty(20) type c, "Open Quantity
unit(20) type c, "UOM
onet(20) type c, "Order Value
pnet(20) type c, "Open Value
curr(20) type c, "Currency key
so_bezei like tvkbt-bezei,"Sales Office
sg_bezei like tvgrt-bezei,"Sales Group
bname(20) type c, "Ordering Party
contact(20) type c, "Contact Name
telf1(20) type c, "Contact telf1
reqqty(20) type c, "Item Request qty
reqval(20) type c, "Item Request value
conqty(20) type c, "Item Confirm qty
conval(20) type c, "Item Confirm value
zzrev(02) type c, "Revenue recognition acceptance
bezei(20) type c, "Revenue recognition text
vgbel(20) type c, "Reference Order for RETURNS
0008text(255) type c, "Internal Order Comment Text
end of t_excel.
data: t_excel_bckord like t_excel occurs 0 with header line,
t_excel_bcklog like t_excel occurs 0 with header line,
t_excel_blkord like t_excel occurs 0 with header line.
types: data1(1500) type c,
ty type table of data1.
data: it type ty with header line,
it_2 type ty with header line,
it_3 type ty with header line,
rec type sy-tfill,
deli(1) type c,
l_amt(18) type c.
data: begin of hex,
tab type x,
end of hex.
field-symbols: <fs> .
constants cns_09(2) type n value 09.
assign deli to <fs> type 'X'.
hex-tab = cns_09.
<fs> = hex-tab.
data gv_sheet_name(20) type c .
M A C R O Declaration
define ole_check_error.
if &1 ne 0.
message e001(zz) with &1.
exit.
endif.
end-of-definition.
t_excel_bckord-vkorg = 'ABC'.
t_excel_bckord-vbtyp = 'DEF'.
t_excel_bckord-auart = 'GHI'.
t_excel_bckord-ernam = 'JKL'.
t_excel_bckord-vbeln = 'MNO'.
t_excel_bckord-0008text = 'XYZ'.
append t_excel_bckord.
t_excel_bckord-vkorg = 'ABC1'.
t_excel_bckord-vbtyp = 'DEF1'.
t_excel_bckord-auart = 'GHI1'.
t_excel_bckord-ernam = 'JKL1'.
t_excel_bckord-vbeln = 'MNO1'.
t_excel_bckord-0008text = 'XYZ1'.
append t_excel_bckord.
t_excel_bckord-vkorg = 'ABC2'.
t_excel_bckord-vbtyp = 'DEF2'.
t_excel_bckord-auart = 'GHI2'.
t_excel_bckord-ernam = 'JKL2'.
t_excel_bckord-vbeln = 'MNO2'.
t_excel_bckord-0008text = 'XYZ2'.
append t_excel_bckord.
t_excel_bcklog-vkorg = 'ABC'.
t_excel_bcklog-vbtyp = 'DEF'.
t_excel_bcklog-auart = 'GHI'.
t_excel_bcklog-ernam = 'JKL'.
t_excel_bcklog-vbeln = 'MNO'.
t_excel_bcklog-0008text = 'XYZ'.
append t_excel_bcklog.
t_excel_bcklog-vkorg = 'ABC1'.
t_excel_bcklog-vbtyp = 'DEF1'.
t_excel_bcklog-auart = 'GHI1'.
t_excel_bcklog-ernam = 'JKL1'.
t_excel_bcklog-vbeln = 'MNO1'.
t_excel_bcklog-0008text = 'XYZ1'.
append t_excel_bcklog.
t_excel_bcklog-vkorg = 'ABC2'.
t_excel_bcklog-vbtyp = 'DEF2'.
t_excel_bcklog-auart = 'GHI2'.
t_excel_bcklog-ernam = 'JKL2'.
t_excel_bcklog-vbeln = 'MNO2'.
t_excel_bcklog-0008text = 'XYZ2'.
append t_excel_bcklog.
t_excel_bcklog-vkorg = 'ABC3'.
t_excel_bcklog-vbtyp = 'DEF3'..
t_excel_bcklog-auart = 'GHI3'.
t_excel_bcklog-ernam = 'JKL3'.
t_excel_bcklog-vbeln = 'MNO3'.
t_excel_bcklog-0008text = 'XYZ3'.
append t_excel_bcklog.
t_excel_blkord-vkorg = 'ABC'.
t_excel_blkord-vbtyp = 'DEF'.
t_excel_blkord-auart = 'GHI'.
t_excel_blkord-ernam = 'JKL'.
t_excel_blkord-vbeln = 'MNO'.
t_excel_blkord-0008text = 'XYZ'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC1'.
t_excel_blkord-vbtyp = 'DEF1'.
t_excel_blkord-auart = 'GHI1'.
t_excel_blkord-ernam = 'JKL1'.
t_excel_blkord-vbeln = 'MNO1'.
t_excel_blkord-0008text = 'XYZ1'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC2'.
t_excel_blkord-vbtyp = 'DEF2'.
t_excel_blkord-auart = 'GHI2'.
t_excel_blkord-ernam = 'JKL2'.
t_excel_blkord-vbeln = 'MNO2'.
t_excel_blkord-0008text = 'XYZ2'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC3'.
t_excel_blkord-vbtyp = 'DEF3'..
t_excel_blkord-auart = 'GHI3'.
t_excel_blkord-ernam = 'JKL3'.
t_excel_blkord-vbeln = 'MNO3'.
t_excel_blkord-0008text = 'XYZ3'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC4'.
t_excel_blkord-vbtyp = 'DEF4'..
t_excel_blkord-auart = 'GHI4'.
t_excel_blkord-ernam = 'JKL4'.
t_excel_blkord-vbeln = 'MNO4'.
t_excel_blkord-0008text = 'XYZ4'.
append t_excel_blkord.
loop at t_excel_bckord.
concatenate
t_excel_bckord-vkorg
t_excel_bckord-vbtyp
t_excel_bckord-auart
t_excel_bckord-ernam
t_excel_bckord-vbeln
t_excel_bckord-posnr
t_excel_bckord-erdat
t_excel_bckord-vdatu
t_excel_bckord-reqdat
t_excel_bckord-condat
t_excel_bckord-lifsk
t_excel_bckord-txt30
t_excel_bckord-lifsp
t_excel_bckord-dispo
t_excel_bckord-dsnam
t_excel_bckord-vmsta
t_excel_bckord-kunnr
t_excel_bckord-cname
t_excel_bckord-regio
t_excel_bckord-cufd
t_excel_bckord-bstnk
t_excel_bckord-bsark
t_excel_bckord-matnr
t_excel_bckord-maktx
t_excel_bckord-t200
t_excel_bckord-vtext
t_excel_bckord-matkl
t_excel_bckord-zzbomind
t_excel_bckord-ostat
t_excel_bckord-cmgst
t_excel_bckord-inco1
t_excel_bckord-oqty
t_excel_bckord-pqty
t_excel_bckord-unit
t_excel_bckord-onet
t_excel_bckord-pnet
t_excel_bckord-curr
t_excel_bckord-so_bezei
t_excel_bckord-sg_bezei
t_excel_bckord-bname
t_excel_bckord-contact
t_excel_bckord-telf1
t_excel_bckord-reqqty
t_excel_bckord-reqval
t_excel_bckord-conqty
t_excel_bckord-conval
t_excel_bckord-zzrev
t_excel_bckord-bezei
t_excel_bckord-vgbel
t_excel_bckord-0008text
into it
separated by deli.
append it.
clear it.
endloop.
loop at t_excel_bcklog.
concatenate
t_excel_bcklog-vkorg
t_excel_bcklog-vbtyp
t_excel_bcklog-auart
t_excel_bcklog-ernam
t_excel_bcklog-vbeln
t_excel_bcklog-posnr
t_excel_bcklog-erdat
t_excel_bcklog-vdatu
t_excel_bcklog-reqdat
t_excel_bcklog-condat
t_excel_bcklog-lifsk
t_excel_bcklog-txt30
t_excel_bcklog-lifsp
t_excel_bcklog-dispo
t_excel_bcklog-dsnam
t_excel_bcklog-vmsta
t_excel_bcklog-kunnr
t_excel_bcklog-cname
t_excel_bcklog-regio
t_excel_bcklog-cufd
t_excel_bcklog-bstnk
t_excel_bcklog-bsark
t_excel_bcklog-matnr
t_excel_bcklog-maktx
t_excel_bcklog-t200
t_excel_bcklog-vtext
t_excel_bcklog-matkl
t_excel_bcklog-zzbomind
t_excel_bcklog-ostat
t_excel_bcklog-cmgst
t_excel_bcklog-inco1
t_excel_bcklog-oqty
t_excel_bcklog-pqty
t_excel_bcklog-unit
t_excel_bcklog-onet
t_excel_bcklog-pnet
t_excel_bcklog-curr
t_excel_bcklog-so_bezei
t_excel_bcklog-sg_bezei
t_excel_bcklog-bname
t_excel_bcklog-contact
t_excel_bcklog-telf1
t_excel_bcklog-reqqty
t_excel_bcklog-reqval
t_excel_bcklog-conqty
t_excel_bcklog-conval
t_excel_bcklog-zzrev
t_excel_bcklog-bezei
t_excel_bcklog-vgbel
t_excel_bcklog-0008text
into it_2
separated by deli.
append it_2.
clear it_2.
endloop.
loop at t_excel_blkord.
concatenate
t_excel_blkord-vkorg
t_excel_blkord-vbtyp
t_excel_blkord-auart
t_excel_blkord-ernam
t_excel_blkord-vbeln
t_excel_blkord-posnr
t_excel_blkord-erdat
t_excel_blkord-vdatu
t_excel_blkord-reqdat
t_excel_blkord-condat
t_excel_blkord-lifsk
t_excel_blkord-txt30
t_excel_blkord-lifsp
t_excel_blkord-dispo
t_excel_blkord-dsnam
t_excel_blkord-vmsta
t_excel_blkord-kunnr
t_excel_blkord-cname
t_excel_blkord-regio
t_excel_blkord-cufd
t_excel_blkord-bstnk
t_excel_blkord-bsark
t_excel_blkord-matnr
t_excel_blkord-maktx
t_excel_blkord-t200
t_excel_blkord-vtext
t_excel_blkord-matkl
t_excel_blkord-zzbomind
t_excel_blkord-ostat
t_excel_blkord-cmgst
t_excel_blkord-inco1
t_excel_blkord-oqty
t_excel_blkord-pqty
t_excel_blkord-unit
t_excel_blkord-onet
t_excel_blkord-pnet
t_excel_blkord-curr
t_excel_blkord-so_bezei
t_excel_blkord-sg_bezei
t_excel_blkord-bname
t_excel_blkord-contact
t_excel_blkord-telf1
t_excel_blkord-reqqty
t_excel_blkord-reqval
t_excel_blkord-conqty
t_excel_blkord-conval
t_excel_blkord-zzrev
t_excel_blkord-bezei
t_excel_blkord-vgbel
t_excel_blkord-0008text
into it_3
separated by deli.
append it_3.
clear it_3.
endloop.
if h_excel-header = space or h_excel-handle = -1.
start Excel
create object h_excel 'EXCEL.APPLICATION'.
endif.
PERFORM err_hdl.
*--- get list of workbooks, initially empty
call method of h_excel 'Workbooks' = h_mapl.
PERFORM err_hdl.
set property of h_excel 'Visible' = 1.
add a new workbook
call method of h_mapl 'Add' = h_map.
PERFORM err_hdl.
*GV_SHEET_NAME = '1st SHEET'.
gv_sheet_name = 'Back Orders'.
get property of h_excel 'ACTIVESHEET' = worksheet.
set property of worksheet 'Name' = gv_sheet_name .
*--Formatting the area of additional data 1 and doing the BOLD
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 50.
call method of h_excel 'Range' = h_cell
exporting
#1 = w_cell1
#2 = w_cell2.
*CALL METHOD OF gs_cells 'Select' .
get property of h_cell 'Font' = gs_font .
set property of gs_font 'Bold' = 1 .
data l_rc type i.
call method cl_gui_frontend_services=>clipboard_export
importing
data = it[]
changing
rc = l_rc
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 1.
PERFORM err_hdl.
call method of h_excel 'Range' = range
exporting
#1 = w_cell1
#2 = w_cell2.
call method of range 'Select'.
PERFORM err_hdl.
call method of worksheet 'Paste'.
PERFORM err_hdl.
CALL METHOD OF h_excel 'QUIT'.
*GV_SHEET_NAME = '2ND SHEET'.
gv_sheet_name = 'Backlog'.
get property of h_excel 'Sheets' = h_sheet2 .
call method of h_sheet2 'Add' = h_map.
set property of h_map 'Name' = gv_sheet_name .
get property of h_excel 'ACTIVESHEET' = worksheet.
*--Formatting the area of additional data 1 and doing the BOLD
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 50.
call method of h_excel 'Range' = h_cell
exporting
#1 = w_cell1
#2 = w_cell2.
get property of h_cell 'Font' = gs_font .
set property of gs_font 'Bold' = 1 .
call method cl_gui_frontend_services=>clipboard_export
importing
data = it_2[]
changing
rc = l_rc
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 1.
PERFORM err_hdl.
call method of h_excel 'Range' = range
exporting
#1 = w_cell1
#2 = w_cell2.
call method of range 'Select'.
PERFORM err_hdl.
call method of worksheet 'Paste'.
*GV_SHEET_NAME = '3rd SHEET'.
gv_sheet_name = 'Blocked Orders'.
get property of h_excel 'Sheets' = h_sheet3 .
call method of h_sheet3 'Add' = h_map.
set property of h_map 'Name' = gv_sheet_name .
get property of h_excel 'ACTIVESHEET' = worksheet.
*--Formatting the area of additional data 1 and doing the BOLD
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 50.
call method of h_excel 'Range' = h_cell
exporting
#1 = w_cell1
#2 = w_cell2.
get property of h_cell 'Font' = gs_font .
set property of gs_font 'Bold' = 1 .
call method cl_gui_frontend_services=>clipboard_export
importing
data = it_3[]
changing
rc = l_rc
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 1.
PERFORM err_hdl.
call method of h_excel 'Range' = range
exporting
#1 = w_cell1
#2 = w_cell2.
call method of range 'Select'.
PERFORM err_hdl.
call method of worksheet 'Paste'.
*--- disconnect from Excel
free object h_zl.
free object h_mapl.
free object h_map.
free object h_excel.
Regards
Sudheer

Similar Messages

  • Email XLS excel attachment from ABAP

    Hi,
    I am trying to email an excel attachment from ABAP, but when I open in excel, it says not a recognizable format, but when I click OK it does open as a tab-delimited file and look OK.
    Any ideas please?

    Hi,
    Please check this link
    http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
    aRs

  • Code generate report in excel format from portal(Application Server)

    Hi all
    Please give some solution with code generate report in excel format from
    oracle portal(Application Server).

    Not feasible.
    Why? Because "the Excel format" is a binary and proprietary Microsoft file format. And writing a generator to generate Excel files will be complex, and resource expensive. In the vast majority of cases this will not be justified.
    As an alternative the very basic Microsoft XML office format can be used. But note that this is not a a ISO standard (it has been shot down in flames) - and effort and resources for that would be better spend on the Open Document XML standard (which very likely will be ratified as the ISO standard instead).
    Of course, you could have meant a CSV file - in which case, you need to play close attention to details. CSV is not an Excel format. A software designers and developers, our success is determined by attention to technical detail. In which case you are not paying any attention to technical detail by confusing CSV with Excel.

  • Getting a report in excel format from oracle report builder 10gDS release2

    I want to get a report in excel format from oracle report builder 10gDS release2.
    Is there ne method by which minimum effort is required for changing already made reports .
    I have searched for it on internet :-
    http://www.oracle.com/webapps/online-help/reports/10.1.2/state/content/navId.3/navSetId._/vtTopicFile.htmlhelp_rwbuild_hs%7Crwwhthow%7Cwhatare%7Coutput%7Coutput_a_simpleexcel~htm/
    Example, given in the last of the page opened from the above url, is not working.
    Can neone plz explain the example and how to use it
    Thanks & Regards
    JD

    Ok, for the release 2 its quite straightfoward, in your calling form you would have something like this code:
    declare
         pl_id ParamList;
    repid REPORT_OBJECT;
    v_rep VARCHAR2(100);
    v_rep_status VARCHAR2(20);
    v_repsrv     VARCHAR2(100):= 'yourreportserver';
    v_serv varchar2(50) := 'yourservername' ;
    begin
    pl_id := Get_Parameter_List('tmpdata');
    if not id_null(pl_id) then
    Destroy_Parameter_List( pl_id );
    end if;
    pl_id := Create_Parameter_List('tmpdata');
    Add_Parameter(pl_id,'DESTYPE' ,TEXT_PARAMETER,'Screen' );
    Add_Parameter(pl_id,'PARAMFORM' ,TEXT_PARAMETER,'NO' );
    repid := FIND_REPORT_OBJECT('yourreport');     SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,RUNTIME);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER, v_repsrv);
    set_report_object_property(repid,REPORT_DESTYPE,CACHE );
    set_report_object_property(repid,REPORT_DESFORMAT,'SPREADSHEET' );
    v_rep := RUN_REPORT_OBJECT(repid,pl_id);
    v_rep := substr(v_rep,length(v_repsrv)+2,10 ) ;
    end;
    I have plenty of reports being formated to excel with this same method so it should work for you, the only diference with my previous code is this line.
    set_report_object_property(repid,REPORT_DESFORMAT,'SPREADSHEET' );
    The rest remains untouched.
    Hope it helps.

  • Ole excel application from abap

    Hi all ,
               I   an calling  one excel application  from abap .  I   don't want to make excel file visible ,  but insted  want to save and close the file , by using method
    saveas for excel application  and later i want to see the file . file name i want to store in a variable .
    eg :
    CALL METHOD OF H_EXCEL 'FILESAVEAS' = RC
    EXPORTING #1 =  filename .
    Can it be possible ?
    regards,
    SA

    hi
    i simpler method will be to use the function modules for this purpose.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
             PROGRAM_NAME        = SYST-CPROG
             DYNPRO_NUMBER       = SYST-DYNNR
             FIELD_NAME          = ' '
             IMPORTING
               file_name           = file_name .
              lc_filename = file_name.
              CALL FUNCTION 'GUI_DOWNLOAD'
                EXPORTING
                BIN_FILESIZE                    =
                  filename                        = lc_filename
                  filetype                        = 'DAT'
                TABLES
                  data_tab                        = gt_itab.
              IF sy-subrc <> 0.
              MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
              ENDIF.
    Fn module F4_filename will prompt for the name of the file to be saved  and GUI_DOWNLOAD will save the file.
    gt_itab is the internal table containing the data to be stored in excel.

  • Can we extract the timesheet in excel format from non-SAPGUI to SAPGUI

    Can we extrat the timesheet in excel format from NON-SAPGUI network to the SAPGUI network

    Hi ,
    Try doing this through Maxl using the below code.
    login 'admin' 'password' on 'localhost';
    alter system load application 'Sample';
    alter application 'Sample' load database 'Basic';
    export outline sample.basic all dimensions to xml_file "c:/_dev/SampleBasicMetaData.xml";
    logout;
    When the script runs, it parses the Sample.Basic outline and stores all key elements about the
    outline and its members in a logical format represented by XML. The Export Outline function
    runs rather quickly against the server and the resulting XML file gets created at the specified
    location. If the file already exists it will be overwritten without warning.
    Opening the resulting XML file in a browser or text editor will show a standard XML structure
    with elements representing both the cube and the dimensions from the outline. The XML file is
    now ready for consumption.
    let me know if it helps.
    Thanks,
    KKT
    http://www.knowhyperion.com

  • How to send ALV Report in excel format from SAP

    Hi Gurus,
    We are using SAP 4.7 and using different SAP reports.Now I want to send SAP ALV report in excel format directly from SAP in background.Now we send these reports in background weekly by using autimetic scheduling but this is PDF format.Now I want to change this pdf format to excel format.In SCOT T.Code I am able to find any excel format.Please help me out.
    I am waiting for your reply.
    Advance Thanks
    Nirmal

    Hi Nirmal,
    I have done the same in my previous organisation.For this particular solution you need to ask your basis guys to upgrade the support package so that BCS classes could be available in the system.
    API interafces five some problem with attachemnts and SAP has recommended to use BCS classes.
    Currently BCS classes won't be availbale in 4.7.
    Once the BCS classes are available
    use below code
       CONSTANTS:
        lc_tab          TYPE c VALUE cl_bcs_convert=>gc_tab,
        lc_crlf         TYPE c VALUE cl_bcs_convert=>gc_crlf,
       lc_codepage     TYPE abap_encod VALUE '4103',
    data :
       lv_string      TYPE string,
       binary_content TYPE solix_tab,
       size           TYPE so_obj_len,
       *" Set Heading of Excel File
      CONCATENATE 'Employee DATA'
                   lc_crlf lc_crlf
                   INTO lv_string.
       *" Set Header for Excel Fields
      CONCATENATE lv_string
                  lc_header1 lc_tab
                  lc_header2 lc_tab
                  lc_header3 lc_tab
                  lc_header4 lc_tab
                  lc_header5 lc_tab
                  lc_header6 lc_tab
                  lc_header7 lc_tab
                  lc_header8 lc_tab
                  lc_header9 lc_tab
                  lc_header10 lc_crlf
                  INTO lv_string.
    "lc_header1 to 10 could be your field headers
       "Move Internal table data
      LOOP AT gt_final1 INTO gwa_final1.
        CONCATENATE lv_string
                    gwa_final1-field1     lc_tab
                    gwa_final1-field2      lc_tab
                    gwa_final1-field3    lc_crlf
                    INTO lv_string.
      ENDLOOP.
       *" convert the text string into UTF-16LE binary data including
    *" byte-order-mark. Mircosoft Excel prefers these settings
    *" all this is done by new class cl_bcs_convert (see note 1151257)
      TRY.
          cl_bcs_convert=>string_to_solix(
            EXPORTING
              iv_string   = lv_string
              iv_codepage = lc_codepage  "suitable for MS Excel, leave empty
              iv_add_bom  = abap_true     "for other doc types
            IMPORTING
              et_solix  = binary_content
              ev_size   = size ).
        CATCH cx_bcs.
          MESSAGE e445(so).
      ENDTRY.
      TRY.
    *" create persistent send request
          send_request = cl_bcs=>create_persistent( ).
          document = cl_document_bcs=>create_document(
            i_type    = lc_doc
            i_text    = main_text
            i_subject = lc_sub  ).     
          document->add_attachment(
            i_attachment_type    = lc_attach                    "#EC NOTEXT
            i_attachment_subject = lc_sub                       "#EC NOTEXT
            i_attachment_size    = size
            i_att_content_hex    = binary_content ).
       send_request->set_document( document ).
       recipient = cl_cam_address_bcs=>create_internet_address( email ).
       CALL METHOD send_request->add_recipient
              EXPORTING
                i_recipient = recipient.
       IF recipient IS NOT INITIAL.
            sent_to_all = send_request->send( i_with_error_screen = abap_true ).
            COMMIT WORK.
    *        MESSAGE text-014 TYPE gc_succ  .
          ENDIF.
        CATCH cx_bcs INTO bcs_exception.
          MESSAGE i865(so) WITH bcs_exception->error_type.
      ENDTRY.
    For BCS decalartion u can go to se 38 and see program BCS_EXAMPLE_1 to BCS_EXAMPLE_7.
    Rewrads if helpful.
    Cheers
    Ramesh Bhatt

  • Running Excel macros from ABAP

    Hello everyone,
    I am trying to execute an Excel macro from an ABAP program.  We are currently on a 46C system.  While doing some research on help.sap.com I came across the method execute_macro in class i_oi_document_proxy.  I’ve never used methods in ABAP before and I’m not really sure what I’m doing.  Has anyone got this to work?  When I try to run the program it dumps with error OBJECTS_OBJREF_NOT_ASSIGNED.
    Thanks,
    Becky
    Here is the program:
    REPORT ztest_program.
    INCLUDE ole2incl.
    DATA gs_excel TYPE ole2_object .
    DATA gs_wbooks TYPE ole2_object .
    DATA gs_wbook TYPE ole2_object .
    DATA gs_application TYPE ole2_object .
    DATA: h_sheet TYPE ole2_object.
    DATA: document TYPE REF TO i_oi_document_proxy.
    *Name of the macro in Excel
    DATA: macro_string(50) TYPE c
                     VALUE 'FB03process.FromTheBeginning',
          no_flush TYPE c,
          param_count TYPE i VALUE 0,
          script_name TYPE c VALUE 'X',
          error TYPE REF TO i_oi_error
                OCCURS 0 WITH HEADER LINE,
          retcode TYPE soi_ret_string,
          error_string(50) TYPE c,
          retvalue(30) TYPE c.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
       EXPORTING
             text       = text-007
         EXCEPTIONS
              OTHERS     = 1.
    CREATE OBJECT gs_excel 'EXCEL.APPLICATION' .
    SET PROPERTY OF gs_excel 'Visible' = 1 .
    GET PROPERTY OF gs_excel 'Workbooks' = gs_wbooks .
    GET PROPERTY OF gs_wbooks 'Application' = gs_application .
    *--Opening the existing document
    CALL METHOD OF gs_wbooks 'Open' = gs_wbook
         EXPORTING #1 = 'D:\temp\FB03process.xls' .
    tell user what is going on
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
       EXPORTING
              PERCENTAGE = 0
             text       = text-009
         EXCEPTIONS
              OTHERS     = 1.
    GET PROPERTY OF gs_excel 'ACTIVESHEET' = h_sheet.
    CALL METHOD document->execute_macro
         EXPORTING macro_string  = macro_string
                   param_count   = param_count
                   script_name   = script_name
                   no_flush      = no_flush
         IMPORTING error         = error
                   retcode       = retcode
         CHANGING  error_string  = error_string
                   retvalue      = retvalue.
    disconnect from Excel
    FREE OBJECT gs_excel.
    PERFORM err_hdl.
    FORM err_hdl.
      IF sy-subrc <> 0.
        WRITE: / 'Fehler bei OLE-Automation:'(010), sy-subrc.
        STOP.
      ENDIF.
    ENDFORM.                    " ERR_HDL

    Hi,
    Please correct me if I am wrong but it seems that you have not fetched a handle to the document object before issuing the statement CALL METHOD document->execute_macro. Hence the error OBJECTS_OBJREF_NOT_ASSIGNED is being dislayed. If you want to use SAP Desktop Office Integration using ABAP Objects, take a look at this article at http://www.intelligenterp.com/feature/archive/ or http://www.sapinfo.net/public/en/index.php4/article/comvArticle-193333c63b4bd807d2/en/articleStatistic
    Hope this helps.
    Regards
    Message was edited by: Shehryar Khan

  • Excel format from Reports Server

    Hi Guys,
    We are about to deploy reports, which need to produce output in Excel format. I know there are a number of ways to do it, but we decided to go this way:
    1. The report will generate its output in XML format
    2. We will apply an XSL to convert the XML to HTML, which could be opened in Excel
    As this report should be accessed from the web we decided to develop our own servlet, which will run the report, apply the transformation and finally deliver the result in the browser.
    Now the question. How to run the report from the servlet?
    We have though of running RWRUN from the command line specifying all the needed parameters. Is this the best way?
    Thanks in advance!
    Krasen Paskalev

    The simplest way would be to either call the reports runtime with a Runtime.exec() call from the servlet. Alternatively, you could construct a URL and call the Reports Servlet (or CGI if you're a 6i user) to have the reports server generate the XML.
    If you're a 9i user then you could either subclass the Reports Servlet, or better still generate your Excel output through a jsp (see the demo of this at http://otn.oracle.com/products/reports/htdocs/getstart/demonstrations/index.html).
    Hope this helps,
    Danny

  • Opening Excel Spreadsheet from ABAP

    Hello,
    Is there any way to put data from an ABAP program into an existing Excel spreadsheet? I know how to put the data into a new spreadsheet but my users want to put the data into an existing spreadsheet where they have developed macros.
    Thanks,
    Becky

    Hi Becky
    Here is a procedure using OLE automation.
    DATA gs_excel TYPE ole2_object .
    DATA gs_wbooks TYPE ole2_object .
    DATA gs_wbook TYPE ole2_object .
    DATA gs_application TYPE ole2_object .
    CREATE OBJECT gs_excel 'EXCEL.APPLICATION' .
    SET PROPERTY OF gs_excel 'Visible' = 1 .
    GET PROPERTY OF gs_excel 'Workbooks' = gs_wbooks .
    GET PROPERTY OF gs_wbooks 'Application' = gs_application .
    *--Opening the existing document
    CALL METHOD OF gs_wbooks 'Open' = gs_wbook
         EXPORTING #1 = <file_path_var> .
    "*--After this point you can go on processing the sheet
    using OLE Automation techniques"
    If it is just the template to be stored you can save the template .xls file at the application server each time downloading it to a temporary place to open. Or you can store it at SAP Office templates folder. For SAP Office operations you can inspect "BC_SO_*" masked FMs.
    And as a last thing, let me introduce you the SDN forums pointing system: You can assign points to posts you find helpful while solving your question. You can reward points by clicking the yellow star icon at header of each reply post. You can reward;
    - one 10 points (solved)
    - two 6 points (very helpful answer)
    - many 2 points (helpful answer)
    Kind Regards...
    *--Serdar

  • When we save a file in excel format from the webpage, the alignment of columns is disturbed which does not happen in IE, P

    We are using Oracle Apps. wherein we have an options to export the contents of the web page. It default stores the file in .tsv format. if we choose to save the file in excel then the file is saved. however when we open the file in excel, the text is garbled. If we try the same option using IE, then the text is automatically aligned as required.

    Dear cor-el, wow you are quick. I understand you better now, but I'm not sure it's a good idea to write to you in dutch, only if you are Dutch yourself.
    Anyway, first the location bar is what I call the address bar.
    Second I work very simple and easy. I never use the address bar when I'm looking for a website.
    I just type the name of whatever I'm looking for in the empty bar on my google page and wait for the response.
    Third, most of the sellers I buy from on ebay, I just discovered by accident and I immediately saved them in my favorites bar.
    So if I need to go to their website(s) I just go to my favorites bar and click on the name of the seller(s) I'm looking for.
    Now to answer the question from your earlier letter, the URL's I'm trying to save are those from the webpage(s) I open on the websites I visit and not from the website(s) itself.
    The second part of your last letter from " You can modify......" is too difficult for me to understand.
    If it's important I'll ask a friend, a mainframe specialist to explain it to me.
    Thanks again for help. Regards, Ruiz

  • Creating datetime in XML format from ABAP

    Hello All:
         I have a ABAP program that creates an XML file and everything is fine. I just need one date field in XML to conform to W3CC standard (EX: 2006-12-01T10:53:05.2170000). I need datetime in the format "2006-12-01T10:53:05.2170000". How do I acheive this in ABAP?
    Thanks.
    Mithun

    That seems to be easy:
    DATA:
      lv_timestamp  TYPE timestampl,
      lv_xml_date   TYPE string.
    GET TIME STAMP FIELD lv_timestamp.
    CONCATENATE lv_timestamp+0(4)
                lv_timestamp+4(2)
                lv_timestamp+6(2)
      INTO lv_xml_date
      SEPARATED BY '-'.
    CONCATENATE lv_xml_date
                'T'
      INTO lv_xml_date.
    CONCATENATE lv_timestamp+8(2)
                lv_timestamp+10(2)
                lv_timestamp+12(2)
      INTO lv_xml_date+12(8)
      SEPARATED by ':'.
    CONCATENATE lv_xml_date
                lv_timestamp+5(7)
      INTO lv_timestamp
      SEPARATED BY '.'.
    Reward points, if reply is applicable
    Edited by: Mike Schernbeck on Jan 30, 2008 9:24 PM

  • Generate PDF format from ABAP List using 'RSPO_SR_OPEN'

    Hi All,
    I need some help on the following code. I have 2 cases.
    First case:
    I am using the function Module 'RSPO_SR_OPEN' to create spool from the List Output.
    Once I get the Spool number from Above function Module I will submit it through report RSTXPDF5 to get spool request for PDF data created.
    I will use this spool number in the report RSTXPDFT5 to download it to Local system in PDF format.
    PDF will be generated but I am unable to open the PDF, some conversion error.
    Second Case:
    Instead of using function Module 'RSPO_SR_OPEN' , I will use standard Print button on the application toll bar to generate the spool number and then remaining step follows.
    In this case PDF file is generating as per the requirement.
    Now my question is why system does not work properly when I am using function module 'RSPO_SR_OPEN' .
    I have attached the code for your reference:
    AT USER-COMMAND.
    CASE SY-UCOMM.
    WHEN 'EMAIL'.
    IF SY-LSIND EQ 1.
    Send mail to User ID
    PERFORM SEND_MAIL.
    LEAVE TO LIST-PROCESSING.
    ENDIF.
    WHEN 'MM03'.
    SET PARAMETER ID 'MAT' FIELD I_MARA-MATNR.
    CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
    WHEN 'LIST'.
    data: pdf_spoolid like tsp01-rqident.
    data: gd_spool_nr1(11) type c,
          gd_spool_nr2(10) type c.
    RANGES : R_SPOOL FOR TSP01-RQTITLE.
    Function Module to Create Spool Number
      call function 'RSPO_SR_OPEN'
           exporting
                dest             =  c_device
                LAYOUT           = 'X_65_200'
                copies           = '1'
                doctype          = 'LIST'
           importing
                spoolid          = gd_spool_nr
           exceptions
                operation_failed = 1
                others           = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Report to Generate spool number for PDF convert
    submit RSTXPDF5 with spoolno  = gd_spool_nr
                    with dstdevic = 'LOCL' and return .
    if sy-subrc eq 0.
    gd_spool_nr2 = gd_spool_nr.
    condense gd_spool_nr2 no-gaps.
    concatenate '00000' gd_spool_nr2 '*' into gd_spool_nr1.
    R_SPOOL-LOW     = gd_spool_nr1.
    R_SPOOL-OPTION  = 'CP'.
    R_SPOOL-SIGN     = 'I' .
    APPEND R_SPOOL.
    To select PDF Spool Number from TSP01 based on Title
    select single * from tsp01 where rqtitle IN R_SPOOL.
    if sy-subrc eq 0.
    Report to Download PDF spool to GUI
      submit RSTXPDFT5 with spoolid = tsp01-rqident and return.
    endif.
    endif.
    ENDCASE.
    Thanks & Regards,
    Nagaraj

    Hi,
    Check this code,
    REPORT  Z_CREATE_PDF_ABAPLIST NO STANDARD PAGE HEADING.
    PF-status containing a PDF button in the report Output to generate
    PDF form
    SET PF-STATUS 'Z_PDF'.
    *Table Declarations
    TABLES: MARA, MARC, MAKT.
    Internal Table Declarations
    DATA: BEGIN OF TS_MARA OCCURS 0,
             MATNR LIKE MARA-MATNR,
             MTART LIKE MARA-MTART,
             MATKL LIKE MARA-MATKL,
             LVORM LIKE MARA-LVORM,
             WERKS LIKE MARC-WERKS,
             MAKTX LIKE MAKT-MAKTX,
           END   OF TS_MARA.
    Selection Screen Parameters
    SELECTION-SCREEN BEGIN OF BLOCK B1.
      SELECT-OPTIONS: S_MATNR FOR MARA-MATNR OBLIGATORY,
                      S_WERKS FOR MARC-WERKS OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
    TOP-OF-PAGE.
    write: 40 'Generating PDF from List Output' color 1 intensified on.
      skip 1.
      write: /1 'Date        :',  SY-DATUM,
             /1 'User ID     :',  SY-UNAME,
             /1(112) SY-ULINE.
    START-OF-SELECTION.
    Perform for Basic Selection
    PERFORM GET_MARA.
    Perform to Display Data
    PERFORM DISPLAY_MARA.
    AT USER-COMMAND.
    User Command to generate PDF Form
      AT USER-COMMAND.
      CASE SY-UCOMM.
        WHEN 'PDF'.
        DATA: L_PARAMS TYPE PRI_PARAMS,
                L_VALID TYPE STRING,
                W_SPOOL_NR LIKE TSP01-RQIDENT.
    TO GET PRINT PARAMETERS
          CALL FUNCTION 'GET_PRINT_PARAMETERS'
            IMPORTING
              OUT_PARAMETERS = L_PARAMS
              VALID          = L_VALID.
          IF SY-SUBRC <> 0.
          ENDIF.
    Internal table for Selection Screen
    DATA: BEGIN OF I_RSPARAMS OCCURS 0.
           INCLUDE STRUCTURE RSPARAMS.
    DATA: END OF I_RSPARAMS.
    Store the current selection screen details
    CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
      EXPORTING
        CURR_REPORT           = SY-REPID
    IMPORTING
      SP                    =
      TABLES
        SELECTION_TABLE       = I_RSPARAMS
    EXCEPTIONS
      NOT_FOUND             = 1
      NO_REPORT             = 2
      OTHERS                = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    SUBMIT TO GET THE SPOOL NUMBER
    SUBMIT Z_CREATE_PDF_ABAPLIST WITH SELECTION-TABLE I_RSPARAMS
                                 TO SAP-SPOOL
                                 SPOOL PARAMETERS L_PARAMS
                                 WITHOUT SPOOL DYNPRO
                                 AND RETURN.
    SELECT THE RECENTLY CREATED SPOOL
          SELECT MAX( RQIDENT ) INTO W_SPOOL_NR FROM TSP01
                                     WHERE RQCLIENT = SY-MANDT
                                     AND   RQOWNER  = SY-UNAME.
    *REPORT TO GENERATE SPOOL NUMBER FOR PDF CONVERT
          SUBMIT RSTXPDF5 WITH SPOOLNO  = W_SPOOL_NR
                          WITH DSTDEVIC = 'LOCL' AND RETURN .
          IF SY-SUBRC EQ 0.
            CLEAR W_SPOOL_NR.
    SELECT THE RECENTLY CREATED SPOOL FOR PDF
            SELECT MAX( RQIDENT ) INTO W_SPOOL_NR FROM TSP01
                                       WHERE RQCLIENT = SY-MANDT
                                       AND   RQOWNER  = SY-UNAME.
    *REPORT TO DOWNLOAD PDF SPOOL TO GUI
            SUBMIT RSTXPDFT5 WITH SPOOLID = W_SPOOL_NR
                             AND RETURN.
          ENDIF.
      ENDCASE.
    *&      Form  GET_MARA
          text
    -->  p1        text
    <--  p2        text
    FORM GET_MARA .
    CLEAR  : TS_MARA.
    REFRESH: TS_MARA.
    To select Materials based on Selection Criteria
    SELECT A~MATNR A~MTART A~MATKL A~LVORM B~WERKS INTO CORRESPONDING
                               FIELDS OF TABLE TS_MARA FROM MARA AS A
                               INNER JOIN MARC AS B ON A~MATNR EQ B~MATNR
                               WHERE A~MATNR IN S_MATNR
                               AND   B~WERKS IN S_WERKS.
    LOOP AT TS_MARA.
       SELECT SINGLE * FROM MAKT WHERE MATNR EQ TS_MARA-MATNR
                                 AND   SPRAS EQ SY-LANGU.
       MOVE MAKT-MAKTX TO TS_MARA-MAKTX.
       MODIFY TS_MARA INDEX SY-TABIX.
    ENDLOOP.
    ENDFORM.                    " GET_MARA
    *&      Form  DISPLAY_MARA
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_MARA .
    CLEAR  : TS_MARA.
    WRITE: /1   '|', 2(18)  'Material Number' COLOR 7,
             21  '|', 22(5)  'Plant          ' COLOR 7,
             28  '|', 29(13) 'Material Type  ' COLOR 7,
             42  '|', 43(14) 'Material Group ' COLOR 7,
             57  '|', 58(13) 'Deletion Flag  ' COLOR 7,
             71  '|', 72(40) 'Description    ' COLOR 7,
             112 '|'.
    WRITE: /1(112) SY-ULINE.
    LOOP AT TS_MARA.
      WRITE: /1   '|', 2(18)   TS_MARA-MATNR,
              21  '|', 22(5)   TS_MARA-WERKS,
              28  '|', 29(13)  TS_MARA-MTART,
              42  '|', 43(14)  TS_MARA-MATKL,
              57  '|', 58(13)  TS_MARA-LVORM,
              71  '|', 72(40)  TS_MARA-MAKTX,
              112 '|'.
    WRITE: /1(112) SY-ULINE.
    ENDLOOP.
    ENDFORM.                    " DISPLAY_MARA
    Thanks & Regards,
    Nagaraj Kalbavi

  • Cannot export crystal report in excel format from crystal report viewer

    This problem occurs on only one workstation.
    Open Advanced Reports > Enter workorder # > Click on 'workorder work(uninvoiced)' > Work order opens.
    Click on icon "Export report"
    Save as type: change to .xls
    Error: Crystal Report Windows Forms Viewer. Error in file
    SAP.......rpt:
    Error detected by export DLL:
    Export failed.

    Try adding c:\Program Files\Business Objects\BusinessObjects Enterprise 12.0\win32_x86 to your windows enviroment variable PATH then restart.

  • Broad casting Webi report in excel format to different users email ids

    Hello,
    Seriously looking for the help, please help with the solution for below scenario.
    We have a requirement to schedule broadcasting of Webi reports to users email in excel format from infoview. But our concern is how the system takes care of authorizations of users when we broadcast the report to their mail id as excel file.
    For example we have one webi report for Finance and there are thousands of users for each department, cost centre etcu2026so how to broadcast the same webi report in excel to different users with only data they have authorized to see. We have committed to client that we can do this with out much massive overhead, please advise what is the easiest way to achieve this. I read something like this can be done using authorization profiles in CMS but creating those many profiles and mapping them to relevant authorizations is not possible as there are thousands of users with different authorization levels. And Client is expecting this broadcasting need to be done automatically with out every time manual intervention. 
    Looking forward for the prompt reply.
    Thanks,
    Gani.

    Please use the Dynmanic Recipients functionality of the Publication.
    For this we need to do follow steps.
    1) Create the WebI Report that needs to be published(Broadcasted)
    2) create Deski/webi report which contains the user details and email id's for publishing main report.
    3) Map the properties of souce report with Dynamic Recipient report.
    Please refer the user guide for more inforamtion.This helps you in avoiding manual creation of profiles in CMC.
    Regards,
    Siva
    Edited by: Nallamala siva on Jun 13, 2011 8:17 AM

Maybe you are looking for

  • Group and display characteristics in a user friendly way

    Hi all, We have a scenario where we have created a DOC type which we assigned to a class with several characteristics. The problem is that the characteristics are not disaplayed in a very user friendly way in tab "additinal data". Is there any custom

  • How to create a home dirve through OIM

    How to create a sharedfolder at the time of user provisioned to AD.pls let me know any one done this.Its very argent...I am new to this. Thanks in advance. Edited by: 790561 on 8/08/2011 15:44

  • How do I invert meter in labview with needle pointing downwards

    Hi, I need to invert meter in labview with needle pointing downwards . Can somebody guide me?

  • Viewing PSD thumbnails...

    Hi, So sick of not being able to view PSD thumbnails, not even from the regular "OPEN FILE" dialog in Photoshop CS6. Besides 3rd party commercial software like Mystic Thumbs, what solutions are out there for me? Thanks.

  • Different OS image

    I have different OS type , Like Windows 2008 SP2 and windows 2008 R2, windows 2007 and windows 2008. How i configure my infra to deploy new server or client . Example  I want my define  client connect to windows 7 image for OSD  Define server connect