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

Remove # character from flat file in application server

Former Member
0 Likes
3,618

Hi Experts,

I have a CSV file in application server from which i should extract data and pass into internal table.

At present i am using READDATASET to extract from flat file but a "#' character is available in my file and ii was unable to remove it.

Strange thing is that this '#' character is not seen when it is present in Presentation server(desktop).

I am able to replace other characters but i am unable to remove # character. I am also putting my code below.

DATA: l_sep1 TYPE c.

      l_sep1 = cl_abap_char_utilities=>HORIZONTAL_TAB.

LD_FILE = '\\FWSAPDEV\sapmnt\EDI\Wal-Mart\in850\FoodService_PO_120712103756.csv'.

OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING NON-UNICODE IGNORING CONVERSION ERRORS.

IF SY-SUBRC NE 0.

ELSE.

  DO.

    CLEAR: WA_STRING, WA_HEADER.

    READ DATASET LD_FILE INTO WA_STRING.

    IF SY-SUBRC NE 0.

      EXIT.

    ELSE.

      SPLIT WA_STRING AT l_sep1 INTO WA_HDR1

                                                                   WA_DTL.

    ENDIF.

  ENDDO.

  CLOSE DATASET LD_FILE.

ENDIF.

Hi Michael,

I was able solve this issue by using following code.

DATA: CR(1) TYPE C,

             WA_STRING TYPE STRING.

          

CR = CL_ABAP_CHAR_UTILITIES=>CR_LF.

SPLIT WA_STRING at CR into TABLE INT_TXT.

If this helpful please reward points

7 REPLIES 7
Read only

Aashish28
Contributor
0 Likes
1,826

Hiii ,

           Try this ,

DATA: str(10) TYPE c,
v1(1) VALUE space,
v2(2) VALUE '#'.

str = 'test##test'.

REPLACE ALL OCCURRENCES OF v2
IN str WITH v1.

WRITE: str.

Read only

former_member129652
Active Participant
0 Likes
1,826

Hi Venkat,

  I encountered similar problem few months ago when I downloading data from my application server to my presentation server. 

  The '#' appeared when I chose a wrong code page.   For example, if the data contains Chinese character but I chose ASCII, all Chinese characters becomes '#' characters. 

  I solved the problem by choosing UTF-8 (codepage:4110).  Maybe you should try UTF-8. too.

  Please let us know whether it solves your problem or not.

  Good luck

Read only

0 Likes
1,826

Hi Michael,

I was able solve this issue by using following code.

DATA: CR(1) TYPE C,

             WA_STRING TYPE STRING.

          

CR = CL_ABAP_CHAR_UTILITIES=>CR_LF.

SPLIT WA_STRING at CR into TABLE INT_TXT.

If this helpful please reward points

Read only

0 Likes
1,826

You started the discussion, so only you can mark replies as helpful or correct. You can mark your own reply as correct, however this will not assign any points to yourself, but that's not what we are here for anyway, right?


Thomas

Read only

0 Likes
1,826

Hi Thomas,

I was not knowing about this since the same issue was getting someone so i told like that.....

Read only

Former Member
0 Likes
1,826

so, look at the character in debug and see what the hex value is and use a hex chart to figure out what that character is...then research why/how you are getting that.  Is it coming at end of line in some display tool?  If so, could be CR or LF character, hex 0D or 0A.

Read only

VijayCR
Active Contributor
0 Likes
1,826

I had faced same problem please check the format when your uploading set the mode as text if your uploading a text file and if its hash separated set the mode accordingly.

Thanks,

Vijay