cancel
Showing results for 
Search instead for 
Did you mean: 

problem in uploading a file

Former Member
0 Kudos

Hi All,

I did one application on file upload using the tutorial given in the saptechnical.com.

But i am unable to run my application due to the function module 'HR_KR_XSTRING_TO_STRING'

that does not exist.Can anybody plz tell me the name of the function module to convert xstring to string or an idea to solve this problem.

Thanks in Advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member402443
Contributor
0 Kudos

Hi Srilatha,

The Function module - HR_KR_XSTRING_TO_STRING u hv mention for converting the xtring to string will be available in ECC 6.0.

Or you can also use the class - CL_ABAP_CONV_IN_CE.

DATA: l_convin TYPE REF TO cl_abap_conv_in_ce,

l_msgstr TYPE string.

TRY.

CALL METHOD cl_abap_conv_in_ce=>create

EXPORTING

encoding = im_encoding "optional

input = im_xstring

RECEIVING

conv = l_convin.

CALL METHOD l_convin->read

IMPORTING

data = ex_string.

CATCH cx_root.

endtry.

Regard

Manoj Kumar

Former Member
0 Kudos

Hi Manoj,

Now i am able convert xstring to string.But my problem is values are uploaded in xml format .Plz give me an idea to solve this........

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Hi Manoj,

>

> Now i am able convert xstring to string.But my problem is values are uploaded in xml format .Plz give me an idea to solve this........

What exactly do you want us to solve. The data is in XML format - why is that a problem exactly? What format do you want it in? What kind of data is it? We need more details on what you want to do.

Former Member
0 Kudos

Hi Thomas,

I want upload the data from excel to the table in webdynpro and i followed the link

More details

For this i have taken 3 attributes of type string.In that i binded one attribute to the data property of the fileupload ui element and remaining 2 attributes for table.But when i execute the applications excel data will be uploaded as a format like this u0152

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I think your posting got garbled. It doens't make any sense.

Former Member
0 Kudos

Hi Thomas,

I followed one tutorial from saptechnical(Uploading Excel sheet using WebDynpro for ABAP)for uploading file.But i am using the class cl_abap_conv_in_ce for converting xstring to string inplace of fm hr_kr_xstring_to_string.But when i run the applications i am uploading the data from excel to table as in the fromat ì Í instead of strings(name and id in my case).

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

So it sounds like your conversion from XSTRING to STRING is not correct. Or you are uploading a native Excel Binary formatted file. I'm not sure what the content of the tutorial is that you are mentioning, but I bet one of the pre-requisites is that the Excel is saved as text-tab delimited, or XML before uploading. If the STRING after the conversion looks like garbage, this is probably because the file you uploaded has not been covereted on the frontend to a text based format.

Former Member
0 Kudos

If you want to upload an EXCEL file. you can achive it by first saving excel as

tab delimeted text file. This is simple open excel from save as choose

save as type Text( Tab delimeted).txt.

Now use file upload UI element from webdynpro abap. within the context declare

a context node lets call it NODE with attribute File type XSTRING. Bind

the data property of file upload UI element to the attribute 'File'.

Create a button upload and on its action write the following code.

Data: s_cont type string,
        x_cont type xstring,
        convt type ref to cl_abap_conv_in_ce,
        item_file type xstringval.

  data: input_string type string,
        fields  type string_table,
        fields2  type string_table,
        tbl_fields  type string_table,
        s_table type string_table,
        ls_table like line of s_table,
        ls like line of fields,
        lv_kunnr type kunnr,
        lv_ret type boolean,
        lv_num_cols type i.

   field-symbols: <wa_table> like line of s_table.


    DATA:
      node_file                           TYPE REF TO if_wd_context_node,
      elem_file                           TYPE REF TO if_wd_context_element,
      stru_file                           TYPE if_v_upload=>element_file ,
      item_file                           LIKE stru_file-file.
*   navigate from <CONTEXT> to <NODE> via lead selection
    node_file = wd_context->get_child_node( name = if_v_upload=>wdctx_node ).

*   get element via lead selection
    elem_file = node_file->get_element(  ).

*   get single attribute
    elem_file->get_attribute(
      EXPORTING
        name =  `FILE`
      IMPORTING
        value = item_file ).

  convt = cl_abap_conv_in_ce=>create( input = item_file ).
  convt->read( importing data = s_cont ).


  "Column headers
  split s_cont at cl_abap_char_utilities=>cr_lf into table s_table.
  read table s_table into ls_table index 1.
  " delete column header
  delete s_table index 1.
  loop at s_table assigning <wa_table>.
      split <wa_table> at cl_abap_char_utilities=>horizontal_tab into : ls_data-recordid
                                                                        ls_data-candno
                                                                        ls_data-fname
                                                                        ls_data-inits
                                                                        ls_data-lname
                                                                        ls_data-gesch
                                                                        ls_data-gbdat
                                                                        ls_data-uln.
      

        append ls_data to lt_data.
      clear ls_data.
    endloop.

  wd_this->m_node_data->bind_table(
     exporting
        new_items            = lt_data
        set_initial_elements = abap_true ).


endmethod.

Greetings Prashant

P.S. Points welcome

Former Member
0 Kudos

Hi Srilalitha,

Did you break through the problem of uploading excel file to web dynpro abap.

Former Member
0 Kudos

Use this FM

Data: 
        mara_string  TYPE string,
        mara_xstring TYPE xstring.

  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text   = mara_string
    IMPORTING
      buffer = mara_xstring.

Greetings

Prashant

Former Member
0 Kudos

Hi Prasanth,

Thanks for ur reply.But i want to convert xstring to string.So i need a function module to convert xstring data to string data.