Application Development and Automation 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: 
Read only

Reading data from appliation server to internal table

Former Member
0 Likes
9,219

Hi all,

I am trying to read application server file to internal table and displaying in ALV format.

But while reading data from application server the data has '#", kindly advice me how to remove it.

Want to remove the special chararcet '#" from the internal table.

Regards,

Rohini

Hi all,

I am trying to read application server file to internal table and displaying in ALV format.

But while reading data from application server the data has '#", kindly advice me how to remove it.

Want to remove the special chararcet '#" from the internal table.

Regards,

Rohini

23 REPLIES 23
Read only

Former Member
0 Likes
7,557

Hi Rohini,

Check this forum

http://scn.sap.com/thread/306888

Try this code.

Thanks,

Pradeep.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
7,557

Try to change the ENCODING option of OPEN DATASET.

Regards,

Raymond

Read only

0 Likes
7,557

Kindly can u advice me wat are the option currently in my code, we have

OPEN DATASET p_path1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.

Regards,

Rohini

Read only

former_member821147
Participant
0 Likes
7,557

Hi Rohini,

First check the data in application server by using AL11.If the data contains # in Application server then try below code.

OPEN DATASET P_PATH1 FOR INPUT IN BINARY MODE.

Regards,

Pradeep.P

Read only

0 Likes
7,557

Hi Pradeep,

I tried this code also, but it is pickin only the first row.

It is not picking all the rows from the application server.

Regards,

Rohinit.

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
7,557

You need to read the lines in a loop, something like this:

  OPEN DATASET filepath FOR INPUT IN TEXT MODE ENCODING DEFAULT.

<...>

    WHILE sy-subrc = 0.

      READ DATASET filepath INTO <structure>.

      IF sy-subrc <> 0.

        EXIT.

      ENDIF.

      APPEND <structure> TO i_table.

    ENDWHILE.

I also used READ DATASET into xstring type variable for binary files.

However, it might be more complex than you think and there might be more to it than removing '#' characters. This looks similar to a wire payment file and those need to be opened by a special transaction.

Read only

Former Member
0 Likes
7,557

Hi Rohini,

Character # can be anything. It can be actually be HASH or it can be any character which cannot be represented. Eg. Tabs, Enter characters, character set not included in your codepage Eg. Japanese on English language. You need to find out what it is you are dealing with here.

PS - All the special characters are under cl_abap_char_utilities. Eg tab is cl_abap_char_utilities=>horizontal_tab.

Regards,

Shravan

Read only

Former Member
0 Likes
7,557

Hi,

Using OPEN DATASET keyword to read a file from application server, there are chances these might not get converted perfectly.

use the extension IGNORING CONVERSION ERRORS to the OPEN DATASET statement.

example:

OPEN DATASET P_PATH1 FOR INPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS.

Read only

Former Member
0 Likes
7,557

Hi,

First check the data inapplication server how its contain. If its contain is # or , seperater of each field value. And also check the what is the separter of each line end with is it # on blank. So based on the separter you can read data internal table of string type.

You can try using bellow class method. May help out you.

CALL METHOD cl_rsan_ut_appserv_file_reader=>appserver_file_read
    EXPORTING
      i_filename   = lv_err_path
    CHANGING
      c_data_tab   = it_out
    EXCEPTIONS
      open_failed  = 1
      read_failed  = 2
      close_failed = 3
      OTHERS       = 4.

here lv_err_apth application server file name and it_out type string type is internal table type of reading data.

Then you can format the data of which you requried from it_out internal table.

Regards,

Suresh M

Read only

0 Likes
7,557

Hi Suresh,

I tried ur code, then also in my internal table i am getting the data withh "#" symbol.

Please find the screen shot.

And when i try to replace the # symbol, i am not able to do.

Kindly advice me wat to do.

Regards,

Rohini    

Read only

0 Likes
7,557

Hi Rohini,

If you can post your code

Read only

0 Likes
7,557

Hi all,

Please find my code below.

REPORT  ZSTEST.
TYPE-POOLS: RSANM.



DATA :DSN VALUE '\\NY-ECCDEVSRVR\ECD_INTERFACES\EUR\3010\A\0491' TYPE STRING.

DATA : RECORD(100) .
DATA: IT_OUT  TYPE  RSANM_FILE_TABLE.

CALL METHOD cl_rsan_ut_appserv_file_reader=>appserver_file_read

    EXPORTING
      i_filename   = DSN
    CHANGING
      c_data_tab   = it_out
    EXCEPTIONS
      open_failed  = 1
      read_failed  = 2
      close_failed = 3
      OTHERS       = 4.

In the application server my data is in this form

But in the internal table it is coming in this format

Read only

0 Likes
7,557

In the debug mode if the SUBRC = 0 i think your data has been read successfully.

Try to write the internal table data by write statement and see'#' symbol is printing or not.

Thanks,

Pradeep.

Read only

0 Likes
7,557

In the debug mode if the SUBRC = 0 i think your data has been read successfully.

Try to write the internal table data by write statement and see'#' symbol is printing or not.

Thanks,

Pradeep.

Read only

0 Likes
7,557

In the debug mode if the SUBRC = 0 i think your data has been read successfully.

Try to write the internal table data by write statement and see'#' symbol is printing or not.

Thanks,

Pradeep.

Read only

0 Likes
7,551

Hi Pradeep,

I tried to write the internal table data, then also the # symbol is coming.

Please find the screen-shot.

Regards,

Rohini.

Read only

0 Likes
7,551

Okay some times the delimiter will be used as '#' so only its printing that too.

Anyway lets wait for the correct replies

Read only

0 Likes
7,551

Okay some times the delimiter will be used as '#' so only its printing that too.

Anyway lets wait for the correct replies

Read only

0 Likes
7,551

Okay some times the delimiter will be used as '#' so only its printing that too.

Anyway lets wait for the correct replies

Read only

0 Likes
7,551
Read only

0 Likes
7,551

I think your code is correct the '#' is the delimiter only(TAB) .

Read only

RaymondGiuseppi
Active Contributor
0 Likes
7,551

What is the code page of the file in application server (or from where was it copied and how)

Regards,

Raymond

Read only

0 Likes
7,551

Hi Raymond,

I think the client is running some script and get that file in application server