Help needed in PI sheet requirment

Hello Experts,
We have one specific requirement for PI sheet for our client (4.6 C)
The business want to sendquality information (inspection requirements ) like MIC, Insp. Method,Specifications etc. for 04 inspection lot and they want to see all these information in tabular format on PI sheet
In SAP, there is no standard way to generate instructions for GR inspection characteristics . SO we planned to use user exit to populate the characteristics values in instruction category for inspection.
If we use Repeated data request and table size,  we could only populate first MIC and its related information in first row of table and it is getting repeated for multiple rows ( Exit is getting called only once).
We cannot create multiple instructions for each MIC as well , since it will generate individual table for each one .
Has anyone worked on such requirement before ? Any help will be appreciated
Thanks,
Sachin C

CREATE OR REPLACE FUNCTION fucntion_name(latA IN NUMBER, longA IN NUMBER, latB IN NUMBER, longB IN NUMBER) RETURN NUMBER
IS
pi      CONSTANT NUMBER:=3.14159;
theta NUMBER;
distX  NUMBER;
distY  NUMBER;
distZ  NUMBER;
distP  NUMBER;
BEGIN
theta :=longA - longB;
distX :=sin( latA * PI /180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180);
distY :=acos(distX); --this is arc cosine
distZ :=distY * 180/PI;  --PI refers to the mathematical PI
distP :=distZ * 60 * 1.1515; --this value should be returned. Of course the intermediate variable names don't matter.
RETURN distP;
END;Edited by: Ora on May 3, 2011 11:46 PM

