BDC for Uploading data from XL sheet with unknown order of fields
Hi SAP Gurus,
My requirement is as follows,
A BDC is to be developed for uploading data from an XL sheet, but the problem here is , the order of fileds in the sheet can be changed .
ie, for example the fields in the XL sheet are :-
matnr maktx menge amount
but the user can give as
matnr amount menge maktx
or
maktx matnr amount menge
how i can solve this problem.
Thanks and Regards,
pavan.
Hi Pavan,
You need to handle it by your self, you can create a dynamic table based on the file value.
The field name pass from file with the record as a header, and based on the header name create your dynamic table.
afterward you can pass your value to BDC.
for creating dynamic table you can use this method
call method cl_alv_table_create=>create_dynamic_table
exporting
i_style_table =
it_fieldcatalog = it_field[]
i_length_in_byte =
importing
ep_table = dyn_tab
e_style_fname =
exceptions
generate_subpool_dir_full = 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.
-Dhirendra
Similar Messages
-
Uploading data from excel sheets through BDC's into sap system
hi guys,
can you please help me with this. As we use gui_upload to upload data from flat file to sap system, which function module you use to upload data from Excel sheet to sap system through bdc'shello pavan,
welcome to SDN
check the below program
REPORT ZEXCEL_TO_INTERNAL .
data: begin of itab occurs 0,
name(20) type c,
addre(20) type c,
end of itab.
DATA : ITAB1 LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
DATA : B1 TYPE I VALUE 1,
C1 TYPE I VALUE 1,
B2 TYPE I VALUE 100,
C2 TYPE I VALUE 9999.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME =
'C:\Documents and Settings\administrator\Desktop\ppcon001bd_24.xls'
I_BEGIN_COL = B1
I_BEGIN_ROW = C1
I_END_COL = B2
I_END_ROW = C2
TABLES
INTERN = itab1
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.
loop at itab1.
write:/ itab1.
Endlop.
Regards,
Naveen -
Hi,
How to upload data from XL sheet to internal table , can u please provide the sample code.
thanks
krishnaHI Krishna
See this code where i had writen to UPLOAD A EXCEL SHEET AND again pass that to APPLICATION server
i think it wil be very useful for you
you can understand this very easily
REPORT ZSD_EXCEL_INT_APP.
parameter: file_nm type localfile.
types : begin of it_tab1,
f1(20),
f2(40),
f3(20),
end of it_tab1.
data : it_tab type table of ALSMEX_TABLINE with header line,
file type rlgrap-filename.
data : it_tab2 type it_tab1 occurs 1,
wa_tab2 type it_tab1,
w_message(100) TYPE c.
at selection-screen on value-request for file_nm.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = 'X'
MASK = ' '
CHANGING
file_name = file_nm
EXCEPTIONS
MASK_TOO_LONG = 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.
start-of-selection.
refresh it_tab2[].clear wa_tab2.
file = file_nm.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '10'
i_end_row = '35'
tables
intern = it_tab
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.
loop at it_tab.
case it_tab-col.
when '002'.
wa_tab2-f1 = it_tab-value.
when '004'.
wa_tab2-f2 = it_tab-value.
when '008'.
wa_tab2-f3 = it_tab-value.
endcase.
at end of row.
append wa_tab2 to it_tab2.
clear wa_tab2.
endat.
endloop.
data : p_file TYPE rlgrap-filename value 'TEST3.txt'.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
IF sy-subrc NE 0.
MESSAGE e001(zsd_mes).
EXIT.
ELSE.
*---Data is downloaded to the application server file path
LOOP AT it_tab2 INTO wa_tab2.
TRANSFER wa_tab2 TO p_file.
ENDLOOP.
ENDIF.
*--Close the Application server file (Mandatory).
CLOSE DATASET p_file.
loop at it_tab2 into wa_tab2.
write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
endloop. -
Upload data from excel sheet into md61
Hi Gurus,
Can anybody please tell me the solution like how to upload the data from excel sheet into the MD61
if u suggest me to write an ABAP code then its fine or any other way would be great
and can u also send me the abap code i would be thankful to allHi,
I can be done in 2 ways.
1. Using LSMW you can upload your MD61 demand thru Excel sheet.
2. You can use BDC to upload the demand from Excel. For this you need to take help from the ABAP. You need to record the macro usinf SHDB and the table maintenance will be taken care by the developer.
For LSMW you need not depend on your developer, as a functional consultant you can do it yourself.
Regards,
V. Suresh -
Uploading data from excel sheet
HI,
Can anyone provide me the details to upload vendor data from excel sheet to database through bdc?
Thankyou.upload the excel file in your internal table and then use BDC to updated the database table.
FM's to upload Excel:
GUI_UPLOAD
KCD_EXCEL_OLE_TO_INT_CONVERT
ALSM_EXCEL_TO_INTERNALTABLE
refer to the link:
http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table-2/
http://www.sap-img.com/abap/learning-bdc-programming.htm
With luck,
Pritam. -
Scheduling Problem for uploading Data from Flat file to SAP
Hi guys,
I am facing a weared problem in uploading some leave records in z table. The code is working fine if we run it through se38 after selecting the file from a shared location from production server which has all the access rights.
This folder lies in the \usr folder of SAP Production.
I have kept all the Flat files in the shared path "
Tis-mum-iz-s1\migration\SAP-INT\leave\" ...
To give u exact directory structure..
Tis-mum-iz-s1 is the Server Name
usr is the SAP System folder used for uploads and downloads
usr |
...-> Migration |
-> SAP-INT |
-> leave -> (Flat Files)
Migration folder is shared with all rights.
Obviously, we cannot give shared drive as the variant in the scheduler.
So i use the system path i.e. \usr\sap\tmp\migration\sap-int\leave\ as the variant.
All my other download programs are working fine with this path as a variant...
But my this particular upload program does not work with this path....
I am giving u my code...
TATA INTERACTIVE SYSTEMS (A Division of TATA INDUSTRIES LIMITED)
REPORT : ZMIGRATE_ZLEAVE
DESCRIPTION : To Upload the Leave data. (ZLEAVE)
CREATED BY : Abhishek Bachhawat
CREATED ON : 01.09.2005
CONSULTANT : ANAND
REPORT ZMIGRATE_ZLEAVE.
TABLES: ZLEAVE.
data: begin of wtab,
MANDT(3),
ZLVID(8),
PERNR(8),
ZSTDT(8),
ZENDT(8),
ZDAYS(4),
AEDAT(8),
ERDAT(8),
end of wtab,
itab like WTAB occurs 0 WITH HEADER LINE.
data: temp like zleave occurs 0 WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK file
WITH FRAME TITLE text-005.
parameters: file like rlgrap-filename Obligatory.
Concatenate File SY-DATUM '_Leave.txt' into File.
SELECTION-SCREEN END OF BLOCK file.
at SELECTION-SCREEN ON VALUE-REQUEST FOR file .
CALL FUNCTION 'WS_FILENAME_GET'
IMPORTING
FILENAME = file.
IF SY-SUBRC <> 0.
ENDIF.
start-of-selection.
if file ne space.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = ITAB.
else.
message e000(zps) with 'Specify a file'.
endif.
SORT ITAB BY ZLVID.
LOOP AT ITAB.
REFRESH TEMP.
CLEAR TEMP.
TEMP-MANDT = sy-mandt.
TEMP-ERDAT = SY-DATUM.
TEMP-ZLVID = ITAB-ZLVID.
TEMP-PERNR = ITAB-PERNR.
TEMP-ZSTDT = ITAB-ZSTDT.
TEMP-ZENDT = ITAB-ZENDT.
TEMP-ZDAYS = ITAB-ZDAYS.
TEMP-AEDAT = ITAB-AEDAT.
TEMP-ERDAT = ITAB-ERDAT.
APPEND TEMP.
SELECT SINGLE *
FROM ZLEAVE
WHERE ZLVID = TEMP-ZLVID
AND PERNR = TEMP-PERNR.
IF SY-SUBRC = 0.
UPDATE ZLEAVE SET ZSTDT = TEMP-ZSTDT
ZENDT = TEMP-ZENDT
ZDAYS = TEMP-ZDAYS
AEDAT = TEMP-AEDAT
ERDAT = TEMP-ERDAT
WHERE ZLVID = TEMP-ZLVID
AND PERNR = TEMP-PERNR.
ELSE.
INSERT ZLEAVE FROM TABLE TEMP.
COMMIT WORK.
ENDIF.
ENDLOOP.Hi,
open dataset file for input in text mode.
check sy-subrc = 0.
while sy-subrc = 0.
read dataset file into wa.
if sy-subrc = 0.
append wa to itab.
else.
exit.
endif.
endwhile.
close dataset file.
regards
Siggi
PS: check also the F1-help for open, read and close statements! -
Uploading Data From Excel Sheet to SAP Database Tables
Dear Friends,
We are having an Excel Sheet with 90 different columns. Now we want only 2 of the columns to be uploaded in the database tables. So, Plz tell me which function module will be suitable for this. And plz help me with the code also.
Thanks,
Nishant JainHi Nishu,
A sample for the same..
data it_excel like table of ALSMEX_TABLINE with header line.
here we retrieve only 2 cols directly..
now itab will contain only 2 cols of all rows seperated by comma ..
data str(1000).
data itab like table of str with header line.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = 'C:sample1.xls'
i_begin_col = 1
i_begin_row = 1
i_end_col = 2
i_end_row = 100
tables
intern = it_excel
LOOP AT it_excel.
AT NEW row.
CLEAR itab.
ENDAT.
IF itab IS INITIAL.
MOVE it_excel-value TO itab.
ELSE.
CONCATENATE itab ',' it_excel-value INTO itab.
ENDIF.
AT END OF row.
APPEND itab.
ENDAT.
ENDLOOP.
regards
satesh -
Uploading Datas From Spread sheet to Database Table
I went to URL http://htmldb.oracle.com/pls/otn/f?p=38131:1 and download Vikas' CSV Upload application (a zip file) as well as the script to create the HTMLDB_TOOLS package.
I follow the steps in the link : Re: File Browse, File Upload
The application is created,Preview shows that the datas in the form of Excel sheet,but I cant upload the spread sheet.
If I click the Upload button It shows the Error:
ORA-01861: literal does not match format string
Error ORA-01861: literal does not match format string
OK
Kindly let me know the reason for the error.
Please help me to solve this Issue.
Thanks in Advance
by
SureshHi Gussay,
Thanks for ur reply.
I found the error,it was due to the date format.
If i drop the date column from the table and also from spread sheet,then it uploads.
How can we load dates in spread sheet to database column.
Thanks in advance
Suresh -
Uploading data from Excel sheet into SAP.
Dear All,
I want to upload data existing in Excel sheet into SAP. Is there any possibility with the following requirements?
1) Excel file contains serial numbers with different values.Like power(230Wp),Voc,Isc,Vmp and Imp.
2) We need to upload the same data into SAP with validations.
3) Validations are like no serial number should be repeated.
4) And depending on the Power value, the serial number should be assigned to different batches.Eg:The batches are as follows:
201 - 210
210 - 220
220 - 230
and if the Pmax of the serial number is 205.It should be assigned to batch 201 - 210 .
5) At present we are using MB31 to post the serial numbers which are existing in the flat file.
Thanks and Regards,
Varun SiddharthHi,
Refer to the following code:
DATA: lv_filetype(10) TYPE c,
lv_gui_sep TYPE c,
lv_file_name TYPE string.
lv_filetype = 'ASC'.
lv_gui_sep = 'X'.
lv_file_name = pa_dfile.
FM call to upload file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file_name
filetype = lv_filetype
has_field_separator = lv_gui_sep
TABLES
data_tab = gi_zhralcon_file
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
The excel file must be a tab delimited file.
Hope it helps.
Regards,
Rajesh Kumar -
Regarding uploading data from excel sheet to internal table
hi,
while executing the code im getting the output one by one but i want it to be displayed in a table format can any one help me regarding this issue.
thanks and regards,
siriHi Sirisha,
Through this FM we can't get the data in tabular format. After getting data from this FM we have to convert to tabular format. As far as i know there is no FM for Excel upload which directly gives data in tabular format.
Check below sample code which uploads 3 columns from excel file.
U can add as many case statements as the number of fields.
PARAMETERS: po_file TYPE rlgrap-filename DEFAULT 'E:test.xls'.
TYPES: BEGIN OF t_final,
empno(10) TYPE c,
name(30) TYPE c,
state(25) TYPE c,
END OF t_final.
DATA: i_tab TYPE STANDARD TABLE OF alsmex_tabline,
i_final TYPE STANDARD TABLE OF t_final,
wa_tab TYPE alsmex_tabline,
wa_final TYPE t_final.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR po_file.
PERFORM open_folder.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = po_file
i_begin_col = 1
i_begin_row = 1
i_end_col = 3
i_end_row = 65256
TABLES
intern = i_tab
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
CHECK NOT i_tab[] IS INITIAL.
LOOP AT i_tab INTO wa_tab.
CASE wa_tab-col.
WHEN 1.
wa_final-empno = wa_tab-value.
WHEN 2.
wa_final-name = wa_tab-value.
WHEN 3.
wa_final-state = wa_tab-value.
ENDCASE.
AT END OF row.
APPEND wa_final TO i_final.
CLEAR wa_final.
ENDAT.
ENDLOOP.
FORM open_folder .
DATA: li_file TYPE TABLE OF sdokpath,
lwa_file TYPE sdokpath.
CLEAR: po_file, lwa_file.
REFRESH li_file[].
CALL FUNCTION 'TMP_GUI_FILE_OPEN_DIALOG'
TABLES
file_table = li_file
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
IF sy-subrc IS INITIAL.
READ TABLE li_file INTO lwa_file INDEX 1.
IF sy-subrc IS INITIAL.
po_file = lwa_file-pathname.
ENDIF.
ENDIF.
ENDFORM. " open_folder
Just try executing above code in debug mode. U will understand the functionality.
Thanks,
Vinod. -
Problem while executing app for retrieving data from EXCEL Sheet
hi
i have this exception while running my application of retrieving data from a Excel sheet through java application , i had also set theclasspath for jxl. jar file but where its going wrong i dont know heres my code
import java.util.Date;
import java.io.*;
import jxl.*;
import javax.swing.*;
import java.awt.*;
import jxl.read.biff.BiffException;
public class testExcel2
public static void main(String args[]) throws jxl.read.biff.BiffException
try
File f=new File("move.xls");
jxl.Workbook workbook=null;
jxl.Sheet sheet=null;
workbook=jxl.Workbook.getWorkbook(f);
sheet=workbook.getSheet(0);
Cell a1 = sheet.getCell(0,0);
String stringa1 = a1.getContents();
System.out.println("stringshaddddddddjk "+stringa1);
workbook.close();
}catch(IOException ex){
System.out.println("Error" + ex);
catch (BiffException ex2){
System.out.println("Error" + ex2);
catch(IndexOutOfBoundsException ex1){
System.out.println("Error" + ex1);
compilation is sucees but while running its giving an EXCeption
MicrosoftXP[Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
G:\mysfw\pgms>java testexcel2
Exception in thread "main" java.lang.NoClassDefFoundError: testexcel2 (wrong nam
e: testExcel2)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)Java is case sensitive. testexcel2 is different from testExcel2.
G:\mysfw\pgms>java testexcel2
Exception in thread "main" java.lang.NoClassDefFoundError: testexcel2 (wrong name: testExcel2) -
Hi,
I am Using BAPI_ACC_MANUAL_ALLOC_POST (Manual cost allocation) for uploading into database. But i am getting the error "DO NOT USE COST ELEMENT xxxxxxxx FOR REPOST COSTS".
can anyone explain me the possible reasons for this error.
any help will be rewarded.
Thanks and Regards,
Gautham PaspalaHi,
Refer to the following code:
DATA: lv_filetype(10) TYPE c,
lv_gui_sep TYPE c,
lv_file_name TYPE string.
lv_filetype = 'ASC'.
lv_gui_sep = 'X'.
lv_file_name = pa_dfile.
FM call to upload file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file_name
filetype = lv_filetype
has_field_separator = lv_gui_sep
TABLES
data_tab = gi_zhralcon_file
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
The excel file must be a tab delimited file.
Hope it helps.
Regards,
Rajesh Kumar -
Mode for check data from R/3 (with tables name)
I have some table´s technicals names that will be check if the data loading in this is forwarding to BW.
Anyone can tell me what´s the procedure to know if data from some R/3´s table (standard) is being load into BW ????
Regards.In this instance - it's via datasource 0MATERIAL_TEXT
To find this out - I checked the description of the table - then based on experience knew it to be that datasource
Difficult to give you hard and fast rules for EVERY table!
This one was simpel it was a view on MAKT - others could be inside thousands of lines of function module reads, inside changepointer BADIs - anywhere! -
Errror when uploading data from xcel sheet into cube.
i created info package .
after dat when i preview the data i get a error which is
Error in conversion exit
CONVERSION_EXIT_CUNIT_INPUT 1.
i am unable to find this error....
but dont know where it is....This error usually comes when you have wrong Unit in file or some extra spaces?Just check them once.
Also=>Error in conversion exit CONVERSION_EXIT_CUNIT_INPUT -
How to get the data from a jtable with random order??
hi everyone,
i have a jtable i filled with Strring and Float data, i put this data to a MySQL database, and i use vectors and iterators to filled the database. the problem is there are some cells that are empty, and the Floats' columns throws me nullpointerexceptions.
please if anyone know how to avoid that exception i'd would be great.
thanks for your time.HI Siggi,
Thank you for your reply..
I am also planning to do FM to get the data. But it is saying that the Cluster table ZES does not exist (ZES is the the standard table, in SE11 also).
How can I use the Fields from the that table.?
What can I do now, can you please explain me about this point.
Waiting for your reply.
Thanks and Regards
Rajesh
Message was edited by:
rajesh
Maybe you are looking for
-
Hello, I am receiving the following error message when I try to access any webpage using Safari 2.0.4: Forbidden You don't have permission to access http://www.8notes.com/guitarchordchart/Fmaj7.asp on this server. Apache Server at www.8notes.com Port
-
Why can't i access the messages in my ipod touch
why cant i access the messages on my ipod touch can u pleaase Help me guys if someone who knows to connect into my ipod touch to chat with my Friends EAGRELY Waiting for Your Reply..
-
Desktop Theater 5.1, DT2200 - no sound
I have a Dell Dimension 8400, the sound card is on the motherboard. I wanted to use my Cambridge Desktop Theater 5.1, DT2200 speakers with it, but I get no sound from them. They work fine on my other computers, and the speakers that came with the Del
-
How to confirm the CO Production Order?
Hi,all The PP Production Order can confirm by TCode CO15. Then how to confirm the CO Production Order(Created by KKF1)?
-
Are there any magazines with articles and tips for Premiere - English language
Are there any magazines with articles and tips for Premiere - English language