‎2006 Aug 10 9:40 AM
Hi Experts,
In my itab..i have data like this:
data: begin of itab occurs 0,
str type string,
end of itab.
<field name="searchDescription">
<![CDATA[]]>
</field>
<field name="longDescription">
<![CDATA[<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In aliquet. Nulla nisi justo, pulvinar eu, venenatis non, convallis placerat, mi. Cras urna dolor, ultricies at, vestibulum sit amet, auctor at, velit. Donec accumsan malesuada nisl. Donec fringilla pulvinar metus. Duis lorem ligula, tempus quis, ultrices vel, consectetuer non, ipsum. Donec lacinia, enim nec auctor vulputate, nibh turpis sollicitudin dolor, et commodo est libero eget enim. Aenean porttitor tristique orci. Integer velit. Pellentesque orci ipsum, varius sed, suscipit ac, egestas iaculis, tortor. Nam dignissim convallis quam. </p>
<p>Ut fringilla tempus lorem. Suspendisse porta molestie ligula. In hac habitasse platea dictumst. Ut eleifend tristique dui. Morbi purus purus, tincidunt ut, pretium ac, pharetra sit amet, felis. Etiam hendrerit ligula quis risus. Praesent aliquet. Vivamus quam ante, posuere eu, faucibus ut, tincidunt non, justo. Sed facilisis sem et metus. Nulla malesuada blandit tellus. Duis vel neque. Pellentesque luctus odio in justo. Pellentesque commodo venenatis neque. Maecenas quis velit vitae dui laoreet vehicula. Praesent molestie nonummy erat. </p>]]>
</field>
So i want to extact the complete data for long description and i have to move to another variable which ials of type string..
Can any body tell me how can we do this..??
‎2006 Aug 10 9:56 AM
if i am correct, i mean you have data (from <FIELD name till </field> ) is in internal table ITAB and you want that data (all records data) to be in a string variable
if so,
DATA : V_STRING TYPE STRING.
LOOP AT ITAB.
*--
CONCATENATE V_STRING
ITAB-STR
INTO V_STRING SEPARATED BY SPACE.
ENDLOOP.after this, V_STRING will have all the lines of ITAB.
Regards
Srikanth
added comments
Message was edited by: Srikanth Kidambi
‎2006 Aug 10 10:15 AM
Hi,
Thanks for response.But what i want is:
First i have to search for "longDescription" in string str.Then i have to extract data starting from <pPLorem ipsum dolor......to end of string.. ie just before </field>.....So betwenn that how many lines are there i have to move all those lines of string into one more variable..
Regards
‎2006 Aug 10 10:23 AM
Hi ravi,
use the search option:
TYPES: BEGIN OF T_TYPE,
LINE(80),
END OF T_TYPE.
DATA: T TYPE STANDARD TABLE OF T_TYPE WITH
NON-UNIQUE DEFAULT KEY,
WA_T TYPE T_TYPE.
MOVE 'Alaska Texas ' TO WA_T.
APPEND WA_T TO T.
MOVE 'California Arizona ' TO WA_T.
APPEND WA_T TO T.
SEARCH T FOR '*ONA'.
more specific to your question.
search itab for 'longDescription'.
now sy-tabix will have line number.
Sy-fdpos will have the offset of the string in that particular line.
start_line = sy-tabix + 1.
search itab for '</field>.
end_line = sy-tabix -1.
loop at itab from start_line to end_line.
concatenate itab-str v_str into v_str separated by space.
endloop.
write: v_str.
Regards,
ravi
Message was edited by: Ravi Kanth Talagana
‎2006 Aug 10 10:24 AM
In that case the below logic should help.
LOOP AT ITAB.
SEARCH itab-str for 'LongDescription'.
if sy-subrc = 0.
l_offset = sy-fdpos.
l_len = strlen ( itab-str ).
l_len = l_len - l_offset.
write itab-str+l_offset(l_len) to l_var.
endif.
endloop.
l_var would have the string.
Regards
Anurag
‎2006 Aug 10 11:21 AM
Hi ravi,
Thanks for response.But i am not able to get what i wanted.
see the code.
data: begin of itab occurs 0,
str type string,
end of itab.
after exicuting if my itab have data like this:
<field name="threadDisplay">
<![CDATA[Deposit]]>
</field>
<field name="searchDescription">
<![CDATA[]]>
</field>
<field name="longDescription">
<![CDATA[<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In aliquet. Nulla nisi justo, pulvinar eu, venenatis non, convallis placerat, mi. Cras urna dolor, ultricies at, vestibulum sit amet, auctor at, velit. Donec accumsan malesuada nisl. Donec fringilla pulvinar metus. Duis lorem ligula, tempus quis, ultrices vel, consectetuer non, ipsum. Donec lacinia, enim nec auctor vulputate, nibh turpis sollicitudin dolor, et commodo est libero eget enim. Aenean porttitor tristique orci. Integer velit. Pellentesque orci ipsum, varius sed, suscipit ac, egestas iaculis, tortor. Nam dignissim convallis quam. </p>
<p>Ut fringilla tempus lorem. Suspendisse porta molestie ligula. In hac habitasse platea dictumst. Ut eleifend tristique dui. Morbi purus purus, tincidunt ut, pretium ac, pharetra sit amet, felis. Etiam hendrerit ligula quis risus. Praesent aliquet. Vivamus quam ante, posuere eu, faucibus ut, tincidunt non, justo. Sed facilisis sem et metus. Nulla malesuada blandit tellus. Duis vel neque. Pellentesque luctus odio in justo. Pellentesque commodo venenatis neque. Maecenas quis velit vitae dui laoreet vehicula. Praesent molestie nonummy erat. </p>]]>
</field>
<field name="shortDescription">
<![CDATA[Deposit]]>
</field>
<field name="banksDescription">
<![CDATA[Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In aliquet. Nulla nisi justo, pulvinar eu, venenatis non, convallis placerat, mi. Cras urna dolor, ultricies at, vestibulum sit amet, auctor at, velit. Donec accumsan malesuada nisl. Donec fringilla pulvinar metus. Duis lorem ligula, tempus quis, ultrices vel, consectetuer non, ipsum. Donec lacinia, enim nec auctor vulputate, nibh turpis sollicitudin dolor, et commodo est libero eget enim. Aenean porttitor tristique orci. Integer velit. Pellentesque orci ipsum, varius sed, suscipit ac, egestas iaculis, tortor. Nam dignissim convallis quam.]]>
</field>
So actually iwant to extract data from (after longDescription)
Lorem ipsum dolor sit amet, consectetuer ...to convallis quam..ie just before </field>
How Can we do this?
Regards
‎2006 Aug 10 11:34 AM
loop at itab.
if itab-str+1(5) = 'field'.
l_start = sy-tabix.
endif.
if itab-str+2(5) = 'field'.
end_line = sy-tabix.
endif.
search itab-str for 'longDescription'.
if sy-subrc = 0.
start_line = l_start + 1.
endif.
endloop.
loop at itab from start_line to end_line.
concatenate v_str itab-str into v_str separated by space.
endloop.
v_str --- is your string.
Regards
Anurag
‎2006 Aug 10 10:12 AM
Hi,
data: ws_flag.
data: begin of itab occurs 0,
str type string,
end of itab.
data: ws_str(30) value '<field name="longDescription">'.
data: itab1 like itab occurs 0 with header line.
Loop at itab.
if itab-string+0(30) eq ws_str.
ws_flag = 'X'.
continue.
endif.
if ws_flag = 'X'.
itab1-string = itab-string.
replace '<!CDATA[' with '' into itab1-string.
replace '<p>' with '' into itab1-string.
replace '</p>' with '' into itab1-string.
append itab1.
clear itab1.
endif.
endloop.
regards
subbu