‎2008 Oct 17 12:35 PM
Hi Experts,
I have a requirement to pick the data form CSV file using BSP and upload the data in SNC DB table, Following are the steps used:
1) Data is picked from BSP using upload ?= cl_htmlb_manager=>get_data( request = request id = 'FileUpload' name = 'fileUpload' ).
2) Above step gives the data in XString format. Next step is to convert the data from XString to string type. For which i have used CALL FUNCTION 'CRM_IC_XML_XSTRING2STRING'
EXPORTING inxstring = filexstring
IMPORTING outstring = filestring.
3) I'm passing the above string (data in filestring) from BSP to a FM where i can update the SNC DB table.
Now Complete data of CSV file is in a single string type variable(say p_content) in which every row of CSV file is separated by '##', so to update the DB table i'm trying to split the string variable(p_content) at '##'. but split is not working in this case.
Split works properly when i test my logic by hardcoding the above data in FM, but doesn't work when content is passed dynamically.
Please suggest me some workaround to rectify the problem.
Thank you very much in advance.
Tarun Kumar
‎2008 Oct 17 12:38 PM
Hi Tarun,
try this class, even i faced one time same problem. I got solved by using this class.
class CL_ABAP_CHAR_UTILITIES definition load.
split text at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into it_txt-time
it_txt-date it_txt-num it_txt-num1 it_txt-event_id it_txt-usrname
it_txt-servername in character mode.
Regards,
shankar.
‎2008 Oct 17 12:37 PM
Hi,
Try with following code,
data:
begin of wa,
data type string,
end of wa.
data:
itab like standard table of wa with header line.
split p_content at '##' into itab.Thanks & Regards,
Navneeth K.
‎2008 Oct 17 12:37 PM
you can split using the CR_LF(carrage rerurn and line feed = '##' )
so split at cl_abap_char_utilities=>cr_lf and you will get each row separately.
‎2008 Oct 20 4:46 AM
Thanks a lot Vijay Babu
Your suggestion was helpful.
Split worked using:
SPLIT l_string at cl_abap_char_utilities=>cr_lf INTO l_temp l_temp1 in CHARACTER MODE.
‎2008 Oct 17 12:38 PM
Hi Tarun,
try this class, even i faced one time same problem. I got solved by using this class.
class CL_ABAP_CHAR_UTILITIES definition load.
split text at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into it_txt-time
it_txt-date it_txt-num it_txt-num1 it_txt-event_id it_txt-usrname
it_txt-servername in character mode.
Regards,
shankar.
‎2008 Oct 17 12:41 PM
Hi,
Check this example .. Hope this will help you.
DATA: str1 TYPE string,
str2 TYPE string,
itab TYPE TABLE OF string,
text TYPE string.
text = `What##drag `.
SPLIT text AT '##' INTO: str1 str2, TABLE itab.
Thanks
‎2008 Oct 17 12:43 PM
Hi ,
For this sort of problem we need to carriage return and line feed.
This is the abap class we need to mention at the starting of the program .
class CL_ABAP_CHAR_UTILITIES definition load.
SHIFT TEXT cl_abap_char_utilites=>horizontal_tab
WITH space INTO text.
Regards,
Bharani