Application Development 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: 

Error in populating data

Former Member
0 Kudos

Hi,

I am taking the data from a file which is available on application server. During reading of file I am storing the data into an internal table. But the problem is, System is taking the data with '#' while passing the data to internal table. Means it is not treating # as a next column. For example if the table line's (file) contains "3#78#N456#78945#" data system is passing it to internal table in the following format (itab-field1 = '3', itab-field2 = '#78' itab-fld3 = '#N456' and so on..

Pls suggest me how to handle it. I am using the following code for updating the table.

data : begin of t_itab occurs 0,

fld1(1),

fld2(3),

fld3(4),

fld4(5),

....

....

fld50(5),

end of t_itab.

OPEN DATASET V_FILE IN TEXT MODE encoding DEFAULT .

IF SY-SUBRC = 0.

DO.

READ DATASET V_FILE INTO t_itab.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

APPEND T_ITAB.

CLEAR T_ITAB.

ENDDO.

ELSE.

WRITE: / 'Error in open file'.

ENDIF.

CLOSE DATASET v_file.

Note : We do't know how many fields are available in the txt file on application server.. so we are assuming that file can contains upto 50 fields that's why I have declared 50 fields in internal table.

pls suggest something.

Thanks,

5 REPLIES 5

Former Member
0 Kudos

Hello Pradeep,

How do you uploading file on application server.

While uploading file on application server which you are reading using open dataset upload it in ASC file format.

This will solve your problem.

Cheers,

Nilesh

Former Member
0 Kudos

Yes it is available in ASC format.

0 Kudos

I remember even I face this problem in one of my interface.....and solution was simple, just upload it in ASC format. If you try to upload in text format it inserts junc characters for line feed.

Anyway ...How do you upload file on application server?

You can use transaction CG3Z / CG3Y to upload and download file on application server. Select file type as ASC and upload it again. I think this will solve your problem.

Cheers,

Nilesh

0 Kudos

Hi,

My problem got resolved. thanks for kind copeartion.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I believe that the # is the tab in your file. You will need to split the line at the tab by using the cl_abap_char_utilities=>horizontal_tab.

data: str type string.

READ DATASET V_FILE INTO str.

split str at l_abap_char_utilities=>horizontal_tab into t_tab-fld1
t_tab-fld2
t_tab-fld3
t_tab-fld4
t_tab-fld5
t_tab-fld6
t_tab-fld7
t_tab-fld8
...

You can also use the <b>SPLIT into table itab</b>And fill in the fields using some creative programming.

Regards,

Rich Heilman