How to use Export-csv

I have a loop at the end of my script which writes a bunch of stuff to the command window
foreach($i in $hash.keys){
write-host "Hostname: $i" ;
Write-host "Template:" "$($hash.$i)";
$objIwsList = $iwsObjSearcher.findAll() |
foreach-object{
$tmp_name = ($_.Properties.Item("distinguishedName")[0].split(',=')[3]);
$tmp_device = ($_.Properties.Item("Vps-deviceTemplate")[0].toString().split(',=')[1])|
where-object{$tmp_name -eq $hash.$i
if($tmp_device -ne $null){write-host "Device:" $tmp_device}
I'd like to export this to a CSV file but I can't figure out how to do it. It seems from all the examples I've found that you need to pass the export at the end of the pipeline? I can't just wrap this whole forloop within the export, eh?
Any help would be appreciated.

I've also noticed that you don't end the statements with semi-colons? Aren't you supposed to? After things like:
$props.Device=$null
Shouldn't it be:
$props.Device=$null;
As there is more than one statement running in that block? Anyhow, I'll continue to work away at it and see if there's something I can use in PS1 that will do the same thing as your -property switch.
Thanks
I recommend a basic book or course in PowerSHell. YTOu are not using V1 unless you are on XP.  All current versions use -property on New-Object.
Seli-colons are not used in PowerShell and are seen as white space except in a hash where they are terminators.
$hash=@{A=1;B-2}
Same as:
$hash=@{
     A=1
     B=2
Trying to use PowerSHell by gueesing at how it works from what you see on teh Internet is a very unuseful way of learning.  It will only lead you to wrong assumptions.
Use "$host.Version" to get the correct version.
All current versions of PS use PS1 extension and live in the "C:\Windows\System32WindowsPowerShell\v1.0" folder.
¯\_(ツ)_/¯

Similar Messages

  • Powershell Patching Information: Problems using Export-CSV / looping

    I've made a simple script that obtains patching information from a series of servers.
    The csv file I use to reference my servers is called patchlevels.csv and just contains some basic information.
    ServerName,OS,ServicePack,Patches,,,,,,,
    SERVER1,Server 2003 R2 Enterprise,SP2,,,,,,,,
    SERVER2,Server 2003 R2 Enterprise X64 Edition,SP2,,,,,,,,
    Yup, that's exactly as its formatted ^
    The problem I am having is updating the Patches column with a link to the server-specific htm file (I figure I can always save as xlsx within Excel to get clickable hyperlinks). I have failed multiple times over the last few hours using
    export-csv to try and update the Patches cell(s).
    Here is my script minus any failed export-csv references for clarity's sake:
    $currentPath = "$pwd\"
    $HostFileName = "patchlevels.csv"
    $CSVLoc = $currentPath + $HostFileName
    Import-Csv "$CSVLoc" | ForEach-Object {
    Write-Host "Processing..."
    Write-Host "------------------------------------------------------------" -ForegroundColor Yellow
    $ServerName=$_.ServerName
    $ServerFile = "$ServerName.htm"
    $OS=$_.OS
    $ServicePack=$_.ServicePack
    $_.Patches = $_.Patches.replace("[","$ServerFile")
    Write-Host "Server Name: $ServerName"
    Write-Host "Operating System: $OS"
    Write-Host "Service Pack: $ServicePack"
    Write-Host "Processing Patch List"
    wmic /node:$ServerName /output:$ServerName.htm qfe list
    Write-Host "Patch List generated for $ServerName"
    Write-Host "------------------------------------------------------------" -ForegroundColor Yellow
    Write-Host "END PROCESSING"
    I can see two things that may be wrong:
    1) Formatting of my CSV file (,,,,,,)
    2) I am not sure about the formatting of $_.Patches = $_.Patches.replace("[","$ServerFile")
    And obviously, I'm missing the export-csv commands to update the patchlevels.csv file with the htm file location (which is what this entire post is about).
    Where would I put export-csv in this code to update my original csv as the script runs?
    Thanks in advance for any help with this.
    Kind Regards,
    Stephen

    I've modified the script so that it now actually works as I want it to (more-or-less).
    I will look into using Get-Hotfix instead of WMIC to check that I am happy with the returned data.
    Modified CSV (I changed the Patch column to a known value to simplify replace operation, I couldn't figure out how to replace " "):
    ServerName,OS,ServicePack,Patches,,,,,,,
    SERVER1,Server 2003 R2 Enterprise,SP2,None,,,,,,,
    SERVER2,Server 2003 R2 Enterprise X64 Edition,SP2,None,,,,,,,
    Working code.
    $currentPath = "$pwd\"
    $HostFileName = "patchlevels.csv"
    $CSVLoc = @()
    $CSVLoc = $currentPath + $HostFileName
    Import-Csv "$CSVLoc" | ForEach-Object {
    Write-Host "Processing..."
    Write-Host "------------------------------------------------------------" -ForegroundColor Yellow
    $ServerName=$_.ServerName
    $ServerFile = "$ServerName.htm"
    $OS=$_.OS
    $ServicePack=$_.ServicePack
    Write-Host "Server Name: $ServerName"
    Write-Host "Operating System: $OS"
    Write-Host "Service Pack: $ServicePack"
    Write-Host "Processing Patch List"
    wmic /node:$ServerName /output:$ServerFile qfe list
    Write-Host "Patch List generated for $ServerName"
    Write-Host "------------------------------------------------------------" -ForegroundColor Yellow
    Write-Host "END DATA GATHERING"
    Write-Host "Updating CSV File"
    $update = Import-Csv "$CSVLoc"
    $update | ForEach-Object {
    $ServerName=$_.ServerName
    $ServerFile = "$ServerName.htm"
    $_.Patches = $_.Patches.replace("None",$currentpath + $ServerFile)
    $update | Export-Csv $CSVLoc -NoTypeInformation -Force
    Write-Host "OPERATION COMPLETE"
    Thanks,
    Stephen

  • How to use a .csv file as a database ?

    Hi everyone,
    I have a .csv file and I need to update some values in a column based on some condition. Basically I want to use the .csv file as a database such that I can perform query on it and update the result set as required.
    I am having trouble using csvjdbc though, can anyone give me a simple example about how to build a new database and import the csv file into it? Many thanks!!
    By the way, I tried a small program which was found online:
    import java.sql.*;
    public class test {
    public static void main(String args[]) throws Exception{
    Class.forName("org.relique.jdbc.csv.CsvDriver");
    System.out.println("I'm ok!");
    But I got an exception as following:
    Exception in thread "main" java.lang.ClassNotFoundException: org.relique.jdbc.csv.CsvDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at test.main(test.java:5)
    Could anyone tell me how to fix it? Thanks.
    Arjin

    It's because Class.forName will throw ClassNotFoundException if it cannot locate the class file. You need to set classpath so that org.relique.jdbc.csv.CsvDriver class can be located by ur code.

  • How to use EXPORT AND IMPORT in OO

    Hi all
    i am trying to send a table to a memory but i am making in a OO to , Does anybody knows how to do it?, i have already check de documentation but it doesn't show any help. please syncerlly i need a help
      EXPORT it_trans_print TO MEMORY ID 'AB'. this is the line that show an error.
    bye

    Hi Gilos,
    You can use Export statement like what mentioned in above threads.
    Actually there is an alternate for this.
    Try this....
    You can also replace the export memory id with a static component in a class.
    I prefer declaring a global class, and a table as a static public property in the same class.
    If you use that Global static component and populate some value to it, through out the execution the value will be there. So you can ignore the export memory id statement. and use a static component.
    Thanks,
    Sreekanth

  • How To Use Exported Function "CallInstrument" of LabView.exe ?

    Hello!
    I want to use the function "CallInstrument" to dynamically call VIs with LabView. Did anyone has experiences with this function?
    All I kow is following:
    The function is used by LabView Internals and its Runtime Library. Its exported by LabView.Exe and lvrt.dll.
    Its prototype is maybe:
    int CallInstrument(CPStr* VIPath, int controlcount, int indicatorcount, int options, [ Variable List of Control/Indicator Parameters ]... );
    ( CPStr Type is a StringArray of PStr (Short PascalStrings) as it is used by LabView to store Path datatypes. )
    I whould be glad, if anyone has information about this function.

    Dear Rolf Kalbermatter,
    Thirst, thanks a lot for your answer! -
    You sure right, It whould be much much more comfortable to use the VI Server.
    And you're also right... using a undocumented dll-function is absolutly no longtime solution.
    Currently I am using VI Server for my problem, but it doesn't fit my interesst so much.
    But I will explain, what I'm trying to do.
    I want to call a VI dynamically from LabView, giving Parameters to its Controls and receive Results from its Indicators.
    Realy no big job, but VI Server only let you do this that easy if you have a VI Typedef. otherwise... with untyped VIs, its not that simple. Ok.. its not impossible, you can use "GetAllControlValues" and "SetControlValue" (functions from VI server) and the call "RunVi". But this can get slow (>100ms per call :/ )
    I'm looking for a alternative function, which let me call a VI dynamically with userdefined Parameters. Maybe you know the ActiveX Interface IVirtualInstrument and its Function "Call2" - it is a nice example, what kind of function i want.
    But this function is not directly available by the VI Server--- i don't know for what reason.
    Then i tried to make use of "Call2" from within LabView, and it took me some time to find out the right Parametersyntax but finnaly i got it and it worked fine ... but it was no long time until problems occur. I cannot tell what really went wrong, but sometimes labview simply crashed or hang into a loop reseting some VIs. And its also impossible to stop a running vi, with has made a call to "Call2", if the call doesn't return by itself.
    Next step is/was trying to take advantage of CallInstrument. So, yesterday... after hours of analysing assemblercode, i finnally found out the correct use of LabView.exe->CallInstrument and i'm very impressed about its speed (0-15ms per call). The prototype seem to be the same as you explained in your reply int CallInstrument(Path path, Bool modal, int32 nInputs, int32 nOutputs, ...)
    But It has the same problem as its ActiveX derivat "Call2".. if you call an endless looping VI, LabView cannot stop your caller-vi. The other bad thing is, that this function is using dynamic paramterlist, which are placed directly onto the stack!
    That means that the paramter count on the stack is NOT FIXED (printf makes it the same). LabVIews DLL InvokeNode doesn't support this.
    At my current position, it looks like i have three possiblities but no one fits into my interesst.
    (continued with next answer)

  • How to use "Exporting Roles as Multitrack QT Movie"?

    I have to export a project with multiple subtitles tracks (English/Dutch/Portuguese/etc.)
    After exporting I need to make a DVD, so that the viewer can choose which subtitles he wants to watch.
    I've searched all over the Internet and found out that I have to export them using "Multitrack QT Movie", but after exporting I just get a normal movie with ALL the subtitles together, one on top of the other.
    Any suggestions?
    I'm using FCPX 10.0.7 on Mountain Lion.

    I don't have either DVD Studio Pro or Encore so I make my DVDs with iDVD which as far as I know does not support multiple text tracks that you can pick from as a menu choice when you play the DVD. When I use multiple subtitles I create each language using a basic text title effect. I then assign each language as a title subrole. Then I share the project as roles so I have a video file, a music/sound file, and multiple title llanguage files. I use QT 7 pro to make these into one movie file. QT pro has an add movie capability which allows multiple video tracks in one movie. You simply open one file first. Then open each of your other files in turn, select all and copy. Then in the original file under edit menu select "add movie" and it will be pasted into the original. After you do this look in the properties window and you will have all your video tracks. you can then turn off the languages you don't want to export, adjust transparency to get the alpha channel for your selected language and bring it into iDVD. You do need to make sure the layers are such that the language layer is on top. Do this for however many languages you have. The downside of this approach is you duplicate the main video, but since iDVD doesn't have a means to select tracks via menu I know of no other way to do what you want without the advanced authoring programs like Ecore etc. The upside is you do only work from one movie file, which you then make selective exports to iDVD.

  • How to use EXPORT  (user option)  ... IMPORT  for migrating ROLES and SYNONYMS

    Hi,
    I want to export a user from one machine to another one. And I have many roles and synonyms to migrate also. How to export / import them because when I import, I have only tables not roles and synonyms.
    Thanks.

    as far as I know, export doesnt export synonyms and roles.
    What I do is write sql scripts that create scripts to recreate all public synonyms, private synonyms, and roles.
    YOu want to roles created ahead of time anyway so that the import can do the grants.

  • How to use exporting prameter IT_FILTER in FM 'REUSE_ALV_GRID_DISPLAY'

    Hi ALL,
    Can u plz tell me what are the fields which i must pass for using IT_FILTER in FM 'REUSE_ALV_GRID_DISPLAY'.
    I am passing
    DATA:WT_TAB TYPE SLIS_T_FILTER_ALV ,
    ws_fieldcat1 TYPE SLIS_FILTER_ALV.
    ws_fieldcat1-fieldname = 'SHIP_TO'.
    ws_fieldcat1-tabname = 'WT_DATA'.
    ws_fieldcat1-convexit = 'ALPHA'.
    APPEND ws_fieldcat1 TO WT_TAB.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_buffer_active = wc_x
    i_callback_program = wv_repid
    is_layout = ws_layout
    it_fieldcat = wt_fieldcat
    i_save = 'A'
    it_events = wt_event
    IT_FILTER = WT_TAB
    TABLES
    t_outtab = wt_data
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    but it is giving dump.
    i think we have to pass more fields while creating  WT_TAB.
    Plz suggest.
    Thanks

    Hi Mahesh,
    Below detail is from the documentation of the 'REUSE_ALV_GRID_DISPLAY'. Check the last point.
    Filter criteria for first list output
    Description: Table with filter criteria
    Using this parameter, you can pass on filter criteria resulting from explicitly loading a display variant in advance, for example, to list output.
    This table should never be set up 'manually'.
    I can suggest use FM 'REUSE_ALV_GRID_LAYOUT_INFO_GET' and check the format of the filter table.
    Hope this will be useful to you!
    Thanks,
    Raj

  • How to save in CSV or TXT file the Powershell script output?

    Hi,
    I am not sure how to expot this to csv/TXT file, should I use export-csv "c:\test.csv" ?
    my code:
    $site = Get-SPSite "http://tst.pg.com/sites/tsta"
    Write-Output("`n" + $site.URL)
    $myweb = $site.AllWebs | where {$_.url -eq $site.url}
    Foreach ($list in $myweb.Lists) 
    if($list.BaseType -eq "DocumentLibrary")
          Write-Output("")
    Write-Output("Doc Library Name:" + $list.Title)                
    Write-Output($list.roleassignments | ft Member,RoleDefinitionBindings -auto)
    }$site.dispose()

    Hi there - If you just want to dump the output as a txt file, how about the following?
    .\yourpowershell.ps1 > output.txt
    Please remember to mark your question as answered and vote it helpful if this solves or helps with your problem. *******************************************************************************************************

  • Export-csv output maximum row size

    Hi all. May I know the maximum row size that can output to .csv using 'export-csv'??

    There's no limit on writing to a CSV file.
    You can try:
    # max rows to export to CSV:
    $i=0
    While ($true) { #Forever
    $i++
    $i
    "Some text" | Export-Csv -Path .\test12.csv -Append -NoTypeInformation
    until you run out of disk space, which may take a while. A million lines using the above script makes a 5 BM file..
    Now reading it back is an entirely different story. Try
    Delimit..
    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable)

  • How to use the CallInstrument function?

    Hello!,
    Related to the message "How To Use Exported Function CallInstrument of LabView.exe? <http://forums.ni.com/ni/board/message?board.id=170&message.id=118159>", can anybody show me a minimal C source example of how to generate the correct definition of the control/indicators parameters?. In other words, I need the definition of the typedef array for the datatype and the pointer to the unflat data of the controls/indicators to be passed to the CallInstrument function.
    At the moment, I have just only used this función without any controls/indicadors parameters.
    MgErr __cdecl CallInstrument( Path path, Bool32 modal, int32 nInputs, int32 nOutputs, ... );
    MgErr MyCallInstrument( char szPath[] ) {
         Path path = NULL;
     MgErr err;
     FTextToPath( szPath, strlen(szPath), &path );
     return CallInstrument( path, TRUE, 0, 0 );
    System: WinXP, LV7.1.1
    Thanks !!!
    Jesus Valero
    Plataforma Solar de Almeria <http://www.psa.es>.

    Hola Javier,
    Lo primero darte las gracias por contestar y lo segundo disculparme por no haberte contestado antes, pero en honor a la verdad acabo de ser padre del hijo más guapo de todo el mundo, por lo que no he podido hacerlo hasta hoy.
    Pues bien, mi intención es crear un control ActiveX que pueda ser integrado en el panel frontal de un archivo VI para que pueda interactuar directamente con este mismo VI. También me gustaría que indirectamente pudiera ejecutar otros Sub-VI's, estableciento los valores de sus controles y leyendo sus indicadores.
    En realidad ya expuse esto mismo en el foro
    http://forums.ni.com/ni/board/message?board.id=170&message.id=150060#M150060
    Pero me encontré con el problema que allí detallo, y como nadie me contestó tuve que investigar por mi cuenta llegando como último paso a la función interna CallInstrument. Y aqui estamos.
    Muchas gracias de antemano.

  • How can I export the report to Excel or CSV format in Rational(Java)?

    <p>Dear all,</p><p>Now I develop CR report integrate with Web application, I use Ratioanl(RAD) to develop. And I want to export the report to Excel/CSV format, but always failed.</p><p>If I force it export CSV file in the system, when I use MS office to open this CSV file, the file content is bad.</p><p>Could any one tell me how to achieve this?</p><p> Many thanks!</p><p>Steven</p>

    <p>CR4E is bundled with RAD 7...actually to be clear it is a version of CR4E Professional. Users of RAD 7 will also get a dev/test license of CR Server as well as number of additional features to support developing applications against their BusinessObjects Enterprise or Crystal Reports Server systems. For more information regarding the RAD 7 launch you can read the press release here:</p><p><strong><a href="http://biz.yahoo.com/bw/061205/20061205005363.html?.v=1">http://biz.yahoo.com/bw/061205/20061205005363.html?.v=1</a> </strong> </p><p>I am hoping to do a webinar in January highlighting a number of the new features available with the IBM Rational Application Developer integration.</p><p>As for RAD 6 support, unfortunately the CR4E toolkit does require Eclipse 3.2 support so it will not work with RAD 6. </p><p>Regards,<br />Sean Johnson (CR4E Product Manager) <br /><br /> <strong><a href="http://www.eclipseplugincentral.com/Web_Links-index-req-ratelink-lid-639.html">Rate this plugin @ Eclipse Plugin Central</a></strong>          </p>

  • How can I export the universe  to CSV format in Rational      (java)

    How can I export the universe to CSV format in Rational ,please give me one demo .thanks!!

    There's no direct access to an Universe from Java - Universes do have an SDK, but it's COM-based.
    If what you want is to retrieve data from the Universe, what you can do is create a Web Intelligence document reporting off that Universe, create a Query with the data you want from the Universe, then use the ReportEngine (REBean) SDK to retrieve the ResultSet from the Query - note that there's no CSV export option, so you'd have to walk through the ResultSet and write to an CSV yourself.
    Sincerely,
    Ted Ueda

  • How can we export table data to a CSV file??

    Hi,
    I have the following requirement. Initially business agreed upon, exporting the table data to Excel file. But now, they would like to export the table data to a CSV file, which is not being supported by af:exportCollectionActionListener component.
    Because, when i opened the exported CSV file, i can see the exported data sorrounded with HTML tags. Hence the issue.
    Does someone has any solution for this ... Like, how can we export the table data to csv format. And it should work similar to exporting the data to excel sheet.
    For youre reference here is the code which i have used to export the table data..
    ><f:facet name="menus">
    ><af:menu text="Menu" id="m1">
    ><af:commandMenuItem text="Print" id="cmi1">
    ><af:exportCollectionActionListener exportedId="t1"
    >title="CommunicationDistributionList"
    >filename="CommunicationDistributionList"
    >type="excelHTML"/> ---- I tried with removing value for this attribute. With no value, it did not worked at all.
    ></af:commandMenuItem>
    ></af:menu>
    ></f:facet>
    Thanks & Regards,
    Kiran Konjeti

    Hi Alex,
    I have already visited that POST and it works only in 10g. Not in 11g.
    I got the solution for this. The solution is :
    Use the following code in jsff
    ==================
    <af:commandButton text="Export Data" id="ctb1">><af:fileDownloadActionListener contentType="text/csv; charset=utf-8"
    >filename="test.csv"
    >method="#{pageFlowScope.pageFlowScopeDemoAppMB.test}"/>
    ></af:commandButton>
    OR
    <af:commandButton text="Export Data" id="ctb1">><af:fileDownloadActionListener contentType="application/vnd.ms-excel; charset=utf-8"
    >filename="test.csv"
    >method="#{pageFlowScope.pageFlowScopeDemoAppMB.test}"/>
    ></af:commandButton>
    And place this code in ManagedBean
    ======================
    > public void test(FacesContext facesContext, OutputStream outputStream) throws IOException {
    > DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    >DCIteratorBinding itrBinding = (DCIteratorBinding)dcBindings.get("fetchDataIterator");
    >tableRows = itrBinding.getAllRowsInRange();
    preparaing column headers
    >PrintWriter out = new PrintWriter(outputStream);
    >out.print(" ID");
    >out.print(",");
    >out.print("Name");
    >out.print(",");
    >out.print("Designation");
    >out.print(",");
    >out.print("Salary");
    >out.println();
    preparing column data
    > for(Row row : tableRows){
    >DCDataRow dataRow = (DCDataRow)row;
    > DataLoaderDTO dto = (DataLoaderDTO)dataRow.getDataProvider();
    >out.print(dto.getId());
    >out.print(",");
    >out.print(dto.getName());
    >out.print(",");
    >out.print(dto.getDesgntn());
    >out.print(",");
    >out.print(dto.getSalary());
    >out.println();
    >}
    >out.flush();
    >out.close();
    > }
    And do the following settings(*OPTIONAL*) for your browser - Only in case, if the file is being blocked by IE
    ==================================================================
    http://ais-ss.usc.edu/helpdoc/main/browser/bris004b.html
    This resolves implementation of exporting table data to CSV file in 11g.
    Thanks & Regards,
    Kiran Konjeti

  • How to use GUI_upload for Uploading a CSV file in Microsoft Excel.

    Hi Guys,
                  can anybody tell me how to Upload the CSV format file in Microsoft excel sheet?
    Thanks,
    Gopi.

    Hi Gopi,
    u can use GUI_UPLOAD, TEXT_CONVERT_XLS_TO_SAP.
    Please check these codes.
    Uploading data from CSV file format into internal table using GUI_UPLOAD
    REPORT zupload MESSAGE-ID bd.
    DATA: w_tab TYPE ZTEST.
    DATA: i_tab TYPE STANDARD TABLE OF ZTEST.
    DATA: v_subrc(2),
    v_recswritten(6).
    PARAMETERS: p_file(80)
    DEFAULT 'C:\Temp\ZTEST.TXT'.
    DATA: filename TYPE string,
    w_ans(1) TYPE c.
    filename = p_file.
    CALL FUNCTION 'POPUP_TO_CONFIRM'
    EXPORTING
    titlebar = 'Upload Confirmation'
    * DIAGNOSE_OBJECT = ' '
    text_question = p_file
    text_button_1 = 'Yes'(001)
    * ICON_BUTTON_1 = ' '
    text_button_2 = 'No'(002)
    * ICON_BUTTON_2 = ' '
    default_button = '2'
    * DISPLAY_CANCEL_BUTTON = 'X'
    * USERDEFINED_F1_HELP = ' '
    * START_COLUMN = 25
    * START_ROW = 6
    * POPUP_TYPE =
    * IV_QUICKINFO_BUTTON_1 = ' '
    * IV_QUICKINFO_BUTTON_2 = ' '
    IMPORTING
    answer = w_ans
    * TABLES
    * PARAMETER =
    * EXCEPTIONS
    * TEXT_NOT_FOUND = 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.
    CHECK w_ans = 1.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = filename
    * FILETYPE = 'ASC
    has_field_separator = 'X'
    * HEADER_LENGTH = 0
    * READ_BY_LINE = 'X'
    * IMPORTING
    * FILELENGTH =
    * HEADER =
    TABLES
    data_tab = i_tab
    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.
    * SYST FIELDS ARE NOT SET BY THIS FUNCTION SO DISPLAY THE ERROR CODE *
    IF sy-subrc <> 0.
    v_subrc = sy-subrc.
    MESSAGE e899 WITH 'File Open Error' v_subrc.
    ENDIF.
    INSERT ZTEST FROM TABLE i_tab.
    COMMIT WORK AND WAIT.
    MESSAGE i899 WITH sy-dbcnt 'Records Written to ZTEST'.
    Uploading data from Excel file format into internal table using TEXT_CONVERT_XLS_TO_SAP
    REPORT  zupload_excel_to_itab.
    TYPE-POOLS: truxs.
    PARAMETERS: p_file TYPE  rlgrap-filename.
    TYPES: BEGIN OF t_datatab,
          col1(30)    TYPE c,
          col2(30)    TYPE c,
          col3(30)    TYPE c,
          END OF t_datatab.
    DATA: it_datatab type standard table of t_datatab,
          wa_datatab type t_datatab.
    DATA: it_raw TYPE truxs_t_text_data.
    * At selection screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          field_name = 'P_FILE'
        IMPORTING
          file_name  = p_file.
    *START-OF-SELECTION.
    START-OF-SELECTION.
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
    *     I_FIELD_SEPERATOR        =
          i_line_header            =  'X'
          i_tab_raw_data           =  it_raw       " WORK TABLE
          i_filename               =  p_file
        TABLES
          i_tab_converted_data     = it_datatab[]    "ACTUAL DATA
       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.
    * END-OF-SELECTION.
    END-OF-SELECTION.
      LOOP AT it_datatab INTO wa_datatab.
        WRITE:/ wa_datatab-col1,
                wa_datatab-col2,
                wa_datatab-col3.
      ENDLOOP.
    reward if helpful
    raam

Maybe you are looking for

  • Week and Day view for Calendar

    All, HTMLDB 1.6 Will HTMLDB generate a week / day view out-of-the-box, like the Month view ? If not, any suggestions on how I can generate these views myself ? THx

  • IPhone keyboard a strange color and quits in Google app and Chrome app

    I'm experiencing strange behavior on my iPhone 4s (iOS version 6.1.3) in two apps: Google Search and Chrome. In these apps, when I invoke the virtual keyboard, it is an odd light violet color rather than the normal black/white/gray color. The keyboar

  • Conditional approval for payment

    Hi Experts,                wanna set approval for on- account outgoing payment . Tried following queries but not working. Kindly suggest the correct one SELECT (Case When (select $[ovpm.nodocsum.0]) > 0 then 'TRUE' Else 'FALSE' End) TF FROM OVPM wher

  • Thinking of cancelling all 8 contracts because of the RAZR

    I have had my Driod Razr ever since it first came out. I was never really impressed with it to begin with because the battery life is AWFUL....even with the help of apps like JuiceDefender and Advanced Task Manager- it dies within a few hours of usag

  • [solved] Can not compile gtk2 apps

    Hello every one When trying to compile, for example, lingot, I'm getting this: I'm getting this when try to compile: checking whether to enable maintainer-specific portions of Makefiles... no checking whether we are cross compiling... no checking for