‎2012 Feb 15 11:44 AM
dear all,
iam using FM read_text to read text (i.e PR and line item )using following code,but my requirement is it may contains 100 of PRs and line items.so my text is like this 0010000035,00## contract,00## 00100000028,02## like this.so for every PR i have to check the etatus of PR to create PO.how to split this total text .iam using string type c but iam unable to get proper data.
data:
BEGIN OF header OCCURS 0,
ld_t1(2000),
ld_t2(163),
ld_txt3(163),
END OF header.
DATA: li_lines LIKE STANDARD TABLE OF tline WITH HEADER LINE,
ID like THEAD-TDID,
TNAME LIKE THEAD-TDNAME,
TDOBJECT like THEAD-TDOBJECT,
string1(8) type c,
string2(4) type c,
string3(8) type c,
string4(4) type c.
ID = 'AT'.
TNAME = wa_final-infnr.
TDOBJECT = 'EINA'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = id
language = sy-langu
name = TNAME
object = TDOBJECT
TABLES
lines = li_lines.
READ TABLE li_lines INDEX 1.
IF sy-subrc = 0.
header-ld_t1 = li_lines-tdline.
ENDIF.
READ TABLE LI_LINES.
CONDENSE li_lines. "NO-GAPS.
split header-ld_t1 at ',' into : string1 string2 string3 string4.
‎2012 Feb 15 11:55 AM
Hi Raj
If the text information is too long you can split it into a Table.
LOOP AT li_lines.
SPLIT AT ',' INTO TABLE my_table.
ENDLOOP.
Best regards
‎2012 Feb 15 2:31 PM
hi,
iam using the table type li_lines,but it iam not getting text properly into table.
my problem is if iam having text
0010000033,03,23243422
ammend,001
0012000000,2,232434343
0012223232,7
like this.
when iam using this FM,if iam splitting at ',' it is taking 23243422##amm,and also 4343430012 this is my problem
iam not able to get proper data.
‎2012 Feb 15 4:14 PM
Hello Raj
Probably those ## characters are CHAR(10) and CHAR(13). So you can replace them using REPLACE statement to substitute them. And can use attribute CL_ABAP_CHAR_UTILITIES=>CR_LF to use asd reference during replacement.
Best regards
‎2012 Feb 16 9:35 AM
i have tried with the two ways,but iam not able to condense the text .
i have writtne code as
data char1 type char1o value '##'.
loop at it_lines to wa_lines.
if wa_lines-tdline CA char1.
replace all occurences of char1 in wa_lines-tdline with space.
endif.
condense wa_lines-tdline.
endloop.
but when i tested simple text type as string with above statement it is working properly.
but iam getting the same result and also i tried with
REPALCE ALL OCCURENCES OF '##' WITH CR_LF
IN wa_lines-tdline .
is there any settings we can provide to get text without special chars.
reg
shiv
‎2012 Feb 15 8:06 PM
Hi Raj,
Generally the READ_TEXT fm reads ASCII data, so if there is any TAB it uses the special character # to identify the same, I belive in your SO10 text you have used some TAB explecitly which can not be read, try to give some paragraph formats and check it that doesn't solve your issue. Check the CL_GUI_FRONTEND_SERVICES class and it's attributes, there are certain attributes for horizonal_tab others.
Use of replace will be a good option as well. But it will read the entire paragraph and if that is too long/big you will recieve a performance issues. I suggest to loop at the itab and check for line by line.
Best Regards,
Tapodipta Khan.
‎2012 Feb 17 10:03 AM