Application Development 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: 

How do I import excel to my Data Base table?

Former Member
0 Kudos

Hi all,

I need to import data from an excel in to my Customizing Data Base table.

Can any one guide me on this?

Best Regards,

Varun.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

First create an internal table compatible to your database table. Then upload the data from file on presentation server in your internal table by using FM GUI_UPLOAD. Then using Insert statement, fill the data in database table

Regards

Abhijeet

7 REPLIES 7

Former Member
0 Kudos

Hi,

First create an internal table compatible to your database table. Then upload the data from file on presentation server in your internal table by using FM GUI_UPLOAD. Then using Insert statement, fill the data in database table

Regards

Abhijeet

Former Member
0 Kudos

Hi ,

There are 2-3 ways to do that,

1. Create an LSMW tool to upload the data directly to your Z table.

2. Create a BDC Program to upload the data.

3. Create a report program.

Use GUI _UPLOAD function in to that and store in to an internal table having three fields to store row no, col no and data.

You can use this declaration for that

DATA IT_DATA TYPE STANDARD TABLE OF ALSMEX_TABLINE WITH HEADER LINE.

Now sort out actual data from this internal table and then MODIFY Z* FROM work_area.

Thanks

Former Member
0 Kudos

HI,

Follow the procedure.

1. Enter the T.code SHDB.

2. Click on u201CNEW RECORDINGu201D PUSH BUTTON on the application tool bar.

3. Enter the recording name starting with Z or Y.

4. Now enter the T.code of the screen were you want to transfer the data.

5. (let us take an example of a t.code SE11.

6. Enter the T.code SE11.

7. Click on start recording bush button.

8. Now you are into SE11 SCREEN.

9. Enter the database table (example: SPFLI).

10. Click on display

11. Now goto the menu bar option u201Cutilities->table contents->create entriesu201D

12. Now create an entry here and click on u201Csave push button on the standard toolbaru201D.

13. Next you can find a message on status bar as u201Cdata record inserted successfullyu201D

14. Now click on u201Cback push button on the standard TOOL BARu201D

15. Now you will be in the DDIC.

16. Again click on u201Cback push button on the standard tool baru201D

17. Now you will be in SE11 screen.

18. Again click on back push button on standard tool bar.

19. Now you will be in the SHDB screen where the GENERATED BDC TABLE WILL BE DISPLAYED.

20. Now click on u201Csave push button on the standard tool baru201D

21. Once the bdc table os saved, click on back push button.

22. Now on the application tool bar you can find the u201Cprogramu201D push button. Click on that.

23. Now you have to give the program name and the short description and click on the radio button u201Ctransfer from recordingu201D and continue from there.

24. Now you will be taken to the abap editor where the generated bdc code is displayed.

25. Now after the report statement you give the following code:

26. TABLES: SPFLI.

27. DATA: ITAB TYPE TABLE OF SPFLI WITH HEADER LINE.

28. Now call the function module GUI_UPLOAD.

29. Fill under exporting the file name, and under tables as ITAB, and uncomment ASC under exporting.

30. Now you got to make the changes as ITAB-CARRID, ITAB-CONNID etc., where ever you find the field values you have mentioned at the time of recording.

31. Now you got to give the u201CLOOP AT ITAB u201C STATEMENT on after the include statement and u201Cendloopu201D at the end.

32. Now activate your program and execute.

33. Select the CALL TRANSACTION radio method.

34. Delete the no indicator field value which is a slash u201C/u201D

35. Now execute the program and check the entries in your database table.

but also make sure that for uploading an data from an excel sheet, you can also call the function module "MS_UPLOAD" or "WS_UPLOAD" i dont remember excatly.. try out.

good luck.

Former Member
0 Kudos

Hi,

1) First get in to internal table from Excel file

Below program shows how to upload into internal table from Excel file.

REPORT ZEXCEL_UPLOAD.

TYPE-POOLS truxs.

TABLES : zscarr.

  • Selection screen

PARAMETER p_file TYPE rlgrap-filename DEFAULT 'C:\TEST.xls'.

TYPES:

BEGIN OF t_tab,

carrid TYPE zscarr-carrid,

seats TYPE zscarr-total_seats,

END OF t_tab.

DATA :

t_upload TYPE STANDARD TABLE OF t_tab,

wa_upload TYPE t_tab,

it_type TYPE truxs_t_text_data.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

  • PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

field_name = 'P_FILE'

IMPORTING

file_name = p_file.

START-OF-SELECTION.

  • Uploading the data in the file into internal table

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

  • I_LINE_HEADER = 'X'

i_tab_raw_data = it_type

i_filename = p_file

TABLES

i_tab_converted_data = t_upload[]

EXCEPTIONS

conversion_failed = 1

OTHERS = 2. IF sy-subrc NE 0.

MESSAGE ID sy-msgid

TYPE sy-msgty

NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

END-OF-SELECTION.

  • Uploading the data into the database table

LOOP AT T_UPLOAD INTO WA_UPLOAD.

ZSCARR-CARRID = WA_UPLOAD-CARRID.

ZSCARR-TOTAL_SEATS = WA_UPLOAD-SEATS.

MODIFY ZSCARR.

ENDLOOP.

2) From the internal table update the database table using modify or insert statement.

Thanks,

Naveen Kumar.

Edited by: Naveen Kumar Maddi on Oct 10, 2008 10:52 AM

Edited by: Naveen Kumar Maddi on Oct 10, 2008 10:53 AM

former_member226203
Active Contributor
0 Kudos

Hi,

get the data from the excel to an internal table.

loop on this internal table and populate the fields in your table.

and after this loop say MODIFY table.

Hope this helps.

Regards,

Kalyan Chakravarthi.M

Former Member
0 Kudos

Try using the fm ALSM_EXCEL_TO_INTERNAL_TABLE .

Thanks

Rahul.

former_member451655
Active Participant
0 Kudos

hi ,

please create a Maintainable View for the Z table , then you can easily move your data to the Table via SM30.

How to create a Maintainable View

SE11->Utilities->table maintenance generator.

You need to enter the values of following fields:

1. Table name

2. Authorization group, and authorization object (select the suitable one)

3. Function group and package

4. Maintenance type: single or double screen maintenance view depending on the option selected.

5. Maintain screen number: you may specify a value or let the system generate one for you.

Br,

Dilum