Uploading Excel file into SAP Database table?
I built a table in the SAP Data Dictionary, and i need to write a program that uploads the Excel table, into the SAP Database table. Does anybody have a sample program that may help me? Thanks!
TYPES:
BEGIN OF ty_upload,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
mbrsh like mara-mbrsh,
END OF ty_upload.
DATA it_upload TYPE STANDARD TABLE OF ty_upload WITH header line.
DATA wa_upload TYPE ty_upload.
DATA: itab TYPE STANDARD TABLE OF alsmex_tabline WITH header line.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = 'C:\Documents and Settings\venkatapp\Desktop\venkat.xls'
i_begin_col = 1
i_begin_row = 1
i_end_col = 4
i_end_row = 65535
TABLES
intern = itab.
if not itab[] is initial.
loop at itab .
case itab-col.
when '0001'.
it_upload-matnr = itab-value.
when '0002'.
it_upload-meins = itab-value.
when '0003'.
it_upload-mtart = itab-value.
when '0004'.
it_upload-mbrsh = itab-value.
append it_upload.
clear it_upload.
clear itab.
endcase.
endloop.
endif.
loop at it_upload into wa_upload.
ztable-matnr = wa_upload-matnr.
ztable-meins = wa_upload-meins.
ztable-mtart = wa_upload-mtart.
ztable-mbrsh = wa_upload-mbrsh.
insert ztable.
endloop.
Similar Messages
-
Hi Friends,
Iam trying to Upload Excel file into SAP using the FM
ALSM_EXCEL_TO_INTERNAL_TABLE. But it is going to dump n the error is
The call to the function module "ALSM_EXCEL_TO_INTERNAL_TABLE" is incorrect:
In the function module interface, you can specify only
fields of a specific type and length under "INTERN".
Although the currently specified field
"ITAB" is the correct type, its length is incorrect.
I have attached the code also.
Please let me know where iam getting the error.
Code :
Tables : mara,
ztable.
parameters : p_infile like rlgrap-filename.
data : begin of itab occurs 0,
matnr like mara-matnr,
mbrsh like mara-mbrsh,
matkl like mara-matkl,
end of itab.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_infile
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 100
I_END_ROW = 100
TABLES
INTERN = itab
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.
sort itab by matnr.
loop at itab.
write:/ itab.
*modify ztable from table itab.
endloop.hi check this code:
DATA : BEGIN OF TYP_INPUT ,
MATNR LIKE MARA-MATNR,
WERKS LIKE MARC-WERKS,
LGORT LIKE MARD-LGORT,
LGNUM LIKE MLGN-LGNUM,
LGTYP LIKE MLGT-LGTYP,
LTKZA LIKE MLGN-LTKZA,
LTKZE LIKE MLGN-LTKZE,
LGBKZ LIKE MLGN-LGBKZ,
LGPLA LIKE MLGT-LGPLA,
END OF TYP_INPUT.
*Input File Data
DATA : IT_FILE LIKE TYP_INPUT OCCURS 0 WITH HEADER LINE.
*"INTERNAL TAB TO TAKE EXCEL SHEET.
DATA : IT_EXCEL LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_PFILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 2
I_END_COL = 9
I_END_ROW = 6000
TABLES
INTERN = IT_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
* IT_EXCEL CONTAINS DATA IN THE FORM OF ROW, COL, VALUE *
* CONVERTING THAT INTERNAL TABLE TO FORMAT THAT OF EXCEL SHEET *
IF NOT IT_EXCEL[] IS INITIAL.
SORT IT_EXCEL BY ROW COL.
LOOP AT IT_EXCEL.
CASE IT_EXCEL-COL.
WHEN 1.
IT_FILE-MATNR = IT_EXCEL-VALUE.
WHEN 2.
IT_FILE-WERKS = IT_EXCEL-VALUE.
WHEN 3.
IT_FILE-LGORT = IT_EXCEL-VALUE.
WHEN 4.
IT_FILE-LGNUM = IT_EXCEL-VALUE.
WHEN 5.
IT_FILE-LGTYP = IT_EXCEL-VALUE.
WHEN 6.
IT_FILE-LTKZA = IT_EXCEL-VALUE.
WHEN 7.
IT_FILE-LTKZE = IT_EXCEL-VALUE.
WHEN 8.
IT_FILE-LGBKZ = IT_EXCEL-VALUE.
WHEN 9.
IT_FILE-LGPLA = IT_EXCEL-VALUE.
ENDCASE.
AT END OF ROW.
APPEND IT_FILE.
CLEAR IT_FILE.
ENDAT.
ENDLOOP.
ELSE.
MESSAGE I000 WITH 'The input file is empty'.
STOP.
ENDIF. -
Error Raised while uploading Excel file to SAP
Hi All,
I am getting error while uploading excel file into SAP using the function module 'TEXT_CONVERT_XLS_TO_SAP'.
Error Message is UX(893) - 'Excel file & cannot be processed' .
Please let me know what went wrong.
Regards,
DeepthiHi,
1 .TEXT_CONVERT_XLS_TO_SAP Funtion module will work if you have installed Microsoft Excel at front end.
2. Whenyou declare internal table for upload, specify the char only in the strcture ,don't specify any data element or dictionary reference. If the data element and dictionaly reference is character field then its ok.
eg.
types:begin of st_data,
field1 type char15,
field2 type char23,
endif.
3. Close the excel before you upload
Hope this might solve your issue.
Regards
Aromal R -
Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure
Please Help , Urgent Help Needed.
Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
Case's are :
1. Excel File is On Users/ Client PC.
2. Application is on Remote Server(Oracle Forms D2k).
3. User Is Using Application Using Terminal Server LogIn.
4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
6. we are Using Oracle 8.7
So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
Jus help to Sort This Issue ........
you can also write me on :
[email protected], [email protected]TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
Justin -
How to upload a Flat file into sap database if the file is in Appl'n Server
Hello Sap Experts , Can you tel me
" How to upload a Flat file into sap database if the file is in Application Server.
what is Path for that ?
Plz Tel Me its Urgent
Thanks for allHi,
ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
*& Report ZUPLOADTAB *
*& Example of Uploading tab delimited file *
REPORT zuploadtab .
PARAMETERS: p_infile LIKE rlgrap-filename
OBLIGATORY DEFAULT '/usr/sap/'..
DATA: ld_file LIKE rlgrap-filename.
*Internal tabe to store upload data
TYPES: BEGIN OF t_record,
name1 like pa0002-VORNA,
name2 like pa0002-name2,
age type i,
END OF t_record.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
wa_record TYPE t_record.
*Text version of data table
TYPES: begin of t_uploadtxt,
name1(10) type c,
name2(15) type c,
age(5) type c,
end of t_uploadtxt.
DATA: wa_uploadtxt TYPE t_uploadtxt.
*String value to data in initially.
DATA: wa_string(255) type c.
constants: con_tab TYPE x VALUE '09'.
*If you have Unicode check active in program attributes then you will
*need to declare constants as follows:
*class cl_abap_char_utilities definition load.
*constants:
* con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
*START-OF-SELECTION
START-OF-SELECTION.
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
DO.
CLEAR: wa_string, wa_uploadtxt.
READ DATASET ld_file INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
wa_uploadtxt-name2
wa_uploadtxt-age.
MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
APPEND wa_upload TO it_record.
ENDIF.
ENDDO.
CLOSE DATASET ld_file.
ENDIF.
*END-OF-SELECTION
END-OF-SELECTION.
*!! Text 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. -
Upload an Excel file into an Internal Table
Hi,
I want to upload an Excel file into an internal table but it doesn't work. I'd appreciate if someone could tell me what is wrong.
My excel file has the following format:
Col1 Col2
Row1 1 2
Row2 2 3
Row3 3 4
And the report code is the following one:
REPORT ZFI_PROKON_PROCESOS.
DATA: BEGIN OF itab OCCURS 0,
num1(1),
num2(1).
DATA: END OF itab.
PARAMETERS: p_file LIKE rlgrap-filename obligatory.
AT SELECTION-SCREEN.
AT SELECTION-SCREEN on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name = p_file.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 2
I_END_ROW = 5
TABLES
INTERN = itab
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 itab.
WRITE: / itab-num1, 10 itab-num2.
ENDLOOP.
Thanks in advance,
GerardTry function module
ALSM_EXCEL_TO_INTERNAL_TABLE
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_path
i_begin_col = 1
i_begin_row = 2
i_end_col = 70
i_end_row = 10000
tables
intern = i_excel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
P_PATH is file name with path.
I_EXCEL is internal table to store data.
declaration is "i_excel like structure alsmex_tabline"
then loop at i_Excel and populate your table
for eg
loop at i_excel.
case i_excel-col.
when '0001'.
i_data-compcode = i_excel-value.
when '0002'.
i_data-rcpttyp = i_excel-value.
when '0003'.
i_data-pocimpro = i_excel-value.
when '0004'.
i_data-tranno = i_excel-value.
when '0005'.
i_data-msrpo = i_excel-value.
when '0006'.
i_data-mporel = i_excel-value.
endcase.
at end of row.
append i_data.
clear i_data.
endat.
endloop. -
How do I upload XML files into sap table?
Dear all,
I found some methods that upload xml into SAP,
but there doesnt work under 4.6c.
Can someone tell me how to upload XML files into
sap under 4.6c?
THX!hi,
You can convert XML to abap using transformations. Simple transformations is a proprietary SAP programming language that describes the transformation of ABAP data to XML (serialization) and from XML to ABAP data (deserialization).
goto SE80->workbench->edit object(or other objects)->in object selection chose more tab and then choose the transformation radio button and write a name and click create new.
Here you enter your transformation like
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl"
>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:transform>
You can use this transfomation in your program using call transformation. You can find more info on call transformation in help.
Hope this helps.
Regards,
Richa -
UPLOADING EXCEL FILE INTO PRESENTATION SERVER
hi guys,
any one can provide the function module to upload an EXCEL file fromt he presentation server into SAP-CRM system.
regards
viswa gunthaHi Viswa,
you should try to use the SDN Search. I've searched for "Excel upload" and the second link was:
Uploading Data From Excel Sheet to SAP Database Tables
Regards
Gregor -
Uploading excel files into Web UI
We are following the blog http://wiki.sdn.sap.com/wiki/display/CRM/CRMWebUI-UploadingdatafromExcelfiles
to upload excel files into Web UI.
The problem which we are facing is that the values are not getting populated in the text are and in the
event handler EH_ONSERVEREVENT, no values are being populated in lt_items table.
It would be great if someone could help us with this.Hi Nidhi,
I have tried the blog but due to some reason, could not get it worked out.
But, If U are ok to use CSV input files, instead of excel, U can use the standard component "GS_FILE_UPLOAD" as a popup and upload the files into the required assignment blocks. -
Uploading the file into sap ( fields are seprerated by ' | '.
Hi All,
Plz let me know how to upload the file into sap in which the fields are separated by the symbol ' | '
sample file format
Material|Oracle_Item_type
(89034)|PFG
001069-000-97|BTF/BTS
001070-000-97|SRV PTS
001074-000-00|SRV PTS
001086-000-97|SRV PTS
001143-000-97|SRV PTS
001176-000-97|SRV PTS
001197-000-97|SRV PTSdata: gt_txtar TYPE truxs_t_text_data.
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = ' | '
TABLES
i_tab_sap_data = itab
CHANGING
i_tab_converted_data = gt_txtar.
CONCATENATE '/usr/sap/tmp/file.txt' INTO lv_dwnfile.
OPEN DATASET lv_dwnfile FOR OUTPUT IN TEXT MODE ENCODING UTF-8 .
loop at gt_txtar.
TRANSFER gt_txtar TO lv_dwnfile.
endloop.
CLOSE DATASET lv_dwnfile .
Regards
Sathar
Edited by: Sathar RA on Sep 1, 2008 9:47 AM -
Loading an Excel file into a Z-Table
Hi Gurus,
Can somebody guide me how to load an excel file into a Z-Table.Hi,
You need to write a ABAP code for this....
The following is the code for loading data into an internal table:
types: begin of ttab,
rec(1000) type c,
end of ttab.
types: begin of tdat,
fld1(10) type c,
fld2(10) type c,
fld3(10) type c,
end of tdat.
data: itab type table of ttab with header line.
data: idat type table of tdat with header line.
data: file_str type string.
parameters: p_file type localfile.
at selection-screen on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
exporting
static = 'X'
changing
file_name = p_file.
start-of-selection.
file_str = p_file.
call function 'GUI_UPLOAD'
exporting
filename = file_str
tables
data_tab = itab
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.
delete itab index 1.
loop at itab.
clear idat.
split itab-rec at cl_abap_char_utilities=>horizontal_tab
into idat-fld1
idat-fld2
idat-fld3.
append idat.
endloop.
loop at idat.
write:/ idat-fld1, idat-fld2, idat-fld3.
endloop.
From this internal store it onto the database.....
Sharma one more thing you must have posted this question in ABAP fourum for better results....
Hope it helps,
Thanks,
Happy Life,
Aravind -
A query while importing an XML file into a Database Table
Hi,
I am Creating an ODI Project to import an XML file into a Database Table.With the help of the following link
http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/odi/odi_11g/odi_project_xml-to-table/odi_project_xml-to-table.htm
I am facing a problem while creating Physical Schema for the XML Source Model.
For the
Schema(Schema)
and
Schema(Work Schema) field they have selected GEO_D.
What is GEO_D here??
or
What I have to select here?
1) schema of the xml file (NB:-I havn't created any .xsd or .dtd file for my .xml file)
or
2)my target servers schema
Please tell me what I'll do??
Thanksand
Schema(Work Schema) field they have selected GEO_D.
What is GEO_D here??This is the schema name which is specified in the XML file .
What I have to select here?
1) schema of the xml file (NB:-I havn't created any .xsd or .dtd file for my .xml file)Yes
2)my target servers schema
Please tell me what I'll do??
Thanks -
Upload excel file in SAP BI-7.0
Hi ,
i need to upload an excel file in SAP BI 7.0 where the standard r/3 fm are not available.
Currently we uploading a file in CSV format but now we want to upload using XLS also.
ia way to upload excel file in SAP BI 7.0
Best Regards,
Sharad
Edited by: sharad narayan on Jan 7, 2011 10:58 AM
while searching the forum i found the fm MS_EXCEL_OLE_STANDARD_DAT .
but while using this FM i am getting the exception file not exist.
Kindlu suggest what to do
i even tried the FM TMP_GUI_GET_FILE_EXIST' to check the existence of the file.
even then same problem.
Please suggest
Edited by: sharad narayan on Jan 10, 2011 2:51 PMHi,
Scheduled jobs are the jobs for which we have scheduled for a time, may be daily so that each day the scheduled jobs will trigger at the time given.So that every time u need not to trigger the job manully urself as the schedule time will hit the job will trigger itself.
Released job means the job which is in between Sheduled state and active state.say For eg: 10 jobs are Scheduled in a queue Job no 1 is released from the queue that means any moment it will be in active state.So it is the state between Schedule and Active state of a job.
Thanks
Varun -
T-code to upload mutliple files into SAP directories ?
Hi,
Is there any other transaction to upload multiple files into SAP directories ( ALL11) other than CG3Z ? Any other procedures at the operating system level ? Please advise.
Regards
ShivaI dont think so. But you can :
-- Ask your developer to create a BDC for this transaction to upload multiple files.
-- Use LSMW to record this transaction to upload multiple files.
Regards,
Jazz -
Uploading Excel File in SAP In Background Mode
Dear All,
We require to upload Excel File in SAP in Background Mode.
Could anyone suggest me the Function Module for this?
Or any other method..........please.
Thanks in advance for ur kind help.
Best Regards,
Prasadhi check this..
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9831750a-0801-0010-1d9e-f8c64efb2bd2
Download in Background
http://sapabap.iespana.es/sap/info/rfcexec/rfcexec_e.htm
Reward if find useful
Maybe you are looking for
-
My security cams record in a .264 file format HD. I want to view, edit, etc on my Mac, what software will do that and are there any easy tips to do this? I'm new to Mac's so I'm not sure what is the best format to convert to? mp4? Suggestions? Th
-
I should note, I am using the latest version as of today, I am using the portable version, and I have a TON of addons, a list of which I can post if I have to. Any Ideas what could be causing this? I use the "Open link in a New Tab" option every sing
-
Why am I getting an error message in Adobe Bridge?
An error has occurred during the delete operation. Some files may not have been processed...then to click OK
-
Calendar events created in iPhone don't sycn to iCal
I migrated from a Blackberry to iPhone about a month ago, so am somewhat green to the nuances of the platform. I notice that when I create a calendar event in the iPhone (3g, 2.2.1), it does not get sync'ed to my iCal calendar. Changes in iCal sync t
-
anyone ever have this problem wit their S10 netbook where you flip the screen down and the computer goes into standby mode, but after an hour the computer boots itself up and the screen turns on? This has happened to me ever since I got my netbook an