‎2010 Oct 12 9:50 AM
Hi ,
i have a strring like #abc#1234#kl# in application server(Windows) (which is placed by reading from excel file in presentation server).
when i am reading the string using open dataset and splitting the content based on #,i am not able to split
but in case of AIX os i am able to split based on # .
can any one suggest why it is happening like this and how to split the string in Windows OS.
Regards
sarath
‎2010 Oct 12 10:28 AM
‎2010 Oct 12 10:32 AM
Hi,
The # in this string are actually tabs.
You need to read it with the tab character otherwise it is not possible to split the data.
CONSTANTS: c_tab type x value '9'.
SPLIT v_string at c_tab into V1, V2, ....
Regards,
Immanuel.
‎2010 Oct 14 10:55 AM
Hi ,
i Tried like above but it is not working.splitting is not happening at #.
note : i am uploading file from Unix OS and processing in Windows OS Vice versa.
please advice the reasons, solution if any.
Regards
sarath
‎2010 Oct 14 11:22 AM
Hi,
Just rename the xls file to .csv file ie. data.xls renamed to data.csv
Then use GUI_UPLOAD as below and then use FM TEXT_CONVERT_XLS_TO_SAP to convert to readable format. After that itab i_locfile will contain your data from xls. Try this.
*--Uploading xls sheet
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_locin
has_field_separator = 'X'
TABLES
data_tab = li_text_data.
IF sy-subrc 0.
ENDIF.
lv_file = p_locin.
*--Converting the xls to readable format
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_tab_raw_data = li_text_data
i_filename = lv_file
TABLES
i_tab_converted_data = i_locfile
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
‎2010 Oct 14 12:26 PM
Hi ,
i am using the mentioned FM only(requirement is excel),After reading i am placing the file in App sever.form there i am reading using READ data set ,
But Main problem is File Upload (Presentation to application server) will be from Diffrent OS and procesing also from diff OS(automatically it will pick up the OS)
when i am reading the file from App server i am getting the Problem in windows OS ,it is not splitting the file contents to internal table fields.
#MPRN#1234# -> fld2-MPRN fld4-1234 - in unix
but it is not happening in Windows OS.i tried with 9 value as well.
I want to know How to split the above string in windows OS.
please suggest the sol.
Regards
sarath
‎2010 Oct 14 12:40 PM
Hi Sarath,
Can you try using CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB instead of '#'?
split <string> at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into ....
Regards,
Hema
‎2010 Oct 14 12:53 PM
HI ,
First i tried with cl_abap_char_utilities=>horizontal_tab only ,by using that in UNIX OS splitting is working fine but for the same code when i am trying in WIndows OS it is not working.
Thank you ,please let me know any other solution/Suggestion.
Regards
sarath
‎2010 Oct 14 1:55 PM
Then I would suggest, go to the lower level and try the following, for each line:
Process the line character by character and split it manually.
Regards,
Hema
‎2010 Oct 14 3:07 PM
Hi ,
Many Thank for the replies,but my test will chnage dynamically,thats why i am using this separator concept,
based on the row/column of stndard excel values i will split.
so its better to split based on #,thats why i am checking for that,
Regards
sarath
‎2010 Oct 14 3:47 PM
Hi Sarath,
This is the sample code which you can use to load the data from the tab delimeted file into internal table.
CONSTANTS: con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
cr_lf type C value cl_abap_char_utilities=>CR_LF.
OPEN DATASET <datasetname> FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
DO.
REad dataset ..................
len = STRLEN( wa_string ).
len1 = len - 1.
lastchar = wa_string+len1(1).
shift wa_string left BY 1 places.
IF lastchar = cr_lf.
wa_string = wa_string+0(len1).
ENDIF.
*This is the logic to get the TAb delimeted Data into string and then load the same into the internal table.
SPLIT wa_string AT con_tab INTO wa_uploadtxt31-auart
wa_uploadtxt31-vkorg
wa_uploadtxt31-vtweg.
CLEAR: wa_string, wa_uploadtxt31, wa_upload31, wa_zrd_va31_rec.
ENDDO.
CLOSE DATASET.
‎2010 Dec 15 10:29 AM
when placing the file In appserver hardcoded #,so when reading problem occured so i am using cl_abap_char_utilities=>HORIZONTAL_TAB when placing and reading also ,after that its working.
Thank you all.
Regards
sarath