Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to identify and get data of a specific table from an Excel file into a generic table #1115

Open
hamida-ashna opened this issue Jun 19, 2023 · 1 comment

Comments

@hamida-ashna
Copy link

I have to make a program that could read data of a specific table via table name from Excel file. Now I am confused about how to identify that table from an Excel file. I looked through the abap2xlsx project, but I didn't find any method for identifying a specific table through the table name.

image033-1

For example, in the below sheet I have 6 tables. But, I want to read or extract only the data of "PriceList" table, not the others. So, how can I do this?

Screenshot 2023-06-18 160152

I know that, we can get data of a table using "get_table". Now if I use "get_table", so how should I find values of these parameters dynamically "iv_skipped_rows", "iv_skipped_cols", "iv_max_col", and "iv_max_row".

If somebody could give me some advice, that would be great. Thanks in advance.

@sandraros
Copy link
Collaborator

Hello. As I said in your original question at SAP forum:

"Do a GET_TABLE of all cells to fill an internal table, and then apply the logic you want on this internal table."

Although the rest of the logic you are looking for is not really part of abap2xlsx, I propose below an example of logic. Maybe you will need few methods of abap2xlsx to convert dates.

  1. Create a kind of dynamic internal table with many string columns (e.g. 100)
  2. Read all the cells of your worksheet into an internal table:
    sheet->get_table(
       IMPORTING
         et_table = internal_table ).
    
  3. Read the line 2 of the internal table, lookup all columns of the internal table till you find your "table" (e.g. if you are looking for "PriceList", you will find it at the column number 9 (column letter "I").
  4. Read the line 3 of the internal table, lookup all fields from the 9th field till you reach an empty field (e.g. you get the fields Brand, Model, Price). So, you know that the last field is at the column number 11 (column letter "K").
  5. Read all the lines of the internal table, starting from the line 4, till you reach an empty line, and transfer the values to a target internal table having the same structure of PriceList table in your system.

Good luck!

If you have some questions related to abap2xlsx itself, don't hesitate to post another question.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants