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

Uploading data from .csv file with dynamic structure

Former Member
0 Likes
1,380

Hi,

My problem is to upload from a .csv file whose structure is unknown.

But the clue here is the first row of the file would be of the technical fields names..

I mean

USR01-BNAME,USR01-LANGU

What could be the best approach??

I read the first row and splitted it and stored in an I_tab...is that of any use?

3 REPLIES 3
Read only

Former Member
0 Likes
670

Hello,

I believe, that you may use the column names to create some kind of dynamic table.

At first, generate a fieldcatalog for your future table.

Then, try to do something like the following:

* 

DATA: new_line TYPE REF TO data.

  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog           = p_it_fieldcatalog
    IMPORTING
      ep_table                  = lt_data
    EXCEPTIONS
      generate_subpool_dir_full = 1
      OTHERS                    = 2.

  IF sy-subrc <> 0.
********
  ENDIF.
 

  ASSIGN lt_data->* TO <fs_table>.

  IF sy-subrc <> 0.
*****
  ENDIF.




  CREATE DATA new_line LIKE LINE OF <fs_table>.
*****
  ASSIGN new_line->* TO <fs2>.

  IF sy-subrc <> 0.
***
  ENDIF.

Read only

Former Member
0 Likes
670

You can try ALSM_EXCEL_TO_INTERNAL_TABLE function module.

this FM will read all the columns n rows of your excel sheet to a internal table.

this internal table contains data in form of

row no col no data.

now as you mentioned first row contains field names, using these you can create a dynamic table. then populate the data acoordingly.

hope this helps.

  • award Forum points to useful answers

Read only

Former Member
0 Likes
670

hi

Welcome to SDN first of all !!!

Please do go through the Craig's post in the ABAP General Forum

I think that your requirement has been discussed before

Please check this thread

https://forums.sdn.sap.com/click.jspa?searchID=93720&messageID=1364406

Do award points if helpful