‎2010 Jul 29 11:36 AM
Hello Experts,
I am downloading one Report in ALV. It is coming perfect but at the same time I am supposed to send the same report in .XLS format to send mail for User when the program runs in Background. When the program is in Foreground o/p is in ALV and in Back ground it is in .XLS.
For this purpose I have used following FM's
1) EFG_GEN_GET_USER_EMAIL - To validate Recepient
2) SO_DOCUMENT_SEND_API1 - To send mail.
.XLS data is Concatenated in internal table. The o/p in ALV is coming perfect but in .XLS it is wrong in allignment.
First Field 'Price group' is displayed in Zigzag manner. It means, Line is not ended perfectly.Other fields are displayed perfectly.
Can you please guide me in this I am writing code here used for concatatenation.
CONCATENATE t_final-konda
t_final-kondm
t_final-matnr
t_final-maktx
w_tmp_atinn
t_final-atnam
t_final-carpo
t_final-atwrt
t_final-atwtb
w_tmp_kbetr
w_tmp_konwa
t_final-cltyp
w_tmp_kmein
INTO t_attach SEPARATED BY c_tab.
CONCATENATE t_attach c_cret
INTO t_attach.
APPEND t_attach.
Please suggest a solution.
Harish
‎2010 Jul 29 12:15 PM
‎2010 Jul 29 12:35 PM
Hi Madhuri,
Can you please explain me how to do it in detail?
Harish
‎2010 Jul 29 12:57 PM
* handles for OLE objects
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
H_C type OLE2_OBJECT, " color
H_N type OLE2_OBJECT. "numeric
data: FILENAME like RLGRAP-FILENAME.
data: H type I, I type I.
data : W_LINE1 type STRING,
W_LINE2 type STRING,
W_LINE3 type STRING,
W_LINE4 type STRING,
call function 'XXL_SIMPLE_API'
exporting
N_KEY_COLS = 4
FILENAME = 'ZPPR035'
HEADER = XMPL_HEADER
tables
DATA = <DYN_TABLE_OLE>
ONLINE_TEXT = XMPLT_O
PRINT_TEXT = XMPLT_P
COL_TEXT = XMPLT_V
exceptions
DIM_MISMATCH_DATA = 71
FILE_OPEN_ERROR = 72
FILE_WRITE_ERROR = 73
INV_WINSYS = 74
INV_XXL = 75.W_LINE5 type STRING,
W_LINE6 type STRING.
data begin of XMPLT_O occurs 1. " For further explanation, please
include structure GXXLT_O. " \ refer to report XXLFTEST.
data end of XMPLT_O. " \ This report is similar in
" \ structure to XXLFTEST, but
data begin of XMPLT_P occurs 1. " \ avoids any special features in
include structure GXXLT_P. " \ order to demonstrate the
data end of XMPLT_P. " \ applicability of XXL_SIMPLE_API
" \ in straight-forward situations.
data begin of XMPLT_V occurs 1.
include structure GXXLT_V.
data end of XMPLT_V.
data: XMPL_HEADER like GXXLT_P-TEXT value 'Gross Net Production Report'.
* DATA: fullpath TYPE String,
* w_filename TYPE String,
* path TYPE String,
* user_action TYPE I,
* encoding TYPE ABAP_ENCODING.
* accessing the alv settings at run time
data : REF_GRID type ref to CL_GUI_ALV_GRID. "new
if REF_GRID is initial.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
E_GRID = REF_GRID.
endif.
if not REF_GRID is initial.
call method REF_GRID->GET_FRONTEND_FIELDCATALOG
importing
ET_FIELDCATALOG = IT_FLDCAT_OLE.
endif.
loop at IT_FLDCAT_OLE into WA_FLDCAT_OLE.
if WA_FLDCAT_OLE-DATATYPE eq 'DEC' or WA_FLDCAT_OLE-DATATYPE eq 'QUAN' or
WA_FLDCAT_OLE-INTTYPE = 'P'.
WA_FLDCAT_OLE-DATATYPE = 'QUAN'.
WA_FLDCAT_OLE-DECIMALS_O = '3'.
WA_FLDCAT_OLE-DOMNAME = 'MENG13'.
WA_FLDCAT_OLE-DO_SUM = 'X'.
WA_FLDCAT_OLE-INTLEN = '17'.
WA_FLDCAT_OLE-REF_TABLE = 'MSEG'.
WA_FLDCAT_OLE-REF_FIELD = 'ERFMG'.
modify IT_FLDCAT_OLE from WA_FLDCAT_OLE
transporting DATATYPE DECIMALS_O DOMNAME DOMNAME
DO_SUM INTLEN REF_TABLE REF_FIELD .
endif.
endloop.
* build dyn_table_ole
data: NEW_TABLE type ref to DATA,
NEW_LINE type ref to DATA.
* CREATE DYNAMIC INTERNAL TABLE AND ASSIGN TO FS
call method CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
exporting
IT_FIELDCATALOG = IT_FLDCAT_OLE
importing
EP_TABLE = NEW_TABLE.
assign NEW_TABLE->* to <DYN_TABLE_OLE>.
* CREATE DYNAMIC WORK AREA AND ASSIGN TO FS
create data NEW_LINE like line of <DYN_TABLE_OLE>.
assign NEW_LINE->* to <DYN_WA_OLE>.
* Fill_dync_table_ole.
loop at <DYN_TABLE> into <DYN_WA>.
loop at IT_FLDCAT_OLE into WA_FLDCAT_OLE.
assign component WA_FLDCAT_OLE-FIELDNAME of structure <DYN_WA_OLE> to <FS1>.
assign component WA_FLDCAT_OLE-FIELDNAME of structure <DYN_WA> to <FS2>.
<FS1> = <FS2>.
endloop.
append <DYN_WA_OLE> to <DYN_TABLE_OLE>.
endloop.
H = 1.
XMPLT_O-LINE_NO = H.
XMPLT_O-INFO_NAME = 'Report-Type'.
XMPLT_O-INFO_VALUE = 'Central'.
append XMPLT_O.
H = H + 1.
XMPLT_O-LINE_NO = H.
XMPLT_O-INFO_NAME = 'Responsible'.
XMPLT_O-INFO_VALUE = 'Craig Young, DP/III'.
append XMPLT_O.
H = H + 1.
XMPLT_O-LINE_NO = H.
XMPLT_O-INFO_NAME = 'Checks'.
XMPLT_O-INFO_VALUE = 'OK'.
append XMPLT_O.
H = H + 1.
XMPLT_P-HF = 'H'.
XMPLT_P-LCR = 'C'.
XMPLT_P-LINE_NO = H.
XMPLT_P-TEXT = 'Periodical Report:'.
append XMPLT_P.
H = H + 1.
XMPLT_P-LINE_NO = H.
XMPLT_P-TEXT = 'Performance per Year'.
append XMPLT_P.
H = H + 1.
XMPLT_P-HF = 'F'.
XMPLT_P-LCR = 'R'.
XMPLT_P-LINE_NO = H.
XMPLT_P-TEXT = 'Distribution:'.
append XMPLT_P.
H = H + 1.
XMPLT_P-LINE_NO = H.
XMPLT_P-TEXT = 'all Sales Accountants'.
append XMPLT_P.
H = H + 1. I = 1.
loop at IT_FLDCAT_OLE into WA_FLDCAT_OLE.
XMPLT_V-COL_NO = I .
XMPLT_V-COL_NAME = WA_FLDCAT_OLE-SELTEXT.
I = I + 1.
append XMPLT_V.
endloop.
H = H + 1.
call function 'XXL_SIMPLE_API'
exporting
N_KEY_COLS = 4
FILENAME = 'ZPPR035'
HEADER = XMPL_HEADER
tables
DATA = <DYN_TABLE_OLE>
ONLINE_TEXT = XMPLT_O
PRINT_TEXT = XMPLT_P
COL_TEXT = XMPLT_V
exceptions
DIM_MISMATCH_DATA = 71
FILE_OPEN_ERROR = 72
FILE_WRITE_ERROR = 73
INV_WINSYS = 74
INV_XXL = 75.
‎2010 Jul 29 3:18 PM
Hi Madhuri,
Thanks for the reply but code is not at all visible.
Harish
‎2010 Jul 30 5:19 AM
Please refer following link
http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm
‎2010 Jul 30 6:59 AM