Help needed on CSV file uploading

Hi All,
I need to upload a csv file in the table through file browse button.For that i have created the below process and function.This method is working perfectly fine when the file size is small.But i need to upload the file of 16 MB size and when i try to upload that file it gives error wwv_flow.accept error.Any expert of APEX please help me out on this error.As i am very new to APEX and i need to get this done as early as possible.Please provide any solution ,i will be really grateful to the person.
function
create or replace function hex_to_decimal
--this function is based on one by Connor McDonald
--http://www.jlcomp.demon.co.uk/faq/base_convert.html
( p_hex_str in varchar2 ) return number
is
v_dec number;
v_hex varchar2(16) := '0123456789ABCDEF';
begin
v_dec := 0;
for indx in 1 .. length(p_hex_str)
loop
v_dec := v_dec * 16 + instr(v_hex,upper(substr(p_hex_str,indx,1)))-1;
end loop;
return v_dec;
end hex_to_decimal;
Process
DECLARE
v_blob_data BLOB;
v_blob_len NUMBER;
v_position NUMBER;
v_clob_data CLOB := 'anything';
dest_offset NUMBER := 1;
src_offset NUMBER := 1;
blob_csid NUMBER := dbms_lob.default_csid;
lang_ctx INTEGER := dbms_lob.default_lang_ctx;
warning INTEGER;
v_raw_chunk RAW(10000);
v_char CHAR(1);
c_chunk_len number := 1;
v_line VARCHAR2 (32767) := NULL;
v_data_array wwv_flow_global.vc_arr2;
v_rows number;
v_sr_no number := 1;
BEGIN
delete from scg_recievables2;
-- Read data from wwv_flow_files
select blob_content into v_blob_data
from wwv_flow_files
where last_updated = (select max(last_updated) from wwv_flow_files where UPDATED_BY = :APP_USER)
and id = (select max(id) from wwv_flow_files where updated_by = :APP_USER);
v_blob_len := dbms_lob.getlength(v_blob_data);
v_position := 1;
-- Read and convert binary to char
WHILE ( v_position <= v_blob_len ) LOOP
dbms_lob.converttoclob(v_clob_data, v_blob_data, v_blob_len, dest_offset,src_offset,blob_csid,lang_ctx,warning);
v_char := dbms_lob.getlength(v_clob_data);
v_line := v_line || v_char;
v_position := v_position + c_chunk_len;
-- When a whole line is retrieved </span>
IF v_char = CHR(10) THEN
-- Convert comma to : to use wwv_flow_utilities
v_line := REPLACE (v_line, ';', ':');
-- Convert each column separated by : into array of data
v_data_array := wwv_flow_utilities.string_to_table (v_line);
if IsNumber(substr(v_data_array(9),1,1)) = 1 then
v_data_array(9) := substr(v_data_array(9),1,11);
else
v_data_array(9) := '01-JAN-1900';
end if;
v_data_array(9) := NVL(v_data_array(9),'01-JAN-1900');
-- Insert data into target table
EXECUTE IMMEDIATE 'insert into scg_recievables2 (Account_receivable_number, the_account_number, bill_history_tran, service_number, item_type, the_amount_billed, the_remaining_amount,source_of_payment)
values (:1,:2,:3,:4,:5,:6,:7,:8,:9)'
USING
v_data_array(1),
v_data_array(2),
v_data_array(3),
v_data_array(4),
v_data_array(5),
v_data_array(6),
v_data_array(7),
v_data_array(8);
-- Clear out
v_line := NULL;
v_sr_no := v_sr_no + 1;
END IF;
END LOOP;
END;

You are probably timing out with your web server. Check the server logs to see if there are any errors there..
Thank you,
Tony Miller
Webster, TX
A lady came up to me on the street, pointed at my suede jacket and said "Do you know a cow was murdered to make that jacket?"
"I didn't know there were any witnesses", I replied " Now I'll have to kill you too"

