Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Splitting based on # problem in reading file from Application server

sarath_7
Participant
0 Likes
2,540

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

11 REPLIES 11
Read only

Former Member
0 Likes
1,534

Hi,

please check below link out,

Link: []

(Specially last reply by : Maen Anachronos.)

I hope it'll help you.

Thanks and regards,

Sachin Bhatt IN.

Read only

0 Likes
1,534

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.

Read only

0 Likes
1,534

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

Read only

Former Member
0 Likes
1,534

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.

Read only

0 Likes
1,534

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

Read only

0 Likes
1,534

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

Read only

0 Likes
1,534

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

Read only

0 Likes
1,534

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

Read only

0 Likes
1,534

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

Read only

0 Likes
1,534

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.

Read only

sarath_7
Participant
0 Likes
1,534

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