2007 Apr 08 8:32 AM
Hi All,
I required to read the data from application server, which the data is in below layout. Each fields are separated by tab. How I can read each of the fields and append to internal table.
Field1#Field2#Field3
Below are my current coding which unable to read out the fields. Please kindly help me to correct it...if i'm wrongly. Thanks.
OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE.
DO.
READ DATASET p_inpfl INTO i_input.
IF sy-subrc EQ 0.
APPEND i_input.
CLEAR i_input.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET p_inpfl.
ENDIF.
2007 Apr 08 8:45 AM
Hi..,
U need to mention the ENCODING mode here...
OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE <b>ENCODING DEFAULT</b>.
DO.
READ DATASET p_inpfl INTO i_input.
IF sy-subrc EQ 0.
APPEND i_input.
CLEAR i_input.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET p_inpfl.
ENDIF.
Hope this solves..
u can use <b>SPLIT INTO ITAB</b> to populate the internal table with Each and every field value separately !!
regards,
sai ramesh
Hi..,
U need to mention the ENCODING mode here...
OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE <b>ENCODING DEFAULT</b>.
DO.
READ DATASET p_inpfl INTO i_input.
IF sy-subrc EQ 0.
APPEND i_input.
CLEAR i_input.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET p_inpfl.
ENDIF.
Hope this solves..
u can use <b>SPLIT INTO ITAB</b> to populate the internal table with Each and every field value separately !!
regards,
sai ramesh
2007 Apr 08 8:45 AM
Hi..,
U need to mention the ENCODING mode here...
OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE <b>ENCODING DEFAULT</b>.
DO.
READ DATASET p_inpfl INTO i_input.
IF sy-subrc EQ 0.
APPEND i_input.
CLEAR i_input.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET p_inpfl.
ENDIF.
Hope this solves..
u can use <b>SPLIT INTO ITAB</b> to populate the internal table with Each and every field value separately !!
regards,
sai ramesh
2007 Apr 08 8:53 AM
Hi,
I get error message in - Type...filter...message....or at position...expected after mode.
How I should make changed to current code if I using
OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE <b>ENCODING DEFAULT</b>.
Thank you.
2007 Apr 08 9:01 AM
HI..
is that i_input your final table.. ?? which contains the individual fields along with their values.. Or onli it saves the entire line read from the file ??
2007 Apr 08 9:06 AM
Hi Sai ramesh,
i_input is not my final table..
I just want to read the data from application server ..then append all these values into i_input. Later I required to select the first field from i_input to extract data from others tables.
Hope this's clarify.
Thanks.
2007 Apr 08 9:23 AM
Ok fine ..
keep your original source code as it is ..
OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE.
DO.
READ DATASET p_inpfl INTO i_input.
IF sy-subrc EQ 0.
APPEND i_input.
CLEAR i_input.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET p_inpfl.
ENDIF.
The character '#' is a Horizontal tab ..
Those '#' are special characters to indicates new line or tab. You need to use the abap objects CL_ABAP_CHAR_UTILITIES to fix this issue.
define a constant..
constants :
C_HTAB value CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.<b> **<--Horizontal tab</b>
loop at i_input.
split i_input at C_HTAB into i_finaltab-field1 i_input.
split i_input at C_HTAB into i_finaltab-field2 i_input.
split i_input at C_HTAB into i_finaltab-field3 i_input.
split i_input at C_HTAB into i_finaltab-field4 i_input.
append i_tab.
endloop.
regards,
sai ramesh
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |