2008 Jul 14 7:55 AM
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?
2008 Jul 14 8:05 AM
Hi Marshal,
I think by declaring a internal table of type string will help you out.
Thanks Sunil Saini,
That should work!
2008 Jul 14 8:05 AM
Hi Marshal,
I think by declaring a internal table of type string will help you out.
2008 Jul 14 8:11 AM
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
2008 Jul 14 8:33 AM
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.
2008 Jul 14 8:36 AM
2008 Jul 14 10:54 AM
The solution is right but is very slow process and if the file grows, the cost increases exponentially.
2008 Jul 14 8:09 AM
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
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |