Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Data Type 'STRING'

Former Member
0 Likes
1,411

Hi,

can anyone tell me the length of datatype STRING .

Also tell me the FM used for Filepth in BDC.

Sonal

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,360

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

11 REPLIES 11
Read only

former_member186741
Active Contributor
0 Likes
1,360

STRINGS are variable in length. You can use STRLEN ( X ). TO FIND THE CURRENT LENGTH OF ONE.

Read only

0 Likes
1,360

Hi Neil,

Please tell me the FM for Popup for filepath in BDC.

Sonal

Read only

Former Member
0 Likes
1,360

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

Read only

0 Likes
1,360

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.

Read only

Former Member
0 Likes
1,360

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.

Read only

Former Member
0 Likes
1,361

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

Read only

0 Likes
1,360

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.

Read only

0 Likes
1,360

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

Read only

0 Likes
1,360

Use <b>F4_FILENAME</b>

regards

vijay

Read only

0 Likes
1,360

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.

Read only

0 Likes
1,360

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