‎2006 Sep 15 1:08 PM
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.
‎2006 Sep 15 1:15 PM
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.
‎2006 Sep 15 1:16 PM
Hi
Because you have insert the loop DO/ENDDO into LOOP/ENDLOOP.
Max
‎2006 Sep 15 1:17 PM
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.
‎2006 Sep 15 1:21 PM
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.