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

code

Former Member
0 Likes
464

Hi experts,

See the following code.

Afetr endo again the curosr is going to read dataset.

It should not go..

What may be the problem?

loop at ifile into wa_files.

concatenate p_path wa_files-name into p_file.

open dataset p_file for input in text mode encoding default.

if sy-subrc = 0.

do.

read dataset p_file into l_str.

if sy-subrc <> 0.

concatenate text-002 p_file into it_error-err.

append it_error.

clear it_error.

exit.

else.

jtab-text = l_str.

append jtab.

endif.

enddo.

else.

concatenate text-001 p_file into it_error-err.

append it_error.

clear it_error.

continue.

endif.

endloop.

loop at jtab.

write:/ jtab.

endloop.

4 REPLIES 4
Read only

Former Member
0 Likes
429

hi Ravi,

Add the code in bold

loop at ifile into wa_files.
concatenate p_path wa_files-name into p_file.

open dataset p_file for input in text mode encoding default.
if sy-subrc = 0.
do.
read dataset p_file into l_str.
<b>if l_str = space.
 exit.
endif.</b>
if sy-subrc <> 0.
concatenate text-002 p_file into it_error-err.
append it_error.
clear it_error.
exit.
else.
jtab-text = l_str.
append jtab.
endif.
enddo.
else.

concatenate text-001 p_file into it_error-err.

append it_error.
clear it_error.
continue.
endif.
endloop.

loop at jtab.
write:/ jtab.
endloop.

Read only

Former Member
0 Likes
429

Hi

Because you have insert the loop DO/ENDDO into LOOP/ENDLOOP.

Max

Read only

Former Member
0 Likes
429

Hi Ravi

Read Data Set is in DO loop and your Exit is inside IF condition. If the code sy-subrc = 0 then it will goto ELSE block and the read is performed again. Untill sy-subrc <> 0 Loop will be performed.

Read only

Former Member
0 Likes
429

hi Ravi,

Check out this way ..

read dataset p_file into l_str.

if sy-subrc <> 0.

concatenate text-002 p_file into it_error-err.

append it_error.

clear it_error.

exit.

else.

jtab-text = l_str.

append jtab.

<b>CLEAR JTAB.</b>

endif.

enddo.

else.

concatenate text-001 p_file into it_error-err.

append it_error.

clear it_error.

continue.

endif.

endloop.