‎2007 Oct 14 4:26 PM
Hi Guru's
I am reading from the UNIX application server.
Even if I dont give the file name.Sy-subrc remains zero after open dataset.
I am giving this file path in initialization '/devabap/if/hcm/out/'
but after that i am not giving any file name.
OPEN DATASET p_infile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
DO.
READ DATASET p_infile INTO wa_file.
IF sy-subrc = 0.
APPEND wa_file TO t_file.
ELSE.
EXIT.
ENDIF.
ENDDO.
ELSE.
MESSAGE i030 WITH p_infile.
ENDIF.
CLOSE DATASET p_infile.
Please help
‎2007 Oct 14 4:40 PM
Put a validation in code to see if file name is entered in selection screen. If not, display an error message. As your user id has read and permission, it is returning SY-SUBRC as 0. But this is not your requirement. Add the validation and it should help.
ashish
‎2007 Oct 14 4:40 PM
Put a validation in code to see if file name is entered in selection screen. If not, display an error message. As your user id has read and permission, it is returning SY-SUBRC as 0. But this is not your requirement. Add the validation and it should help.
ashish
‎2007 Oct 14 4:50 PM
Hi
Have awarded u points
But still i read write permissions are there
from where it is reading when idont give a file name.
1 more thing i am not using F4 help
user can change the path as well
how can i check whether user has entered a file name?
‎2007 Oct 14 5:00 PM
Hi,
For checking you can do something like this:
AT SELECTION-SCREEN.
Check if the Directory Exists, If not display Error
gv_file = p_promo.
PERFORM split_dir USING gv_file.
IF cl_gui_frontend_services=>directory_exist( gv_path ) <> 'X'.
message text-e01 type 'E'. "Directory doesnt exist
EXIT.
ENDIF.
FORM split_dir USING iv_fullpath TYPE string.
DATA:
lv_temp type I.
lv_temp = strlen( iv_fullpath ) - 1.
if lv_temp <= 0.
message text-e01 type 'E'.
endif.
while ( iv_fullpath+lv_temp(1) NE '\' ).
subtract 1 from lv_temp.
if lv_temp <= 0.
message text-e01 type 'E'.
endif.
endwhile.
add 1 to lv_temp.
gv_path = iv_fullpath(lv_temp).
ENDFORM. " split_dir
Here it checks if the directory specified exists or not.
It should help your case.
Sri
‎2007 Oct 14 5:03 PM
You can make the file parameter mandatory and also add search help for Application server file -
It is possible to retrieve the name of a file server by pressing F4 rs_get_f4_dir_from_applserv the program.
Código: Code:
SELECTION-SCREEN BEGIN OF BLOCK 002 WITH FRAME TITLE text-002. SELECTION-SCREEN BEGIN WITH FRAME 002 BLOCK OF TITLE text-002.
PARAMETERS : p_aps LIKE rlgrap-filename MODIF ID pth . PARAMETERS: p_aps LIKE rlgrap-filename COMMISS ID pth.
SELECTION-SCREEN END OF BLOCK 002. SELECTION-SCREEN END OF BLOCK 002.
DATA : path_name(150) TYPE c. DATA: (150) TYPE file_name c.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_aps. AT SELECTION-SCREEN ON FOR VALUE-REQUEST p_aps.
SUBMIT rs_get_f4_dir_from_applserv AND RETURN. Rs_get_f4_dir_from_applserv SUBMIT AND RETURN.
IMPORT path_name FROM MEMORY ID 'PATH_NAME_SDL'. IMPORT FROM MEMORY ID file_name 'PATH_NAME_SDL'.
p_aps = path_name. P_aps = file_name.
Also you can check the file entered is a valid or not by doing the validation suggested by Sri.
ashish
‎2007 Oct 14 5:09 PM
I am not required to have a search help.
The code given by sri is not clear.
can you help?
‎2007 Oct 14 5:27 PM
Slight modification:
AT SELECTION-SCREEN.
Check if the Directory Exists, If not display Error
gv_unproc = p_unproc.
PERFORM split_dir USING gv_unproc.
IF cl_gui_frontend_services=>directory_exist( gv_path ) <> 'X'.
message text-e01 type 'E'. "Directory doesnt exist
EXIT.
ENDIF.
FORM split_dir USING iv_fullpath TYPE string.
DATA:
lv_temp type I,
lv_len type I.
lv_temp = strlen( iv_fullpath ) - 1.
if lv_temp <= 0.
message text-e01 type 'E'.
endif.
while ( iv_fullpath+lv_temp(1) NE '\' ).
subtract 1 from lv_temp.
if lv_temp <= 0.
message text-e01 type 'E'.
endif.
endwhile.
add 1 to lv_temp.
lv_len = strlen( iv_fullpath ) - lv_temp.
gv_path = iv_fullpath(lv_temp).
gv_file = iv_fullpath+lv_temp(lv_len).
So this code actually splits the Path and the Filename, the gv_path consists of the Path
and gv_file would contain the filename.
So in your case you can just make sure that gv_file is not INITIAL. if it is you can throw an error message to enter the filename.
Hope i make sense.
Cheers
Sri