‎2006 Jun 01 7:55 AM
Hi,
can anyone tell me the length of datatype STRING .
Also tell me the FM used for Filepth in BDC.
Sonal
‎2006 Jun 01 8:07 AM
Hi Sonal,
i do it on this way:
...
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME
DEFAULT 'D:\SAP\*.TXT'.
...
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
*
DATA: PATH LIKE RLGRAP-FILENAME VALUE 'D:\SAP\'.
*
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = SPACE
DEF_PATH = PATH
MASK = ',.txt ,.txt.'
MODE = 'O'
TITLE = 'PC-File-Selection'
IMPORTING
FILENAME = P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
*
Regards, Dieter
‎2006 Jun 01 7:57 AM
STRINGS are variable in length. You can use STRLEN ( X ). TO FIND THE CURRENT LENGTH OF ONE.
‎2006 Jun 01 8:01 AM
Hi Neil,
Please tell me the FM for Popup for filepath in BDC.
Sonal
‎2006 Jun 01 8:01 AM
Hi,
you can use the key word STRLEN to find the length.
data : text type string.
data: len type i.
len = STRLEN ( text ).
and the fm is <b>F4_fielname</b>.
regards
vijay
‎2006 Jun 01 8:01 AM
hi sonal ,
length of datatype string is 8.
for reference check the following code.
DATA: lv_str TYPE string,
lv_i TYPE i.
DESCRIBE FIELD lv_str LENGTH lv_i.
WRITE lv_i.
‎2006 Jun 01 8:02 AM
Hi Sonal,
You can use the method file_open_dialog of the class CL_GUI_FRONTEND_SERVICES to get the filepath to be used in BDC.
For eg:
at selection-screen on value-request for path.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
WINDOW_TITLE = 'Open File'
DEFAULT_EXTENSION = '.'
DEFAULT_FILENAME =
FILE_FILTER =
INITIAL_DIRECTORY = 'D:\SP'
MULTISELECTION =
WITH_ENCODING =
CHANGING
file_table = file_tab[]
rc = ret_code
USER_ACTION = user_act
FILE_ENCODING =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5
.
Here <b>file_tab</b> will contain the path you have selected and <b>ret_code</b> will contain value of either you have clicked OK button or CANCEL button.
Regards,
SP.
‎2006 Jun 01 8:07 AM
Hi Sonal,
i do it on this way:
...
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME
DEFAULT 'D:\SAP\*.TXT'.
...
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
*
DATA: PATH LIKE RLGRAP-FILENAME VALUE 'D:\SAP\'.
*
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = SPACE
DEF_PATH = PATH
MASK = ',.txt ,.txt.'
MODE = 'O'
TITLE = 'PC-File-Selection'
IMPORTING
FILENAME = P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
*
Regards, Dieter
‎2006 Jun 01 8:13 AM
Hi Sonal,
Here is the sample code.
REPORT ZSHAIL_FILEPROG .
data: it_tab type filetable with header line,
gd_subrc type i.
tables: rlgrap.
selection-screen: begin of screen 200.
parameters file_nam type rlgrap-filename .
selection-screen: end of screen 200.
data: user_act type i.
start-of-selection.
call selection-screen 200.
at selection-screen on value-request for file_nam.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
WINDOW_TITLE = 'select a file'
DEFAULT_EXTENSION =
DEFAULT_FILENAME = ''
FILE_FILTER = '*.txt'
INITIAL_DIRECTORY = 'D:\SP'
MULTISELECTION = 'X'
WITH_ENCODING =
CHANGING
file_table = it_tab[]
rc = gd_subrc
USER_ACTION = user_act
FILE_ENCODING =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
if user_act = '0'.
read table it_tab index 1 .
file_nam = it_tab-filename.
endif.
Dieter,
I think WS_FILENAME_GET is an obsolete Function Module.
Regards,
SP.
‎2006 Jun 01 8:23 AM
m with ver. 4.7 . Is it fine if i use following FM -
CALL FUNCTION 'AL_POPUP_FOR_LOCAL_PATH'
EXPORTING
DOC_TYPE = 'TXT'
IMPORTING
FILERETURN = Filepath1
.
Is it fine ??????
Sonal
‎2006 Jun 01 8:27 AM
‎2006 Jun 01 8:30 AM
Hi Sonal,
What is your requirement exactly??
If you want to upload data from a flat file, just go through the program in my previous post. It will work..
The path will be stored in the <b>file_nam</b>.
Now you have to use GUI_UPLOAD to upload the data .In that Function Module, jsut give file_nam as the parameter for the path.
Regards,
SP.
‎2006 Jun 01 8:49 AM
Hi Sylendra,
i think you are right.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
...
is the better one and i will it use.
Thanks for the Info.
Regards, Dieter