‎2007 Jul 18 4:41 AM
hi,
i want to upload the vendor details from an excel file to sap using bdc.
i have taken four fileds
LIFNR
BURKS
EKORG
KTOKK
PLS help how to upload this from an excel file.
‎2007 Jul 18 4:49 AM
1. upload the input file to a internal table in your program using "GUI_UPLOAD".
2. record the vendor master transaction in SHDB , passing the parameters you want to pass.
3. Generate the program from the recording in SHDB. There is a option of generating the program from the recording.
4. In the program there parameters what you want to pass will be hardcoded. Replace them with the fields of the workarea of the table which you have populated from the input file.
5.Place the generated program inside the loop of the internal table.
6. Save the program and activate and execute.
7. In selection screen chose call transaction or session method and execute.
8. If you choose session method then a session will be create in SM35. you have to execute the session to upload the vendor informations. If you use call transaction then the venvor message will be autometically uploaded when you execute.
‎2007 Jul 18 4:43 AM
Use the FM : ALSM_EXCEL_TO_INTERNAL_TABLE
See the sample code below, with a single field in excel file. like wise you can use it with all your fields in Excel.
If you find any difficulty in implementing it do let me know.
parameters : p_ifname type rlgrap-filename.
data : it_data type table of alsmex_tabline initial size 0,
is_data type alsmex_tabline.
* Flatfile internal table.
types : begin of ty_tab,
zuonr type bsid-zuonr,
end of ty_tab.
data : it_tab type table of ty_tab initial size 0,
is_tab type ty_tab.
* If Input file name is not initial.
if not p_ifname is initial.
* Upload EXCEL data into internal table
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_ifname
i_begin_col = 1
i_begin_row = 1
i_end_col = 256
i_end_row = 65356
tables
intern = it_data
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endif.
* Append EXCEL Data into a internal table
loop at it_data into is_data.
at new row.
clear is_tab.
endat.
if is_data-col = '001'.
move is_data-value to is_tab-zuonr.
endif.
at end of row.
append is_tab to it_tab.
endat.
clear : is_data.
endloop.Regards
Gopi
‎2007 Jul 18 4:45 AM
thanks gopi can u please tel me a sample program for this.
or any referal blogs to see..
‎2007 Jul 18 4:47 AM
HI Dinesh,
Here is the sample code for uploading data through excel.
Just change the fields it will work.
If you still have problem. do get bk.
&----
*& Report UPLOAD_EXCEL *
*& *
&----
*& *
*& Upload and excel file into an internal table using the following *
*& function module: ALSM_EXCEL_TO_INTERNAL_TABLE *
&----
REPORT UPLOAD_EXCEL no standard page heading.
*Data Declaration
*----
data: itab like alsmex_tabline occurs 0 with header line.
Has the following format:
Row number | Colum Number | Value
---------------------------------------
i.e. 1 1 Name1
2 1 Joe
TYPES: Begin of t_record,
name1 like itab-value,
name2 like itab-value,
age like itab-value,
End of t_record.
DATA: it_record type standard table of t_record initial size 0,
wa_record type t_record.
DATA: gd_currentrow type i.
*Selection Screen Declaration
*----
PARAMETER p_infile like rlgrap-filename.
************************************************************************
*START OF SELECTION
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_infile
i_begin_col = '1'
i_begin_row = '2' "Do not require headings
i_end_col = '14'
i_end_row = '31'
tables
intern = itab
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
message e010(zz) with text-001. "Problem uploading Excel Spreadsheet
endif.
Sort table by rows and colums
sort itab by row col.
Get first row retrieved
read table itab index 1.
Set first row retrieved to current row
gd_currentrow = itab-row.
loop at itab.
Reset values for next row
if itab-row ne gd_currentrow.
append wa_record to it_record.
clear wa_record.
gd_currentrow = itab-row.
endif.
case itab-col.
when '0001'. "First name
wa_record-name1 = itab-value.
when '0002'. "Surname
wa_record-name2 = itab-value.
when '0003'. "Age
wa_record-age = itab-value.
endcase.
endloop.
append wa_record to it_record.
*!! Excel data is now contained within the internal table IT_RECORD
Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop.
Reward points if useful,
Aleem.
‎2007 Jul 18 4:49 AM
1. upload the input file to a internal table in your program using "GUI_UPLOAD".
2. record the vendor master transaction in SHDB , passing the parameters you want to pass.
3. Generate the program from the recording in SHDB. There is a option of generating the program from the recording.
4. In the program there parameters what you want to pass will be hardcoded. Replace them with the fields of the workarea of the table which you have populated from the input file.
5.Place the generated program inside the loop of the internal table.
6. Save the program and activate and execute.
7. In selection screen chose call transaction or session method and execute.
8. If you choose session method then a session will be create in SM35. you have to execute the session to upload the vendor informations. If you use call transaction then the venvor message will be autometically uploaded when you execute.
‎2007 Jul 18 5:09 AM
Use, FM--> ALSM_EXCEL_TO_INTERNAL_TABLE or
GUI_UPLOAD
For more info read the documentation, from SE37.
Regards,
Sairam
‎2007 Jul 18 5:22 AM
You can try this also...
TABLES : LFA1,LFB1,LFM1.
DATA : BEGIN OF ITAB OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
BUKRS LIKE LFB1-BUKRS,
EKORG LIKE LFM1-EKORG,
KTOKK LIKE LFA1-KTOKK,
END OF ITAB.
DATA : ITAB1(4096) TYPE C OCCURS 0.
PARAMETERS : P_FNAME LIKE RLGRAP-FILENAME.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
FILE_NAME = P_FNAME
.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
i_tab_raw_data = ITAB1
i_filename = P_FNAME
tables
i_tab_converted_data = ITAB
* EXCEPTIONS
* CONVERSION_FAILED = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT ITAB.
* do processing
ENDLOOP.
regards
shiba dutta