2007 Jul 20 10:57 AM
hi,
i do one report program i want down load my internal table in exale i want set every column headings in header also i wnt display some information how dto i do this.
2007 Jul 20 11:03 AM
hi,
While downloading file, u wont get the header part, u have to append the header part before the data. Then u pass the final output table with header to the function module.
So that it will read the first line that will be header and then remaning data.
U can create an internal table.
TYPES: begin of ty_itab ,
name(4) TYPE c,
sex(3) Type c,
end of ty_itab.
DATA: i_itab type standard table of ty_itab,
w_itab type ty_itab.
Then do as below.
w_itab-name = 'NAME'.
w_itab-sex = 'SEX'.
APPEND w_itab to i_output_final.
i_output[] = i_output_final.
APPEND i_output_final.
Now pass this final table to the functionmodule, so it is now with header.
2007 Jul 20 11:05 AM
Hello,
Check this sample code:
DATA: LT_TAB TYPE TABLE OF STRING.
DATA: LR_TAB TYPE STRING,
L_F_NETPR_VE(21) TYPE C,
L_F_NETPR_UM(21) TYPE C,
L_F_ERDAT_VE(10),
L_F_ERDAT_UM(10),
L_F_PLAN(21) TYPE C,
L_F_IST(21) TYPE C,
L_F_OBLIGO(21) TYPE C,
L_F_WIP(21) TYPE C,
LV_FILE TYPE STRING,
L_F_COUNT TYPE I,
L_F_DATUM(10).
CLEAR: LT_TAB,LR_TAB.
REFRESH: LT_TAB.
CONCATENATE TEXT-U01 TEXT-U02 TEXT-U03 TEXT-U04 TEXT-U05
TEXT-U07 TEXT-U08 TEXT-U09 TEXT-U10 TEXT-U11 TEXT-U12
TEXT-U14 TEXT-U17 TEXT-U15 TEXT-U16 TEXT-U21 TEXT-U18
TEXT-U19 TEXT-U20 INTO LR_TAB
SEPARATED BY CON_TAB.
APPEND LR_TAB TO LT_TAB.
LOOP AT G_T_OUTTAB.
CLEAR: L_F_NETPR_VE,L_F_NETPR_UM, L_F_ERDAT_VE, L_F_ERDAT_UM,
L_F_PLAN,L_F_IST,L_F_OBLIGO.
WRITE: G_T_OUTTAB-NETPR_VE TO L_F_NETPR_VE,
G_T_OUTTAB-NETPR_UM TO L_F_NETPR_UM,
G_T_OUTTAB-ERDAT_VE TO L_F_ERDAT_VE,
G_T_OUTTAB-ERDAT_UM TO L_F_ERDAT_UM,
G_T_OUTTAB-PLAN TO L_F_PLAN,
G_T_OUTTAB-IST TO L_F_IST,
G_T_OUTTAB-OBLIGO TO L_F_OBLIGO,
G_T_OUTTAB-WIP TO L_F_WIP,
SY-DATUM TO L_F_DATUM.
CONCATENATE G_T_OUTTAB-PRATX G_T_OUTTAB-POSID G_T_OUTTAB-POST1
G_T_OUTTAB-WWGBE G_T_OUTTAB-WWGFE G_T_OUTTAB-VERNA
G_T_OUTTAB-STTXT_INT G_T_OUTTAB-STTXT_EXT
L_F_NETPR_VE L_F_ERDAT_VE L_F_NETPR_UM L_F_ERDAT_UM
L_F_PLAN L_F_IST L_F_OBLIGO L_F_WIP G_T_OUTTAB-VBELN_VE
G_T_OUTTAB-VBELN_UM L_F_DATUM
INTO LR_TAB SEPARATED BY CON_TAB.
APPEND LR_TAB TO LT_TAB.
ENDLOOP.
IF PC = 'X'.
LV_FILE = FILENAME.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = LV_FILE
FILETYPE = 'ASC'
TABLES
DATA_TAB = LT_TAB
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
LEAVE PROGRAM.
ELSE.
DESCRIBE TABLE LT_TAB LINES L_F_COUNT.
SUBTRACT 1 FROM L_F_COUNT.
MESSAGE I145 WITH L_F_COUNT FILENAME.
ENDIF.
VAsanth
2007 Jul 20 11:05 AM
Hi Jai,
You can try the following function modules for downloading data into the excel sheet.
1. <b>MS_EXCEL_OLE_STANDARD_OLE</b> : will build a file, and automatically
start Excel
2. <b>RH_START_EXCEL_WITH_DATA</b> : starts Excel with the contents of an internal
table. This function finds Excel in the desktop registry. It also uses a local
PC working directory to save the file (that's what the 'W' value for data path
flag does). Very transparent to user!
regards,
Thasneem