Problem in printing the JTable values

Dear Friends,
I have to print the JTable values (on paper using print dialogue box).
I'm using jtableObj.print to print the table values. But jtableObj.print takes more time to print the table values because it prints the values as a image(approximately 5 mins to print 10 pages).
My code is ,
boolean complete = tableObj.print(mode, header, footer, showPrintDialog, null, interactive,
                              null);Could anyone please tell me how to reduce the time?
Thanks in advance

Hi again,
1. what problem are u facing ?
  (there is no sapscript symbol / system symbol
   for finding out the length )
  (In abap u can use strlen)
2.  data and gets trimmed
   what is the meaning of it ?
3. do u mean to say that  !
  ABCDEF                     123 45
  GEF                        123 45
  is getting pritned like
  ABCDEF 123 45  ?
  GEF  123 45
4. If so , then use TABS
5. This happens because SPACE
   is different in different varlues of
   ABCDEF and GEF !
regards,
amit m.
Message was edited by: Amit Mittal

Similar Messages

  • How to print the Jtable into paper

    im facing a problem which is after i get the data to be dispaly in the jtable but im facing problem of printing the table in paper as a report.. the report must be info about the data in table..thanks

    My table has narrow columns resulting in clipping of
    text. Is there some way to print the full text in the
    columns?I researched Manning's Swing book and found an example of printing the content of JTable without clipping. But alas, my table doesn't fit in a standard 8.5''x11'' paper even in landscape setting. When one looks at Excel's spreadsheet output, the columns can span over multiple pages. I can live with that. Any solutions?

  • I have a Problem in print the long description data through EDI.

    I have a Problem in print the long description data through EDI:Actually we want to print the long description data through EDI, but it not handling our huge long description data. Here is the example of that>We can print the first two lines into EDI output, but it is failing to print the below text: 
    <B>EPSON, TM-U590 Series: </B> Reliable 88 column slip printer. Operator friendly dot matrix impact printing. Ideal for hotel, bank, restaurant and many more applications .<br><BR> Includes: Printer, Black ribbon & a Connect-It Interface. Power Supply & interface cable sold separately. All printers are RoHS compliant & have a standard 1 year depot warranty. <BR> <BR>
       -------------------------------------Failing to print this lines------------------------------------------------------------------
    <b>COLORS:</b> Epson Cool White (ECW) Only<BR><BR><B><FONT COLOR=#FF0000#>Click links below for helpful Information</FONT><b><br><table border="0" bordercolor="" style="" width="100%" cellpadding="5" cellspacing="5"><tr><td><FONT SIZE="2"><CENTER><A HREF="www.sample.com"f.2605" target="_blank"><b>Spec Sheet</b></a></CENTER></FONT></td><td><FONT SIZE="2"><CENTER><A HREF="www.sample.com"f.2606" target="_blank"><b>MSRP Price List</b></a></CENTER></FONT></td><TD><FONT SIZE="2"><CENTER><A HREF="www.sample.com"f.2868" target="_blank"><b>Product Information Guide</b></a></CENTER></FONT></TD></TR><TR><td><FONT SIZE="2" COLOR=#0000FF><B>Warranty Information</B></FONT></td></tr><Tr><td><FONT SIZE="2"><CENTER><A HREF="www.sample.com"f.2554" target="_blank"><b>Depot Warranty</b></a></CENTER></FONT></td><td><FONT SIZE="2"><CENTER><A HREF="www.sample.com"f.2555" target="_blank"><b>Spare In the Air Warranty</b></a></CENTER></FONT></td><td></td></tr></table><br>
    Please provide some useful thoughts on this EDI issue.
    Thanks
    Ameer

    Try using the FM:
    ENQUE_READ2
    Passing the follwing values:
    GNAME --> VBAK (Sales Order header table)
    GARG   --> The lock argument
                       (This will be a combination of client number anb Sales Order No.
                        Eg: '3001210000054' where the first three digit i,e 300 is the client No
                       and 1210000054 is the sales order no.)
    Regards,
    Firoz.

  • How to print the HEX values of non-displayable characters!

    I am trying to tokenize a string that contains non-displayable characters i.e. EBCDIC or ASCII. How can I print the HEX values of the non-displayable characters. e.g.
    "StartTEST1TEST2TEST3TEST4TEST5TEST6TEST7TEST812END"
    How can print the HEX values of in the above string. Any help is appreciated.
    Thanks

        char ch = 28; // or whatever character you want to look at.
        String hexString = Integer.toHexString(ch);
        System.out.println(hexString);

  • How to print the table values in fastest way?

    Dear Friends,
    I'm having table in my application and i need to print the table values. For that I used print() method to print the table values.
    boolean complete = tableObj.print(mode, header, footer, showPrintDialog, null, interactive,
                                  null);But, the time taken for displaying print dialouge box so late and printing operation is done very slowly.
    Could anyone please tell me is there any better way and fastest way to print the table values?
    Thanks in advance

    Hi,
    In the Module pool you will have fields. For those fields you have created the name also. Assign those name to work area and from there to internal table.
    And for your requirement viceversa you need to done.
    With Regards,
    Sumodh.P

  • Problem  in Printing the ALV list

    Hi,
       I have one problem with printing the ALV list. While printing the ALV list(thro Print Icon on application Tool bar) ,Fist page of my print out contains some other inforamtion.
      inforamtions included two tables
      first table  contains Sort Criteria, Ascdg, Descnd, Subtotal  columns.
      And second table contains Data statistics , number of
    columns.
    But from Second page onwards , my alv list printed correctly .
      How can i avoid the First page inforamtion and
          what is the Reason of coming like this?
    Thanks,
    Neptune.M

    I assume you are using function module Reuse_alv_grid_display or reuse_alv_list_display for ALV.
    If this is the case, there is a parameter called IS_PRINT that you need to supply while calling the function module.
    you can for exapmle declare
    data:
    printstruc type SLIS_PRINT_ALV.
    printstruc-NO_PRINT_LISTINFOS = 'X'.
    call function 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
    IS_PRINT = printstruc
    There are many other flags in is_print structures that you can use to manipulate the printing.
    Cheers!

  • Problem with Printing the Billing date...

    Hi Experts...
    Here im facing the problem in printing the billing date.
    The scenario is as follows.
    The posting date of Billing is 10.10.2008
      The document date of Billing is also 10.10.2008.
    At the time of printing the Billing document it is taking another date otherthan 10.10.2008,where it should be 10.10.2008.
    What modifications should i do to rectify the problem.
    Please advice.
    Regards,
    Y P.

    Prasad,
    Ask your ABAPer do debug and find out what date (Table-Field) is used in the Invoice Output program. You will know the reason and if you think that the date being used is incorrect, you can ask your ABAPer to change it to VBRK-FKDAT which is the billing date.
    Chandan

  • Print the conditions value in PO

    hi ppl,
             I want to print the conditions value in sap script.For this i need to start with the perform/form.so based on what value  and table i call pull the data..

    u need the table konv( conditions table ) by using ekko-knumv for that PO no.
    once u get knumv field frm ekko u can compare this with field knumv of konv.
    and based on this value the amount value wud be konv-kwert field.

  • Does not print the string value ? what is wrong here

    Hi,
    I am trying to print the string value that does not have spaces.
    when I do that,I dont get what I want i.e 3334445555.
    Any help in this regard is appreciated.
    Thanks
    Chat
    import java.util.StringTokenizer;
    class TestTokenizer{
    public static void main(String args[]){
              StringTokenizer st = new StringTokenizer(" 333 444 5555");
              String tokens[] =new String[3];
              int i=1;
              while (st.hasMoreTokens()) {
                   //System.out.println(st.nextToken());
                   tokens=st.nextToken();
              System.out.println(tokens.toString());

    also, be sure to format your code in your next post...click the code button at the top of the message box you type in, and past your code
    *here*[\code]                                                                                                                                                                                                                                                                                                                               

  • Problem printing the JTable

    Hi all,
    I have a problem with printing JTable.
    My application has a submit button,JTable and Print Button.
    As I click on the Submit button, the data is retrieved from the Database(MS Access) and displayed on the JTable.
    Now when I click on the Print button, the printer properties dialog box is displayed. But when I click on the print button in the dialog box, nothing is printed on the paper.
    I checked the printers and faxes in the control panel, It showed Java printing under the Document name and Printing under the Status. It is displayed for sometime and then disappeared after some time. But nothing is printed on the paper(not even the blank paper).
    I tried a lot but couldn't understand the problem.
    I have used the following files:
    PrintJTable.java
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.print.*;
    import java.awt.geom.*;
    import java.awt.Dimension;
    import java.applet.*;
    import java.sql.*;
    import java.util.*;
    import java.net.*;
    import java.lang.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    class PrintJTable implements ActionListener,Printable
    Connection connect;
    ResultSet rs;
    JTable table;
    JScrollPane tableAggregate;
    DisplayTable displayTable;
    JButton print,submitButton;
    public PrintJTable()
    JFrame frame = new JFrame("Table");
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}});
    connect();
    displayTable= new DisplayTable();
    JButton submitButton= new JButton("SUBMIT");
    submitButton.addActionListener(this);
    JButton printButton= new JButton("PRINT!");
    // for faster printing turn double buffering off
    RepaintManager.currentManager( frame).setDoubleBufferingEnabled(false);
    printButton.addActionListener( new ActionListener(){
    public void actionPerformed(ActionEvent evt) {
    PrinterJob pj=PrinterJob.getPrinterJob();
    pj.setPrintable(PrintJTable.this);
    pj.printDialog();
    try{
    pj.print();
    }catch (Exception PrintException) {}
    tableAggregate = createTable();
    tableAggregate.setBorder(new BevelBorder(BevelBorder.LOWERED));
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(submitButton,BorderLayout.NORTH);
    frame.getContentPane().add(tableAggregate,BorderLayout.CENTER);
    frame.getContentPane().add(printButton,BorderLayout.SOUTH);
    frame.pack();
    frame.setVisible(true);
    } // end of constructor
    public void connect()
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("Opening db connection");
    connect = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/db1.mdb","","");
    catch (ClassNotFoundException ex) {
    System.err.println("Cannot find the database driver classes.");
    System.err.println(ex);
    catch (SQLException ex) {
    System.err.println("Cannot connect to this database.");
    System.err.println(ex);
    public JScrollPane createTable() {
    displayTable= new DisplayTable();
    JTable table = new JTable(displayTable);
         table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
         table.getTableHeader().setReorderingAllowed(false);
    JScrollPane scrollpane = new JScrollPane(table,
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    return scrollpane;
    } // end of createTable()
    public void actionPerformed(ActionEvent ie)
    try
    Statement statement6=connect.createStatement();
    ResultSet rs6=statement6.executeQuery("select * from benf_details");
    displayTable.executeQuery(rs6);
    statement6.close();
    catch(SQLException sqle)
    JOptionPane.showMessageDialog(null,"error2"+sqle);
    }// end of actionPerformed
    public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
    Graphics2D g2 = (Graphics2D)g;
    g2.setColor(Color.black);
    int fontHeight=g2.getFontMetrics().getHeight();
    int fontDesent=g2.getFontMetrics().getDescent();
    double pageHeight = pageFormat.getImageableHeight()-fontHeight; //leave room for page number
    double pageWidth = pageFormat.getImageableWidth();
    System.out.println("page width = " + pageWidth );
    double tableWidth = (double) table.getColumnModel().getTotalColumnWidth();
    System.out.println("table width = " + tableWidth );
    double scale = 1;
    if (tableWidth >= pageWidth) {
    scale = pageWidth / tableWidth;
    System.out.println("scale = " + scale );
    double headerHeightOnPage = table.getTableHeader().getHeight() * scale;
    double tableWidthOnPage = tableWidth * scale;
    double oneRowHeight = (table.getRowHeight() + table.getRowMargin()) * scale;
    int numRowsOnAPage = (int)((pageHeight - headerHeightOnPage) / oneRowHeight);
    double pageHeightForTable = oneRowHeight * numRowsOnAPage;
    int totalNumPages = (int)Math.ceil(((double)table.getRowCount())/numRowsOnAPage);
    if(pageIndex >= totalNumPages) {
    return NO_SUCH_PAGE;
    g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
    g2.drawString("Page: "+ (pageIndex + 1),(int)pageWidth / 2 - 35,
    (int)( pageHeight + fontHeight - fontDesent ));//bottom center
    g2.translate( 0f, headerHeightOnPage );
    g2.translate( 0f, -pageIndex * pageHeightForTable );
    //If this piece of the table is smaller than the size available,
    //clip to the appropriate bounds.
    if (pageIndex + 1 == totalNumPages) {
    int lastRowPrinted = numRowsOnAPage * pageIndex;
    int numRowsLeft = table.getRowCount() - lastRowPrinted;
    g2.setClip(0, (int)(pageHeightForTable * pageIndex),
    (int) Math.ceil(tableWidthOnPage),
    (int) Math.ceil(oneRowHeight * numRowsLeft));
    //else clip to the entire area available.
    else{
    g2.setClip(0, (int)(pageHeightForTable * pageIndex),
    (int) Math.ceil(tableWidthOnPage),
    (int) Math.ceil(pageHeightForTable));
    g2.scale(scale,scale);
    table.paint(g2);
    g2.scale(1/scale,1/scale);
    g2.translate( 0f, pageIndex * pageHeightForTable);
    g2.translate( 0f, -headerHeightOnPage);
    g2.setClip(0, 0,(int) Math.ceil(tableWidthOnPage), (int)Math.ceil(headerHeightOnPage));
    g2.scale(scale,scale);
    table.getTableHeader().paint(g2);//paint header at top
    return Printable.PAGE_EXISTS;
    } // end of print()
    public static void main(String[] args) {
    new PrintJTable();
    }// end of PrintJTable
    DisplayTable.java
    import java.util.Vector;
    import java.sql.*;
    import javax.swing.*;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.event.TableModelEvent;
    public class DisplayTable extends AbstractTableModel {
    Connection connection;
    Statement statement;
    ResultSet resultSet;
    String[] columnNames = {};
    Vector          rows = new Vector();
    ResultSetMetaData metaData;
    String db_uname,db_passwd;
    public DisplayTable() {
    public void executeQuery(ResultSet resultSet) {
    try {
    metaData = resultSet.getMetaData();
    int numberOfColumns = metaData.getColumnCount();
    columnNames = new String[numberOfColumns];
    // Get the column names and cache them.
    // Then we can close the connection.
    for(int column = 0; column < numberOfColumns; column++) {
    columnNames[column] = metaData.getColumnLabel(column+1);
    // Get all rows.
    rows = new Vector();
    while (resultSet.next()) {
    Vector newRow = new Vector();
    for (int i = 1; i <= getColumnCount(); i++) {
         newRow.addElement(resultSet.getObject(i));
    rows.addElement(newRow);
    // close(); Need to copy the metaData, bug in jdbc:odbc driver.
    fireTableChanged(null); // Tell the listeners a new table has arrived.
    catch (SQLException ex) {
    System.err.println(ex);
    public void close() throws SQLException {
    System.out.println("Closing db connection");
    resultSet.close();
    statement.close();
    connection.close();
    protected void finalize() throws Throwable {
    close();
    super.finalize();
    // Implementation of the TableModel Interface
    // MetaData
    public String getColumnName(int column) {
    if (columnNames[column] != null) {
    return columnNames[column];
    } else {
    return "";
    public Class getColumnClass(int column) {
    int type;
    try {
    type = metaData.getColumnType(column+1);
    catch (SQLException e) {
    return super.getColumnClass(column);
    switch(type) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    return String.class;
    case Types.BIT:
    return Boolean.class;
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
    return Integer.class;
    case Types.BIGINT:
    return Long.class;
    case Types.FLOAT:
    case Types.DOUBLE:
    return Double.class;
    case Types.DATE:
    return java.sql.Date.class;
    default:
    return Object.class;
    // to make the cells editable
    public boolean isCellEditable(int row, int column) {
    try {
    return metaData.isWritable(column+1);
    catch (SQLException e) {
    return false;
    public int getColumnCount() {
    return columnNames.length;
    // Data methods
    public int getRowCount() {
    return rows.size();
    public Object getValueAt(int aRow, int aColumn) {
    Vector row = (Vector)rows.elementAt(aRow);
    return row.elementAt(aColumn);
    public String dbRepresentation(int column, Object value) {
    int type;
    if (value == null) {
    return "null";
    try {
    type = metaData.getColumnType(column+1);
    catch (SQLException e) {
    return value.toString();
    switch(type) {
    case Types.INTEGER:
    case Types.DOUBLE:
    case Types.FLOAT:
    return value.toString();
    case Types.BIT:
    return ((Boolean)value).booleanValue() ? "1" : "0";
    case Types.DATE:
    return value.toString(); // This will need some conversion.
    default:
    return "\""+value.toString()+"\"";
    public void setValueAt(Object value, int row, int column) {
    try {
    String tableName = metaData.getTableName(column+1);
    // Some of the drivers seem buggy, tableName should not be null.
    if (tableName == null) {
    System.out.println("Table name returned null.");
    String columnName = getColumnName(column);
    String query =
    "update "+tableName+
    " set "+columnName+" = "+dbRepresentation(column, value)+
    " where ";
    // We don't have a model of the schema so we don't know the
    // primary keys or which columns to lock on. To demonstrate
    // that editing is possible, we'll just lock on everything.
    for(int col = 0; col<getColumnCount(); col++) {
    String colName = getColumnName(col);
    if (colName.equals("")) {
    continue;
    if (col != 0) {
    query = query + " and ";
    query = query + colName +" = "+
    dbRepresentation(col, getValueAt(row, col));
    System.out.println(query);
    System.out.println("Not sending update to database");
    // statement.executeQuery(query);
    catch (SQLException e) {
    // e.printStackTrace();
    System.err.println("Update failed");
    Vector dataRow = (Vector)rows.elementAt(row);
    dataRow.setElementAt(value, column);
    }

    Java 1.5 incorporates a very simple way to print from a JTable. I am using a mysql DB but it is the same concept. Review my code and let me know if you have any questions.
    package emsmain;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.*;
    import java.sql.*;
    import java.text.MessageFormat;
    import java.util.*;
    import javax.print.*;
    import javax.print.attribute.HashPrintRequestAttributeSet;
    import javax.print.attribute.PrintRequestAttributeSet;
    import javax.swing.*;
    import javax.swing.JTable;
    import javax.swing.table.*;
    import java.awt.print.*;
    public class TableFromDatabase extends JFrame implements ActionListener{
        JButton jbtprint = new JButton("Print Report");
        JTable Reporttable;
        Connection conn = Connect_Database.getConnection();
         public TableFromDatabase()
    Vector columnNames = new Vector();
    Vector data = new Vector();     
              try{  
                String query = null;
                Statement ps = null;
                ResultSet rs = null;
                  //Class Master List
                  if (Report_Menu.jrbMaster_list.isSelected()){
                      query =("Select * from students") ;
                  //Classes taken by student
                  if (Report_Menu.jrbClass_taken.isSelected()){
                      String taken = Report_Menu.jtfStudent.getText();
                      query = ("select program.course_num, course_name, course_start_date, course_stat_desc from registration, program where student_id = '"+taken+"' and program.course_num = registration.course_num");
                  //Birthday report
                  if (Report_Menu.jrbBirthday.isSelected()){
                      String birthday = (String) Report_Menu.jcb_birthday.getSelectedItem();
                      query = ("SELECT student_id, fname, lname, address, city, state_name, zipcode, dob FROM students where substring(dob, 6,2) = '"+birthday+"'"); 
                  //Course Catologue
                  if (Report_Menu.jrbCourseCatologue.isSelected()){
                      String course = (String) Report_Menu.jcbChooseCourse.getSelectedItem();
                      query = ("select  course_name, course_length, course_cost, course_credits from course where course_name = '"+course+"'");
                  //Certification expiration report
                  if (Report_Menu.jrbExpiration.isSelected()){
                      String month = (String) Report_Menu.jcbMonth.getSelectedItem();
                      String year = (String) Report_Menu.jcbYear.getSelectedItem();
                      query = ("SELECT FNAME, LNAME FROM STUDENTS, REGISTRATION WHERE substring(expiration_date, 6,2) = '"+month+"' and substring(expiration_date, 1,4) = '"+year+"' and registration.student_id = students.student_id") ;
                  //Class Roster
                  if (Report_Menu.jrbRoster.isSelected()){
                      String c_number = Report_Menu.jtfClassNumber.getText();
                      query = ("Select course_name, course_start_date, fname, lname from program, registration, students where program.course_num = '"+c_number+"' and registration.student_id = students.student_id;");
                  //Squad list and counts
                  if (Report_Menu.jrbSquadCount.isSelected()){
                      query = ("SELECT Squad_Name, count(student_id) from students group by Squad_Name");
                  //Student List
                  if (Report_Menu.jrbStudent_list.isSelected()){
                      String Choose_month = (String) Report_Menu.jcbcourse_month.getSelectedItem();
                      String Choose_Course = (String) Report_Menu.jcbcourse_name.getSelectedItem();
                      query = ("select count(student_id) from (registration, program) where program .course_name = '"+Choose_Course+"' and substring(course_start_date, 6,2) = '"+Choose_month+"'and registration.course_num = program.course_num;");
                ps = conn.createStatement();
                //Run Selected Report
                ps.execute(query);
                rs = ps.executeQuery(query);
                ResultSetMetaData md = rs.getMetaData();
                int columns = md.getColumnCount();
                //  Get column names
                for (int i = 1; i <= columns; i++)
                    columnNames.addElement( md.getColumnName(i) );
                //  Get row data
                while (rs.next())
                    Vector row = new Vector(columns);
                    for (int i = 1; i <= columns; i++)
                        row.addElement( rs.getObject(i) );
                    //add row data to JTable
                    data.addElement( row );
                rs.close();
                ps.close();
            catch(Exception e)
                JOptionPane.showMessageDialog(null,e.getMessage());
            //  Create Jtable with database data 
            Container c = getContentPane();
            c.setLayout(new BorderLayout());
            Reporttable = new JTable(data, columnNames);
            JScrollPane scrollPane = new JScrollPane( Reporttable );
            c.add( scrollPane );
            JPanel buttonPanel = new JPanel();
            buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
            buttonPanel.add(jbtprint);
            c.add(buttonPanel,BorderLayout.SOUTH);
            jbtprint.addActionListener(this);
        public void actionPerformed(ActionEvent e){
             if(e.getActionCommand().equals("Print Report")){
               PrintForm();
    public void PrintForm(){ 
         try {
             String name = null;
             // Will display correct heading for print job
             if (Report_Menu.jrbMaster_list.isSelected()){
             name = "Master List";
             if (Report_Menu.jrbBirthday.isSelected()){
             name = "Birthday List";
             if (Report_Menu.jrbClass_taken.isSelected()){
             name = "Classes taken by Student";
             if (Report_Menu.jrbCourseCatologue.isSelected()){
             name = "Course Catalogue";
             if (Report_Menu.jrbExpiration.isSelected()){
             name = "Certification Expiration Report";
             if (Report_Menu.jrbRoster.isSelected()){
             name = "Class Roster";
             if (Report_Menu.jrbSquadCount.isSelected()){
             name = "Squad list with Student Counts";
             if (Report_Menu.jrbStudent_list.isSelected()){
             name = "Student count by Course";
             // fetch the printable
             Printable printable = Reporttable.getPrintable(JTable.PrintMode.FIT_WIDTH,
                                                      new MessageFormat(name),
                                                      new MessageFormat("Page - {0}"));
             // fetch a PrinterJob
             PrinterJob job = PrinterJob.getPrinterJob();
             // set the Printable on the PrinterJob
             job.setPrintable(printable);
             // create an attribute set to store attributes from the print dialog
             PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
             // display a print dialog and record whether or not the user cancels it
             boolean printAccepted = job.printDialog(attr);
             // if the user didn't cancel the dialog
             if (printAccepted) {
                    try {
                          // do the printing (may need to handle PrinterException)
                        job.print(attr);
                    } catch (PrinterException ex) {
                        ex.printStackTrace();
         } finally {
             // restore the original table state here (for example, restore selection)
    }

  • Problem in printing the selected labels value in smartform-SD_PACKING.....

    Dear all,
    Iam trying to print the packing list using smarforms,
    T.Code - VL74 - After providing the input for the selection screen,
    eg. output_type - 0001.
         outbound.deliv - 80000834.
    In the "OUTPUT FROM HANDLING UNITS" screen, im getting the list of labels available for that selection.
    say for eg.
      HU         Ob Object key Out. Med Role Name 1        City            PkMtT PackMatls
    1000004002 01 0080000834 0001 1   WE   CALCADOS LTDA BENTO GONCALVES Z001  300026
      1000004003 01 0080000834 0001 1   WE   CALCADOS LTDA BENTO GONCALVES Z001  300026
    1000004005 01 0080000834 0001 1   WE   CALCADOS LTDA BENTO GONCALVES Z001  300026
    1000004006 01 0080000834 0001 1   WE   CALCADOS LTDA BENTO GONCALVES Z001  300026
    with the Selection check box attached to the first field, when i
    select the first and second HUs, it should be passed to the
    driver program, but im getting only one HU value passed into the driver program.
    In the driver program my code goes like below,
    REPORT ZSDPACKDR LINE-COUNT 100 MESSAGE-ID VV.
    TABLES: VBCO3, TVST.
    INCLUDE ZPALIDATA_PL.
    INCLUDE RVADTABL.
    DATA: RETCODE LIKE SY-SUBRC,             "Returncode
           XSCREEN(1) TYPE C.                 "Ausgabe Printer/Screen
    Internal table for lips
    DATA: lips_wa TYPE lips.
    DATA: int_lips LIKE lips_wa OCCURS 0 WITH HEADER LINE.
    *&      Form  ENTRY
          text
         -->RETURN_CODE  text
         -->US_SCREEN    text
    FORM ENTRY USING RETURN_CODE US_SCREEN.
       CLEAR RETCODE.
       XSCREEN = US_SCREEN.
       PERFORM PROCESSING USING XSCREEN.
       IF RETCODE NE 0.
         RETURN_CODE = 1.
       ELSE.
         RETURN_CODE = 0.
       ENDIF.
    ENDFORM.                    "ENTRY
    FORM PROCESSING USING PROC_SCREEN.
       PERFORM GET_DATA.
       CHECK RETCODE = 0.
    ENDFORM.                    "PROCESSING
    FORM GET_DATA.
      REFRESH: LVBPLK, LVBPLA, int_lips.
      CLEAR: LVBPLK, LVBPLA, int_lips.
       DATA: FM_NAME TYPE RS38L_FNAM.
       VBCO3-VENUM = NAST-OBJKY.                                "00000.....
       VBCO3-SPRAS = NAST-SPRAS.      "D
       VBCO3-KUNDE = NAST-PARNR.      "KUNDE
       VBCO3-PARVW = NAST-PARVW.      "WE
       VBCO3-PACKD = 'X'.
       CALL FUNCTION 'SD_PACKING_PRINT_VIEW_SINGLE'
         EXPORTING
           COMWA                    = VBCO3
         IMPORTING
           VBPLK_WA                 = LVBPLK
           VBPLA_WA                 = LVBPLA
           VBADR_TVST               = LVBADR                    "n_916660
         TABLES
           VBPLP_TAB                = LVBPLP
         EXCEPTIONS
           SHIPPING_UNIT_NOT_UNIQUE = 1
           SHIPPING_UNIT_NOT_FOUND  = 2
           OTHERS                   = 3.
       IF SY-SUBRC NE 0.
         RETCODE = 1.
         PERFORM PROTOCOL_UPDATE.
       ENDIF.
    in the above coding, i used SD_PACKING_PRINT_VIEW_SINGLE', but i tried with SD_PACKING_PRINT_VIEW also, but no values getting loaded in the importing structures. if im doing anything wrong, pls correct me.
    *CALL FUNCTION 'SD_PACKING_PRINT_VIEW'
    EXPORTING
       COMWA                         = VBCO3
      AUFTRAG_NICHT_LESEN           = ' '
      EXPORTDATEN_NICHT_LESEN       = ' '
    IMPORTING
      VBPLA_WA                      =
    TABLES
       VBPLK_TAB                     = LVBPLK
       VBPLP_TAB                     = LVBPLP
       VBPLS_TAB                     = LVBPLS
    EXCEPTIONS
      OBJECT_NOT_FOUND              = 1
      OTHERS                        = 2
    *IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    The problem is:
    For any of the above function call,
    The VBCO3 itself im getting only one label number, hence it is processing for only one, i want to know how to pass on the multiple
    label number to this function call ie, in VBC03.
    meaning i would like to know, in which internal table , i can get the list of all the selected HUs, so that i shall loop this function call inorder get the appropriate output.
    kindly help me to sort this issues.
    Points assured.
    regs,
    Raja

    Dear Srihari,
    I wrote above code in first label(now i deleted do-enddo) only.
    first i  am moving seven lebels data into seven wa's.
    after that reading the first record and moving another itab(for printing at main window i.e. 8 label).
    clearly, there is no space problem..because instead puttting all the required field i put only customer name.
    Now it is printing well in first page with 8 labels(main window) also.
    But in the second Page it displays only 7 labels and not printing rest of the labels.
    for example my itab has 20 records it displays 8 labels in first page &
    next 7 labels in second page and not print the rest of the 5 labels i.e. it is not calling third page(?).
    code..
    CLEAR : WA1, WA2, WA3, WA4, WA5, WA6, WA7.
    loop at it_final into wa_final FROM 1 TO 7.
      if sy-tabix = '1'.
        wa1 = wa_final.
      elseif sy-tabix = '2'.
        wa2 = wa_final.
      elseif sy-tabix = '3'.
        wa3 = wa_final.
      elseif sy-tabix = '4'.
        wa4 = wa_final.
      elseif sy-tabix = '5'.
        wa5 = wa_final.
      elseif sy-tabix = '6'.
        wa6 = wa_final.
      elseif sy-tabix = '7'.
        wa7 = wa_final.
      endif.
      endloop.
       delete it_final from 1 to 7. 
    **Push every 8th row if it_final in it_main
        read table it_final into wa_final index 1.  "deleting 8th, 16th,... records
        if sy-subrc = 0.
          append wa_final to it_main.
         else.
          exit.
        endif.
    *Delete the rows from it_main which are present in it_final
      loop at it_main into wa_final.
        delete table it_final from wa_final.  "deleting 8 th row from it_final.
      endloop.
    Edited by: anurag.radha on Jan 6, 2012 1:09 PM

  • Problem in Printing the values in SAP Script

    Hi,
    I have to print the material, description, quantity and value in the invoice.. the problem i face is.. the variables which is of size 40 characters. only prints the data and gets trimmed because of which the data displayed in the invoice not in order.
    can any one tell me how to find the length of the variable or is there any way to protect the variable from getting trimmed.
    Advance Thanks..
    Guhapriyan S

    Hi again,
    1. what problem are u facing ?
      (there is no sapscript symbol / system symbol
       for finding out the length )
      (In abap u can use strlen)
    2.  data and gets trimmed
       what is the meaning of it ?
    3. do u mean to say that  !
      ABCDEF                     123 45
      GEF                        123 45
      is getting pritned like
      ABCDEF 123 45  ?
      GEF  123 45
    4. If so , then use TABS
    5. This happens because SPACE
       is different in different varlues of
       ABCDEF and GEF !
    regards,
    amit m.
    Message was edited by: Amit Mittal

  • Issue with printing the decimal value in smartforms

    Hi experts,
    Here I am printing the net valve in to smartforms.The problem is, valve i want to print is 4505.600.But it is displaying as 45056.00.It is in OMR currency. This problem occurs only for this currency.i am picking the value from PO.
    I have used komv-kwert feild for display. Please give me the solution
    Regards,
    madhu

    Hi Madhu,
    I have faced similar problem in my Smartform with currency JPY with no decimal places at all.
    To resolve this you have to specify Reference Currency with the Currency type  under Global Definitions-->Currency/Quant.Fields. For example take your case :
    Fieldname               Reference Field     Data Type
    WA_FINAL-KWERT              W_WAERS           C CURR
    *Here W_WAERS should contain OMR
    *WA_FINAL-KWERT sould contain 45056.00 then your output will look like 4505.600
    Thanks & Regards,
    Rock.

  • Problem while updating the forecast value in m.master by direct input menth

    Hi All
      Good Day
      I am updating the forecast value in material master by direct input method.
    my program is working fine when I am running it online.
    but when i am runnig in back ground I am getting one error which is mentioned below
                                                                                    Job ZM_OPTIMIZA_UPLOAD: Data does not match the job definition; job terminated    BD    078     E    
    Please anyone can help ne in above case.
    Thanks in advance.
    Cheers
    Vallabhaneni

    Hi Hakim
    How are you
    Thanks for your valuable suggestion.
    I am executing my program in background with bmv0 transaction with variant, in development I can run this job in background with out any logical errors but in QA I am getting errors.
    Can you please help me in the above case.
    In Bmv0 transaction first I defined the job and in  program rmdatind (execute) screen first I mentioned the Max. no of logical errors as 500 and Transactions per commit unit as 500 and I run the program in background in bmv0 transaction and I am getting the message background job terminated immediately
    Because of this again I changed the Max. no of logical errors 500 to 99999 and transaction per commit unit 500 to 999999 and then i scheduled my program in background.
    Alomost it ran for 27 hours and then it has given the message background job terminated.
    Job log entries are as follows.
    22.12.2008  11:19:46  A system error has occurred while locking                                 
    22.12.2008  11:19:46  Transaction 0000040840; material number SUJ82J8400; error gravity E       
    22.12.2008  11:19:46  Transaction 0000040840: Taxes for sales org.  cannot be transferred       
    22.12.2008  11:19:46  A system error has occurred while locking                                 
    22.12.2008  11:19:46  Transaction 0000040841; material number SUJ84G3001; error gravity E       
    22.12.2008  11:19:46  Transaction 0000040841: Taxes for sales org.  cannot be transferred       
    22.12.2008  11:19:46  A system error has occurred while locking                                 
    22.12.2008  11:19:46  Transaction 0000040842; material number SUJ84G3002; error gravity E       
    22.12.2008  11:19:46  Transaction 0000040842: Taxes for sales org.  cannot be transferred       
    22.12.2008  11:19:46  A system error has occurred while locking                                 
    22.12.2008  11:19:46  Transaction 0000040843; material number SUJ86G0100; error gravity E       
    22.12.2008  11:19:46  Transaction 0000040843: Taxes for sales org.  cannot be transferred       
    22.12.2008  11:19:46  A system error has occurred while locking                                 
    22.12.2008  11:19:46  Transaction 0000040844; material number SUJ86G0300; error gravity E       
    22.12.2008  11:19:46  Transaction 0000040844: Taxes for sales org.  cannot be transferred       
    22.12.2008  11:19:46  A system error has occurred while locking                                 
    22.12.2008  11:19:46  Transaction 0000040845; material number SUJ86G0900; error gravity E       
    22.12.2008  11:19:46  Transaction 0000040845: Taxes for sales org.  cannot be transferred       
    22.12.2008  11:19:46  A system error has occurred while locking                                 
    22.12.2008  11:19:46  Transaction 0000040846; material number SUJ86G9600; error gravity E       
    22.12.2008  11:19:46  Transaction 0000040846: Taxes for sales org.  cannot be transferred       
    22.12.2008  11:19:46  A system error has occurred while locking                                 
    22.12.2008  11:19:46  Transaction 0000040847; material number SUJ86G9601; error gravity E       
    22.12.2008  11:19:46  Transaction 0000040847: Taxes for sales org.  cannot be transferred       
    22.12.2008  11:19:46  A system error has occurred while locking                                 
    22.12.2008  11:19:46  Transaction 0000040848; material number SUJ86J0000; error gravity E       
    22.12.2008  11:19:46  Transaction 0000040848: Taxes for sales org.  cannot be transferred       
    22.12.2008  11:19:46  A system error has occurred while locking                                 
    22.12.2008  11:20:54  Transaction 0000040848 completed Mat. no.  No. of log. errors 0000040848  
    22.12.2008  11:21:30  ABAP/4 processor: TSV_TNEW_PAGE_ALLOC_FAILED                              
    22.12.2008  11:21:30  Job cancelled      
    I know it has taken long time to process the job  because of I changed the transactions per commit unit (500 to 999999) it kills the system
    But I am supposed to provide some number < 999999 in transactions per commit unit
    actually I haven't tried like I said above < 999999 because i don't have any hopes.
    Please look at this problem and help me in this case.
    Thanks in advance.
    Vallabhaneni

  • Problem in printing the data from database when i print inside servlet

    hi to all!
    the objective of the code below is getting the data from database table and has to send that data to the web browser using out.println .note: out - PrintWriter object
    In a getQuestion method, i am getting the data from database table and store it in String q and when i print the q within this method it is getting printed, but i got the null value when i printed the String q inside service method doPost. why..? its puzzling me.
    package servlet;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class test extends HttpServlet {
         Connection con;
         ResultSet rs;
         Statement s;
         StringBuffer q;
         StringBuffer o1;
         StringBuffer o2;
         StringBuffer o3;
         public void getQuestion() throws Exception
              if(rs.next())
                   q=new StringBuffer(rs.getString("question"));
                   o1=new StringBuffer(rs.getString("option1"));
                   o2=new StringBuffer(rs.getString("option2"));
                   o3=new StringBuffer(rs.getString("option3"));
                   System.out.println(q);
                   System.out.println(o1);
                   System.out.println(o2);
                   System.out.println(o3);
         public void connect(){
              try
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              con=DriverManager.getConnection("jdbc:odbc:ds","sa","server");
              s=con.createStatement();
              rs=s.executeQuery("select * from qa order by newid()");
              getQuestion();
              catch(Exception e)
                   System.out.println("erroe");
         public void doPost(HttpServletRequest request,HttpServletResponse response)
         throws IOException,ServletException
              response.setContentType("text/html");
              new test().connect();
              PrintWriter out=response.getWriter();
              request.setAttribute("question", q);
              request.setAttribute("option1", o1);
              request.setAttribute("option2", o2);
              request.setAttribute("option3", o3);
              //RequestDispatcher rd=getServletContext().getRequestDispatcher("/show.jsp");
              //rd.forward(request, response);
              out.println("<html>");
    out.println("<head>");
         out.println("<title>" + "shock!!!" + "</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h2>"+"Read twice before u answer"+"<h2>");
    out.println("<p></p>");
    //why the value of q is not getting printed, instead i get null
    out.println("<h2>"+ q +"<h2>");
    out.println("how is it");
    out.println("</body>");
    out.println("</html>");
    Edited by: Mahesh_yeswecan on Nov 29, 2008 10:42 AM

    As u said , i have done a silly mistake earlier. though i have corrected the code still i am getting the same null value
    package servlet;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class test extends HttpServlet  {
         Connection con;
         ResultSet rs;
         Statement s;
         StringBuffer q;
         StringBuffer o1;
         StringBuffer o2;
         StringBuffer o3;
         public void getQuestion() throws Exception
              if(rs.next())
                   q=new StringBuffer(rs.getString("question"));
                   o1=new StringBuffer(rs.getString("option1"));
                   o2=new StringBuffer(rs.getString("option2"));
                   o3=new StringBuffer(rs.getString("option3"));
                   System.out.println(q);
                   System.out.println(o1);
                   System.out.println(o2);
                   System.out.println(o3);
         public void connect(){
              try
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              con=DriverManager.getConnection("jdbc:odbc:ds","sa","server");
              s=con.createStatement();
              rs=s.executeQuery("select * from qa order by newid()");
              getQuestion();
              catch(Exception e)
                   System.out.println("erroe");
         public void doPost(HttpServletRequest request,HttpServletResponse response)
         throws IOException,ServletException
              response.setContentType("text/html");
              connect();
              PrintWriter out=response.getWriter();
              request.setAttribute("question", q);
              request.setAttribute("option1", o1);
              request.setAttribute("option2", o2);
              request.setAttribute("option3", o3);
              //RequestDispatcher rd=getServletContext().getRequestDispatcher("/show.jsp");
              //rd.forward(request, response);
              out.println("<html>");
            out.println("<head>");
             out.println("<title>" + "shock!!!" + "</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h2>"+"Read twice before u answer"+"<h2>");
            out.println("<p></p>");
            //why the value of q is not getting printed, instead i get null
            out.println("<h2>"+ q +"<h2>");
            out.println("how is it");
            out.println("</body>");
            out.println("</html>");
    }

Maybe you are looking for

  • How do I install Pages on my iPhone if I already have it for my macbook?

    Is there any way to install Pages onto my iPhone, or do I have to buy a separate app?

  • Upload problems with Facebook and Vimeo from Premiere Elements 10

    I have created a project in HD and am trying to upload to Vimeo.  Premiere Elements 10 does not have a preset so I followed some instructions from the Vimeo website.  Project is "blurry" when viewed.  I checked with Vimeo and they said what they conv

  • Repl. Partioning BSO to ASO: increase of size of .dat file in temp-folder

    Hello, we are shifting data from a BSO Cube to an ASO cube via replicated partitioning. The partitioning takes about 50 minutes to execute. Size of .dat in metadata-folder: 8 mb Size of .dat in default-folder: 150 mb Size of .dat in temp-folder: 38 g

  • Unwanted EKRS entries - ERS process

    Hallo, my Friends. We are in the middle of negotiating ERS process with our vendors in Mexico, legal considerations prevent us from using it "as is".  The table EKRS has been populated for some time, the GR were cleared using MIRO. My question is: ca

  • Create a correct EAR file

    Hi there, i've create a server which has connections to an Oracle DB, the servlet is runnig perfectly in the oc4j integrated with JDeveloper9i. I have created a connection-> Application server. i see the data-sources.xml that jdeveloper creates, in m