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

Very large string to internal text table

Former Member
0 Likes
1,453

Hi,

I have a string that contains all the information read from a flat file and I want to put all that information in an internal table where each row is just 1024 char in order to contain a row of the original flat file.

In the string I can recognize the special character "carriage return" in order to separate identify each row but now my problem is that I don't know can I parse the string text.

Can you help me please?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,370

Hi Marshal,

I think by declaring a internal table of type string will help you out.

Thanks Sunil Saini,

That should work!

6 REPLIES 6
Read only

Former Member
0 Likes
1,371

Hi Marshal,

I think by declaring a internal table of type string will help you out.

Read only

0 Likes
1,370

No, I need the information in a type char internal table...

My problem is that I don't know how to parse the string to get something like that:


LOOP AT string INTO aux_string FOR EACH new_line.

 APPEND aux_string TO char_internal_table.

ENDLOOP.

Obviously you can't use loop at string... but I need some way to do something similar

Edited by: Marshal Oliveras on Jul 14, 2008 9:12 AM

Read only

0 Likes
1,370

Hi Marshal,

continuing the program of sandeep.


Constant:
  c_enter type c,
  c_hash type c value '#' .

Data:
  BEGIN OF wa_text ,
    text(1024) TYPE c,
  END OF wa_text.
  
  i_text LIKE STANDARD TABLE OF wa_text.

REPLACE ALL OCCURRENCES OF c_enter
IN wa_text WITH c_hash.

DO.
    SPLIT wa_text AT c_hash INTO: str1 str2.
    IF str2 NE SPACE.
      APPEND str1 To i_text.
      wa_text = str2.
      CLEAR str2.
    ELSE.
      EXIT.
  ENDIF.
ENDDO.

WHERE c_enter contains the value of Carriage Return, which I also don't know.

Best Regards,

Sunil.

Read only

0 Likes
1,370

Thanks Sunil Saini,

That should work!

Read only

0 Likes
1,370

The solution is right but is very slow process and if the file grows, the cost increases exponentially.

Read only

Former Member
0 Likes
1,370

hi marshal ,

do like this first read the internal table and replace the all occurencse of carriage return with '#' and split the string

at '#'.

constant : c_enter type c ,

c_hash type c value '#' ..

data:

BEGIN OF wa_text ,

text(1024) TYPE c,

END OF wa_text.

i_text LIKE STANDARD TABLE OF wa_text.

REPLACE ALL OCCURRENCES OF c_enter

IN wa_text WITH c_hash.

SPLIT wa_text AT c_hash INTO: str1 str2 str3,

TABLE i_text.

regards,

sandeep

Edited by: Sandeep patel on Jul 14, 2008 12:43 PM