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: 

Exporting data from excel to database

Former Member
0 Kudos

I want to export data from excel sheet into a database and display it in an ALV with an additional field which will show the status whether every entry is saved successfully or not.

Here, I have a field 'Id' which is a primary key. When I am copying data from excel into an internal table consisting of the same id then the values from excel are getting overwritten into the internal table.

Can somebody tell me how can I print a message in this 'Status' field to show if data is successfully saved or not without getting it overwritten into the database?

8 REPLIES 8

loyd_enochs3
Participant
0 Kudos

Data in the ALV will not be written to the database without explicit update logic. Changes made to the internal table that is used to display the ALV list will not change the database unless you write the procedure to update the database (Call Transaction, BAPI, IDoc, BusObject, etc).

"Viewer" is the key word in the name "ABAP List Viewer".

Sandra_Rossi
Active Contributor

You are talking about memory and database operations, altogether mixed-up, that don't make sense to me. Can you elaborate? (and "separate the concerns" if possible)

Former Member
0 Kudos

How can I validate duplicate records while exporting data from excel to the database and display a field in ALV which shows a status whether data is saved or not in the database?

Sandra_Rossi
Active Contributor
0 Kudos

"Elaborate" doesn't mean "give an abstract"... 🙂

Sorry, I really don't understand your question. Or your question is about a so-complex topic that nobody knows the answer.

SachinArtani
Participant
0 Kudos

You can use one of those FM to take data from excel file into an internal table -

1. ALSM_EXCEL_TO_INTERNAL_TABLE

2. TEXT_CONVERT_XLS_TO_SAP

Then insert the data of internal table to database table by sorting the internal table, deleting adjacent records as per your condition using below syntax -

SORT itab BY <field1> <field2> <field3>.DELETE ADJANCEMENT DUPLICATES from itab COMPARING <field1> <field2> <field3>.

Now using simple insert syntax, enter data to database table and on success, popup a Message (Type 'I' showing that the records has been updated in db successfully) and show the ALV using that internal table.

rudramani
Participant
0 Kudos

Can you check this article: https://gocoding.org/abap-excel-upload/
Here, the uploading excel is explained. What apart from the content mentioned here you want to know?

Former Member
0 Kudos

here I am trying to display contents of excel sheet in an ALV with an additional field 'Status' which will show duplicate entries are not saved and unique ones are saved. My actual problem is validating duplicate entries.

Ps: thank you for everyone's help I am able to export data from excel to z table. Now I just want to validate it.

SachinArtani
Participant
0 Kudos

Before showing your internal table data, you can sort the internal table and delete duplicate entries as I mentioned in below answer. Please check.