cancel
Showing results for 
Search instead for 
Did you mean: 

Upload file from within Excel to SAP

Former Member
0 Kudos

I have the results of an optimization program stored in Excel. I save the required data in a .csv file on the desktop. Currently the file is uploaded from within a "Z" transaction.

What I want to do now is further automate process by uploading file to SAP from within Excel. Currently I can logon to SAP, call a "Z" transaction via presentation server (users pc) and that's where it ends. Seems the transaction goes out to upload and never comes back as if it is in the background.

Can someone pls point in the correct direction to resolve this?

Thanks

Bob

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
Active Contributor
0 Kudos

Hi Bob,

I think you should create a RFC Enabled Function Module which can take the result as an internal table and update the values in SAP. Unfortunately I'm not a VBA / SAP specialist, but I think a Google or SDN Search should help.

Regards

Gregor

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Bob,

Refer the below program to upload data to internal table from excel.

report ZBDC_MM01_NEW no standard page heading line-size 255.

DATA : BEGIN OF STR,

MATNR LIKE RMMG1-MATNR,

MBRSH LIKE RMMG1-MBRSH,

MTART LIKE RMMG1-MTART,

MAKTX LIKE MAKT-MAKTX,

MEINS LIKE MARA-MEINS,

END OF STR.

DATA : ITAB LIKE TABLE OF STR WITH HEADER LINE.

CALL FUNCTION 'UPLOAD'

EXPORTING

  • CODEPAGE = ' '

FILENAME = 'C:\MAT.TXT'

FILETYPE = 'DAT'

  • ITEM = ' '

  • FILEMASK_MASK = ' '

  • FILEMASK_TEXT = ' '

  • FILETYPE_NO_CHANGE = ' '

  • FILEMASK_ALL = ' '

  • FILETYPE_NO_SHOW = ' '

  • LINE_EXIT = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • SILENT = 'S'

  • IMPORTING

  • FILESIZE =

  • CANCEL =

  • ACT_FILENAME =

  • ACT_FILETYPE =

TABLES

data_tab = ITAB

  • EXCEPTIONS

  • CONVERSION_ERROR = 1

  • INVALID_TABLE_WIDTH = 2

  • INVALID_TYPE = 3

  • NO_BATCH = 4

  • UNKNOWN_ERROR = 5

  • GUI_REFUSE_FILETRANSFER = 6

  • OTHERS = 7

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Regards,

Sheron