2008 Jan 01 2:07 PM
Hello all,
I have a text tab delimited file in application server.I used open data set and sysubrc was 0 and when i tried to read the file i fot sy-subrc as 4......pls advice.....
filename like rlgrap-filename......."file name in Appln ser
file name
lv_itab(200) type char
OPEN DATASET pfilenaem FOR INPUT IN TEXT MODE DEFAULT MESSAGE.
here sy-subrc gives as 0
Read dataset pfilename into lv_itab.
here sy-subrc is givin as 4.....
i feel the pfilename is of file type and lv_itab is of type char so s ths causin error..........
pls advice....thanks in advance
Title edited by: Alvaro Tejada Galindo on Jan 1, 2008 9:47 AM
Hello all,
I have a text tab delimited file in application server.I used open data set and sysubrc was 0 and when i tried to read the file i fot sy-subrc as 4......pls advice.....
filename like rlgrap-filename......."file name in Appln ser
file name
lv_itab(200) type char
OPEN DATASET pfilenaem FOR INPUT IN TEXT MODE DEFAULT MESSAGE.
here sy-subrc gives as 0
Read dataset pfilename into lv_itab.
here sy-subrc is givin as 4.....
i feel the pfilename is of file type and lv_itab is of type char so s ths causin error..........
pls advice....thanks in advance
Title edited by: Alvaro Tejada Galindo on Jan 1, 2008 9:47 AM
2008 Jan 01 2:48 PM
You have to declare the lv_itab as an internal table.
declare something like this
DATA: BEGIN OF LV_ITAB OCCURS 0,
RECORD(1000),
END OF LV_ITAB.
You shud be fine.
Le'me know if you need any more
Vinodh Balakrishnan
2008 Jan 01 5:34 PM
Hi sapuser acc,
probably the length of your itab record (200) does not match the length of the record read.
Here is something that always works. The routine will also return the length of the longest record read.
types:
TYPE typ_t_string type table of string.
*&---------------------------------------------------------------------*
*& Form READ_TEXT_FILE
*&---------------------------------------------------------------------*
FORM read_text_file USING p_file TYPE file
CHANGING pt_str TYPE typ_t_string
p_maxs TYPE sytleng.
STATICS:
l_file TYPE file,
l_maxs TYPE sytleng,
lt_str TYPE typ_t_string.
DATA:
l_str TYPE string,
l_len TYPE sytleng.
* keep the file read last avoiding duplicate read
IF p_file <> l_file.
l_file = p_file.
CLEAR: l_maxs, lt_str.
OPEN DATASET p_file IN TEXT MODE ENCODING DEFAULT FOR INPUT
IGNORING CONVERSION ERRORS.
WHILE sy-subrc = 0.
READ DATASET p_file INTO l_str LENGTH l_len.
CHECK sy-subrc = 0.
IF l_len > l_maxs.
l_maxs = l_len.
ENDIF." l_len > l_maxs.
APPEND l_str TO lt_str.
ENDWHILE." sy-subrc = 0.
CLOSE DATASET p_file.
ENDIF." p_file <> l_file.
pt_str = lt_str.
p_maxs = l_maxs.
CHECK lt_str IS INITIAL.
CLEAR l_file.
MESSAGE s000 WITH 'File read error:' l_file '' ''.
* & & & &
ENDFORM. " READ_TEXT_FILE
Regards,
Clemens
2008 Jan 01 5:48 PM
check this
-
*To read the Source Unix file
FORM fr_open_file USING p_ufile.
OPEN DATASET p_ufile FOR INPUT IN TEXT MODE.
IF sy-subrc <> 0.
EXIT.
ENDIF.
DO.
READ DATASET p_ufile INTO in_file.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND in_file.
CLEAR in_file.
ENDDO.
CLOSE DATASET p_ufile.
LOOP AT in_file.
SPLIT in_file AT c_tab INTO
wa_citm_b-type
wa_citm_b-vbeln
wa_citm_b-posnr
wa_citm_b-uepos.
wa_citm_b-matnr
lv_menge
wa_citm_b-arktx
wa_citm_b-vbegdat
wa_citm_b-venddat
wa_citm_b-prctr
wa_citm_b-zterm
wa_citm_b-faksp
wa_citm_b-taxm1
wa_citm_b-vlaufz
wa_citm_b-vlauez
wa_citm_b-vlaufk
wa_citm_b-vkuegru
wa_citm_b-bstkd
wa_citm_b-bstdk
wa_citm_b-posex
wa_citm_b-bstkd_e
wa_citm_b-bstdk_e
wa_citm_b-period.
IF NOT wa_citm_b-posnr CA sy-abcde.
APPEND wa_citm_b TO lt_citm_b.
ENDIF.
ENDLOOP.
SORT lt_citm_b BY vbeln posnr.
DELETE ADJACENT DUPLICATES FROM lt_citm_b COMPARING vbeln posnr.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |