Conver a report in to txt file

Hi all,
I need to convert the report output into txt file .How can i do that?. can any one post some sample codes.
Regards,
Lisa.

Here is a sample program which submits the report program, brings the output back from memory and downloads it to a text file.
report zrich_0003 .
data: begin of listout occurs 0,
      line(1024) type c,
      end of listout.
* Submit the report and export list to memory
submit your_report_program exporting list to memory
            and return.
* Get list from memory and convert to ascii
perform retrieve_list_from_memory tables listout.
call function 'GUI_DOWNLOAD'
     exporting
          filename = 'C:Test.txt'
     tables
          data_tab = listout.
* RETRIEVE_LIST_FROM_MEMORY
form retrieve_list_from_memory tables reportlines.
  data: list like abaplist occurs 0 with header line.
  data: txtlines(1024) type c occurs 0 with header line.
  clear list.  refresh list.
  clear reportlines. refresh reportlines.
  call function 'LIST_FROM_MEMORY'
       tables
            listobject = list
       exceptions
            not_found  = 1
            others     = 2.
  check sy-subrc = 0.
  call function 'LIST_TO_ASCI'
       tables
            listobject         = list
            listasci           = txtlines
       exceptions
            empty_list         = 1
            list_index_invalid = 2
            others             = 3.
  check sy-subrc = 0.
  reportlines[] = txtlines[].
  call function 'LIST_FREE_MEMORY'.
endform.
Regards,
Rich Heilman

Similar Messages

  • Saving a CSV report output as TXT file

    Hi,
    We are generating reports on the web using Intenet Explorer. The report is a CSV report, i.e. the data displayed is comma separated. After generating the report, we need to save it as TXT file.
    If the length of a line is long (let us say more than 80 chars) while saving it as TXT file, it is saving as 2 lines. If the length of a line is less, then it is saving in a single line.
    How can I avoid this 2 line problem?
    I am not facing this problem if I generate report with Netscape browser and save as TXT file.
    We are using Reports 6i.
    Thanks in Advance,
    Srinivas

    Hello,
    I had the same problem. And I think what I did to fix it is I made the mode=charcter, batch=yes, and background=yes. Hope this helps.
    Martin

  • Report download to system as txt FILE.

    Hi All,
    My Requirement is to download the report output as .txt file in the local PC. As of now i am using fm WS_DOWNLOAD to download. But what is the problem is that the formatting and the positioning is diffrent from the report and the txt file. I heared that there is an option like write the report to spool & then we need to  read the spool as report wil gives the proper output. Does any one has that type of pgm ?? if so please send it to me its bit urgent. And please write comments also..
    Points awarded..??
    Thanks
    Raghu

    Hi,
    Use GUI_DOWLOAD FM instead. This should work fine.
    Else refer following program:
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    Best regards,
    Prashant

  • Export to Excel and Txt File

    Is there a way to export a report to more than one option?
    In other words, I need to be able to provide an option to
    report to excel and report to a txt file in a tilde-delimited format.

    I too am asking if there is an API to do things like this -
    i imagine I could run a trace and see what it does ....

  • Background processing of S_ALR_87013558 report with output in txt file

    Dear Friend's,
    Here I have a requirement of, to execute standard report S_ALR_87013558 (Budget/Actual/Commitment/Rem Plan/Assigned) in background processing mode. Here we have to run this report in background on daily basis at a particular given time.
    Once this report gets executed in background, output of this report should get converted automatically into txt file and this converted txt file must be downloaded in a respective folder automatically by giving desired path.
    After completion of this process, downloaded txt file they have to use for internal MIS reporting purpose.
    Is this possible via standard PS or else I have to go for the development.Please suggest, what should be the approach?
    Regards,
    Sandeep

    Hi Sandeep,
    Check if you can create batch job to run for S_ALR_87013558 using SM36
    The Program name is GP8YTY7TBR1TYRPCIPKAC6X9GZG
    Please check with ABAP.
    Regards,
    Nitin

  • Report with Access Database or TXT file

    Dear All,
    I was wondering if someone can help me with the following issue.
    We have created a Crystal Reports XI report which has a Access MDB or Plain Text file as source data (2 different reports; one with MDB connection only and the other one with a Lotus Notes ODBC connection and TXT file).
    The report runs correctly locally and it also runs correctly on the server but as soon as I post the report via the repository folder to the server, it does not work anymore.
    Viewing the report via InfoView gives me a password request while both, the MDB and TXT file are not password protected.
    We have tried to make system DSN and file DSN connections to both the MDB and TXT file but also this ends with a password request which is not defined.
    Did anyone came across this as well? Any idea about a solution?
    Thank you in advance,
    Annique.

    Hi Annique,
    Since this works in CR Designer I'm moving your post to the Business Objects forum.
    It's likely due to BOE servers not having access to the data sources. Make sure you put them in a folder that the WEB server and BOE Servers have access to. To prompt for log on is because we can't find the data files.
    Thank you
    Don

  • Import txt file into report

    I have an Arinc signal that I have decoded into each of its digital I/Os.  Since I have over 150 I/Os I needed a way to sort and do a quick report on them.
    I have three categories.
    1. Stayed =1 throughout test
    2. Stayed = 0 throughout test
    3. Changed either from 0 --> 1 or 1-->0 during the test.
    I want to just put a list of the signals for each of these categories into my report.
    I have created a txt file for these to go in, but how do I import that into my report?
    Or is there an easier way?
    Here is an example of my code...
    'HCM1
    'HCM1 Label 104 decode - Untitled 3
    Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_HSOV_A1_CLOSED"")= GetB (Ch(""[1]/Untitled 3""),0)")
    Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_HSOV_A2_CLOSED"")= GetB (Ch(""[1]/Untitled 3""),1)")
    Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_HPP_A_RUNNING"")= GetB (Ch(""[1]/Untitled 3""),2)")
    Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_SYS_A_HI_TEMP"")= GetB (Ch(""[1]/Untitled 3""),4)")
    Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_SYS_A_LO_PRS"")= GetB (Ch(""[1]/Untitled 3""),7)")
    Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_HPP_A_LO_PRS"")= GetB (Ch(""[1]/Untitled 3""),12)")
    Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_HPP_A_HI_TEMP"")= GetB (Ch(""[1]/Untitled 3""),13)")
    'HCM1 Label 105 decode - Untitled 4
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_HSOV_A1_FAIL"")= GetB (Ch(""[1]/Untitled 4""),0)")
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_HSOV_A2_FAIL"")= GetB (Ch(""[1]/Untitled 4""),1)")
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_EDP_A1_FAIL"")= GetB (Ch(""[1]/Untitled 4""),2)")
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_EDP_A2_FAIL"")= GetB (Ch(""[1]/Untitled 4""),3)")
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_SYS_A_PRS_FLT_CLG"")= GetB (Ch(""[1]/Untitled 4""),6)")
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_SYS_A_RET_FLT_CLG"")= GetB (Ch(""[1]/Untitled 4""),7)")
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_EDP_A1_FLT_CLG"")= GetB (Ch(""[1]/Untitled 4""),8)")
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_EDP_A2_FLT_CLG"")= GetB (Ch(""[1]/Untitled 4""),9)")
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_HPP_A_LO_QTY"")= GetB (Ch(""[1]/Untitled 4""),11)")
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_HPP_A_FAIL"")= GetB (Ch(""[1]/Untitled 4""),12)")
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_HPP_A_CDF_FLT_CLG"")= GetB (Ch(""[1]/Untitled 4""),14)")
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_IV_A_FAIL"")= GetB (Ch(""[1]/Untitled 4""),15)")
    Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_IV_A_FAIL_LOCAL"")= GetB (Ch(""[1]/Untitled 4""),16)")
    'HCM1 Label 106 decode - Untitled 5
    Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_SYS_A_PF_DPI_FAIL"")= GetB (Ch(""[1]/Untitled 5""),0)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_SYS_A_RF_DPI_FAIL"")= GetB (Ch(""[1]/Untitled 5""),1)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_EDP_A1_CDF_DPI_FAIL"")= GetB (Ch(""[1]/Untitled 5""),2)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_EDP_A2_CDF_DPI_FAIL"")= GetB (Ch(""[1]/Untitled 5""),3)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_EDP_A1_PS_FAIL"")= GetB (Ch(""[1]/Untitled 5""),4)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_EDP_A2_PS_FAIL"")= GetB (Ch(""[1]/Untitled 5""),5)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_SYS_A_PX_FAIL"")= GetB (Ch(""[1]/Untitled 5""),6)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_SYS_A_TX_FAIL"")= GetB (Ch(""[1]/Untitled 5""),7)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_SYS_A_QX_FAIL"")= GetB (Ch(""[1]/Untitled 5""),8)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_HSOV_A1_IND_FAIL"")= GetB (Ch(""[1]/Untitled 5""),10)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_HSOV_A2_IND_FAIL"")= GetB (Ch(""[1]/Untitled 5""),11)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_EDP_A1_FAIL"")= GetB (Ch(""[1]/Untitled 5""),12)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_EDP_A2_FAIL"")= GetB (Ch(""[1]/Untitled 5""),13)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_FV_A_FAIL"")= GetB (Ch(""[1]/Untitled 5""),14)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_HSOV_A1_RELAY_FAIL"")= GetB (Ch(""[1]/Untitled 5""),15)")
    Call Calculate ("Ch(""HCM1_106/HCM_1_HSOV_A2_RELAY_FAIL"")= GetB (Ch(""[1]/Untitled 5""),16)")
    Dim k, m, pMyChn, result, ArincTrue, intMyHandle01, intMyHandle02,intMyHandle03,intMyText, intMyError01, intMyError02, intMyError03
    intMyHandle01 = TextFileOpen("C:\ArincTrue.txt",tfCreate or tfWrite)
    intMyHandle02 = TextFileOpen("C:\ArincFalse.txt",tfCreate or tfWrite)
    intMyHandle03 = TextFileOpen("C:\ArincChange.txt",tfCreate or tfWrite)
    For k = 2 to 4
    For m = 1 to GroupChnCount(k)
    Set pMyChn = Data.Root.ChannelGroups(k).Channels(m)
    Result = ChnValMax(pMyChn)-ChnValMin(pMyChn)
    If Result = 0 and ChnValMax(pMyChn) > 0 then
    intMyText= TextfileWriteLn(intMyHandle01, pMyChn.Name)
    elseif result= 0 and ChnValMax(PMyChn) = 0 then
    intMyText= TextfileWriteLn(intMyHandle02, pMyChn.Name)
    else
    intMyText= TextfileWriteLn(intMyHandle03, pMyChn.Name)
    End If
    Next
    Next
    intMyError01 = TextFileClose(intMyHandle01)
    intMyError02 = TextFileClose(intMyHandle02)
    intMyError03 = TextFileClose(intMyHandle03)
    Solved!
    Go to Solution.

    Hi 2Pale4TX,
    You can't easily reference the content of an ASCII file.  Instead, I suggest you make a new Group of 3 text channels that you can drag onto a REPORT table.
    Dim k, m, z, ResultsGroup, TrueChannel, FalseChannel, ChangeChannel, Group, Channel, Result
    Set ResultsGroup = Data.Root.ChannelGroups.Add("Results")
    Set TrueChannel = ResultsGroup.Channels.Add("ArincTrue", DataTypeString)
    Set FalseChannel = ResultsGroup.Channels.Add("ArincFalse", DataTypeString)
    Set ChangeChannel = ResultsGroup.Channels.Add("ArincChange", DataTypeString)
    For k = 2 to 4
    Set Group = Data.Root.ChannelGroups(k)
    For m = 1 to Group.Channels.Count
    Set Channel = Group.Channels(m)
    ChMax = CMax(Channel)
    ChMin = CMin(Channel)
    Result = ChMax - ChMin
    If Result = 0 and ChMax > 0 Then
    z = TrueChannel.Size + 1
    TrueChannel(z) = Channel.Name
    Elseif Result = 0 and ChMax = 0 Then
    z = FalseChannel.Size + 1
    FalseChannel(z) = Channel.Name
    Else
    z = ChangeChannel.Size + 1
    ChangeChannel(z) = Channel.Name
    End If
    Next ' m
    Next ' k
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Is it possible to output a report as a text file (.txt) in a Data Driven Subscription?

    Is it possible to create a Data Driven Subscription report as a text file output to a shared folder? Thanks.
    Kahlua

    Hi Vicky:
    Thank you for your reply. I changed the config file in SSRS and it works. I managed to generate a text file with Data Driven Subscription as the report output in a shared folder. However is it possible not to have the "double quote" wrapping around
    the text. Do I need to modify the config file to remove the "double quote" and how. Thanks. 
    Kahlua
    <Render>
    <Extension Name="XML" Type="Microsoft.ReportingServices.Rendering.DataRenderer.XmlDataReport,Microsoft.ReportingServices.DataRendering"/>
    <Extension Name="NULL" Type="Microsoft.ReportingServices.Rendering.NullRenderer.NullReport,Microsoft.ReportingServices.NullRendering" Visible="False"/>
    <Extension Name="CSV" Type="Microsoft.ReportingServices.Rendering.DataRenderer.CsvReport,Microsoft.ReportingServices.DataRendering"/>
    <Extension Name="PDF" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.PDFRenderer,Microsoft.ReportingServices.ImageRendering"/>
    <Extension Name="TAB" Type="Microsoft.ReportingServices.Rendering.DataRenderer.CsvReport,Microsoft.ReportingServices.DataRendering">
    <OverrideNames>
    <Name Language="en-US">TAB (Tab Delimited Text File)</Name>
    </OverrideNames>
    <Configuration>
    <DeviceInfo>
    <FieldDelimiter xml:space="preserve">[TAB]</FieldDelimiter>
    <UseFormattedValues>True</UseFormattedValues>
    <NoHeader>True</NoHeader>
    <FileExtension>txt</FileExtension>
    <Qualifier xml:space="preserve"></Qualifier>
    <ExcelMode>False</ExcelMode>
    </DeviceInfo>
    </Configuration>
    </Extension>
    <Extension Name="RGDI" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.RGDIRenderer,Microsoft.ReportingServices.ImageRendering" Visible="False" LogAllExecutionRequests="False"/>
    <Extension Name="HTML4.0" Type="Microsoft.ReportingServices.Rendering.HtmlRenderer.Html40RenderingExtension,Microsoft.ReportingServices.HtmlRendering" Visible="False" LogAllExecutionRequests="False"/>
    <Extension Name="MHTML" Type="Microsoft.ReportingServices.Rendering.HtmlRenderer.MHtmlRenderingExtension,Microsoft.ReportingServices.HtmlRendering"/>
    <Extension Name="EXCEL" Type="Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer,Microsoft.ReportingServices.ExcelRendering"/>
    <Extension Name="RPL" Type="Microsoft.ReportingServices.Rendering.RPLRendering.RPLRenderer,Microsoft.ReportingServices.RPLRendering" Visible="false" LogAllExecutionRequests="false"/>
    <Extension Name="IMAGE" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering"/>
    <Extension Name="WORD" Type="Microsoft.ReportingServices.Rendering.WordRenderer.WordDocumentRenderer,Microsoft.ReportingServices.WordRendering"/>
    </Render>

  • Termination txt file not generating for EEA report for canada

    Hi
    When executing the EEA report for Canada ,the report output does not show any error for all the sample data.
    When I generate the txt files, it shows that all 4 files ( i.e. Employee.txt  , promo.txt , term.txt , error.txt) exported successfully.
    BUT when I check the folder created in C driver , I can only see Employee file and PROMO file. The TERM file is not getting created for the PERNRs with termination actions .
    ANY IDEA why is that so?
    HERE IS THE SAP REPORT OUTPUT :
    Summarized Employment Equity report:
           General data
               Industry sectors
                   Transportation & storage indus     1
               Employment status categories
                   Full-time employees                1
                   Part-time employees                0
                   Temporary employees                0
                   Other employees                    0
                   Casual employees                   0
               Provinces
                   New Bruns.                         1
               Designated CMAs
                   New Brunswick less CMA             1
               Peak Dates
                   All employees                  2012/02/09 - 2012/03/03
                   Temporary employees            2012/06/01 - 2012/06/01
           Employee data:                                  1
               00300838 claire ballings
               Event  Status Ind.Se Prov/CMA NOC/Job  Gender Abor.Mino.Disab Salary From    - to
               O      F      07     NB/      0641/02  Women  X               100000 20120209-20120225
               O      F      07     NB/0088  0641/02         X               100000 20120226-20120303
                F      F      07     NB/0088  0641/02         X               100000 20120304-20121231
    Export generated employee files for WEIMS       1 
    But when I check the folder in C drive , no TERM file is created !
    Edited by: Sarika Saini on Mar 7, 2012 2:08 PM

    This report generates the TERM.txt file only if the terminated employee has contract type - Temporary in IT0001 .

  • Outputting BW Reports as .txt files - Will award points

    Hello all,
       I am on 3.5, and need to schedule some reports to be run.  Here's the kicker - I need to be able to take the output of the reports and put them out on a server as a .txt file.
       Will happily award points for a good answer...
       Thanks.
    Dave Knudson

    No - this isn't what I mean.  I need to use a trans code (like rsrt) to output the file as .txt.  I do not want to use the browser.
    Here's the deal - right now I IB 300 or so reports a day.  I do not have a pre-calc server, so my only option is HTML.  My sales force hates HTML, and there are security/technical issues with giving them access to the BEx.  What I want to do is pre-run all of these reports, and dump them on a server somewhere.  Then a SQL trool can pick them up and parse them, and put them into individual file folders.
    What I want is ABAP code or a function module which will run the reports, and output the results as .txt.
    Thanks.
    Dave Knudson

  • Script to search all files in specified folder for multiple string text values listed in a source file and output each match to one single results txt file

    I have been searching high and low for this one.  I have a vbscript that can successfully perform the function if one file is listed.  It does a Wscript.echo on the results and if I run this via command using cscript, I can output to a text file
    that way.  However, I cannot seem to get it to work properly if I want it to search ALL the files in the folder.  At one point, I was able to have it create the output file and appear as if it worked, but it never showed any results when the script
    was executed and folder was scanned.  So I am going back to the drawing board and starting from the beginning.
    I also have a txt file that contains the list of string text entries I would like it to search for.  Just for testing, I placed 4 lines of sample text and one single matching text in various target files and nothing comes back.  The current script
    I use for each file has been executed with a few hundred string text lines I want it to search against to well over one thousand.  It might take awhile, but it works every time. The purpose is to let this run against various log files in a folder and
    let it search.  There is no deleting, moving, changing of either the target folder/files to run against, nor of the file that contains the strings to search for.  It is a search (read) only function, going thru the entire contents of the folder and
    when done, performs the loop function and onto the next file to repeat the process until all files are searched.  When completed, instead of running a cscript to execute the script and outputting the results to text, I am trying to create that as part
    of the overall script.  Saving yet another step for me to do.
    My current script is set to append to the same results file and will echo [name of file I am searching]:  No errors found.  Otherwise, the
    output shows the filename and the string text that matched.  Because the results append to it, I can only run the script against each file separately or create individual output names.  I would rather not do that if I could include it all in one.
     This would also free me from babysitting it and running each file script separately upon the other's completion.  I can continue with my job and come back later and view the completed report all in one.  So
    if I could perform this on an entire folder, then I would want the entries to include the filename, the line number that the match occurred on in that file and the string text that was matched (each occurrence).  I don't want the entire line to be listed
    where the error was, just the match itself.
    Example:  (In the event this doesn't display correctly below, each match, it's corresponding filename and line number all go together on the same line.  It somehow posted the example jumbled when I listed it) 
    File1.txt Line 54 
    Job terminated unexpectedly
     File1.txt Line 58 Process not completed
    File1.txt
    Line 101 User input not provided
    File1.txt
    Line 105  Process not completed
    File2.txt
    No errors found
    File3.txt
    Line 35 No tape media found
    File3.txt
    Line 156 Bad surface media
    File3.txt Line 188
    Process terminated
    Those are just random fake examples for this post.
    This allows me to perform analysis on a set of files for various projects I am doing.  Later on, when the entire search is completed, I can go back to the results file and look and see what files had items I wish to follow up on.  Therefore, the
    line number that each match was found on will allow me to see the big picture of what was going on when the entry was logged.
    I actually import the results file into a spreadsheet, where further information is stored regarding each individual text string I am using.  Very useful.
    If you know how I can successfully achieve this in one script, please share.  I have seen plenty of posts out there where people have requested all different aspects of it, but I have yet to see it all put together in one and work successfully.
    Thanks for helping.

    I'm sorry.  I was so consumed in locating the issue that I completely overlooked posting what exactly I was needing  help with.   I did have one created, but I came across one that seemed more organized than what I originally created.  Later
    on I would learn that I had an error in log location on my original script and therefore thought it wasn't working properly.  Now that I am thinking that I am pretty close to achieving what I want with this one, I am just going to stick with it.
    However, I could still use help on it.  I am not sure what I did not set correctly or perhaps overlooking as a typing error that my very last line of this throws an "Expected Statement" error.  If I end with End, then it still gives same
    results.
    So to give credit where I located this:
    http://vbscriptwmi.uw.hu/ch12lev1sec7.html
    I then adjusted it for what I was doing.
    What this does does is it searches thru log files in a directory you specify when prompted.  It looks for words that are contained in another file; objFile2, and outputs the results of all matching words in each of those log files to another file:  errors.log
    Once all files are scanned to the end, the objects are closed and then a message is echoed letting you know (whether there errors found or not), so you know the script has been completed.
    What I had hoped to achieve was an output to the errors.log (when matches were found) the file name, the line number that match was located on in that file and what was the actual string text (not the whole line) that matched.  That way, I can go directly
    to each instance for particular events if further analysis is needed later on.
    So I could use help on what statement should I be closing this with.  What event, events or error did I overlook that I keep getting prompted for that.  Any help would be appreciated.
    Option Explicit
    'Prompt user for the log file they want to search
    Dim varLogPath
    varLogPath = InputBox("Enter the complete path of the logs folder.")
    'Create filesystem object
    Dim oFSO
    Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
    'Creates the output file that will contain errors found during search
    Dim oTSOut
    Set oTSOut = oFSO.CreateTextFile("c:\Scripts\errors.log")
    'Loop through each file in the folder
    Dim oFile, varFoundNone
    VarFoundNone = True
    For Each oFile In oFSO.GetFolder(varLogPath).Files
        'Verifies files scanned are log files
        If LCase(Right(oFile.Name,3)) = "log" Then
            'Open the log file
            Dim oTS
            oTS = oFSO.OpenTextFile(oFile.Path)
            'Sets the file log that contains error list to look for
            Dim oFile2
            Set oFile2 = oFSO.OpenTextFile("c:\Scripts\livescan\lserrors.txt", ForReading)
            'Begin reading each line of the textstream
            Dim varLine
            Do Until oTS.AtEndOfStream
                varLine = oTS.ReadLine
                Set objRegEx = CreateObject("VBScript.RegExp")
                objRegEx.Global = True  
                Dim colMatches, strName, strText
                Do Until oErrors.AtEndOfStream
                    strName = oFile2.ReadLine
                    objRegEx.Pattern = ".{0,}" & strName & ".{0,}\n"
                    Set colMatches = objRegEx.Execute(varLine)  
                    If colMatches.Count > 0 Then
                        For Each strMatch in colMatches 
                            strText = strText & strMatch.Value
                            WScript.Echo "Errors found."
                            oTSOut.WriteLine oFile.Name, varLine.Line, varLine
                            VarFoundNone = False
                        Next
                    End If
                Loop
                oTS.Close
                oFile2.Close
                oTSOut.Close
                Exit Do
                If VarFoundNone = True Then
                    WScript.Echo "No errors found."
                Else
                    WScript.Echo "Errors found.  Check logfile for more info."
                End If
        End if

  • How to update a table AUTOMATICALY with data from a .txt file??

    HI ,
    I want to upload data which is in a notepad file and Create a table. This notepad file stores a string of datas. Here, the data comes in to the .txt file every second.
    (The data is actually stored into the notepad file when a program is executed in Processing.js software)
    Is it possible to do the following using APEX ? ?
    1. This table has to be updated automatically once in 2 minutes (I want this completely automatic, no human intervention -- no update buttons)
    2. A report is to be created in a apex application with this table, it should reflect the updates in the table every 2 minutes.
    Is it possible?? give your ideas.. I want to do this soon for my engineering project :) Any help from you is appreciated. :)
    Edited by: user13301695 on 28-Mar-2011 10:09

    And how do you expect your database server to access a local file in your machine ?
    Is the file accessible from outside your machine say inside a webserver folder so that some DB process can poll on the file ?
    Or, is your DB server in the same machine where you have the text file ?
    You will have to figure out the file acess part before automating user interaction or even auto-refreshing.

  • Email attachment with .txt file (first line blank in the file)

    Hi all ,
    Iam trying attach .txt file to email , the file that iam accessing from server  . But first line blank (extra) even though i dont have blank line in original file .Can any help me out to resolve this issue?
    <u>Example</u> original file
    12345     aa    pq
    <u>Email attachment file</u>
                                        -> This line
    12345     aa    pq
    This is my code:
    REPORT  ZTEST_FILE  .
    DATA:BEGIN OF t_upload occurs 0,
           matnr LIKE zwplcsmev-matnr,
           zwgehrrg LIKE zwplcsmev-zwgehrrg,
           zwgehrct LIKE zwplcsmev-zwgehrct,
           zwgbev LIKE   zwplcsmev-zwgbev,
           zwpldt LIKE zwplcsmev-zwpldt,
           zwacdt LIKE zwplcsmev-zwacdt,
         END OF t_upload.
    *DATA:  maildata type sodocchgi1.
    *DATA:  mailtxt type table of solisti1 with header line.
    *DATA:  mailrec type table of somlrec90 with header line.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:REC(80) TYPE C.
    DATA g_mask(20) TYPE c VALUE ',., ..'.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:P_ERROR(3).
    DATA:P_REFO(3).
    DATA:   gd_error TYPE sy-subrc,
            gd_reciever TYPE sy-subrc.
    DATA:   t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            w_cnt TYPE i,
            w_sent_all(1) TYPE c,
            w_doc_data LIKE sodocchgi1.
    selection-screen begin of block b1 with frame title text-001.
    parameters:p_file type localfile.
    parameter:p_email type ad_smtpadr.
    selection-screen end of block b1.
    --At Selection-Screen- -
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'TB_LIMIT_WS_FILENAME_GET'
          EXPORTING
            def_filename     = p_file
            mask             = g_mask
         mode             = 'S'
            title            = 'INPUT FILE'
          IMPORTING
            filename         = p_file
          EXCEPTIONS
            selection_cancel = 1
            selection_error  = 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.
    START-OF-SELECTION.
      PERFORM process_file.
      if p_error = 'X' AND P_REFO <> 'X'.
      PERFORM populate_message_body.
      ENDIF.
      IF P_REFO = 'X' AND P_ERROR <> 'X'.
      it_message = 'Please find Attached file'.
      APPEND it_message.
      PERFORM send_attachment tables it_message
                                 it_attach
                          using  p_email
                         'Crest to Plc Data'
                                          'TXT'
                                          p_file
                                 changing gd_error
                                          gd_reciever.
      ENDIF.
      Instructs mail send program for SAPCONNECT to send email(rsconn01)
    PERFORM initiate_mail_execute_program.
    END-OF-SELECTION.
    *&      Form  process_file
          text
    FORM process_file.
    *CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
                con_tab TYPE x VALUE '09'.   "OK for non Unicode
      DATA :l_path TYPE  string.
      l_path = p_file.
    CONSTANTS:  con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB
      con_cret type c value cl_abap_char_utilities=>newline.
    OPEN DATASET P_FILE  FOR INPUT IN TEXT MODE encoding default.
    if sy-subrc = 0.
    do.
    read dataset p_file into IT_ATTACH.
    IF SY-SUBRC  NE 0 .
    EXIT.
    ELSE.
    T_UPLOAD = IT_ATTACH.
    CONCATENATE con_cret it_attach  INTO it_attach .
    append it_attach.
    clear it_attach.
    P_REFO = 'X'.
    APPEND T_UPLOAD .
    clear t_upload.
    ENDIF.
    ENDDO.
    else.
    p_error = 'X'.
    ENDIF.
    ENDFORM.                    "process_file
    *&      Form  populate_message_body
          text
    FORM populate_message_body.
    w_doc_data-obj_name = 'TEST'.
      w_doc_data-obj_descr = 'Crest to Plc Data'.
      w_doc_data-obj_langu = sy-langu.
      it_message = 'File Not Found'.
      APPEND it_message.
    t_receivers-receiver = p_email.
      t_receivers-rec_type = 'U'.
      append t_receivers.
      call function 'SO_NEW_DOCUMENT_SEND_API1'
           exporting
                document_data              = w_doc_data
                document_type              = 'RAW'
                put_in_outbox              = 'X'
           tables
                object_header              = it_message
                object_content             = it_message
                receivers                  = t_receivers
           exceptions
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                others                     = 8.
        if sy-subrc = 0.
      commit work.
        SUBMIT rsconn01 USING SELECTION-SET 'SAP&CONNECTINT' AND RETURN.
      else.
        MESSAGE s027(vv) WITH 'E-mail not sent'.
      endif.
    ENDFORM.                    "populate_message_body
    *&      Form  send_attachment
          text
    FORM send_attachment tables pit_message
                                pit_attach
                         using  p_email
                                p_mtitle
                                p_format
                                p_filename
                                p_attdescription
                                p_sender_address
                                p_sender_addres_type
                       changing p_error
                                p_reciever.
      DATA:   ld_error    TYPE sy-subrc,
              ld_reciever TYPE sy-subrc,
              ld_mtitle LIKE sodocchgi1-obj_descr,
              ld_email LIKE  somlreci1-receiver,
              ld_format TYPE  so_obj_tp ,
              ld_attdescription TYPE  so_obj_nam ,
              ld_attfilename TYPE  so_obj_des ,
              ld_sender_address LIKE  soextreci1-receiver,
              ld_sender_address_type LIKE  soextreci1-adr_typ,
              ld_receiver LIKE  sy-subrc.
      ld_email  = p_email.
      ld_mtitle = p_mtitle.
      ld_format = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
      w_doc_data-doc_size = 1.
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = pit_attach[].
      clear t_attachment.
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = w_doc_data
          put_in_outbox              = 'X'
          sender_address             = ld_sender_address
          sender_address_type        = ld_sender_address_type
          commit_work                = 'X'
        IMPORTING
          sent_to_all                = w_sent_all
        TABLES
          packing_list               = t_packing_list
          contents_bin               = t_attachment
          contents_txt               = it_message
          receivers                  = t_receivers
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
      if sy-subrc = 0.
        commit work.
        SUBMIT rsconn01 USING SELECTION-SET 'SAP&CONNECTINT' AND RETURN.
      else.
        MESSAGE s027(vv) WITH 'E-mail not sent'.
      endif.
    Populate error return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.                    "send_attachment

    Just copy the code below and execute . I just checked and found the exact values on attachment with no blank lines. This is more simple than the one u have written , just include ur data upload logic . For ITAB values to be attached i have written a simple logic to retrive from EKPO. Just copy this code and execute. u will understand then.
    I understand that ur initial requirement was to attach the file directly and not to upload and attach. If u still want to go for the old requirement then check out the code(2nd program of the two that i have sent) that i have sent u on ur previous post.
    REPORT  ZEMAIL_ATTACH                   .
    TABLES: ekko.
    PARAMETERS: p_email   TYPE somlreci1-receiver
                                      DEFAULT '[email protected]'.
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
          wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
      ebeln(10) TYPE c,
      ebelp(5)  TYPE c,
      aedat(8)  TYPE c,
      matnr(18) TYPE c,
    END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            w_cnt TYPE i,
            w_sent_all(1) TYPE c,
            w_doc_data LIKE sodocchgi1,
            gd_error    TYPE sy-subrc,
            gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
      Retrieve sample data from table ekpo
      PERFORM data_retrieval.
      Populate table with detaisl to be entered into .xls file
      PERFORM build_TXT_data_table.
    *END-OF-SELECTION
    END-OF-SELECTION.
    Populate message body text
      perform populate_email_message_body.
    Send file by email as .TXT speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_message
                                          it_attach
                                    using p_email
                                          'Example .TXT documnet attachment'
                                          'TXT'
                                          'filename'
                                 changing gd_error
                                          gd_reciever.
      Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM initiate_mail_execute_program.
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp aedat matnr
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekpo.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_TXT_DATA_TABLE
          Build data table for .txt document
    FORM build_txt_data_table.
      CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
                 con_tab TYPE x VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen 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,
       con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
             INTO it_attach  SEPARATED BY SPACE . "con_tab.
    CONCATENATE con_cret it_attach  INTO it_attach." Use this if req.
      APPEND  it_attach.
      LOOP AT it_ekpo INTO wa_charekpo.
        CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
                    wa_charekpo-aedat wa_charekpo-matnr
               INTO it_attach SEPARATED BY SPACE ."con_tab.
       CONCATENATE con_cret it_attach  INTO it_attach." Use this if req.
        APPEND  it_attach.
      ENDLOOP.
    ENDFORM.                    " BUILD_txt_DATA_TABLE
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables pit_message
                                              pit_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = pit_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
           Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test ekpo records'.
      APPEND it_message.
    endform.                    " POPULATE_EMAIL_MESSAGE_BODY
    execute this code and i hope that will help u.
    regards,
    Barath.

  • How to get a txt file output of Bookmarks or Annotations

    I just tried to get a txt file report for the bookmarks. but its not working.
    var root = this.bookmarkRoot;
    var Report = new Report();
    PrintBookmark(Report, root, 0);
    Report.save("/c/temp/newreport.txt");
    function PrintBookmark(Report, Bm, nLevel)
    Report.writeText(Bm.name);
    if (Bm.children != null)
      for (var i = 0; i < Bm.children.length; i++)
       PrintBookmark(Report, Bm.children[i], nLevel + 1);
    This is the result i got in console.
    NotAllowedError: Security settings prevent access to this property or method.
    Report.save:5:Batch undefined:Exec
    Whats wrong i did?

    First of all, a Report is a PDF that you can generate with JavaScript, not a text file. It might be better to create a text data object (doc.createDataObject), which you can then export (doc.exportDataObject).
    Edit: corrected mistake

  • How to generate .txt file from data in internal table

    Hi I am using the program below to load .txt file into SAP table.
    I am moving the records from a .txt file into internal table final and then into ZOUT_CCFOBS table.
    How do I load records from internal table final back to another .txt file with the same layout? Pls advice.
    REPORT  ZOUP_LOAD_CCF_OBS.
    TABLES: ZOUT_CCFOBS.
    TYPES: BEGIN OF tline, "structure to store a line of each row
        line(1000) TYPE c,
    END OF tline.
    TYPES: BEGIN OF i_split, "structure to store split record of each row
          t_ZOTFACIL(100)    TYPE c,
          t_ZOTCCF(8)    TYPE c,
          t_ZOTOBSCAT(100)    TYPE c,
    END OF i_split.
    DATA: itab TYPE TABLE OF tline WITH HEADER LINE.
    DATA: idat TYPE TABLE OF i_split WITH HEADER LINE.
    DATA: final TYPE STANDARD TABLE OF ZOUT_CCFOBS WITH HEADER LINE.
    DATA: file_str TYPE string.
    DATA: c_fnh_mask TYPE dxfields-filemask VALUE '.',
          c_search_dir TYPE dxfields-longpath.
    SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
    PARAMETERS p_file LIKE rlgrap-filename.                "file location
    SELECTION-SCREEN END OF BLOCK a1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM f4_dxfilename USING p_file.
    START-OF-SELECTION.
    Download data from application server
      PERFORM download_data.
      file_str = p_file.
      LOOP AT itab.
        CLEAR idat.
    this will split the line at every delimeter into single field
        SPLIT itab-line AT ',' INTO idat-t_ZOTFACIL
        idat-t_ZOTCCF
        idat-t_ZOTOBSCAT.
        APPEND idat.
      ENDLOOP.
    copying the internal table into final table which compatible with table tcurr
      LOOP AT idat.
        final-ZOTFACIL = idat-t_ZOTFACIL.
        final-ZOTCCF = idat-t_ZOTCCF.
        final-ZOTOBSCAT = idat-t_ZOTOBSCAT.
        APPEND final.
      ENDLOOP.
      LOOP AT final.
        MODIFY ZOUT_CCFOBS FROM final.
        IF sy-subrc EQ 0.
          MESSAGE S001(ZCURR).
        ELSE.
          MESSAGE A000(ZCURR).
        ENDIF.
      ENDLOOP.
    FORM f4_dxfilename USING p_file.
    addition TAICK 15/07/2008.
    *maintain application server default search path.
      IF sy-sysid = 'BWP'.
        c_search_dir = '//rdmsbw/prd/data/output/all'.
      ELSEIF sy-sysid = 'BWQ'.
        c_search_dir = '//rdmsbw/uat/data/output/all'.
      ELSEIF sy-sysid = 'BWD'.
        IF sy-mandt = '900'.
          c_search_dir = '//rdmsbw/sit/data/output/all'.
        ELSE.
          c_search_dir = '//rdmsbw/dev/data/output/all'.
        ENDIF.
      ENDIF.
      DATA: wa_file LIKE dxfields-longpath.
      CLEAR: wa_file.
      CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
        EXPORTING
          i_location_flag = 'A'
          i_server        = ' '
          i_path          = c_search_dir
          filemask        = c_fnh_mask
          fileoperation   = 'R'
        IMPORTING
          o_path          = wa_file
        EXCEPTIONS
          rfc_error       = 1
          error_with_gui  = 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.
      ELSE.
        p_file = wa_file.
      ENDIF.
    addition end TAICK 15/07/2008.
    ENDFORM. " f4_dxfilename
    FORM download_data .
      OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      DO.
        IF sy-subrc <> 0.
          exit.
        ENDIF.
        READ DATASET p_file INTO itab.
        if sy-subrc = 0.
          APPEND itab.
        clear itab.
        endif.
      ENDDO.
      CLOSE DATASET p_file.
      delete itab index 1. "remove column header
    ENDFORM.                    " download_data
    Edited by: RebekahMBB on Feb 20, 2012 12:56 PM

    Hi I am using this piece of code to download my internal table into an .xls file on my pc.
    FORM Z_CONVERT_EXCEL .
      "This part of code to add column name in the downloaded file.
      data : begin of int_head occurs 0,
      Filed1(20) type c,                     " Header Data
      end of int_head.
      int_head-Filed1 = 'ZOTOUS'.
      APPEND int_head.
      CLEAR int_head.
      int_head-Filed1 = 'ZOTOUS'.
      APPEND int_head.
      CLEAR int_head.
      int_head-Filed1 = 'ZOTOGCUR'.
      APPEND int_head.
      CLEAR int_head.
    Select ZOTOUS ZOTSYORGU ZOTOGCUR from ZOUT_ORG_CURR into CORRESPONDING FIELDS OF TABLE itab.
      v_filetype = '.xls'. "I just manipulate the file name using XLS file type.
      v_filename = 'C:\Documents and Settings\00088592\Desktop\OUs automation\development'.
      CONCATENATE v_filename v_filetype INTO lv_filename.
      CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
            filename         = lv_filename
            filetype         = 'ASC'
          APPEND           = 'X'
            write_field_separator = 'X'
          CONFIRM_OVERWRITE = 'X'
       TABLES
            data_tab         = itab
            FIELDNAMES       = int_head
       EXCEPTIONS
            file_open_error  = 1
            file_write_error = 2
            OTHERS           = 3.
      IF sy-subrc <> 0.
      ENDIF.
    ENDFORM.                    "Z_CONVERT_EXCEL
    As you can see the code specifies the header row separately and appends it in int_head.
    What if I have 76 fields or more? I cant be specifying each like that.
    Is there any other way to do this? To move the 76 field headers into int_head?
    Pls help.
    Thanks!

