cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Upload in WD4A

jitendra_it
Active Contributor
0 Kudos

Hello WD4A Gurus,

I have search a lot about excel upload functionality in WD but didnt get solution.

I managed to  upload an excel by learning some tutorial but its showing garbage values in WD table.

Could you please make some suggestion or any other way to deal with excels uploads.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

jitendra_it
Active Contributor
0 Kudos

Hello Guys,

Things mentioned in link  ABAP WebDynpro - Upload Excel File using Class CL_FDT_XL_SPREADSHEET   woked for me. Thanks..

jitendra_it
Active Contributor
0 Kudos

Hi ,

If i upload a blank excel file then it gives me a dump.

I tried with xstrlen() to get the file size before calling the program ,    but its not working.

Any clue where I can handle dump,  since  standard code is throwing dump.

Former Member
0 Kudos

Use a try catch instruction with system exception handling it will do the job.

Answers (3)

Answers (3)

Former Member
0 Kudos

As suggested by Kiran you should use abap2xlsx. It gives very good results. But it's limited to xlsX (xml based) files. Nothing for binary format xls files...

former_member184578
Active Contributor
0 Kudos

Hi,

Check my reply in the following thread: http://scn.sap.com/thread/3419026

Regards,

Kiran

vimal
Active Participant
0 Kudos

Hi Kiran,

I am uploading .csv comma separated file

1)  using cl_abap_char_utilities=>newline we get all the values in an internal table.

2) We loop at this internal table and use SPLIT ls_data AT ',' INTO TABLE lt_fields. to get the values as follows :

i) Material Description

ii)MAKTX

iii)TEST#

This # signifies the end of line but how to remove it ,i have use all the attributes given in cl_abap_utilities to replace it with space but of no use.And when we bind this data to our field it gets shown as ******.

So how to resolve it?

former_member184578
Active Contributor
0 Kudos

Hi,

Write the below code in the action handler of upload and it should work if you use .csv file with correct file encding.


DATA lo_nd_table TYPE REF TO if_wd_context_node.

   DATA lt_table    TYPE wd_this->elements_table.

   DATA ls_table    TYPE wd_this->element_table.

   DATA lt_rows     TYPE STANDARD TABLE OF string.

   DATA ls_rows     TYPE string.

   DATA lo_el_context TYPE REF TO if_wd_context_element.

   DATA ls_context TYPE wd_this->element_context.

   DATA lv_content TYPE wd_this->element_context-content.

   lo_el_context = wd_context->get_element( ).

*Read File Context

   lo_el_context->get_attribute(

     EXPORTING

       name `CONTENT`

     IMPORTING

       value = lv_content ).

   DATA : lr_conv   TYPE REF TO cl_abap_conv_in_ce,

          string_data TYPE string.                

*Convert Xstring data to string

   CALL METHOD cl_abap_conv_in_ce=>create

     EXPORTING

       input       = lv_content

       encoding    = 'UTF-8'

       replacement = '#'

       ignore_cerr = abap_true

     RECEIVING

       conv        = lr_conv.

   CALL METHOD lr_conv->read

     IMPORTING

       data = string_data.

   SPLIT string_data AT cl_abap_char_utilities=>cr_lf INTO TABLE lt_rows.

   LOOP AT lt_rows INTO ls_rows .

     SPLIT ls_rows AT ',' INTO ls_table-f1 ls_table-f2 ls_table-f3. " here f1, F2,f3 are the attr names in your context node

     REPLACE ALL OCCURRENCES OF '#' in ls_table-f3 WITH space.

     APPEND ls_table TO lt_table.

   ENDLOOP.

   lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).

   lo_nd_table->bind_table( new_items = lt_table set_initial_elements = abap_true ).

hope this helps u,

Regards,

Kiran

ramakrishnappa
Active Contributor
0 Kudos

Hi Jitendra,

Please refer the below link

Rectifying garbage value problem in excel

Hope this helps you.

Regards,

Rama

jitendra_it
Active Contributor
0 Kudos

Hello Ramakrishnapaa,

Thanks for your help. My client doesnt want a sample download. Client wants direct upload.