‎2005 Dec 23 6:46 AM
Hi All
I have to display a selection screen to the user to upload date from the application server or he can upload using EXCEL file.
If he want to select that file from application server what code I have to do.
Give me the function module name for uploading excel file to BDC.
Regards
Praveen
‎2005 Dec 23 7:03 AM
Hi!
To display file selection dialog for application server files proceed as follows:
DATA:
c_file_mask TYPE dxfields-filemask VALUE '*',
searched_dir TYPE dxfields-longpath,
file_path LIKE dxfields-longpath.
searched_dir = 'INITIAL_DIRECTORY_TO_START_WITH'.
TRANSLATE searched_dir TO LOWER CASE .
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
i_location_flag = 'A'
i_server = ' '
i_path = searched_dir
filemask = c_file_mask
FILEOPERATION = 'R'
IMPORTING
O_LOCATION_FLAG =
O_SERVER =
o_path = file_path
ABEND_FLAG =
EXCEPTIONS
rfc_error = 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.
file_path is the full path of selected file.
Hope it helps.
Regards,
Maxim.
‎2005 Dec 23 6:50 AM
ALSM_EXCEL_TO_INTERNAL_TABLE
use this to upload excel to internal table
vijay
‎2005 Dec 23 6:51 AM
HI Praveen,
If you will try to upload excel file from the application server it will give many errors. Better upload tab delimited text file from application server.
You can use OPEN DATASET statement for that.
Do F1 on this and you will find detail procedure.
Regards,
Atish
‎2005 Dec 23 6:52 AM
what exactly your requirement..
vijay
Message was edited by: Vijay Babu Dudla
‎2005 Dec 23 10:29 AM
Hi Vijay
Here I have to give options to user either he can upload data from excel sheet or from application server.
Regarding to this one I wanna to give a selection-screen giving the excel file name of application server file path. What I have to do for this one.
What is the procedure for getting the data to upload ".CSV" file.
Regards
Praveen
‎2005 Dec 23 10:45 AM
using FM ALSM_EXCEL_TO_INTERNAL_TABLE
upload the data to internal table, that is comma delimited file, so you can do in the other way...
data: begin of itab occurs 0,
line(300) type c,
end of itab.
data: begin of it_data occurs 0,
field1..
field2...
end of it_data.
call function 'GUI_UPLOAD'
exporting
filename = 'C:file.csv'
filetype = 'ASC'
tables
data_tab = itab.
loop at itab.
split itab-lineat ',' into
it_data-field1
it_data-field2
it_data-field3.
append it_data.
endloop.p_fiel will come from selection screen.
give p_file type rlgrap-filename in the selection screen.
parameters: p_file like rlgrap-filename.
open dataset p_file for output in textmode encoding default.
if sy-subrc = 0.
Loop at it_data.
transfer it_data to p_file.
endloop.
endif.
cloase dataset p_file.vijay
Message was edited by: Vijay Babu Dudla
‎2005 Dec 23 10:58 AM
Hi Praveen,
Can you be a bit clear as I am still not sure whatz the req is and where are you stuck?
For CSV files on your presentation server, you can use FM KCD_CSV_FILE_TO_INTERN_CONVERT to upload it into internal table. The return parameter is of type kcde_intern.
Hope this helps....
Regards,
Srikanth
‎2005 Dec 23 7:00 AM
Hi praveen,
1. I don't think there is any FM
which can display to the user
a dialog screen to select files
from APPLICATION SERVER.
(The path needs to be mentioned directly
as a string/character)
2. For front-end pc,
the FM is
F4_FILENAME.
regards,
amit m.
‎2005 Dec 23 7:03 AM
Hi!
To display file selection dialog for application server files proceed as follows:
DATA:
c_file_mask TYPE dxfields-filemask VALUE '*',
searched_dir TYPE dxfields-longpath,
file_path LIKE dxfields-longpath.
searched_dir = 'INITIAL_DIRECTORY_TO_START_WITH'.
TRANSLATE searched_dir TO LOWER CASE .
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
i_location_flag = 'A'
i_server = ' '
i_path = searched_dir
filemask = c_file_mask
FILEOPERATION = 'R'
IMPORTING
O_LOCATION_FLAG =
O_SERVER =
o_path = file_path
ABEND_FLAG =
EXCEPTIONS
rfc_error = 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.
file_path is the full path of selected file.
Hope it helps.
Regards,
Maxim.
‎2005 Dec 23 7:12 AM
Hi using ALSM_EXCEL_TO_INTERNAL_TABLE function module first upload the excel to internal table.
then
loop at itab.
open dataset........
endloop.
satish
‎2005 Dec 23 11:09 AM
Hi,
Here is the sample code to get F4 help for application server.Kindly reward points by clicking the star on the left of reply,if it helps.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
F4 help for the flat file path
PERFORM f4_filepath USING 'P_FILE' p_file.
FORM f4_filepath USING p_applfile p_presfile.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = p_applfile
dyname = sy-cprog
dynumb = sy-dynnr
filetype = c_p
location = c_a
server = space.
ENDFORM. " F4_FILEPATH
‎2005 Dec 23 10:52 AM
Hi Praveen
your problem is upload the file or see a file browser for application server?
‎2005 Dec 23 10:53 AM
Hi Praveen,
If you want to give F4 help for the Application server
then use the below func.
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = ' '
filemask = ' '
IMPORTING
serverfile = dl_file
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e999 WITH 'Error while getting the file name'(036).
ELSE.
p_file = dl_file.
ENDIF.
Hope this will help you.
Thanks&Regards,
Siri.
‎2005 Dec 23 11:08 AM
Hey Praveen,
Please see the Below Code Which really Helps you a lot.
To Upload the Excel Sheet, Please use this FM Below.
parameter: File1 like RLGRAP-filename.
parameter: File2 like RLGRAP-filename.
For Navigation Help say like F4 Functionality, Please use the Below Code and go on.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE1.
CALL FUNCTION 'NAVIGATION_FILENAME_HELP'
IMPORTING
SELECTED_FILENAME = FILE1.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = File1
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 256
I_END_ROW = 65536
TABLES
INTERN = it_itab
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.
Where It_tab is the Internal Table equal to the Structure of Excel Sheet.
Well, If you want to take it from the Application Server, Please use the Below Code For Upload from the Application Server.
DATA: WA(30000).
DATA: SEPARATOR TYPE X VALUE 09.
Open DataSet ****
OPEN DATASET file2 FOR INPUT IN TEXT MODE.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'FILE COULD NOT BE OPENED'(104).
EXIT.
ELSE.
DO.
READ DATASET file 2INTO
INT_TAB_TEMP-INPUT.
IF SY-SUBRC = 0.
APPEND INT_tab_TEMP.
CLEAR INT_tab_TEMP.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
Close DataSet ****
CLOSE DATASET file2.
Once you Open the File for Output, Please use the Below Code for Conversion.
CLEAR: INT_tab_final, INT_tab_TEMP.
LOOP AT INT_tab_TEMP.
SPLIT INT_tab-INPUT AT SEPARATOR INTO
*Please populate the splitted fields
Int_tab_Final - Fields
APPEND INT_tab_final.
CLEAR INT_tab_final.
ENDLOOP.
REFRESH: INT_tab_temp.
SORT INT_tab_final.
DELETE ADJACENT DUPLICATES FROM INT_tab_final
COMPARING ALL FIELDS.
, Then you can use this Internal Table(int_tab_final) for Display or Inserting into the DB tables.
Please do let me know any Issues.
Note: If you feel this code works you a lot, Please allot Points for Very Useful Answer.
Thanks,
Satya KRishna.M
‎2005 Dec 30 9:53 AM
‎2005 Dec 30 9:56 AM