2013 Mar 26 2:56 PM
Hallo Gurus,
do you have an example to export an internal table FROM excel to abap via RFC?
Thank you very much indeed!
2013 Mar 26 5:53 PM
Hallo Gurus,
do you have an example to export an internal table FROM excel to abap via RFC?
Thank you very much indeed!
2013 Mar 26 3:25 PM
Hi Mick,
I'm not sure I am understanding very well your problem but if you want to upload an excel file into an internal table you can use this code:
DATA: BEGIN OF I_DATA OCCURS 0.
INCLUDE STRUCTURE ALSMEX_TABLINE.
DATA: END OF I_DATA.
*Uplaod excel
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = locfile
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 6
I_END_ROW = 65000
TABLES
INTERN = I_DATA
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC NE 0.
* MESSAGE E000 WITH TEXT-E01.
ENDIF.
*excel into internal table
LOOP AT I_DATA.
*If header line
AT NEW ROW.
CLEAR: rectab.
ENDAT.
CASE I_DATA-COL.
WHEN 1.
MOVE I_DATA-VALUE TO itab-field1.
WHEN 2.
MOVE I_DATA-VALUE TO itab-field2.
WHEN 3.
MOVE I_DATA-VALUE TOitab-field3.
WHEN 4.
MOVE I_DATA-VALUE TOitab-field4.
ENDCASE.
AT END OF ROW.
APPEND itab.
ENDAT.
ENDLOOP.
Hope this can help you.
Reagrds,
Christophe
2013 Mar 26 3:33 PM
Use the standard function modules - gui_upload
Thanks,
Vikram.M
2013 Mar 26 3:36 PM
Hi Vikram,
GUI_UPLOAD will be helpful only if the data is converted from xls to txt format i.e. tab de-limited format.
Regards,
Pranav.
2013 Mar 26 3:34 PM
Hi Mick,
You can search for posts that will help you use any FM to read data from excel to ABAP. e.g. TEXT_CONVERT_XLS_TO_SAP.
Use any of these FM in a custom FM and make the custom FM RFC enabled.
Let us know what you tried and any errors faced to help you further.
Regards,
Pranav.
2013 Mar 26 3:36 PM
Hallo Pranav,
thank you for your quick reply.
Actually I do have an external procedure (written in VBA) that has to pass a sort of internal table to SAP, via RFC, therefore I can't use TEXT_CONVERT_XLS_TO_SAP.
2013 Mar 26 3:42 PM
Please add the following information:
1. What is the format of the internal table of the VBA procedure. (stored as a file on the application server or database dump to a staging table or ......)
2. What is the destination of your RFC?
Regards,
Pranav.
2013 Mar 26 3:44 PM
1. internal table is like:
| VAR1 | 1 Type | CHAR40 |
| VAR2 | 1 Type | CHAR40 |
| VAR3 | 1 Type | CHAR40 |
| VAR4 | 1 Type | CHAR40 |
2. destination is Our SAP system...
2013 Mar 26 3:50 PM
1, The internal table you have mentioned is probably SAP format whereas what about the VBA procedure?
If you could explain your problem in detail as:
1. Does the VBA procedure read the excel file or you want directly SAP to read it via RFC?
2. What processing does the VBA procedure do?
Regards,
Pranav.
2013 Mar 26 3:56 PM
1. VBA data is defined as
ReDim cdRack(0 To 1, 0 To 3) As String
2. I do not have an excel file. It is a vba procedure that, after the user filled some fields on a mask, has to pass these informations to SAP.
2013 Mar 26 4:06 PM
Mick Farina wrote:
1. VBA data is defined as
ReDim cdRack(0 To 1, 0 To 3) As String
2. I do not have an excel file. It is a vba procedure that, after the user filled some fields on a mask, has to pass these informations to SAP.
Interesting,
The statement "after the user filled some fields on a mask, has to pass these informations to SAP", is confusing. You need to get the complete details and be specific about the source for SAP or ABAP or FM to read data. I'm still clueless about the VBA procedure output and how do you intend to read data from the mask. Maybe you can add some details about the mask and VBA procedure for help.
Regards,
Pranav.
2013 Mar 26 4:12 PM
I try to explain...
Our company has a procedure that is written in VBA. This procedure has to communicate with SAP, and I don't want to communicate via txt files or something like this. I do prefer on-line communications in order to pass back to vba procedure return-codes and so on.
That's why I was thinking about RFC.
From VBA I pass some data to SAP and SAP sends back result of operations (has to execute a call transaction for which there's no BAPI, it's a custom transaction).
2013 Mar 26 5:09 PM
For this, I believe you can try this:
1. Create a RFC enabled FM to call the transaction and will give you the output or result of operations.
2. The FM will be called from your VBA via middleware (SAP PI or DLL connectors) or any other mechanism you may think of.
3. You can easily store the result of the operations in SAP and complete the acknowledgement process to your source VBA procedure.
The question would be the middleware part........
Regards,
Pranav.
2013 Mar 26 5:53 PM
2013 Mar 27 8:32 AM
Great Shambu,
that's exactly what I need!
Thank you very much indeed!
2013 Mar 26 7:11 PM
Hello,
you can use ALSM_EXCEL_TO_INTERNAL_TABLE fm..but this not RFC enabled fm. you can copy from this fm to a custom fm..make it RFC enabled fm.
Thanks
Sabyasachi
2019 Jun 13 1:40 PM
Hello,
You are talking about function modules that do not exist in SAP NW 7.50 and higher. I cannot find any of those:
ALSM_EXCEL_TO_INTERNAL_TABLE,
TEXT_CONVERT_XLS_TO_SAP
,
These function modules do not exist in SAP NW 7.50, 7.51, and 7.52.
Please, mention an existing function module or a workaround.
Kind regards,
Jean
2019 Jun 13 1:49 PM
Hi,
Please, note that I do not have Excel. I just want to download a table from SAP as an Excel file. Then I want to upload the data later into an internal table or update the DB table.
Thank you.
Jean
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |