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: 

uploding the data from two or more sheets

Former Member
0 Kudos
93

Dear friends

Hi all! My name is Ashish Nagar and iam new to this group joined few days back. First of happy new year. My problem is that i am unable to convert the data into flat file (or Sap understand able file) given in two excel sheet from the client it is only converting the active sheet data. I am using the function ALSM_EXCEL_TO_INTERNAL_TABLE to convert the data . I request you to please help me up.

Bye

(Ashish V Nagar)

3 REPLIES 3

Former Member
0 Kudos
54

You have to use the FM GUI_UPLOAD, then you will have the data from the excel file into a internal table in SAP, later you can do anything with that 😃

0 Kudos
54

If you have any problem just get notice!! ok!?

ssimsekler
Active Contributor
0 Kudos
54

Hi Ashish

You can use <b>OLE automation</b> within ABAP. However, you should know the data area to consider performance. The code below may need some rework since I did not try it on the system.


DATA gs_excel TYPE ole2_object .
DATA gs_wbooks TYPE ole2_object .
DATA gs_wbook TYPE ole2_object .
DATA gs_worksheet TYPE ole2_object .


CREATE OBJECT gs_excel 'EXCEL.APPLICATION' .
SET PROPERTY OF gs_excel 'Visible' = 1 .
GET PROPERTY OF gs_excel 'Workbooks' = gs_wbooks .

*--Opening the existing document
CALL METHOD OF gs_wbooks 'Open' = gs_wbook
     EXPORTING #1 = <file_path_var> .

"* << ---- BEGIN OF BLOCK A

*--Activating sheet #1
GET PROPERTY OF gs_excel 'WorkSheets' = gs_worksheet
    EXPORTING #1 = <the_name_of_the_worksheet_1> .
CALL METHOD OF gs_worksheet 'Activate' .

*--Construct a loop according to your data area
DO n TIMES .
*--exit condition
  DO m TIMES .
*--exit condition

    CALL METHOD OF gs_excel 'Cells' = gs_cell
         EXPORTING #1 = m
                   #2 = n .
    GET PROPERTY OF gs_cell 'Value' = <variable> .

*--Assign the variable to the proper internal table field
  ENDDO .

*--A possible append to the intenal tablehere.
ENDDO .
"* >> ---- END OF BLOCK A

"*--And do the similar coding of "block A" for the second sheet."

<i>And as a last thing, let me introduce you the SDN forums pointing system: You can assign points to posts you find helpful while solving your question. You can reward points by clicking the yellow star icon at header of each reply post. You can reward;

- one 10 points (solved)

- two 6 points (very helpful answer)

- many 2 points (helpful answer)</i>

Kind Regards...

*--Serdar