Similar Messages

  • Help needed with header and upload onto business catalyst

    Can someone help with a problem over a header please?
    I have inserted a rectangle with a jpeg image in  background, in the 'header' section, underneath the menu. It comes up fine on most pages when previsualised, going right to the side of the screen, but stops just before the edge on certain pages. I have double checked that I have placed it in the right place in relation to the guides on the page.
    That's one problem.
    The second problem is that I tried to upload onto business catalyst, which got to 60% and refused to go any further, saying it couldn't find the header picture, giving the title and then u4833-3.fr.png. The picture is in the right folder I have double checked. And it isn't a png. Does it have to be ?
    And the third problem is that I got an email following my upload from business catalyst in Swedish. I am living in France.
    Can anyone help ? Thanks.

    Thanks for replying,
    How can I check the preview in other browsers before I publish a provisional site with BC?
    The rectangle width issue happens on certain pages but not others. The Welecom page is fine when the menu is active, also the contact page, but others are slightly too narrow. Changing the menu spacing doesn’t help - I was already on uniform but tried changing to regular and back.
    In design mode the rectangle is set to the edge of the browser, that’s 100%browser width right?
    Re BC I have about 200 images on 24 different pages and it seems to be having difficulty uploading some of them. But it has managed a couple I named with spaces but not others I named with just one name.
    Is there an issue on size of pictures ? If I need to replace is there a quick way to rename and relink or do I have to insert the photos all over again?
    I’m a novice with Muse with an ambitious site !
    Thanks for your help.
    Mary Featherstone
    Envoyé depuis Courrier Windows
    De : Sanjit_Das
    Envoyé : vendredi 14 février 2014 22:15
    À : MFeatherstone
    Re: Help needed with header and upload onto business catalyst
    created by Sanjit_Das in Help with using Adobe Muse CC - View the full discussion 
    Hi
    Answering the questions :
    - Have you checked the preview in Muse and also in other browsers ?
    - Does the rectangle width issue happens when menu is active , or in any specific state , Try to change the menu with uniform spacing and then check.
    - In design view the rectangle is set to 100% browser width ?
    With publishing :
    - Please try to rename the image file and then relink
    - If it happens with other images as well , see if all the image names includes strange characters or spaces.
    - Try again to publish
    With e-mail from BC :
    - Under preferences , please check the country selected.
    - If you have previously created partner account in BC and selected country and language then it would follow that, please check that.
    Thanks,
    Sanjit
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/6121942#6121942
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/6121942#6121942
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/6121942#6121942. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Help with using Adobe Muse CC at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • Need help to download csv file in application by writting to outputstream.

    HI All,
    Requirment of my client is donloading CSV file from portal.
    My approach  is:
    On clicking "Download" button in JSP I am calling an action in controller and from here I am redirecting call to DownloadCSV.jsp where i am writing to output stream of response.
    Action called in controller:
         @Jpf.Action(forwards = { @Jpf.Forward(name = StaticConstants.SUCCESS, redirect = true, path = "DownloadCSV.jsp") })
         public Forward gotoReports() {
              Forward forward = new Forward(StaticConstants.SUCCESS);
              return forward;
    Download jsp:
    response.resetBuffer();
         response.reset();
         response.setContentType("application/vnd.ms-excel");
         response.addHeader("Content-Disposition", "attachment;filename="+ companyId +"_Audit_Report.csv");
         ServletOutputStream os = response.getOutputStream();
              os .println();
              os .print("DATE");
              os .print("USER");
    os .println();
    os.flush();
    os.close();
    I am able to download the csv file in excel. But after that i am not able to perform any operation in portal page. Mouser pointer becomes busy and cant click on anything.
    Second approach followed:
    I wrote the code for writting to outputstream of outputresponse in controller action itself and forwarded to the same jsp where my download button resides.
    Problem:
    Download happens perfectly but the excel in csv format contains the portal framework generated content also other than content i wrote to response.
    If u have any other approach to download an excel without redirecting to JSP plz let me know. Coing is being done in 10.2 weblogic portal.
    Please help. Its very urgent.
    Plz let me know how a file can be downloded in portal context without keeping a file at server side. I need to download file by writting to outputstream.
    If it is possible plz attach one small example project also.
    Thanks a ton in advance.
    It is very important plz do reply.

    Hi Srinivas,
    For downloading binary content that is not text/html, the Oracle WebLogic Portal content management tools use javascript in an onclick event handler to set the window URL to the URL of a download pageflow controller: window.location = url. The content management tools are in a portal so it should be possible for you to do the same thing.
    The url is a custom pageflow controller that streams the bytes to the response. It sounds like you already have a pageflow you could recycle to use in that way. You don't want to stay within your portlet pageflow because then you will be streaming bytes into the middle of a portal response. You want a separate download pageflow that you invoke directly, outside of the portal framework (in other words, don't invoke it by rendering a portlet that invokes the pageflow).
    You can set the url to invoke the pageflow directly by giving the path to the pageflow controller from the web root (remember the pageflow path matches the package name of the pageflow controller class) like this: "/content/node/nodeSelected/download/DownloadContentController.jpf"
    By the way, for the case of text/html, the tools uses a standalone portlet URL so that the text/html is not rendered in the browser window, which would replace the portal markup (because the browser renders text/html by default, instead of giving you a download widget or opening some other application to deal with the bytes).

  • Help needed in BAPI for uploading data in FB01 -  Urgent!!!

    Hi,
        i need to post a document in FB01.
    i am getting the following details from the user in a .CSV file.
    Vendor no, vendor name, amount, document date, posting datem reference vendor line item text and Gl account line item text.
    i am using BAPI BAPI_ACC_DOCUMENT_POST to post the document.
    Now my req is if the amount is in negative then
       use posting key 31 against the vendor and 40 for GL account
    if its positive amounts
      use posting key of 24 against vendor and 50 against the GL account.
    Now by default, when the amount is negative the function is working fine.
                    but when its is positive its posting 21 against vendor and 50 against GL account. but i need 24 against vendor
    can any one tel me, where should i pass these value in the BAPI?
    or is there any other way of doing it?
    Regards,
    Niyaz

    Hi,
    the posting keys 31/21 (01/11 and 40/50) are hard coded and cannot be populated from the  interface. This is because a different posting key could have a different posting logic from what is implemented in the BAPI.
    So unless you want to do some modifications here, you have to use the fixed PKs. Pls. let me know if you are interested in where exactly the PKs are defined (hardcoded). I have this noticed for myself earlier but my notices are on another PC
    Hope that helps, points welcome
    Csaba

  • CSV File upload in SharePoint 2013

    Hi,
    We need to upload the CSV file in document library and need to call the java service in the event receiver and read the uploaded CSV file content and parse it as JSON and pass to the java service. 
    Is there anyway we can compare the already uploaded file content with same file name user trying to upload again with the same content . In case if user changed the some content and trying to upload again, we nee to identify whether the file is really updated
    the content or not. This will avoid the unnecessary java service call. Please let me know the suggestion.
    Thank you,
    Mylamy

    there is no method or properties to compare files.We have do row by row
    using power shell we can do it
    http://blogs.technet.com/b/stefan_stranger/archive/2011/02/08/compare-two-different-csv-files-using-powershell.aspx
    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/00ef8b0d-00d9-42fd-9b6a-c6de58b9bd00/using-powershell-to-compare-2-csv-files?forum=winserverpowershell
    other solutions
    http://stackoverflow.com/questions/5154370/compare-two-csv-file-using-in-c-sharp
    http://stackoverflow.com/questions/3458355/c-sharp-comparing-two-csv-files-and-giving-an-output

  • .CSV Files upload

    I have all my contacts in a web based database that can export .csv files. I want to upload this data to a fifth generation Ipod for contact management purposes.
    Does the ipod have a csv upload feature?
    How can do this?
    what is the easiest method? I would prefer not to upload to outlook b/f uploading to Ipod

    Welcome to Apple Discussions!
    Hm...Windows-formatted iPods take contacts from Outlook Express. Try taking your .csv files to Outlook for it to convert (I believe it will, however I'm not sure because I don't have it because I hate Outlook :P). If after Outlook takes your contacts, put your iPod into Disk Mode and when your plug your iPod in for synching with iTunes, you will see a folder that comes up with Contacts, Notes, and Calendar (the default name for the iPod drive is Drive F:, I believe). Take your contacts then from Outlook Express to your Contacts folder, that should work if all of the above goes smoothly.
    Be careful with Disk Mode though, it confuses a lot of people
    Hope this helps!
    rjl
    307

  • Schedule a CSV File upload?

    I have a requirement from a customer to upload a Exchance Rate Currency file into an Oracle 10g database table at a specific time every day. I can see how to upload the table, but I need to know if there is a way to schedule this to happen daily and if there are instructions on this process.
    I am using the utillity in Enterprise Manager to upload data from a CSV file.
    Thanks,
    Winston

    Thanks guys. I am actually running 10g on a Windows
    platform, so I can't follow the guidelines for that.
    HJ, can you expand a little on your suggestion? That
    doesn't mean anything to me. I'm fairly new to the
    Oracle DB.
    Thanks,
    WinstonOK, so write a batch file (to invoke sqlldr) and schedule it through the Windows scheduler. Same principal as writing a shell script and scheduling with cron.

  • Error message when CSV file link to datasource(CSV file upload to BW)

    hello friends,
    I have met one problem when i upload CSV file to BW, i want to show the error screenshot, how can i show it in this website?
    Please help me analysis it base below error message;
    tks;
    below is my steps
    1.create datasource;
    2.general info tab, input description
    3. extraction tab, input file name, value of data format is separated with separator (for example CSV),data separator is ,
    4.proposal tab, click "load example data",it can show correct data the same as CSV file;
    5.when i click fields tab, Popup show"field list no longer corresponds to dafault copy change? "Yes" or "NO" button"
    6.Click Yes, fields tab show correct data;
    7.click "read preview data " in preview Tab, show error infomation;
    ---Runtime error -description of exception;
    Runtime errors           Data_length_negative
    Except.                       CX_XY_RANGE_OUT_OF_BOUNDS
    short text             Invailid partial field access :length negative
    what happened  Errpr in the ABAP application  program
                                The current Abap program "CL_RSAR_PSA==============CP " has to be terminated bacause it has
                                come across a statement that unfortunately can't be executed.
    Error analysis
       An exception occured that is

    Please see the error message;
    Runtime Errors         DATA_LENGTH_NEGATIVE
    Except.                CX_SY_RANGE_OUT_OF_BOUNDS
    Date and Time          09/04/2009 21:34:14
    Short text
    Invalid partial field access: Length negative
    What happened?
    Error in the ABAP Application Program
    The current ABAP program "CL_RSAR_PSA===================CP" had to be
    terminated because it has
    come across a statement that unfortunately cannot be executed.
    What can you do?
    Note down which actions and inputs caused the error.
    To process the problem further, contact you SAP system
    administrator.
    Using Transaction ST22 for ABAP Dump Analysis, you can look
    at and manage termination messages, and you can also
    keep them for a long time.
    Error analysis
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_RANGE_OUT_OF_BOUNDS', was not
    caught in
    procedure "_GET_DDIC_STRUCTURE" "(METHOD)", nor was it propagated by a RAISING
    clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    In the executed program "CL_RSAR_PSA===================CP", the system
    attempted to access the field
    "ME->P_PSA_TECHNAME" using the length "-3".
    However, a partial field access with a negative length specification is
    not allowed.
    How to correct the error
    Use a positive length specification if a part of the field "ME->P_PSA_TECHNAME"
    is to be
    accessed.
    If the error occurred in your own ABAP program or in an SAP
    program you modified, try to remove the error.
    If the error occures in a non-modified SAP program, you may be able to
    find an interim solution in an SAP Note.
    If you have access to SAP Notes, carry out a search with the following
    keywords:
    "DATA_LENGTH_NEGATIVE" "CX_SY_RANGE_OUT_OF_BOUNDS"
    "CL_RSAR_PSA===================CP" or "CL_RSAR_PSA===================CM00A"
    "_GET_DDIC_STRUCTURE"
    If you cannot solve the problem yourself and want to send an error
    notification to SAP, include the following information:
    1. The description of the current problem (short dump)
    To save the description, choose "System->List->Save->Local File
    (Unconverted)".
    2. Corresponding system log
    Display the system log by calling transaction SM21.
    Restrict the time interval to 10 minutes before and five minutes
    after the short dump. Then choose "System->List->Save->Local File
    (Unconverted)".
    3. If the problem occurs in a problem of your own or a modified SAP
    program: The source code of the program
    In the editor, choose "Utilities->More
    Utilities->Upload/Download->Download".
    4. Details about the conditions under which the error occurred or which
    actions and input led to the error.
    The exception must either be prevented, caught within proedure
    "_GET_DDIC_STRUCTURE" "(METHOD)", or its possible occurrence must be declared
    in the
    RAISING clause of the procedure.
    To prevent the exception, note the following:

  • Help working with CSV files

    I have a CSV file with 3 columns
    Jobtitles-----ADRole1----- AdRole2
    title1---------Role1---------Role4
    title2---------Role2---------Role5
    title2---------Role3--------Role6
    And i also have a list of Active Directory Users in other variable $users.
    I need to get the AD users which jobtitle match the ones in the first column of the csv "jobtitles"
    I do it like:
    import-module activedirectory
    $csv2= Import-Csv e:\mycsv.csv | Select-Object JobTitles
    $Jobtitles = @()
    foreach ($line in $csv2) {
    $Jobtitles += $line.title
    $users = foreach ($user in $result){
    get-aduser $user.loginname -properties title, samaccountname
    foreach ($User in $Users) {
    if ($Jobtitles -contains $User.title) {
    write-host $User.samaccountname $User.title
    This works fine.
    What i don't know how to do is reference the same row in the csv
    For example if the user jobtitle matches title1, add the user to the AD group Role1 and Role4 (because it is in the same row as those roles)
    Any idea?
    thanks

    In the second line in your script, the " | select-object jobTitles" causes only the data from the jobTitles column in the .CSV file to be included in the array of objects stored in the $csv2 variable. If you avoid doing that, then all of the data from the
    .CSV file will be present in $CSV.
    But I don't think the code as shown "works fine". In the first foreach statement, your code references a property called .title, whereas the only property in $csv would appear to be .jobTitles. But, if it had been coded correctly, this would be a wasted
    step, as it seems only intended to create another array of "title" values, which you already have in $csv2.
    then the second foreach processes data in an undefined array called $result.
    With these issues, it is a little difficult to determine what actually happens in the following code.
    I'd suggest you give it another try then copy/paste the complete code for us to comment on.
    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

  • Help needed making SWF file loop

    Hello Everyone-
    I have been researching this topic and am really struggling.
    I'm not much of a HTML guy and I think I'll need to do some to
    resolve my issues. I have searched and searched but I'm not having
    any luck.
    I create an animation in Apple Motion, exported it as a MOV
    and imported it as video into Flash CS3. It was encoded using
    Progressive download from server it creates a FLV file a SWF file
    and an HTML file. My provider is 1and1. I then use Adobe GoLive to
    create my webpage and upload to the web. I need my SWF file to loop
    and I cannot get it to loop.
    In flash. Everything plays fine. When I do a publish preview
    however, the swf file does not loop. I've got the loop option
    checked in my publish preview settings and even in the inspector in
    GoLive but it does nothing.
    Here is the link to the page. And the source code. If anyone
    can help me that would be genius.
    PS there is actually two SWF that I need to loop. Neither of
    them are looping.
    http://www.drewwfilms.com/Index2.html
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type"
    content="text/html;charset=utf-8" />
    <meta name= content="Adobe GoLive" />
    <title>Drew W Films Index</title>
    </head>
    <body>
    <div
    style="position:relative;width:750px;height:571px;margin:auto;-adbe-g:p;">
    <div
    style="position:absolute;top:64px;left:16px;width:720px;height:150px;">
    <object
    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
    height="150" width="720">
    <param name="loop" value="true" />
    <param name="movie" value="IndexHeader2/IndexHeader2.swf"
    />
    <param name="quality" value="best" />
    <param name="play" value="true" />
    <embed height="150" pluginspage="
    http://www.macromedia.com/go/getflashplayer"
    src="IndexHeader2/IndexHeader2.swf"
    type="application/x-shockwave-flash" width="720" quality="best"
    play="true" loop="true"></embed>
    </object></div>
    <div
    style="position:absolute;top:16px;left:64px;width:624px;height:32px;-adbe-c:c">
    <menumachine name="indexheader2" id="mre8mxf">
    <csobj t="Component"
    csref="menumachine/indexheader2/menuspecs.menudata"><noscript>
    <p><a class="mm_no_js_link"
    href="menumachine/indexheader2/navigation.html">Site
    Navigation</a></p>
    </noscript> </csobj>
    <script type="text/javascript"><!--
    var mmfolder=/*URL*/"menumachine/",zidx=1000;
    //--></script>
    <script type="text/javascript"
    src="menumachine/menumachine2.js"></script>
    <script type="text/javascript"
    src="menumachine/indexheader2/menuspecs.js"></script>
    </menumachine>
    </div>
    <div
    style="position:absolute;top:224px;left:16px;width:720px;height:304px;">
    <object
    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
    height="304" width="720">
    <param name="loop" value="true" />
    <param name="movie" value="IndexHeader2/IndexBody.swf"
    />
    <param name="quality" value="best" />
    <param name="play" value="true" />
    <embed height="304" pluginspage="
    http://www.macromedia.com/go/getflashplayer"
    src="IndexHeader2/IndexBody.swf"
    type="application/x-shockwave-flash" width="720" quality="best"
    play="true" loop="true"></embed>
    </object></div>
    </div>
    <p></p>
    </body>
    </html>

    The problem you are encountering is that you are telling the
    SWF to loop, when in fact you need to tell the FLV to loop.
    Unfortunately, you need to code a few lines of Actionscript
    to get this to work, you would think that it would be as simple as
    just checking an option.
    I don't know if you have an AS2 or AS3 project, so I'm going
    to give you both for the code.
    Actionscript 2:
    1. Select the FLVPlayback component on the stage.
    2. In the Actions panel, enter the following:
    on(complete){
    this.autoRewind = true;
    this.play();
    Actionscript 3:
    1. Select the FLVPlayback component on the stage, and give it
    an instance name by entering some text in the properties panel.
    (Upper left corner of the panel, right under where it says
    "Component" there is a text input box. This is where you input it.)
    Names are commonly things like "myFLVPlayback" or "myVideo" etc.
    2. Deselect everything.
    3. In the actions panel, enter the following (replacing
    "myVideo" with the instance name you chose):
    myVideo.addEventListener(VideoEvent.COMPLETE,doLoop);
    function doLoop(evt:VideoEvent):void {
    evt.currentTarget.play();
    Either of those blocks of code should work for you. Simply
    add them to your flash project and re-export the SWF.

  • Help needed:Printing HTML file using javax.print

    Hi
    I am using the following code which i got form the forum for rpinting an HTML file.
    The folllowing code is working fine, but the problem is the content of HTML file is not getting printed. I am geeting a blank page with no content. What is the change that is required in the code? ALso is there any simpler way to implement this. Help needed ASAP.
    public boolean printHTMLFile(String filename) {
              try {
                   JEditorPane editorPane = new JEditorPane();
                   editorPane.setEditorKit(new HTMLEditorKit());
                   //editorPane.setContentType("text/html");
                   editorPane.setSize(500,500);
                   String text = getFileContents(filename);
                   if (text != null) {
                        editorPane.setText(text);                    
                   } else {
                        return false;
                   printEditorPane(editorPane);
                   return true;
              } catch (Exception tce) {
                   tce.printStackTrace();
              return false;
         public String getFileContents(String filename) {
              try {
                   File file = new File(filename);
                   BufferedReader br = new BufferedReader(new FileReader(file));
                   String line;
                   StringBuffer sb = new StringBuffer();
                   while ((line = br.readLine()) != null) {
                        sb.append(line);
                   br.close();
                   return sb.toString();
              } catch (Exception tce) {
                   tce.printStackTrace();
              return null;
         public void printEditorPane(JEditorPane editorPane) {
                   try {
                        HTMLPrinter htmlPrinter = new HTMLPrinter();
                        htmlPrinter.printJEditorPane(editorPane, htmlPrinter.showPrintDialog());
                   } catch (Exception tce) {
                        tce.printStackTrace();
         * Sets up to easily print HTML documents. It is not necessary to call any of the setter
         * methods as they all have default values, they are provided should you wish to change
         * any of the default values.
         public class HTMLPrinter {
         public int DEFAULT_DPI = 72;
         public float DEFAULT_PAGE_WIDTH_INCH = 8.5f;
         public float DEFAULT_PAGE_HEIGHT_INCH = 11f;
         int x = 100;
         int y = 80;
         GraphicsConfiguration gc;
         PrintService[] services;
         PrintService defaultService;
         DocFlavor flavor;
         PrintRequestAttributeSet attributes;
         Vector pjlListeners = new Vector();
         Vector pjalListeners = new Vector();
         Vector psalListeners = new Vector();
         public HTMLPrinter() {
              gc = null;
              attributes = new HashPrintRequestAttributeSet();
              flavor = null;
              defaultService = PrintServiceLookup.lookupDefaultPrintService();
              services = PrintServiceLookup.lookupPrintServices(flavor, attributes);
              // do something with the supported docflavors
              DocFlavor[] df = defaultService.getSupportedDocFlavors();
              for (int i = 0; i < df.length; i++)
              System.out.println(df.getMimeType() + " " + df[i].getRepresentationClassName());
              // if there is a default service, but no other services
              if (defaultService != null && (services == null || services.length == 0)) {
              services = new PrintService[1];
              services[0] = defaultService;
         * Set the GraphicsConfiguration to display the print dialog on.
         * @param gc a GraphicsConfiguration object
         public void setGraphicsConfiguration(GraphicsConfiguration gc) {
              this.gc = gc;
         public void setServices(PrintService[] services) {
              this.services = services;
         public void setDefaultService(PrintService service) {
              this.defaultService = service;
         public void setDocFlavor(DocFlavor flavor) {
              this.flavor = flavor;
         public void setPrintRequestAttributes(PrintRequestAttributeSet attributes) {
              this.attributes = attributes;
         public void setPrintDialogLocation(int x, int y) {
              this.x = x;
              this.y = y;
         public void addPrintJobListener(PrintJobListener pjl) {
              pjlListeners.addElement(pjl);
         public void removePrintJobListener(PrintJobListener pjl) {
              pjlListeners.removeElement(pjl);
         public void addPrintServiceAttributeListener(PrintServiceAttributeListener psal) {
              psalListeners.addElement(psal);
         public void removePrintServiceAttributeListener(PrintServiceAttributeListener psal) {
              psalListeners.removeElement(psal);
         public boolean printJEditorPane(JEditorPane jep, PrintService ps) {
                   if (ps == null || jep == null) {
                        System.out.println("printJEditorPane: jep or ps is NULL, aborting...");
                        return false;
                   // get the root view of the preview pane
                   View rv = jep.getUI().getRootView(jep);
                   // get the size of the view (hopefully the total size of the page to be printed
                   int x = (int) rv.getPreferredSpan(View.X_AXIS);
                   int y = (int) rv.getPreferredSpan(View.Y_AXIS);
                   // find out if the print has been set to colour mode
                   DocPrintJob dpj = ps.createPrintJob();
                   PrintJobAttributeSet pjas = dpj.getAttributes();
                   // get the DPI and printable area of the page. use default values if not available
                   // use this to get the maximum number of pixels on the vertical axis
                   PrinterResolution pr = (PrinterResolution) pjas.get(PrinterResolution.class);
                   int dpi;
                   float pageX, pageY;
                   if (pr != null)
                        dpi = pr.getFeedResolution(PrinterResolution.DPI);
                   else
                        dpi = DEFAULT_DPI;
                   MediaPrintableArea mpa = (MediaPrintableArea) pjas.get(MediaPrintableArea.class);
                   if (mpa != null) {
                        pageX = mpa.getX(MediaPrintableArea.INCH);
                        pageY = mpa.getX(MediaPrintableArea.INCH);
                   } else {
                        pageX = DEFAULT_PAGE_WIDTH_INCH;
                        pageY = DEFAULT_PAGE_HEIGHT_INCH;
                   int pixelsPerPageY = (int) (dpi * pageY);
                   int pixelsPerPageX = (int) (dpi * pageX);
                   int minY = Math.max(pixelsPerPageY, y);
                   // make colour true if the user has selected colour, and the PrintService can support colour
                   boolean colour = pjas.containsValue(Chromaticity.COLOR);
                   colour = colour & (ps.getAttribute(ColorSupported.class) == ColorSupported.SUPPORTED);
                   // create a BufferedImage to draw on
                   int imgMode;
                   if (colour)
                        imgMode = BufferedImage.TYPE_3BYTE_BGR;
                   else
                        imgMode = BufferedImage.TYPE_BYTE_GRAY;
                   BufferedImage img = new BufferedImage(pixelsPerPageX, minY, imgMode);
                   Graphics myGraphics = img.getGraphics();
                   myGraphics.setClip(0, 0, pixelsPerPageX, minY);
                   myGraphics.setColor(Color.WHITE);
                   myGraphics.fillRect(0, 0, pixelsPerPageX, minY);
                        java.awt.Rectangle rectangle=new java.awt.Rectangle(0,0,pixelsPerPageX, minY);
                   // call rootView.paint( myGraphics, rect ) to paint the whole image on myGraphics
                   rv.paint(myGraphics, rectangle);
                   try {
                        // write the image as a JPEG to the ByteArray so it can be printed
                        Iterator writers = ImageIO.getImageWritersByFormatName("jpeg");
                        ImageWriter writer = (ImageWriter) writers.next();
                                       // mod: Added the iwparam to create the highest quality image possible
                        ImageWriteParam iwparam = writer.getDefaultWriteParam();
                        iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT) ;
                        iwparam.setCompressionQuality(1.0f); // highest quality
                        ByteArrayOutputStream out = new ByteArrayOutputStream();
                        ImageOutputStream ios = ImageIO.createImageOutputStream(out);
                        writer.setOutput(ios);
                        // get the number of pages we need to print this image
                        int imageHeight = img.getHeight();
                        int numberOfPages = (int) Math.ceil(minY / (double) pixelsPerPageY);
                        // print each page
                        for (int i = 0; i < numberOfPages; i++) {
                             int startY = i * pixelsPerPageY;
                             // get a subimage which is exactly the size of one page
                             BufferedImage subImg = img.getSubimage(0, startY, pixelsPerPageX, Math.min(y - startY, pixelsPerPageY));
                                                 // mod: different .write() method to use the iwparam parameter with highest quality compression
                             writer.write(null, new IIOImage(subImg, null, null), iwparam);
                             SimpleDoc sd = new SimpleDoc(out.toByteArray(), DocFlavor.BYTE_ARRAY.JPEG, null);
                             printDocument(sd, ps);
                             // reset the ByteArray so we can start the next page
                             out.reset();
                   } catch (PrintException e) {
                        System.out.println("Error printing document.");
                        e.printStackTrace();
                        return false;
                   } catch (IOException e) {
                        System.out.println("Error creating ImageOutputStream or writing to it.");
                        e.printStackTrace();
                        return false;
                   // uncomment this code and comment out the 'try-catch' block above
                   // to print to a JFrame instead of to the printer
                   /*          JFrame jf = new JFrame();
                             PaintableJPanel jp = new PaintableJPanel();
                             jp.setImage( img );
                             JScrollPane jsp = new JScrollPane( jp );
                             jf.getContentPane().add( jsp );
                             Insets i = jf.getInsets();
                             jf.setBounds( 0, 0, newX, y );
                             jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
                             jf.setVisible( true );*/
                   return true;
              * Print the document to the specified PrintService.
              * This method cannot tell if the printing was successful. You must register
              * a PrintJobListener
              * @return false if no PrintService is selected in the dialog, true otherwise
              public boolean printDocument(Doc doc, PrintService ps) throws PrintException {
                   if (ps == null)
                   return false;
                   addAllPrintServiceAttributeListeners(ps);
                   DocPrintJob dpj = ps.createPrintJob();
                   addAllPrintJobListeners(dpj);
                   dpj.print(doc, attributes);
                   return true;
              public PrintService showPrintDialog() {
                   return ServiceUI.printDialog(gc, x, y, services, defaultService, flavor, attributes);
              private void addAllPrintServiceAttributeListeners(PrintService ps) {
                   // add all listeners that are currently added to this object
                   for (int i = 0; i < psalListeners.size(); i++) {
                   PrintServiceAttributeListener p = (PrintServiceAttributeListener) psalListeners.get(i);
                   ps.addPrintServiceAttributeListener(p);
              private void addAllPrintJobListeners(DocPrintJob dpj) {
                   // add all listeners that are currently added to this object
                   for (int i = 0; i < pjlListeners.size(); i++) {
                   PrintJobListener p = (PrintJobListener) pjlListeners.get(i);
                   dpj.addPrintJobListener(p);
              // uncomment this also to print to a JFrame instead of a printer
              /* protected class PaintableJPanel extends JPanel {
                   Image img;
                   protected PaintableJPanel() {
                        super();
                   public void setImage( Image i ) {
                        img = i;
                   public void paint( Graphics g ) {
                        g.drawImage( img, 0, 0, this );
    Thanks
    Ram

    Ram,
    I have had printing problems too a year and a half ago. I used all printing apis of java and I still find that it is something java lacks. Now basically you can try autosense. To check whether your printer is capable of printing the docflavor use this PrintServiceLookup.lookupPrintServices(flavor, aset); . If it lists the printer then he can print the document otherwise he can't. I guess that is why you get the error.
    Regards,
    Kevin

  • HI Masters , I need information for file upload program in web dynpro java

    Hi masters,
           i need some inforamtion and documentation on file upload program in web dynpro java

    Hi surya,
    You can follow this procedure to upload the file
    i) Take One Context Attribute named as "D1" of Type "binary".
    ii) Take one FileUpload UI Element in the Layout Tab.
    iii) Bind FileUpload UI Element's data Property to the taken Context Attribute. Here it is "D1".
    iv) Take one Button UI Element in the Layout Tab named "Upload" and in the Action of that Button write the following Code.
    v) The following code Generates one Folder in the Server & inside that Folder given file is Uploaded.
    File ff=new File("FolderXYZ"); // Creates One Folder with the given Name ( Here Folder name is "FolderXYZ")
    ff.mkdir();
    try
    byte b[]=null;
    IWDAttributeInfo objAttinfo=null;
    IWDModifiableBinaryType binType=null;
    File f=null;
    FileOutputStream fos=null;
    if(wdContext.currentContextElement().getD1()!=null)
    b=wdContext.currentContextElement().getD1();
    objAttinfo=wdContext.getNodeInfo().getAttribute(IPrivateAttachView.IContextElement.D1);
    binType=(IWDModifiableBinaryType)objAttinfo.getModifiableSimpleType();
    f=new File(ff.getName()+"
    "+binType.getFileName());
    fos=new FileOutputStream(f);
    fos.write(b);
    fos.flush();
    fos.close();
    objMessageManager.reportSuccess("File uploaded to server");
    } catch (Exception e)
    objMessageManager.reportException("Unable to upload file to server, error is:"+e,false);
    return;
    The Uploaded file is stored in the folder & that folder is stored in the Server's following Path.
    <Your Server>\c$\usr\sap\J2E\JC00\j2ee\cluster\server0
    You can access your Uploaded file from the following Path
    <Your Server>\c$\usr\sap\J2E\JC00\j2ee\cluster\server0\FolderXYZ
    Regards
    Sagar Ingalwar

  • I Need Information Regarding File Upload?

    Where can I get information regarding the File uploading packages in Portal. Is there a specification I can get a hold of. I know such a package exists, as it is used by portal itself. I just need to know where I can get hold of information as to what it is called and how to invoke it.

    Suraj,
    The APIs to do file upload are not public as of yet. We are looking into the feature right now. Currently, the only supported method of file upload is using the Web Interface.
    You may find more information about this in the 9iAs Portal forum
    Sue

  • CSV FILE UPLOAD

    DEAR ALL,
    I am facing one problem while uploading csv file.
    I have 2 csv files.
    i use the function module
    CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'
        EXPORTING
          i_filename      = L_FILENAME "'C:\Temp\Book1.csv'
          i_separator     = ','
        TABLES
          e_intern        = l_intern
        EXCEPTIONS
          upload_csv      = 1
          upload_filetype = 2.
      LOOP AT l_intern.
        MOVE : l_intern-col TO v_index.
        ASSIGN COMPONENT v_index OF STRUCTURE W_ERQ TO <fs>.
        MOVE : l_intern-value TO <fs>.
        AT END OF row.
          APPEND W_ERQ TO GT_ERQ.
          CLEAR W_ERQ.
        ENDAT.
      ENDLOOP.
    It is working working for one file. while uploading another file it is showing simble (") " with mail ids"
    In the sence i have my csv files one column mail id of approver. But it is fetching from csv file mail-ids but starting mail with " and end of mail it showing the simble ".
    HOw should i over come this problem
    Thanks
    margani

    If your CSV has tabulator as separetor, this code will fill your internal table without any other code.
    DATA: l_filename TYPE string.
      l_filename = p_file.
      REFRESH wt_input.
    CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                      = l_filename
         filetype                      = 'ASC'
         has_field_separator           = 'X'
         dat_mode                      = 'X'
        TABLES
          data_tab                      = wt_input[]
       EXCEPTIONS
         file_open_error               = 1
         file_read_error               = 2
         no_batch                      = 3
         gui_refuse_filetransfer       = 4
         invalid_type                  = 5
         no_authority                  = 6
         unknown_error                 = 7
         bad_data_format               = 8
         header_not_allowed            = 9
         separator_not_allowed         = 10
         header_too_long               = 11
         unknown_dp_error              = 12
         access_denied                 = 13
         dp_out_of_memory              = 14
         disk_full                     = 15
         dp_timeout                    = 16
         OTHERS                        = 17
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  • Csv file uploading for database table creation

    Hi there,
    I'm in the process of making an application that will be able to upload a csv file and create a table based on the same file. As of now, I have managed to make my application upload a csv file into the database. My problem now is to transfer the data in the csv into a table. If there is a function that can do this, please let me know. But as of now, I have tried all that I can but in vain. I would appreciate any assistance rendered as to how I can go about this.
    Kind regards,
    Lusuntha

    hai Lusuntha ,
    Go to search forum and type "upload within html db".here u will find the required information ,as well as the code.go for each topic in the search result.

Maybe you are looking for

  • Problems with hp officejet pro 8610 printing labels

    I have a new HP offficejet Pro 8610 less than 6 months old. I was printing address lables (Avery 8160) and everything seemed fine after the first group then when I started the second set they were out of alignment I readjusted the paper and tried aga

  • Acrobat 9.4.2 won't "save"

    When I open PDF documents in Adobe Acrobat Pro 9.4.2, the "Save" option is grayed out. It will let me "Save As ..." It's not a major issue, but it's annoying! I'm running Windows 7 Home Premium 64-bit edition. Any ideas would be welcomed. Thanks. Tim

  • How to add Content workflow to Webcenter spaces/ custom application

    I would like to add Content work-flows ( Add - review - publish of content) to Webcenter spaces.so that users of Spaces/ application can work with add- publish-review cycle. I want to know if any thing like portlet or something available that can be

  • Incorrect value for global variable

    Hi, I am facing an issue in a query. In the query there is a Global variable 'Volume type'. In the default value tab of the variable it is given Default value as Litre. In the table RSZGLOBV also i have checked the global variable and there also the

  • How to set Batch as mandatory field in Subcontracting PR component input

    Hello,SDN members Happy New Year! My scenario is about subcontracting purchasing: 1. Move stock to vendor through movement 541 2. Create a purchase requisition includes items with item category "L",     and then input component,that is a quantity of