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

Open dataset not working

manubhutani
Active Contributor
0 Likes
845

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

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

6 REPLIES 6
Read only

former_member195698
Active Contributor
0 Likes
817

hi,

What exactly is your requirement.

Thanks & Regards

Abhishek

Message was edited by:

Abhishek Jolly

Read only

0 Likes
817

Hi

I am reading a file from UNIX app server.

Even if i dont gve filename on sel screen.

after open dataset sy-subrc returns 0

i dont know y its returnig it and from where its reading the garbage values

Read only

0 Likes
817

My assumption would be - it reads dierctory as File,so whatever under directory ,it shows data.

open dataset will give sy-subrc eq 0 ,if file opens ,so here directory becomes file and it is opening.

Thanks

Seshu

Read only

0 Likes
817

are you able to see this file in AL11..if no then path may be incorrect..

Read only

0 Likes
817

Hi Manu,

What might be happening is the path which u r giving......<b>at that path a dir mite be existing...</b>So u can use 2 separate FM to identify this.... <b><i>Use the following piece of code</b></i>&----


*& Form sub_file_presence_check

&----


  • Checking the existence of the file on application server

&----


FORM sub_file_presence_check .

*--Local data declaration

DATA : tl_file TYPE STANDARD TABLE OF spflist."returned table by FM

IF NOT p_file IS INITIAL.

*--Check to see if it is a directory or file and make sure it is a file

CALL FUNCTION 'RZL_READ_DIR'

EXPORTING

name = p_file "file name to be verified

TABLES

file_tbl = tl_file "returned table by FM

EXCEPTIONS

argument_error = 1

not_found = 2

send_error = 3

system_failure = 4

OTHERS = 5.

*--If file does not exist

IF sy-subrc = 0.

*--This is a directory

MESSAGE e000 WITH text-005.

ELSEIF sy-subrc <> 0.

*--Check for file name

CALL FUNCTION 'RZL_READ_FILE'

EXPORTING

name = p_file "file name to be verified

TABLES

line_tbl = tl_file "returned table by FM

EXCEPTIONS

argument_error = 1

not_found = 2

send_error = 3

system_failure = 4

OTHERS = 5.

IF sy-subrc <> 0.

MESSAGE e000 WITH text-006."'No such file exists'.

ENDIF.

ENDIF.

ELSE. "of if p_file is not initial

*--Please enter a file name

MESSAGE e000 WITH text-007.

ENDIF. ""of if p_file is not initial

ENDFORM. " sub_file_presence_check

Read only

0 Likes
817

Plz reward