Maybe you are looking for

  • ITunes 7.1.1.5 will not restore iPod

    My iPod Photo stopped playing, and when I tried to restored it with iTunes, I got the message "iPod cannot be restored because it contains files in use by another application". What files? What application? How can I get around this error? iPod Photo

  • Error instalation CE 7.2

    Hi, Im getting this error. does anyone know what it means? An error occurred while processing option SAP NetWeaver Composition Environment (CE) 7.2 > Installation Options > Application Server Java > Standard System > Standard System( Last error repor

  • Issue with Decimals

    Hi, I have a report which takes data from a BI BexQuery. I have BOE XI 3.1 and SAP7.1. I have 4 numeric values defined in same 100.12345 format in SAP. When i run the webI report one numeric value is picking data properly in 100.12345 format where as

  • Why the 3D graph control shortcut menu is disabled?And how to set 3D graph to default view when running?

    1).Controls have shortcut  menu,but the 3d graph's shortcut menu cannt be able. why? how to make it able? 2).3D graph can be rotated free by dragging, and when it is not running,right click ,select default view, the graph go back to initial view. But

  • Compiling a servlet file,HELP

    Hi, I have put the classpath of servlet-api.jar and jsp-api.jar in a batch file by name tomcat.bat.I ran the classpath and then tried javac on HelloServlet.java and I get a series of complation errors, /****** Errors *******/ HelloServlet.java:2: pac