2006 Aug 02 11:58 AM
Hi All!
I am downloading DAT file from appl. server with the following code.But when i execute my program my system hangs ocassionally and i have to manually stop the transaction.Any problem with my code.Please advise.
FORM f_dcs_file_extract .
OPEN DATASET p_file FOR INPUT
IN TEXT MODE
ENCODING DEFAULT.
CLEAR g_car_ret.
CLEAR g_lin_fed.
MOVE cl_abap_char_utilities=>cr_lf TO g_car_ret.
MOVE cl_abap_char_utilities=>cr_lf TO g_lin_fed.
DO.
TRY.
Read the current row of the file
READ DATASET p_file INTO w_dcs_file.
IF sy-subrc NE 0.
EXIT. "End of file entries
ENDIF.
CATCH cx_root.
'Invalid input file format :Extraneous column'(048).
ENDTRY.
Remove the trailing carriage return character, if any
SEARCH w_dcs_file FOR g_car_ret.
IF sy-subrc EQ 0.
CLEAR g_pos.
MOVE sy-fdpos TO g_pos.
REPLACE w_dcs_file+g_pos(1) IN w_dcs_file WITH space.
ENDIF.
Remove the trailing line feed character, if any
SEARCH w_dcs_file FOR g_lin_fed.
IF sy-subrc EQ 0.
CLEAR g_pos.
MOVE sy-fdpos TO g_pos.
REPLACE w_dcs_file+g_pos(1) IN w_dcs_file WITH space.
ENDIF.
w_dcs_file-ois_item = w_dcs_file+0(6).
w_dcs_file-quan = w_dcs_file+21(7).
w_dcs_file-status = w_dcs_file+32(2).
Internal Table i_dcs_file contains all data read from appl. server.
APPEND w_dcs_file TO i_dcs_file.
CLEAR w_dcs_file.
ENDDO.
CLOSE DATASET p_file.
ENDFORM.
Regards
Praneeth
Hi All!
I am downloading DAT file from appl. server with the following code.But when i execute my program my system hangs ocassionally and i have to manually stop the transaction.Any problem with my code.Please advise.
FORM f_dcs_file_extract .
OPEN DATASET p_file FOR INPUT
IN TEXT MODE
ENCODING DEFAULT.
CLEAR g_car_ret.
CLEAR g_lin_fed.
MOVE cl_abap_char_utilities=>cr_lf TO g_car_ret.
MOVE cl_abap_char_utilities=>cr_lf TO g_lin_fed.
DO.
TRY.
Read the current row of the file
READ DATASET p_file INTO w_dcs_file.
IF sy-subrc NE 0.
EXIT. "End of file entries
ENDIF.
CATCH cx_root.
'Invalid input file format :Extraneous column'(048).
ENDTRY.
Remove the trailing carriage return character, if any
SEARCH w_dcs_file FOR g_car_ret.
IF sy-subrc EQ 0.
CLEAR g_pos.
MOVE sy-fdpos TO g_pos.
REPLACE w_dcs_file+g_pos(1) IN w_dcs_file WITH space.
ENDIF.
Remove the trailing line feed character, if any
SEARCH w_dcs_file FOR g_lin_fed.
IF sy-subrc EQ 0.
CLEAR g_pos.
MOVE sy-fdpos TO g_pos.
REPLACE w_dcs_file+g_pos(1) IN w_dcs_file WITH space.
ENDIF.
w_dcs_file-ois_item = w_dcs_file+0(6).
w_dcs_file-quan = w_dcs_file+21(7).
w_dcs_file-status = w_dcs_file+32(2).
Internal Table i_dcs_file contains all data read from appl. server.
APPEND w_dcs_file TO i_dcs_file.
CLEAR w_dcs_file.
ENDDO.
CLOSE DATASET p_file.
ENDFORM.
Regards
Praneeth
2006 Aug 02 12:04 PM
Is that not possible to do all the manipulations outside the DO...ENDDO and then <b>TRANSLATE</b> the formatted one as output?
Cheers,
Thomas.
2006 Aug 02 12:09 PM
Hi Mann!
Do you think because of DO and ENDDO I am facing this problem.Maybe wrong declaration of the DO and END DO syntax.
Regards
Praneeth
2006 Aug 02 12:31 PM
Hello,
Yes.. you have a probelm in you do .. enddo.
You have to stop your loop at some time.
like
do
read p_file into l_line.
if sy-subrc <> 0.
exit.
endif.
.... rest procesing
enddo
regards,
Naimehs