Application Development and Automation 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: 
Read only

export data FROM excel TO abap

Former Member
0 Likes
3,228

Hallo Gurus,

do you have an example to export an internal table FROM excel to abap via RFC?

Thank you very much indeed!

1 ACCEPTED SOLUTION
Read only

Former Member

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.

17 REPLIES 17
Read only

Former Member
0 Likes
2,880

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

Read only

Former Member
0 Likes
2,880

Use the standard function modules - gui_upload

Thanks,

Vikram.M

Read only

0 Likes
2,880

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.

Read only

former_member222709
Contributor
0 Likes
2,880

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.

Read only

0 Likes
2,880

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.

Read only

0 Likes
2,880

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.

Read only

0 Likes
2,880

1. internal table is like:

VAR11 TypeCHAR40
VAR21 TypeCHAR40
VAR31 TypeCHAR40
VAR41 TypeCHAR40

2. destination is Our SAP system...

Read only

0 Likes
2,880

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.

Read only

0 Likes
2,880

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.

Read only

0 Likes
2,880

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.

Read only

0 Likes
2,880

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).

Read only

0 Likes
2,880

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.

Read only

Former Member
Read only

0 Likes
2,880

Great Shambu,

that's exactly what I need!

Thank you very much indeed!

Read only

Former Member
0 Likes
2,880

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

Read only

0 Likes
2,880

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

Read only

0 Likes
2,880

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