12-15-2006 7:56 AM
hi explain the logic for the flatfile maintaining in the excelsheet.
from r/3 to excelsheet.
from excelsheet to ps&as
12-15-2006 8:12 AM
HI karthik,
*Logic for the flatfile maintaining in the excelsheet.
Give the filename with extension '.XLS' and use FM: GUI_DOWNLOAD to presentation server.
Check this simple example for some idea:
types: begin of t_dat,
bukrs type bukrs,
sep(10) type c,
butxt type butxt,
end of t_dat.
data: it_dat type table of t_dat,
wa_dat type t_dat.
select bukrs butxt into corresponding fields of table it_dat
from t001.
data: file type string value 'C:\Comp_Codes.xls'.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
FILENAME = FILE
WRITE_FIELD_SEPARATOR = 'X'
CHANGING
DATA_TAB = IT_DAT[]
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
NOT_SUPPORTED_BY_GUI = 22
ERROR_NO_GUI = 23
others = 24.
________________________________________
Sample source for uploading data from excel into any ztable.
You can use the following code and get an idea
-
REPORT ZEXCEL_TO_INTERNAL .
data: begin of itab occurs 0,
name(20) type c,
addre(20) type c,
end of itab.
DATA : ITAB1 LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
DATA : B1 TYPE I VALUE 1,
C1 TYPE I VALUE 1,
B2 TYPE I VALUE 100,
C2 TYPE I VALUE 9999.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME =
'C:\Documents and Settings\administrator\Desktop\ppcon001bd_24.xls'
I_BEGIN_COL = B1
I_BEGIN_ROW = C1
I_END_COL = B2
I_END_ROW = C2
TABLES
INTERN = itab1
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 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.
loop at itab1.
write:/ itab1.
Endlop.
_________________
R/3 to excelsheet:
______________
Please check these threads for sample codes.
https://forums.sdn.sap.com/click.jspa?searchID=233062&messageID=2701893
Hope this will help.
Regards,
Kumar
12-15-2006 8:37 AM
Hi Karthik
I guess this example can give you some idea:
data: it_t001 type table of t001.
field-symbols: <wa>.
select * into table it_t001
from t001.
*** Downloading to Presentation Server
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
FILENAME = 'C:Comp_Codes.xls'
WRITE_FIELD_SEPARATOR = 'X'
CHANGING
DATA_TAB = it_t001[]
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
NOT_SUPPORTED_BY_GUI = 22
ERROR_NO_GUI = 23
others = 24.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*** Downloading to application server
data: fname type filename value '/usr/sap/comp_code.xls'.
open dataset fname for output in text mode encoding default.
if sy-subrc ne 0.
write:/ 'Unable to open application server file'.
else.
loop at it_t001 assigning <wa>.
transfer <wa> to fname.
endloop.
close dataset fname.
endif.
Kind Regards
Eswar