Similar Messages

  • Help need in balance sheet reporting

    Hi BW buddies,
    I posted a question but still i have not got a solution.
    Please help me. i am reposting it.
    "Hi BW gurus,
    I have a problem with reporting.
    I need to get Balance-Sheet Plan Reports for the Planned year and for the current year.
    To get the report for the planned year its straight forward just by restricting 0balance by the version to 1 and the valuetype 20.
    But I have a problem with the current year report.
    I have fiscal year and the company code as the variables.
    The report should be like this.
    If we need the report as of today(July 26 2006),we may input 2006 for the fiscal year variable.
    And the 0balance for the twelve fiscal periods should be as follows
    From jan 2006 to june 2006(fiscal periods) it should have only the actuals
    From july 2006 to dec 2006(fiscal periods) it should have only the plan
    I have already built a query by having two restricted keyfigures on 0balance.
    One by restricting version and valuetype 0 and 10 , and the other with 1 and 20.
    But in the report I am getting two columns of data for each fiscal period for 12 periods.0balance with actuals and 0balance with plan.
    But I need to get 0balance with actuals from jan to june(individually for each fiscal period columnwise),and 0balance with plan from july to dec(individually for each fiscal period columnwise).
    Hope you people can visualize my report.
    Please help me ASAP.
    Any kind of help is appreciated.
    My mail id is [email protected]
    Thanks in advance
    Regards
    Sam Mathew

    Hi Sam,
    hope I have undestood your needs:
    try inserting OVER key figures tree in columns the Characteristic 0FISCPER3, it will split your columns for every period. Also enter in Global Properties of the query and ask the system to suppress the columns with 0 values, it will hide all the periods in the future for the Actual data and will hide all the periods in the past for the Plan data.
    Ciao.
    Riccardo.

  • Help needed on balance sheet plan report for the current year

    Hi BW gurus,
    I have a problem with reporting.
    I need to get  Balance-Sheet Plan Reports for the Planned year and for the current year.
    To get the report for the planned year its  straight forward just by restricting 0balance by the version to 1 and the valuetype 20.
    But I have a problem with the current year report.
    I have fiscal year and the company code as the variables.
    The report should be like this.
    If we need the report as of today(July 26 2006),we may input 2006 for the fiscal year variable.
    And the 0balance for the twelve fiscal periods should be as follows
    From jan 2006 to june 2006(fiscal periods) it should have only the actuals
    From july 2006 to dec 2006(fiscal periods) it should have  only  the plan
    I have already built a query by having two restricted keyfigures on 0balance.
    One by restricting version and valuetype 0 and 10 , and the other with 1 and 20.
    But in the report I am getting two columns of data for each fiscal period for 12 periods.0balance with actuals and 0balance with plan.
    But I need to get 0balance with actuals from jan to june(individually for each fiscal period columnwise),and 0balance with plan from july to dec(individually for each fiscal period columnwise).
    Hope you people can visualize my report.
    Please help me ASAP.
    Any kind of help is appreciated.
    My mail id is [email protected]
    Thanks in advance
    Regards
    Sam Mathew

    Hi Sam,
        Did u get this issue solved. I am having the same issue now. Can u please let me know if u have a solution for this.
    Thanks
    Prasad

  • I have OS X 10.5.8- I need tunes 11.1-requires OS X 10.6 and older-Can someone help?

    I have Mac OS X 10.5.8- I need tunes 11.1- requires OS X 10.6 and older- Can someone help? Or can I just UN Do my recent update on my !Phone 4S?-I can no longer Sync my Iphone to my MAC.

    It depends on whether or not your Mac is Intel powered.
    If it is, you can upgrade to Snow Leopard for $19.99 http://store.apple.com/us/product/MC573Z/A/mac-os-x-106-snow-leopard
    If it isn't... your troubles with the Mac are just beginning. As time goes on, there will be more and more things you find you can no longer do with it.

  • Help needed for file processing using FTP

    Hi All,
    I am new to ODI tool and currently we are implementing one project in ODI. Could you please, any one help me on the following requirement... how to implement it?
    Scenario:
    i) I need to pick a file from remote host 'outbox' dir using FTP process, and place into local 'temp' dir. (I can do it with odiFTPGet tool)
    ii) Change the file as per target business requirement.??? ( this step challenging me)
    for ex:
    if source file name : <project name>_<source ID>_<transaction name>_<unique id>.txt
    target name should be : 1234_<transaction name>_<sysdate in yyyyMMddhhmmss>_<unique id>_2345.txt ( here 1234 and 2345 are hard coded values)
    iii) Later move to local 'temp' to local 'outbox' dir. ( I can do it with odiFileMove tool)
    iv) After successful process move the file from remote 'outbox' to remote 'archive' dir ??? (again this is challenging me).
    For this my questions are:
    1) How to get file name into a variable ( In one of the post , it says we need to create data model and data stores, and interface to get the file names into a file. apart from is there any easy way i can implement it in package it self?)
    2) How to tokenize a long string ( i.e., need to tokenize the source file to get <unique id> and <transaction name> and map to target file name)
    3) How to define implementation for Java in user function?? do we need to use class declarations and import statements?? I need a sample user function in Java.
    4) How to move/rename a file in remote server?? ( need to move file from remote 'outbox' server to remote archive' dir)
    5) If any step in package fails, How to get the error msg into a variable which i can use for sending mail and raise a ticket in remedy?? ( I will pass that variable to as content to mail and remedy ticket)
    6) How to handle list type data (string list) by variables in ODI?? (As we can define single variable not as list.)
    I am sorry to ask all my queries I a single post. But I need to solutions for all to implement this in my project.
    Thanks in advance. Appreciate early response.
    Regards,
    Kiran.N

    Can any one share your thoughts for my request.
    Thanks in advance.
    Regards,
    Kiran

  • HELP NEEDED WITH ADDAPTER-DVI TO VGA.

    PLEASE ...HELP NEEDED WITH WIRING CROSS OVER....CAN YOU HELP WITH BACK OF PLUG CONNECTIONS...I SORTA UNDERSTAND THE PINOUTS BUT CANT MAKE AN EXACT MACH...WOULD LIKE TO BE 100% SURE...
    ......THIS ENSURES NO SMOKE!!!                                                                                           
    THE CARD IS AN ATI RADEON RX9250-DUAL HEAD-.........ADDAPTER IS DVI(ANALOG)MALE TO VGA(ANALOG)FEMALE.
    ANY HELP VERY MUCH APPRECIATED........ SEEMS YOU NEED TO BE ROCKET SCI TO ATTACH A BLOODY PICTURE...SO THIS HAS BEEN BIG WASTE OF FING TIME!

    Quote from: BOBHIGH on 17-December-05, 09:21:31
    Get over it mate !
    I find it easy t read CAPS...and if you dont like it ...DONT READ IT!
    And why bother to reply...some people have nothing better to do.
    Yes there chep and easy to come by...Ive already got a new one.
    All I wanted was to make a diagram of whats inside the bloody thing...it was a simple question and required a simple answer.
    NO NEED TO A WANKA !!
    I feel a bann comming up.
    Have you tryed Google ? really.. your question is inrelevant. No need to reply indeed.
    Why do you come here asking this question anyway ? is it becouse you have a MSI gfx card ? and the adapter has nothing to do with this ?
    You think you can come in here yelling.. thinking we have to put up with it and accept your style of posting. This is not a MSI tech center.. it's a user to user center.. Your question has nothing to do with MSI relavant things anyway's.
    Google = your friend.
    Quote from: BOBHIGH on 17-December-05, 09:21:31
    it was a simple question and required a simple answer
    Simple for who ? you (buying a new one) ? me ? we ?   .really...........
    Quote from: Dynamike on 16-December-05, 04:11:48
    1: There are allot of diffrent types of those adapters.
    If any of the mods have a problem about my reply.. please pm me.

  • Help needed in PS module on CJ9ECP/CJ20N for revaluating CCR??

    help needed in PS module on CJ9ECP/CJ20N for revaluating CCR??
    How to handle method on_costing_component_to_outtab which belongs to badi gui_itemization_ck. This is to revaluate CCR in CJ20N.
    From sale transaction(va01/va02) i need to call cj20n/cj9ecp for revaluating cost estimates. Can anyone say how to proceed with this thing.
    Can any one say how to handle pop up window in CJ20N/CJ9ECP when clicked edit ecp button. Later how to revaluate cost estimates. For this should i need to go for call transaction or is there any method available. If so how to handle method for revaluating cost estimates for ECP of WBS elements

    Thanks Amol for the advice.
    My friend doesn't belong to an engineering background and had not worked in a manufacturing environment.
    He holds an MBA degree specialised in systems and has worked in software companies supporting software projects and the functions(like HR,Procurement in the same setup) as a software quality guy.
    Moreover the modules mentioned by you requires engineering background with manufacturing exposure.
    He had enquired for the course at siemens and they said that he may not be suitable for any of the modules offered by them as per the above reasons.They also mentioned that they have to check with SAP Labs for expert opinion.
    Please provide your inputs.
    regards,
    Zubair.

  • Help needed to optimize the query

    Help needed to optimize the query:
    The requirement is to select the record with max eff_date from HIST_TBL and that max eff_date should be > = '01-Jan-2007'.
    This is having high cost and taking around 15mins to execute.
    Can anyone help to fine-tune this??
       SELECT c.H_SEC,
                    c.S_PAID,
                    c.H_PAID,
                    table_c.EFF_DATE
       FROM    MTCH_TBL c
                    LEFT OUTER JOIN
                       (SELECT b.SEC_ALIAS,
                               b.EFF_DATE,
                               b.INSTANCE
                          FROM HIST_TBL b
                         WHERE b.EFF_DATE =
                                  (SELECT MAX (b2.EFF_DATE)
                                     FROM HIST_TBL b2
                                    WHERE b.SEC_ALIAS = b2.SEC_ALIAS
                                          AND b.INSTANCE =
                                                 b2.INSTANCE
                                          AND b2.EFF_DATE >= '01-Jan-2007')
                               OR b.EFF_DATE IS NULL) table_c
                    ON  table_c.SEC_ALIAS=c.H_SEC
                       AND table_c.INSTANCE = 100;

    To start with, I would avoid scanning HIST_TBL twice.
    Try this
    select c.h_sec
         , c.s_paid
         , c.h_paid
         , table_c.eff_date
      from mtch_tbl c
      left
      join (
              select sec_alias
                   , eff_date
                   , instance
                from (
                        select sec_alias
                             , eff_date
                             , instance
                             , max(eff_date) over(partition by sec_alias, instance) max_eff_date
                          from hist_tbl b
                         where eff_date >= to_date('01-jan-2007', 'dd-mon-yyyy')
                            or eff_date is null
               where eff_date = max_eff_date
                  or eff_date is null
           ) table_c
        on table_c.sec_alias = c.h_sec
       and table_c.instance  = 100;

  • Help needed for using BASIC authentication through JDBCRealm

    Help needed.
    Hello,
    I am doing a degree project, so far it works fine in my local machine, I need to try it on my virtual hosting (as it is a live server).
    My project requires JDBCRealm, that is BASIC authentication loading access data from mysql database. Normally this setup can be done in Server.xml file, because my Tomcat hosting is a virtual one, I only have permission to access the web.xml file.
    My question is: is it possible to get it done in an alternative way? In web.xml? Some properties file maybe?
    Thank you very much.

    You can set this up for your context using META-INF/context.xml instead of working with server.xml.
    Make a directory called META-INF under your webapp ( it'll be at the same level as WEB-INF ). Under this, add a context.xml with all your context specific configuration including the realm. A sample is below
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/myApp" reloadable="true">
        <Realm
            className="org.apache.catalina.realm.JDBCRealm"            
            driverName="com.microsoft.jdbc.sqlserver.SQLServerDriver"         
            connectionURL="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=myDB;SelectMethod=Cursor;"
            connectionName="username" connectionPassword="password"
            digest="MD5" userTable="users" userNameCol="userid" userCredCol="userpassword"
            userRoleTable="user_roles" roleNameCol="rolename"
        />
    </Context>Hope this helps.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

  • Urgent help needed on deployment facts

    Hi
    I had completed a Java Web based application using JApplet, which in turn uses Java Media Framework and Java Communications APIs. So when i deploy this application and let the clients use this application. I need to dump some jar files and properties files into the clients JRE so that all the APIs will work properly. Without any installations. I tried doing this manually by copying these files into client machines So is there a direct method for performing the task. Or i need to add some additional code to my applet so as to find the clients current JRE version and place the required files under using FTP? Can i write a setup routine or something which does all these operations once the client access the applet?
    Help needed in the above issues
    Thanks in advance
    Swaraj

    What you will want to do is look into JNLP and Java WebStart. They allow you to write a setup for your product that makes installation as easy as InstallShield&trade; does for the Windows&trade; platform (ie: it allows customers who cannot tell Java from Perl to install your product).

  • Pop up Window before saving remembering the need (forcing) to fill required fields in a form

    Hi!
    I searched the "old" forum and have very good help from UVSAR but unfortunately I'm not able to access my message sent to that forum anymore.
    [I could never thank all the people who answered because I keep receiving "Your submission has triggered the spam filter and will not be accepted.""]
    I've have never use Java scripts in my life: I started about three days ago.
    1) I'm using Adobe Acrobat Pro X (Windows 7)
    2) I've created a form using Microsoft Word and save it as a pdf file.
    3) After I created a form using Acrobat Pro X;
    3.1.) This form it's not going to be submitted over Internet. It will be send by e-mail to some persons. They will receive it, fill in the form and send it back to me via e-mail. Note: I will save it with extended rights in order to allow to be read with acrobat reader (I'm the only one of the group having Professional edition).
    4) In that form I've created some text fields (for now it's just what I need - no radio buttons, dropdown
    menus, and so...)
    5) Choosed Properties and marked 7 fields as "required";
    6) Used a script I found in here: http://forums.adobe.com/thread/784322 (thank you for the authors of the thread)
    if (!event.target.valueAsString) {
    app.alert("My text My text", 3);
    7) This script allows me to remember people to fill that 7 specific fields (when using mouse or tab).
    8) So... What I really need? Here are the reasons for my request for help:
    8.1.) When people use the Acrobat Reader Save button (not a button I created inside the form) it will pop up an alert message. Users will receive a pop up window telling them they need to fill those fields before saving the form and send it back to me. Can someone share a script, please? Thanks in advance.
    8.2.) Is there a way to colorize the fileds that need to be filled? Again I only learned where to insert a java script yestaerday sou I'm not able to write one. I'm sorry for my newbie questions.
    8.3.) Last question: In one of the fields there will be an e-mail address. On the end of the form I want to create a button like "Send by e-mail" and When someone press that button the e-mail will be sent to the address that was written in the earlier specific field. How can I do this (link a button to an e-mail address in a specific field)? Can someone help me with a script or ideas? Hope I was clear.
    8.1.) UVSAR sent me the following code that works fine untill I save the document for the first time. Affter that he never shows me pop up window again.
    var isFilled = true;
    for (var i=0;i < this.numFields;i++){
    var f = this.getNthFieldName(i);
    if (this.getField(f).required && !this.getField(f).valueAsString) isFilled = false;
    if (!isFilled) app.alert("You must complete all the required fields");
    8.3.) With the help of UVSAR I used:
    var mailto = this.getField('emaddr').valueAsString;
    if (mailto!='') this.mailForm({ bUI:true, cTo:mailto, cSubject:"This is the subject", cMsg: "This is the body of
    the mail." });
    else app.alert("Cannot submit form until the email address field is completed");
    but gives me an error (Note: I named the filed with e-mail "emaddr")
    Once again Thank you so very very much to all the kind people who take their time to share knowledge...
    I'm not a native speaker, sorry for some errors
    Best regards
    AC

    Hi Winnie
    Unfortunately I have been sick and did not read the message before. I apologize.
    I have not received help beyond what is on the page. But when I get I tell you.
    I hope you can get answers. If you receive, I ask that you share with me.
    thank you very much
    best regards
    AC
    Date: Mon, 27 Feb 2012 09:33:10 -0700
    From: [email protected]
    To: [email protected]
    Subject: Pop up Window before saving remembering the need (forcing) to fill required fields in a form
        Re: Pop up Window before saving remembering the need (forcing) to fill required fields in a form
        created by Win_Form in Forms - View the full discussion
    Hi ACI wonder if you can share any responses on to your question above?I too have never used a script but, I have the same problems as you in regards to building a form. And wants to have the same 'protection' and message reminders for the end users. Any information, including a script and/or a contact email of experts you can share with me will help tremendously. Thank you so much in advance. Winnie
         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/4232307#4232307
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4232307#4232307. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Forms by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Help need in Signed Applets.....Urgent

    Hi,
    I am stuck with a problem. Please help me out.
    The requirement is :
    I have an applet which has to run an executable which produces a .txt. The applet should use this .txt to produce its output.
    I made the applet into a signed jar and ran the executable to produce the .txt . But the .txt is outside the jar file and I am not able to use it to create the result.
    How do I use the .txt now?? Is the method that I am trying proper or should I use some other method?
    Another doubt is, when I run the .html of the applet code (which is in the server), is it cached in the client???

    I made the applet into a signed jar and ran the
    executable to produce the .txt . But the .txt is
    outside the jar file and I am not able to use it to
    create the result.
    How do I use the .txt now??Hand the user a JFileChooser and let him tell you where the file is, or loook at the exe to see whether you can specify an output directory as a parameter.
    Is the method that I am
    trying proper or should I use some other method?It's highly ugly, but I can't think of anything else.
    Another doubt is, when I run the .html of the applet
    code (which is in the server), is it cached in the
    client???Yes. No need to download the same stuff each time. The details are browser-specific.

  • Help Needed in Reports (Breaks, totals)

    Hi All,
    I am a fairly new user in Apex and would appreciate any help. I have a requirement to generate a report as follows:
    In below reports 1001,1002 are projects and i need to obtain project totals (e.g. 500,300,150,50) displayed conditionally. At first i had to display only projects and i could do it using 1 column report break.
    But how can i include the totals in the report breaks. And its more than 3 columns that i would need in breaks.
    Any suggestions? I dont think i can use breaks for this as APEX does not support more than 3 columns.
    Name task budget Expense commitments balance end_Date
    1001 500 300 150 50 15-01-2008
    1001-1-aa 1 200 100 50 50 15-01-2008
    1001-2-ab 2 300 200 100 0 15-01-2008
    1002 500 300 150 50 15-01-2008
    1002-1-aa 1 200 100 50 50 01-01-2008
    1002-2-ab 2 300 200 100 0 01-01-2008
    Thanks
    Sumana

    Hi All,
    Thanks Arie, your suggestion helped me to move in the right direction.
    I could display the project totals as needed without using breaks, but using a combination of query and report template change. The above examples given helped to certain extent.
    Now I have a requirement which is an extention to the above problem. I dont know if I must start a new thread for this.
    I need the report totals to be displayed conditionally. This condition has 3 cases, out of which I am able to achecive two.
    For the 3rd I would really appreciate any help/suggestions. I tried changing query/template. But it dint help.
    Here is the prob:
    Col1 Col2 Col3
    Project_name sum(amt) sum(amt)
    task1 amt amt
    task2 amt amt
    In above, the sum(amt) must be displayed when project_owner is person logged in.
    Col1 Col2 Col3
    Project_name
    task1 amt amt
    task2 amt amt
    In above, when task owner is person logged in then I must not display the sum(amt).
    I am successful in acheving both of the above, when all tasks owner is person logged in and when project owner is person logged in.
    But when I have project owner = person logged in and task1 owner = person logged in and task2 owner != person logged in my display comes out as shown below.
    Col1 Col2 Col3
    Project_name sum(amt) sum(amt)
    Project_name
    task1 amt amt
    *task2                     amt                           amt
    The actual display for third case must be:
    Col1 Col2 Col3
    Project_name sum(amt) sum(amt)
    task1 amt amt
    *task2                     amt                           amt
    Thanks
    Sumana

  • Help needed with printer settings for wired ethernet connection

    I'm hoping someone can help me with a network printing issue. I have a large format color laser printer (Tektronix Phaser) and since moving to OS 10.6 I can't figure out how to configure the printer so that the system sees it. I have a simple wired ethernet network with a couple of Macs and a couple of printers. All devices are connected via a switch. When using earlier OSs I was able to connect to the Phaser using Ethertalk. Obviously this is no longer supported and I can't figure out how to set the printer so the OS can see it. I have lots of options which can be turned on or off and in some cases set up in other ways: Ethertalk, IPX, Netware, TCP/IP, DNS, LPR, HTTP and remote internet printing, I've tried messing with these but the result is always the same--system doesn't see the printer. Currently Ethertalk is on, IPX and Netware are off, TCP/IP is on, DNS and LPR are on, as are AppSocket, HTTP, FTP and remote internet printing. I can change the IP address but no matter what address I've tried I cannot ping the printer. (I'm using a Gutenprint driver for this printer.)
    I don't really know enough about all this to get anywhere and I haven't been able to find help anywhere even from tech friends. Xerox won't help me and neither will Apple. Any help would be appreciated. I can supply more detail on specifics where necessary. Thanks, Bob

    Old Phaser models may becoming more and more difficult to use, but you can give this a try.
    1. Configure the printer via front panel to use TCP/IP and enable DHCP if it's supported. If not then you will need to configure an IP address for the printer together with your local network's mask, and gateway IP address. Except for the first the others will be provided by opening Network preferences to see what those settings are. The printer's IP address needs to be set somewhere within the range of IP addresses your router provides locally.
    2. You need the PPD file required for your printer. If you have the Phaser driver installer you can use it to install the PPD or you can extract the specific PPD from the installer package. This part is tricky because I don't know where you may find the driver now if you don't have the installer. The older installers can be accessed through the Finder by selecting the package then CTRL- or RIGHT-click and select Show Package Contents from the contextual menu. You can then rummage through the package to search for the PPD for your printer. Then navigate to the /Library/Printers/PPD/Contents/Resources/ folder and drop the PPD file inside.
    3. Open Print & Fax preferences and click on Add [+] to add a new printer. Click on the IP icon in the toolbar. Select Line Printer Daemon - LPD from the Protocol drop down menu. Input the IP address you assigned the printer in the Address field. You can file in the optional fields that follow. Then from the Print Using drop down menu locate the listing for your printer and select it.

  • 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

Maybe you are looking for

  • How to use HTML Video for iPad in iWeb

    I agree with all the advantages of HTML Video. How do you use html video on your iweb site? I want my iWeb site video to be viewable on iPads. I have learned the technique to use the HTML Snippet tool in iWeb to successfully post Flash video. I creat

  • Is it possible to create a PDF/A1a compliant file with SOAP API ?

    I saw that I can create two kind of PDF/A1b (CMJN and RVB), but nothing about PDF/A1a. Unfortunately, I see the same limitation in the administration pages of the LiveCycle server. -              Here is my code (using SOAP api) :       Document inDo

  • Ios7 is slow on my iPhone 4

    Why is iOS7 so slow on my iphone4?

  • HELP!! WHAT'S WRONG WITH MY PROGRAM?

    It prints out "Please input next string" twice the first time and I can't figure out why. Here's the code: import java.util.*; public class VowelCounter {      public static void main(String[] args) {           Scanner read = new Scanner(System.in);

  • Final Cut Pro 7 on Macbook Pro

    Hi I am running Final Cut Pro 7 on my 2009 Macbook Pro. 13" 2.26GHZ with 4gb of Ram. I am wondering if how I should set up my final cut to optimize it for this 2 core machine. I have had a lot of troubles with dropped frames and clips. Which codecs s