cancel
Showing results for 
Search instead for 
Did you mean: 

SRM function module to upload excel to internal table

Former Member
0 Kudos

Hi Experts,

I need to import an excel data into my internal table in SRM.

I was not able to find any FM for this purpose..!!

i tried to copy 'ALSM_EXCEL_TO_INTERNAL_TABLE' from ECC to SRM ..but in vain...

it throws many errors....

Please guide me through this,,,,,,,,,,,,,!!!!!!!!!!!!!!1

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Nagaraj,

In SRM you can use .CSV files very easily but you need to convert excel file to .CSV format before using. You also need to change all the commas (,) to cemicallons ( before useing it.

Please find the below code for ready reference.

FORM upload_file USING fp_p_file TYPE localfile

CHANGING fp_gt_main TYPE gs_main.

  • Declaration

DATA: l_file_nam TYPE string,

l_file_typ TYPE string,

l_type TYPE string VALUE 'CSV'.

  • Checking path is not empty

IF fp_p_file IS INITIAL.

  • If no file selected giving one error

PERFORM check_file.

ELSE.

SPLIT fp_p_file AT gc_mark INTO: l_file_nam l_file_typ.

TRANSLATE l_file_typ TO UPPER CASE.

IF l_file_typ EQ l_type.

  • Uploading file data to a internal table

CALL FUNCTION 'BBPU_UPLOAD_DATA_FILE'

EXPORTING

filename = fp_p_file

TABLES

transfer_tab = fp_gt_main

EXCEPTIONS

file_open_error = 1

file_read_error = 2

invalid_type = 3

no_batch = 4

unknown_error = 5

action_cancelled = 6

gui_refuse_filetransfer = 7

no_authority = 8

file_is_empty = 9

OTHERS = 10.

IF sy-subrc <> 0.

LEAVE LIST-PROCESSING.

ENDIF.

ELSE.

PERFORM error_msg.

ENDIF.

ENDIF.

ENDFORM. " UPLOAD_FILE

If you want exactly the same functinality like FM 'ALSM_EXCEL_TO_INTERNAL_TABLE' then you can copy the standard one & create a z FM for your SRM system.

Regards,

Sujoy

Former Member
0 Kudos

Hi Vidya,

How did you achieve this?

I have a similar type of requirement.

BR,

Sri

Former Member
0 Kudos

Sri,

We finally went ahead with a tab delimited text file.

If you still want an excel file then,

You can enter the required data in the excel and then save the file as

file name : abc.tab

Save as type : Text (Tab delimited) (*.txt)

By this your file gets saved as a tab file but still it appears as an excel for you to enter data......

then you can use gui_upload ....as per your requirement.....

Best Regards,

Vidya