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

validating the logical path

Former Member
0 Likes
1,310

Hi,,

how to validate the logical path entered on the selection screen.

5 REPLIES 5
Read only

Former Member
0 Likes
861

At selection-screen on p_field.

try.

opendataset p_field text mode encoding default.

if sy-subrc NE 0.

<< throw error message>>

endif.

endtry.

Read only

amit_khare
Active Contributor
0 Likes
861

There r two ways -

1. Use this FM and check the Filename entered on screen with the populated table.

CALL FUNCTION 'RZL_READ_DIR'

EXPORTING

name = directory

nrlines = 1

TABLES

file_tbl = file_table

EXCEPTIONS

argument_error = 1

not_found = 2

send_error = 3

OTHERS = 4.

2. Use open Dataset

open dataset d1........

if sy-subrc <> 0.

write:/ 'File path not found'.

endif.

try this FM also.

DX_FILE_EXISTENCE_CHECK

Regards,

Amit

Reward all helpful replies.

Read only

Former Member
0 Likes
861

Hi,

Use the Fucntion module FILE_GET_NAME to Retrieve Logical file path.

For example, look at the below code

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db95e635c111d1829f0000e829fbfe/content.htm

Regards

Sudheer

Read only

former_member404244
Active Contributor
0 Likes
861

Hi,

check the piece of code..

*--Call the function module to get the physical file name for the

  • logical file path provided.

DATA: lv_mandt LIKE sy-mandt,

lv_opsys LIKE sy-opsys.

MOVE: sy-mandt TO lv_mandt,

sy-opsys TO lv_opsys.

CALL FUNCTION 'FILE_GET_NAME'

EXPORTING

client = lv_mandt

logical_filename = p_lpn

operating_system = lv_opsys

IMPORTING

file_name = v_fname1

EXCEPTIONS

file_not_found = 1

OTHERS = 2.

IF sy-subrc NE 0.

  • File not found.

MESSAGE i137.

LEAVE LIST-PROCESSING.

ENDIF.

reward if helpful..

Regards,

Nagaraj

Read only

Former Member
0 Likes
861

sorry,,,

i have to validate the physical path entered by the user not logical path..

i can use open dataset..

but if the user enters only directory then also it will give sy-subrc 0.

please tell me how to validate the file.