‎2011 Oct 12 7:44 AM
Hi all,
I need to split a string based internal table into multiple internal tables based on some sub strings in that string based internal table...
High priority help me out...
eg...
a | jhkhjk | kljdskj |lkjdlj |
b | kjhdkjh | kldjkj |
c | jndojkok |
d |
this data which is in the application server file is brought into a internal table as a text. Now i need to send 'a' to one internal table, 'b' to one internal table, so on... help me
<Priority downgraded>
Edited by: Suhas Saha on Oct 12, 2011 12:24 PM
‎2011 Oct 12 7:50 AM
‎2011 Oct 12 7:56 AM
The example says how the file is there in the application server.
Now i got that file read into an internal table which has only 1 field string.
So it would contain only 1 file.
Now i would like to send the line starting with 'a' (in the example) in one internal table, 'b' in another internal table, so on....
how could i send can u help me out wit some logic or code?
‎2011 Oct 12 8:04 AM
Pradeep,
Can you share your actual requirement ?
Splitting it into different internal tables is very much possible based on 1st field (before 1st pipe) but if there are 1000 rows coming, you may end up with 1000 internal tables. How you declare them ?? It will be always random, right ?
Regards,
Diwakar
‎2011 Oct 12 8:00 AM
There should be some better solutions for this instead of creating internal tables for each row in the file.
What is the maximum row count expected ( is it 26 )
Please let us know what are you going to do after moving each row to a internal table ?
‎2011 Oct 12 8:00 AM
Hi,
Assign Internal table name dynamicaly.
LOOP AT IT_STR INTO WA_STR.
IF <Cond to put data in table >.
ASSIGN <table> TO <F_TAB>. "<TABLE> here you hav to required table name
SPLIT WA_STR INTO TABLE <F_TAB>.
ENDIF.
ENDLOOP.
Thanks,
Anmol.
Edited by: anmol112 on Oct 12, 2011 3:05 AM
‎2011 Oct 12 8:01 AM
First split the line into corresponding columns of the internal table using
loop at itab into wa_itab.
SPLIT wa_itab AT '|' into wa_itab1-column1 wa_itab1-column2 wa_itab1-column3.
append wa_itab1 into itab1.
endloop.
read the itab1 using column1 and move the rows into different internal tables.
‎2011 Oct 12 8:03 AM
Hi pradeep,
eg...
a | jhkhjk | kljdskj |lkjdlj |
b | kjhdkjh | kldjkj |
c | jndojkok |
d |
As per your statement "Now i need to send 'a' to one internal table, 'b' to one internal table"
Do you want only a to one internal table and b to one internal table
OR
Do you want the whole row of the internal table i mean
a | jhkhjk | kljdskj |lkjdlj | to 1 internal table
Having the case of an internal table which is of type string,
1) Loop through the internal table. LOOP AT lt_tab INTO lwa_tab.
2) Ge the work area contents and get the first char wa_tab-string+0(1)
3) FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
w_tabname = p_table.
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
ASSIGN w_dref->* TO <t_itab>.
Follow the link
http://www.sap-img.com/ab030.htm
http://www.sapdev.co.uk/tips/dynamic-structure.htm
and then based on the sy-tabix values you will get that many number of internal table
<FS> = wa_tab-string+0(1)
append <FS>
OR
USE SPLIT statement at the relevant seperator
revert for further clarification
Thanks
Sri
Edited by: SRIKANTH P on Oct 12, 2011 12:36 PM
‎2011 Oct 17 5:02 AM