SSIS Excel import skip first rows
Hello,
1. Is it possible during import data from Excel to DB table skip first 6 rows for example?
2. Also Excel data divided by sections with headers. Is it possible for example to skip every 12th row?
Thank you,V. A.
1.In Excel connection you cannot remove the 1st n rows as you want.
2. Not possible.
1. YES YOU CAN. Actually, you can do this very easily if you know the number columns that will be imported from your Excel file. In your Data Flow task, you will need to set the "OpenRowset" Custom Property of your Excel Connection (right-click
your Excel connection > Properties; in the Properties window, look for OpenRowset under Custom Properties). To ignore the first 5 rows in Sheet1, and import columns A-M, you would enter the following value for OpenRowset: Sheet1$A6:M (notice,
I did not specify a row number for column M. You can enter a row number if you like, but in my case the number of rows can vary from one iteration to the next)
2. AGAIN, YES YOU CAN. You can import the data using a conditional split. You'd configure the conditional split to look for something in each row that uniquely identifies it as a header row; skip the rows that match this 'header logic'.
Another option would be to import all the rows and then remove the header rows using a SQL script in the database...like a cursor that deletes every 12th row. Or you could add an identity field with seed/increment of 1/1 and then delete all rows
with row numbers that divide perfectly by 12. Something like that...
Similar Messages
-
File Adapter - Skipping first row (header row) in a csv file
How can I skip processing the first row in BPEL? I have a csv file and the first row has column header that I should not process.
ThanksHi,
Use nxsd:headerLines="1" in the declaration section see the sample below
Name,Street,City,State,Country
ABC Private Limited, Street 1, Bangalore, Karnataka, India
XYZ Private Limited, Street 2, Bangalore, Karnataka, India
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
targetNamespace="http://www.oracle.com/ias/processconnect"
xmlns:tns="http://www.oracle.com/ias/processconnect"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
nxsd:encoding="US-ASCII"
*nxsd:headerLines="1"* nxsd:stream="chars"
nxsd:version="NXSD"> <xsd:element name="AddressBook">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Address" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Name" type="xsd:string" nxsd:style="terminated"
nxsd:terminatedBy="," >
</xsd:element>
<xsd:element name="Street" type="xsd:string" nxsd:style="terminated"
nxsd:terminatedBy="," >
</xsd:element>
<xsd:element name="City" type="xsd:string" nxsd:style="terminated"
nxsd:terminatedBy="," >
</xsd:element>
<xsd:element name="State" type="xsd:string" nxsd:style="terminated"
nxsd:terminatedBy="," > </xsd:element>
<xsd:element name="Country" type="xsd:string" nxsd:style="terminated"
nxsd:terminatedBy="${eol}" >
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element> -
select 'A' from dual
union
select '1' from dual
union
select '0' from dual
union
select '3' from dual
union
select '2' from dual
union
select '4' from dual;
Output of above query is
0
1
2
3
4
A
but i need as
A
0
1
2
3
4
Can anyone help?Hi,
This is Application Express forum.
I think your question belongs more to SQL and PL/SQL forum. Searching from that forum I did find this
sorting - numbers first and then the alphabets ?
Regards,
Jari
My Blog: http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0
Twitter: http://www.twitter.com/jariolai -
Regarding ssis - skip first 10 rows in excel source
Hi,
I have received an Excel Source file, but the first 10 rows have only company information; actual data starts from Row 11. How will you skip the first 10 rows and start reading from row 11Hi Koteswararao,
If the first row includes the column names, and the first 10 rows you said don’t include the first row. That means you want to skip the rows from 2 row to 10 row, then we can union two Excel sources to work around this issue. For more details, please refer
to the following steps:
Set the FirstRowHasColumnName property of the Excel Connection Manager to False, so the first row stores the column names in the sheet.
Drag two Excel Sources to the Data Flow Task.
In the Excel Source, use the SQL command below to replace the former(supposing there are three columns in the Excel sheet: col1, col2 and col3):
SELECT F1 AS col1,F2 AS col2, F3 AS col3 FROM
[sheet$A1:C1]
In the Excel Source 1, please type the SQL command below (note that the ‘n’ means the number of rows in the sheet):
SELECT F1 AS col1,F2 AS col2, F3 AS col3 FROM
[sheet$A11:Cn]
Drag a Union All component to the same task, then union those two Excel Sources.
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
How to ignore the first row in a csv import
Hello
This is the file we want to add to the datamodel:
https://www.mediafire.com/?a9xrwrwu79whu18
(BTW this is the csv output from a neat & free software called Jstock)
Here is an image of the problem:
As you can see they add automatically a timestamp in the A1 cell ruining the possibility of a clean import.
Can anyone help with a query to fix this and get the real headers?Hi NicoPer,
To follow your M code. You have this lines #"First Row as Header" = Table.PromoteHeaders(Source).
This mean you use first line ( the line include "timestamp=1415926728041" ) to make
table header. So you no need to use Table.Skip function. You just use one more Table.PromoteHeaders to make second line to your table header. Below is your code:
let
Source = Csv.Document(File.Contents("C:\PATH\JSTOCK.csv"),null,null,null,1252),
#"First Row as Header" = Table.PromoteHeaders(Source),
#"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"timestamp=1415926728041", type text}}),
FirstRowAsHeader = Table.PromoteHeaders(#"Changed Type")
in
FirstRowAsHeader
Regards, -
Program Will Not Read First Row in Excel Sheet
I am having difficulty getting my program to read the first row of my excel sheet. When I use the next() method the first time it automatically starts at the second row. Here is what I have for my method that reads the data from an excel file.
package excel;
import java.sql.*;
public class Excel
public void readexel(String filename) throws SQLException
Connection c = null;
Statement stmnt = null;
try
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=" + filename);
stmnt = c.createStatement();
String query = "Select * from [Sheet1$]" ;
ResultSet rs = stmnt.executeQuery( query );
while( rs.next() )
System.out.print("Row #" + rs.getRow() + ": ");
System.out.print( rs.getInt(1) + " " );
System.out.print( rs.getInt(2) + " ");
System.out.println( rs.getInt(3) );
catch( Exception e )
System.err.println( e );
}Thats because the first row typically contains the column headers, and you don't want them read as data. Either insert a blank row, or put in column labels, and than you can get the column labels/names from the ResultSetMetaData.
Message was edited by:
SomeoneElse -
SSIS excel destination , data loads into header row
I have SSIS package
that is supposed to load data into excel destination (template file).
The destination has first row is Title , 2nd row has headers so I do as follows,
Select
* from [TemplateName$A2:$AD10000]
But what happens is it inserts first set of data (SQL source) into second row of template which contains header names and overwrites but if I select A3 istead,
it gives error since mapping needs column names.
Please suggest, thanksyou dont need to select range like this for that
What you can do is just select property column names in first row in the excel connection manager for that
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
SSIS Excel destination blank row
I have create an SSIS package in VS 2005 (because we are still in the stone age) where I have three Excel exports using the Excel Destination. One works fine but the other two have a blank first row each time (the second row of the sheet). I have reviewed
other threads but cannot seem to find a solution.
I do not have extra data in my templates. I even tried creating new ones but that didn't help. Pressing <CTRL><END> takes me the the first line where the header is.
There was one that looked promising but the selected answer referred to dead Microsoft forum link (forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2915256&SiteID=1).
Any suggestions to fix this?
Thanks for any help.I think it may be because of some unprintable characters present at the end of the excel header row.did you try explicitly setting a range to start from 2nd row for them and see if blank row disappears
http://sqlserversolutions.blogspot.in/2009/02/selecting-excel-range-in-ssis.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to skip the first row in Text file (in Sql Loader)
Hi All,
How to say the control file to skip the first row of the text file..
i just going this example
this is my text file:
01308201222455038130820122245503813082012224550382
1090358 474661834012245503813082012 0075 0 00000000000 000000000 00000130820120000000000000000 136.84 -833.3911082012 000000 000 009035847466183 090358 47466183 0015007514300000970001430000097700BH1150274792012081320120811201208122012-08-11-22.45.50.38369899999.0075LIQJGL17
Control file:
OPTIONS
DIRECT = TRUE ,
PARALLEL = FALSE ,
SKIP = 1,
ERRORS = 0
UNRECOVERABLE
LOAD DATA
INFILE <"FILE_DIR">
BADFILE <"FILE_DIR">
INSERT
INTO TABLE DAILY_TRANSACTION
WHEN (1:1)='D'
TRAILING NULLCOLS
Above the Eaxmple text file i need to Skip the first row which is
01308201222455038130820122245503813082012224550382
please can anyone suggest me is this correct?
if not please correct me please
since two days i been serching but i didn't get any thing
Thank's
Edited by: Lavanya on 24-Sep-2012 00:51Lavanya wrote:
Hi Jeneesh,
Thank you for your prompt replay
I didn't try to load this control file
And i need one more question
I have Text file in my Machine which Contains very huge data so i was wrote one control file for that, and i got FTP connection also as well as.
My question is firstly I need to PUT the Text file Into Unix Server isn't?
so when i trying to put the text file into unix it's giving an error
ftp>put c:/abc.txt
Not connectedYou haven't succesfully made your FTP connection to the server.
e.g.
c:\>ftp
ftp> o testserver
Connected to testserver.mycompany.com.
220 testserver FTP server ready.
User (testserver.mycompany.com:(none)): myuser
331 Password required for myuser.
Password:
230 User myuser logged in.
ftp>then you can use FTP to put your data to the server. Remember, if you are transferring a text file from a windows based operating system to a unix server you need to put it in ASCII mode...
ftp> ascii
200 Type set to A.
ftp>which will automatically convert the windows CR/LF pairs to the single LF character used by unix. -
Export in Excel- always first row blank
hi,
if i export in excel file always i am getting first row as blank with line. how can i eliminate this row.Hi Kayadhu,
Generally, if we design a report and the top of report body remain extra blank space, it will result in the extra blank row after export the report to Excel. Please see the screenshot below:
In your case, please try to reduce the blank space in the report body. If the issue still persists, please post more information about your report design structure to us.
Regards,
Bin Long
Bin Long
TechNet Community Support -
Excel import: importing too many rows
I am working with SQL Developer 1.2.0 Build MAIN-29.98 and have a problem with Excel import: I would like to import some data from an XLS file. I click on Actions -> Import Data -> Excel, complete the dialog and check the DML: there are 3 insert into SQL statements that are correct (I can run them manually); however, SQL Developer imports not only 3 rows but much more! I cancelled the action after SQL Developer already imported 1015 rows!
What am I doing wrong?
Thanks!When I do a print preview I see only the rows and columns I entered, there is only one page. It seems that everything is ok in Excel.
In the Excel import dialog SQL Developer correctly shows the preview of the content of the XLS file.
Interestingly I often get a Java NullPointerException (local Java 6 JRE & JDK installation) when calling the Excel import dialog :( -
Re:colors in Excel sheet (first row should be completely filled with yellow
I am using the type pools OLE2 to put colors in the Excel sheet.
What is the property to fill color in the Excel sheet cell.
i got the text in colors but not the background...
for example:
i need the first row ie..the heading to be in yellow.
Can some one send me some sample code .plz its urgent..........Hi,
Check to see the following code:
Sub Find_match()
Dim Range1 As Range
Dim Range2 As Range
Set Range1 = Application.InputBox("Select the range on the first sheet to Compare", Type:=8)
Set Range2 = Application.InputBox("Select the range on the second sheet to Compare", Type:=8)
Dim range_row1 As Integer
Dim range_row2 As Integer
Dim loop_row1 As Integer
Dim loop_row2 As Integer
Dim find_value As String
range_row1 = Range1.Rows.Count
range_row2 = Range2.Rows.Count
For loop_row1 = 1 To range_row1
find_value = Range1.Cells(loop_row1, 1)
For loop_row2 = 1 To range_row2
If Range2.Cells(loop_row2, 1) = find_value Then
If Range1.Cells(loop_row1, 2) = Range2.Cells(loop_row2, 2) Then
Range1.Rows(loop_row1).Interior.Color = vbYellow
End If
End If
Next
Next
End Sub
When the macro run, it will prompt to select the range in both sheet, the range is where the cells contain the data, it contains two columns.
Jaynet Zhang
TechNet Community Support
Jaynet,
Thank you so much. This is exactly how I wanted it to work. The only thing I wanted to know which I will try and figure out while I await your answer is if I can make this work between workbooks instead of worksheets? Currently, it does not allow me to switch
workbooks when running the macro to select the second range. Thank you. -
Skip bad row during importing large dump into sql server
Hello,
I have an issue during importing very large (more than 3 GB) dump file into sql server express. I have used command line for this purpose. Unfortunately this file was exported in UTF-8 so I had to convert it unicode. The unicode columns contain N' prefix.
Unfortunately the file contains apostrophes in other fields as well.
My question is: Is there an opportunity to skip bad rows during importing? (Force import e.g.)
Sincerely, Laszlo Toth>>>Unfortunately the file contains apostrophes in other fields as well.
You can concatenate the single quote using the CHAR function to build the string:
SELECT N'Brian O'+CHAR(39)+'Brien'
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Importing problem - first song skips
Wonder if anyone has had this problem and, if so, how they fixed it. I've the most up-to-date version of iTunes. This happens with all the cds I import - the first song, 5 seconds into it, has a skip/momentary pause. Again, it is only the happening on the first song - everything else imports just fine. I've tried uninstalling and reinstalling the software but it still does it. This didn't happen in the older versions of the software I had. If anyone can help, I'd be most appreciative.
Gateway Windows XPCheck this out:
Songs That Skip On iPod
I hope this helps! -
How to skip first record while inserting data from a flat file to BW system
Hi Experts,
In my project we have to upload flat file into a BW system. I have written a program and it is working fine.
Now we have got another requirement. The flat file will have a header record (first row). While uploading the flat file we have to skip this record. How I can do so?
The code is as below:
FORM upload1.
DATA : wf_title TYPE string,
lt_filetab TYPE filetable,
l_separator TYPE char01,
l_action TYPE i,
l_count TYPE i,
ls_filetab TYPE file_table,
wf_delemt TYPE rollname,
wa_fieldcat TYPE lvc_s_fcat,
tb_fieldcat TYPE lvc_t_fcat,
rows_read TYPE i,
p_error TYPE char01,
l_file TYPE string.
DATA: wf_object(30) TYPE c,
wf_tablnm TYPE rsdchkview.
wf_object = 'myprogram'.
DATA i TYPE i.
DATA:
lr_mdmt TYPE REF TO cl_rsdmd_mdmt,
lr_mdmtr TYPE REF TO cl_rsdmd_mdmtr,
lt_idocstate TYPE rsarr_t_idocstate,
lv_subrc TYPE sysubrc.
TYPES : BEGIN OF test_struc,
/bic/myprogram TYPE /bic/oimyprogram,
txtmd TYPE rstxtmd,
END OF test_struc.
DATA : tb_assum TYPE TABLE OF /bic/pmyprogram.
DATA: wa_ztext TYPE /bic/tmyprogram,
myprogram_temp TYPE ziott_assum,
wa_myprogram TYPE /bic/pmyprogram.
DATA : test_upload TYPE STANDARD TABLE OF test_struc,
wa2 TYPE test_struc.
DATA : wa_test_upload TYPE test_struc,
ztable_data TYPE TABLE OF /bic/pmyprogram,
ztable_text TYPE TABLE OF /bic/tmyprogram,
wa_upld_text TYPE /bic/tmyprogram,
wa_upld_data TYPE /bic/pmyprogram,
t_assum TYPE ziott_assum.
DATA : wa1 LIKE test_upload.
wf_title = text-026.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = wf_title
default_extension = 'txt'
file_filter = 'Tab delimited Text Files (*.txt)'
CHANGING
file_table = lt_filetab
rc = l_count
user_action = l_action
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
OTHERS = 3. "#EC NOTEXT
IF sy-subrc <> 0.
EXIT.
ENDIF.
LOOP AT lt_filetab INTO ls_filetab.
l_file = ls_filetab.
ENDLOOP.
CHECK l_action = 0.
IF l_file IS INITIAL.
EXIT.
ENDIF.
l_separator = 'X'.
wa_fieldcat-fieldname = 'test'.
wa_fieldcat-dd_roll = wf_delemt.
APPEND wa_fieldcat TO tb_fieldcat.
CALL FUNCTION 'MESSAGES_INITIALIZE'.
CLEAR wa_test_upload.
Upload file from front-end (PC)
File format is tab-delimited ASCII
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file
has_field_separator = l_separator
TABLES
data_tab = i_mara
data_tab = test_upload
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.
EXIT.
ELSE.
CALL FUNCTION 'MESSAGES_INITIALIZE'.
IF test_upload IS NOT INITIAL.
DESCRIBE TABLE test_upload LINES rows_read.
CLEAR : wa_test_upload,wa_upld_data.
LOOP AT test_upload INTO wa_test_upload.
CLEAR : p_error.
rows_read = sy-tabix.
IF wa_test_upload-/bic/myprogram IS INITIAL.
p_error = 'X'.
MESSAGE s153 WITH wa_test_upload-/bic/myprogram sy-tabix.
CONTINUE.
ELSE.
TRANSLATE wa_test_upload-/bic/myprogram TO UPPER CASE.
wa_upld_text-txtmd = wa_test_upload-txtmd.
wa_upld_text-txtsh = wa_test_upload-txtmd.
wa_upld_text-langu = sy-langu.
wa_upld_data-chrt_accts = 'xyz1'.
wa_upld_data-co_area = '12'.
wa_upld_data-/bic/zxyzbcsg = 'Iy'.
wa_upld_data-objvers = 'A'.
wa_upld_data-changed = 'I'.
wa_upld_data-/bic/zass_mdl = 'rrr'.
wa_upld_data-/bic/zass_typ = 'I'.
wa_upld_data-/bic/zdriver = 'yyy'.
wa_upld_text-langu = sy-langu.
MOVE-CORRESPONDING wa_test_upload TO wa_upld_data.
MOVE-CORRESPONDING wa_test_upload TO wa_upld_text.
APPEND wa_upld_data TO ztable_data.
APPEND wa_upld_text TO ztable_text.
ENDIF.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM ztable_data.
DELETE ADJACENT DUPLICATES FROM ztable_text.
IF ztable_data IS NOT INITIAL.
CALL METHOD cl_rsdmd_mdmt=>factory
EXPORTING
i_chabasnm = 'myprogram'
IMPORTING
e_r_mdmt = lr_mdmt
EXCEPTIONS
invalid_iobjnm = 1
OTHERS = 2.
CALL FUNCTION 'MESSAGES_INITIALIZE'.
**Lock the Infoobject to update
CALL FUNCTION 'RSDG_IOBJ_ENQUEUE'
EXPORTING
i_objnm = wf_object
i_scope = '1'
i_msgty = rs_c_error
EXCEPTIONS
foreign_lock = 1
sys_failure = 2.
IF sy-subrc = 1.
MESSAGE i107(zddd_rr) WITH wf_object sy-msgv2.
EXIT.
ELSEIF sy-subrc = 2.
MESSAGE i108(zddd_rr) WITH wf_object.
EXIT.
ENDIF.
*****Update Master Table
IF ztable_data IS NOT INITIAL.
CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
EXPORTING
i_iobjnm = 'myprogram'
i_tabclass = 'M'
I_T_ATTR = lt_attr
TABLES
i_t_table = ztable_data
EXCEPTIONS
attribute_name_error = 1
iobj_not_found = 2
generate_program_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = 'zddd_rr'
msgty = 'E'
txtnr = '054'
msgv1 = text-033
EXCEPTIONS
OTHERS = 3.
MESSAGE e054(zddd_rr) WITH 'myprogram'.
ELSE.
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = 'zddd_rr'
msgty = 'S'
txtnr = '053'
msgv1 = text-033
EXCEPTIONS
OTHERS = 3.
ENDIF.
*endif.
*****update Text Table
IF ztable_text IS NOT INITIAL.
CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
EXPORTING
i_iobjnm = 'myprogram'
i_tabclass = 'T'
TABLES
i_t_table = ztable_text
EXCEPTIONS
attribute_name_error = 1
iobj_not_found = 2
generate_program_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = 'zddd_rr'
msgty = 'E'
txtnr = '055'
msgv1 = text-033
EXCEPTIONS
OTHERS = 3.
ENDIF.
ENDIF.
ELSE.
MESSAGE s178(zddd_rr).
ENDIF.
ENDIF.
COMMIT WORK.
CALL FUNCTION 'RSD_CHKTAB_GET_FOR_CHA_BAS'
EXPORTING
i_chabasnm = 'myprogram'
IMPORTING
e_chktab = wf_tablnm
EXCEPTIONS
name_error = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
****Release locks on Infoobject
CALL FUNCTION 'RSDG_IOBJ_DEQUEUE'
EXPORTING
i_objnm = 'myprogram'
i_scope = '1'.
ENDIF.
ENDIF.
PERFORM data_selection .
PERFORM update_alv_grid_display.
CALL FUNCTION 'MESSAGES_SHOW'.
ENDFORM.
Please let me know how I can skip first record of the flat file?
Regards,
Sgo through this hope u can get some idea
REPORT ztest no standard page heading line-size 255.
Declaration *
TYPES t_itab1 TYPE alsmex_tabline.
types: begin of t_csks,
kostl like csks-kostl,
end of t_csks.
types: begin of t_cska,
kstar like cska-kstar,
end of t_cska.
data: begin of t_flatfile,
docdate like COHEADER-BLDAT,
postdate like COHEADER-BUDAT,
doctext like COHEADER-BLTXT,
costele like RK23F-KSTAR,
amount like RK23F-WTGBTR,
scostctr like RK23F-SKOSTL,
rcostctr like RK23F-EKOSTL,
rintorder like RK23F-EAUFNR,
end of t_flatfile.
data: begin of t_flatfile1,
docdate like COHEADER-BLDAT,
postdate like COHEADER-BUDAT,
doctext like COHEADER-BLTXT,
costele like RK23F-KSTAR,
amount like RK23F-WTGBTR,
scostctr like RK23F-SKOSTL,
rcostctr like RK23F-EKOSTL,
rintorder like RK23F-EAUFNR,
NUM LIKE SY-INDEX,
end of t_flatfile1.
data: itab like table of t_flatfile with header line.
data: itab2 like table of t_flatfile1 with header line.
DATA: it_itab1 TYPE STANDARD TABLE OF t_itab1 WITH HEADER LINE,
MESSTAB1 LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,
MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
data: begin of bdcdata occurs 0.
include structure bdcdata.
data: end of bdcdata.
data:t_lin type i VALUE '0',
u_rec type i VALUE '0',
s_rec type i VALUE '0'.
data: it_csks type standard table of t_csks,
wa_csks type t_csks.
data: it_cska type standard table of t_cska,
wa_cska type t_cska.
*Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
parameters: p_docdat LIKE COHEADER-BLDAT obligatory,
p_postda LIKE COHEADER-BUDAT obligatory,
p_doctxt LIKE COHEADER-BLTXT.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-011.
parameters: p_file LIKE RLGRAP-FILENAME obligatory,
DIS_MODE LIKE CTU_PARAMS-DISMODE DEFAULT 'N'.
SELECTION-SCREEN END OF BLOCK b2.
A T S E L E C T I O N S C R E E N *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM get_local_file_name USING p_file.
*Start of Selection
START-OF-SELECTION.
Perform get_Excel_data.
perform validate_data.
Perform Process_Data.
end-of-selection
end-of-selection.
perform display_data.
*& Form get_local_file_name
text
-->P_P_FILE text
FORM get_local_file_name USING P_P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
CHANGING
file_name = p_file.
ENDFORM. " get_local_file_name
*& Form get_Excel_data
text
--> p1 text
<-- p2 text
FORM get_Excel_data .
FIELD-SYMBOLS : <FS>.
DATA : V_INDEX TYPE I.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = 1
i_begin_row = 2
i_begin_row = 1
i_end_col = 256
i_end_row = 9999 "65536
TABLES
intern = it_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.
Message text-013 type 'E'.
ENDIF.
IF IT_ITAB1[] IS INITIAL.
Message text-001 type 'E'.
else. "IF IT_ITAB1[] IS INITIAL.
data: itab2 like itab occurs 0 with header line.
SORT IT_ITAB1 BY ROW COL.
LOOP AT IT_ITAB1.
MOVE :IT_ITAB1-COL TO V_INDEX.
ASSIGN COMPONENT V_INDEX OF STRUCTURE itab2 TO <FS>.
MOVE : IT_ITAB1-VALUE TO <FS>.
AT END OF ROW.
MOVE-CORRESPONDING itab2 TO itab.
APPEND itab.
CLEAR:itab,itab2.
ENDAT.
endloop.
describe table itab lines t_lin.
endif. "IF IT_ITAB1[] IS INITIAL.
ENDFORM. " get_Excel_data
*& Form Process_Data
text
--> p1 text
<-- p2 text
FORM Process_Data .
data:l_tabix type sy-tabix.
data:l_periv like t001-periv,
l_monat like bkpf-monat,
l_gjahr like bkpf-gjahr,
l_amt(21) type c.
data: l_ddate(10),
l_pdate(10).
WRITE p_docdat TO l_ddate.
WRITE p_postda TO l_pdate.
clear: l_periv,l_monat,l_gjahr.
select single periv from t001 into l_periv where bukrs = '5000'. "P_bukrs
if sy-subrc eq 0.
l_gjahr = p_postda+0(4).
call function 'FI_PERIOD_DETERMINE'
EXPORTING
i_budat = p_postda
i_bukrs = '5000' "p_bukrs
i_periv = l_periv
i_gjahr = l_gjahr
IMPORTING
e_monat = l_monat.
clear:l_periv.
endif.
loop at itab2.
refresh:bdcdata.
clear:bdcdata.
l_tabix = sy-tabix.
perform bdc_dynpro using 'SAPLK23F1' '1200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'COHEADER-SEND_REC_REL'
'10SAP'.
perform bdc_field using 'RK23F-STATUS'
'S'.
perform bdc_field using 'COHEADER-BLDAT'
itab-docdate.
l_ddate.
perform bdc_field using 'COHEADER-BUDAT'
itab-postdate.
l_pdate.
perform bdc_field using 'COHEADER-PERIO'
l_monat. "'9'.
perform bdc_field using 'COHEADER-BLTXT'
itab-doctext.
p_doctxt.
perform bdc_field using 'RK23F-KSTAR'
itab2-costele.
WRITE itab2-amount TO l_amt.
l_amt = itab-amount.
condense l_amt no-gaps.
perform bdc_field using 'RK23F-WTGBTR'
l_amt.
itab-amount.
perform bdc_field using 'RK23F-WAERS'
'USD'.
*perform bdc_field using 'RK23F-SGTXT'
itab-doctext.
perform bdc_field using 'RK23F-SKOSTL'
itab2-scostctr.
perform bdc_field using 'BDC_CURSOR'
'RK23F-EAUFNR'.
perform bdc_field using 'RK23F-EKOSTL'
itab2-rcostctr.
perform bdc_field using 'RK23F-EAUFNR'
itab2-rintorder.
perform bdc_dynpro using 'SAPLK23F1' '1200'.
perform bdc_field using 'BDC_OKCODE'
'=POST'.
perform bdc_field using 'COHEADER-SEND_REC_REL'
'10SAP'.
perform bdc_field using 'RK23F-STATUS'
'S'.
perform bdc_field using 'COHEADER-BLDAT'
itab-docdate.
l_ddate.
perform bdc_field using 'COHEADER-BUDAT'
itab-postdate.
l_pdate.
perform bdc_field using 'COHEADER-PERIO'
'9'.
l_monat.
perform bdc_field using 'COHEADER-BLTXT'
itab-doctext.
p_doctxt.
perform bdc_field using 'BDC_CURSOR'
'RK23F-KSTAR'.
perform bdc_field using 'RK23F-WAERS'
'USD'.
CALL TRANSACTION 'KB15N' USING BDCDATA MODE DIS_MODE MESSAGES INTO MESSTAB.
If sy-subrc = 0.
s_rec = s_rec + 1.
ELSE.
u_rec = u_rec + 1.
move ITAB2-NUM to messtab1-msgv1.
concatenate itab2-costele ' | ' itab2-scostctr ' | ' itab2-rcostctr ' | ' itab2-rintorder into messtab1-msgv2.
condense messtab1-msgv2.
condense messtab1-msgv1.
append messtab1.
endif.
clear:itab2.
endloop.
ENDFORM. " Process_Data
BDC_DYNPRO *
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. "BDC_DYNPRO
BDC_FIELD *
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> ''. "NODATA.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM. "BDC_FIELD
*& Form display_data
text
--> p1 text
<-- p2 text
FORM display_data .
skip 2.
write:/15 text-002.
skip 2.
write:/8 text-003.
SKIP.
write:/12 text-008,
25 P_DOCDAT.
SKIP.
write:/12 text-009,
25 P_POSTDA.
SKIP.
write:/12 text-012,
25 P_DOCTXT.
SKIP.
write:/12 text-004,
25 p_file.
skip 2.
write:/8 text-005,
60 t_lin.
skip.
write:/8 text-006,
60 s_rec.
skip.
write:/8 text-007,
60 u_rec.
skip.
write:/10 'row no',
20 'Information'.
skip.
loop at messtab1.
write:/10 messtab1-msgv1,
20 messtab1-msgv2.
clear:messtab1.
endloop.
ENDFORM. " display_data
*& Form validate_data
text
--> p1 text
<-- p2 text
FORM validate_data .
data: l_tabix1 type sy-tabix.
data: l_tabix2 type sy-tabix.
if not itab[] is initial.
select kostl from CSKS into table it_csks.
if sy-subrc eq 0.
sort it_csks by kostl.
endif.
select kstar from CSKA into table it_cska.
if sy-subrc eq 0.
sort it_cska by kstar.
endif.
loop at itab.
l_tabix1 = sy-tabix.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = itab-scostctr
IMPORTING
OUTPUT = itab-scostctr .
read table it_csks into wa_csks with key kostl = itab-scostctr.
if sy-subrc ne 0.
u_rec = u_rec + 1.
L_TABIX2 = l_tabix1 + 1.
move l_tabix2 to messtab1-msgv1.
move l_tabix1 to messtab1-msgv1.
move itab-rintorder to messtab1-msgv2.
concatenate itab-costele ' | ' itab-scostctr ' | ' itab-rcostctr ' | ' itab-rintorder into messtab1-msgv2.
condense messtab1-msgv2.
condense messtab1-msgv1.
append messtab1.
clear:wa_csks.
CLEAR:L_TABIX2.
continue.
endif.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = itab-rcostctr
IMPORTING
OUTPUT = itab-rcostctr .
read table it_csks into wa_csks with key kostl = itab-rcostctr.
if sy-subrc ne 0.
u_rec = u_rec + 1.
L_TABIX2 = l_tabix1 + 1.
move l_tabix2 to messtab1-msgv1.
move l_tabix1 to messtab1-msgv1.
concatenate itab-costele ' | ' itab-scostctr ' | ' itab-rcostctr ' | ' itab-rintorder into messtab1-msgv2.
condense messtab1-msgv2.
condense messtab1-msgv1.
append messtab1.
clear:wa_csks.
CLEAR:L_TABIX2.
continue.
endif.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = itab-costele
IMPORTING
OUTPUT = itab-costele .
read table it_cska into wa_cska with key kstar = itab-costele.
if sy-subrc ne 0.
u_rec = u_rec + 1.
L_TABIX2 = l_tabix1 + 1.
move l_tabix2 to messtab1-msgv1.
move l_tabix1 to messtab1-msgv1.
concatenate itab-costele ' | ' itab-scostctr ' | ' itab-rcostctr ' | ' itab-rintorder into messtab1-msgv2.
condense messtab1-msgv2.
condense messtab1-msgv1.
append messtab1.
clear:wa_csks.
CLEAR:L_TABIX2.
continue.
endif.
move-corresponding itab to itab2.
MOVE l_tabix1 TO ITAB2-NUM.
append itab2.
clear: itab2.
clear:itab.
endloop.
else.
message 'No records in File' type 'S'.
endif.
ENDFORM. " validate_data
Maybe you are looking for
-
I cannot re-download music that is no longer on my computer
A portion of my purchaesed items are no longer located on my computer (not sure how) and itunes says that I've already downloaded and will not allow my to re-download and replace the "unlocated" songs. I tried to delete my purchased items in the hop
-
I have this problem were my iphone just reboots on its own
I have recently upgraded to io6 and my iphone 4 cdma started rebooting on its own. I took it to a store and they said to take the battery out because it was overheating. So now i lay with a iphone without a battery. Is there any way were i can take i
-
In my BlackBerry Curve 8520 any applicatio​n is not working
Hello.. My name is Hamza Qureshi. I am using blackberry curve 8520. My service provider is Airtel Prepaid.I am facing some problems when i am using 2g plan in my curve 8520 then except browser not a single application is not working like (whatapp, we
-
Hide your JS code? Now it's possible...
If anyone's is interested in being able to have a binary, practically non-reversible version of their JS scripts for PS versions CS to CS3 (Windows only at the moment; Earlier versions will probably work as well, but are not tested yet), I've develop
-
No Appointments Available in Any London Apple Store - ***?
I am trying to get an appointment to get my MacBook internally cleaned, having used it in Afghanistan for the last 6 months. There are no appointments at all available in any of the London Apple Stores. This is pretty poor to say the least - I unde