How to set column width in alvgrid

hi
how to set column width in alvgrid.
thanks.

Hi,
Check this,
REPORT  ztest.
DATA: BEGIN OF i_scarr_tab OCCURS 0.
        INCLUDE STRUCTURE  scarr.
DATA: END OF i_scarr_tab.
DATA: i_scarr LIKE TABLE OF i_scarr_tab WITH HEADER LINE,
      w_scarr LIKE LINE OF i_scarr_tab.
DATA: o_grid      TYPE REF TO cl_gui_alv_grid,
      o_container TYPE REF TO cl_gui_custom_container.
DATA: lt_fcat     TYPE lvc_t_fcat,
      ls_layo     TYPE lvc_s_layo,
      ls_sort     TYPE lvc_s_sort,
      lt_sort     TYPE lvc_t_sort,
      ls_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
START-OF-SELECTION.
  CALL SCREEN 9000.
*&      Module  status_9000  OUTPUT
      text
MODULE status_9000 OUTPUT.
  SET PF-STATUS '9000'.
  SET TITLEBAR '9000'.
ENDMODULE.                 " status_9000  OUTPUT
*&      Module  user_command_9000  INPUT
      text
MODULE user_command_9000 INPUT.
  CASE sy-ucomm .
    WHEN 'BACK' OR 'EXIT'.
      SET SCREEN 0.
      LEAVE SCREEN.
  ENDCASE.
ENDMODULE.                 " user_command_9000  INPUT
*&      Module  init_9000  OUTPUT
      text
MODULE init_9000 OUTPUT.
  IF o_container IS INITIAL.
    SELECT * FROM scarr INTO CORRESPONDING FIELDS OF TABLE
       i_scarr UP TO 100 ROWS.
    IF cl_gui_alv_grid=>offline( ) IS INITIAL.
Create a custom container control for ALV Control
      CREATE OBJECT o_container
          EXPORTING
              container_name = 'CONTROL'.
Create a ALV Control
      CREATE OBJECT o_grid
          EXPORTING i_parent = o_container.
      PERFORM build_field_catalgue.
      ls_layo-sel_mode = 'A'.
      CALL METHOD o_grid->set_table_for_first_display
        EXPORTING
          i_save          = 'A'
          i_default       = 'X'
          is_layout       = ls_layo
        CHANGING
          it_outtab       = i_scarr[]
          it_fieldcatalog = lt_fcat
          it_sort         = lt_sort[].
    ENDIF.
  ENDIF.
ENDMODULE.                 " init_9000  OUTPUT
*&      Form  build_field_catalgue
      text
-->  p1        text
<--  p2        text
FORM build_field_catalgue .
  DATA: ls_fcat TYPE lvc_s_fcat.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name         = sy-cprog
      i_internal_tabname     = 'I_SCARR_TAB'
      i_structure_name       = 'SCARR'
     i_client_never_display = 'X'
    CHANGING
      ct_fieldcat            = ls_fieldcat[]
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.
  IF sy-subrc <> 0.
    MESSAGE 'FCAT Error' TYPE 'I'.
    EXIT.
  ENDIF.
  LOOP AT  ls_fieldcat.
    CLEAR ls_fcat.
    ls_fcat-fieldname = ls_fieldcat-fieldname.     "Fieldname
    ls_fcat-ref_table = ls_fieldcat-tabname.       "DDIC ref struct
    ls_fcat-inttype   = ls_fieldcat-inttype.       "Data type
    ls_fcat-outputlen = ls_fieldcat-outputlen.     "Column width
    ls_fcat-coltext   = ls_fieldcat-seltext_m.     "Column Header
    ls_fcat-seltext   = ls_fieldcat-seltext_m.     "Column Desc
    ls_fcat-ref_field = ls_fieldcat-ref_fieldname. "Reference field
    ls_fcat-ref_table = ls_fieldcat-ref_tabname.   "Reference table
    CASE  ls_fieldcat-fieldname.
      WHEN 'LUGGWEIGHT' OR 'FORCURAM'.
        ls_fcat-edit      = 'X'.
        ls_fcat-do_sum    = 'X'.
      WHEN 'URL'.
        ls_fcat-no_out = 'X'.
      WHEN OTHERS.
        ls_fcat-edit      = ' '.
        ls_fcat-do_sum    = ' '.
    ENDCASE.
    APPEND ls_fcat TO lt_fcat.
  ENDLOOP.
ENDFORM.                    " build_field_catalgue
check the programs bcalv_grid*.
check this link for more detailed example.
http://www.supinfo-projects.com/fr/2005/alv_display_fr/2/
Regards
Sruthi

Similar Messages

  • How to set column widths in tables for selected table only, not globally throughout document?

    I've been utilizing the below script (thank you so much Ramkumar. P!) to set column widths throughout a sizable InDesign book with tables on every page and it is truly a time saver. At this point in time, I have three versions of it because there are different column widths throughout the book. Is it possible to augment the script to run only on a selected text frame (containing a table)? If so, would someone be kind enough to share the augmented script with me? I've been trying to figure out this seemingly simple change through trial and error with no success as yet. I realize this is a totally newbie request and I'm entirely at the mercy of the kindness of the Javascript gods that contribute within this forum. Seeing that in a different post related to this script, one such guru responded to a request as simple as "Where do I put the scripts in InDesign" gave me enough courage to ask for some help! Thank you in advance to anyone willing to provide a solution.
      var myDoc = app.activeDocument;
         var myWidths = [100, 100, 150, 150];
         for(var T=0; T < myDoc.textFrames.length; T++){
             for(var i=0; i < myDoc.textFrames[T].tables.length; i++){
                 for(var j=0; j < myWidths.length; j++){
                     myDoc.textFrames[T].tables[i].columns[j].width = myWidths[j];
         alert("Table width updated successfully...");

    Hello all
    I have the same problem in that I'm not a scripting person, but was able to get the above script working without problem, and it does set irregular table column widths perfectly, so thanks to Ramkumar. P for that.
    BUT, it changes the column width for ALL tables in the document, whereas I would like to just target the selected table.
    Any ideas as to how I might amend this script to achieve this?
    Thx, Christian

  • How to set column width in GridPane in FXML?

    I would like to set width, for ex, of column 4 in GridPane.
    I can do like this:
    <columnConstraints>
                <ColumnConstraints prefWidth="100"/>
                <ColumnConstraints prefWidth="200" />
                <ColumnConstraints prefWidth="200" />
                <ColumnConstraints prefWidth="200" />
    </columnConstraints>If i have 10 columns should i add 10 column constraints? (i need to set only width of 4th column)
    How can i do it easier?

    >
    Hi, Can someone please help on how to set the columnwidth in csv file using javacode.
    I used FileWriter class to upload data into the csv file but csv file is taking default width while showing content. Is there a way to set the fixed column width or set width dinamically based on value?
    >
    The fields in CSV (Comma-Separated-Value) files are separated by commas; they do not have a fixed width.

  • How to set column width for Label in Form region?

    In the form region, the label value is a lengthy text, and it does not wrap. How do I make it wrap to a fixed column width?
    Under Home>Application Builder>Application>Page>Edit Page Item,
    i have set "HTML Table Cell Attributes" to width="300", but it still does not wrap. and pushes the field to the right end of the page.
    I am quite sure there are better ways of doing this.

    thanks Simakas for the reply.
    I had set the label template to "Optional" and that was forcing a "nowrap". After unsetting the template, I used your suggestion and it works like a charm. Thanks.

  • How to set column width based on header width?

    I have a column that will only hold 1 character. This is good, but I want the Column width to match the column header.
    For example,
    Currently I get:
    select * from table;
    I NAME
    1 ROBERT
    The problem is, I want the Column header spelled out (in this case it's just ID)
    ID NAME
    1 ROBERT
    Better Yet,
    if i did:
    select ID "ID NUMBER", NAME "FIRST NAME" from table;
    I'd like to see:
    ID NUMBER FIRST NAME
    1 ROBERT
    (Centering the ID within the Column width would be good too, but that is "gravy")
    Any thoughts? I've been trying:
    COLUMN ID FORMAT A10 (which obviously didn't work!)
    Thanks,
    KSL.
    Edited by: leonhardtk on Aug 23, 2010 11:55 AM

    If you use tags it'll be easier to see what formatting effects you're talking about.
    Does <a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e10823/ch_six.htm"><tt>col id head "ID Number" format a9</tt></a> do what you want?
    Edited by: William Robertson on Aug 23, 2010 6:50 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to set column width in OBIEE

    hi ,
    I want to set the coumn width in table, my version is obiee 10.
    any one know how adjust the width of column?
    thanks.

    Use column properties->Additional Formatting Options
    and set width 10px or as per your req.
    Pls mark correct/helpful if helps

  • How to set the WIDTH and ALIGN of h:column in h:dataTable ??

    How to set the WIDTH and ALIGN of <h:column> in <h:dataTable>??
    Thanks a lot!

    Hi,thanks to your reply.
    Now I find a more convenient appraoch to set column's width and align respectively:
    <h:dataTable ...>
    <h:column>
    <f:facet name='header'>
    </f:facet>
    <h:outputText style="width:80px; text-align: right;" value='#{row.fieldA}'/>
    </h:column>
    <h:column>
    <f:facet name='header'>
    </f:facet>
    <h:outputText style="width:120px; text-align: left;" value='#{row.fieldB}'/>
    </h:column>
    </h:dataTable>
    It works fine.
    ^-^

  • How can I set column width in JTable?

    How can I set column width in JTable?

    Also, read the JTable API before posting questions. You will find a link to the Swing tutorial on "How to Use Tables", which contains an example of doing exactly this.

  • HELP Friends!!! How to set the width of columns of JTABLE?

    Hi!
    How to set the width of a particular column in JTable?
    I tried using headerRenderers and though I'm able to set the color and font of the header (using getTableCellRendererComponent method)I can't change the size.
    Pls some one help me..it's very urgent.
    Thanks in advance.
    Regards,
    Naval

    JTable.getColumnModel().getColumn(i).setWidth(width). There are also setPreferredWidth, setMaxWidth and setMinWidth methods.

  • Setting column width in a command-line program

    Is there a way to send data to the screen in a command-line Java program that will be formatted as a number
    of columns with a set column width? I am looking for something similar to the C++ setw() I/O manipulator
    used in cout.
    Thanks,
    Steve

    If you go to: http://java.sun.com/docs/books/tutorial/essential/io/writingFiltered.html
    it will show you how to subclass a filtered output stream and add your own formatting methods.Then you can chain your new class to System.out
    like this:
    YourFilteredStream yfs = new YourFilteredStream(System.out); .
    Then:
    yfs.yourNewMethod(); goes directly to system out in the new format.

  • Set Column width in query (not using SQL*Plus)

    How can I Set Column width in query
    I understand you can set column width using
    column col1 FORMAT A5
    select col1 from table1;But this only works in SQL*Plus
    I want to be able to do this in a regular SQL query window (not in SQL*Plus), how can I do it.....
    I am using a 'SQL window' in PL/SQL Developer IDE
    and when I use this syntax it says:
    ORA-00900: Invalid SQL statement
    Any suggestions are appreciated...
    thanks,
    M.

    Did you try using RPAD or LPAD functions? They fill the unfilled part of a string with character you provide... either on right or left side depending on what function you use.
    e.g.
    SELECT RPAD('Smith', 10, ' ') Name FROM dual;http://www.adp-gmbh.ch/ora/sql/rpad.html
    Edited by: Zaafran Ahmed on Nov 10, 2010 11:50 AM

  • How to save column widths in tag monitor and tag config editor?

    how to save column widths in tag monitor and tag config editor?

    The attached example may help.
    After launching the editor, I locate a reference to the front panel control named "Tag List".
    This is type cast as a multicolumn list box which then allows me to increment through all of the cells and set the widths as i go.
    Trying to help,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Attachments:
    Set_Width2.vi ‏60 KB
    SET_WIDTH.JPG ‏94 KB

  • How to set the width for a selectManyShuttle component

    Hi,
    I'm using selectManyShuttle component from Oracle ADF Core and some of the items in the showing list are long, therefore the width of selectManyShuttle expands the page. How to set the width property for selectManyShuttle component? After that does selectManyShuttle provide horizontal scrollbar as well?
    Thanks in advance,
    lapi
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]

    Solution here:
    Re: ADF Faces Scrollable Panel or Scroll Bar inside a component
    Regards
    Grant

  • How to set line width using CoreGraphics ?

    Hi guys.
    I trying draw line with 2 pixels width.
    How to set line width on CoreGraphics ?
    AFAIK, OpenGLES.framework has method like this :
    glLineWidth(2.0);
    Is it possible for CoreGraphics ?
    Thanks in advance.

    See CGContextSetLineWidth in the CGContextReference.
    You might also want to look over Painting a Path in the +Quartz 2D Programming Guide+.
    \- Ray

  • How to set columns for Zip Codes?

    I am new to iMac and in my first week using trial version of Numbers. I work in sales and we do lots of mailings using merging of data and addresses for post cards, labels, etc.
    I cannot see how to set columns to a zip code setting. All zips entered beginning with a 0 drop the front 0. I tried calling the column as Text, but it did not help. I can type a ' in from of the 0 and it works, but this takes an insane amount of time and will not work for us.
    How do you deal with Zip Codes? Are there labeling options for mailing built into Numbers? I really want to dump all MS products but will have to drop mac and return buy Office if this is not correctable.
    Thank you,
    Brownie

    Hello
    Setting the column format to text do the trick on my french version too.
    With AppleWorks, I was accustomed to use a zeroSlashed so it remained in my zip codes when I moved codes here and there.
    Yvan KOENIG (from FRANCE jeudi 13 septembre 2007 17:44:38)

Maybe you are looking for

  • Importing to AE files - goes to wrong folder

    I looked in the AE FAQ, didn't see the answer to my question, so here goes. I am using AE with editing video, meaning I only use AE for some basic things. This is one of those times where my lack of knowledge is driving me mad. When I went to import

  • File manager - search app

    Can anyone recommend a file manager for the Playbook that I can buy? Also is there an app for searching within files on the PB, not just the file names (ie searchable PDFs, Word files etc) like Windows search and X1? Thanks

  • Cannot initialize Photoshop because preferences file was deleted

    Hi. I recently had problems with startup disk being full and had to empty Cache. Now, when I go to open up Photoshop CS5 for the first time after rebooting, I get this error message: Cannot initialize Photoshop because preferences file not found, it

  • ORA-06510 Message error in Process Modeller Designer

    HI� I'M DAVE I HAVE SOME PROBLEMS USING DESIGNER 6i. I log on to Windows Designer tools then I open Process Modeller Tool and I try to modify the previuous model process but, when I add a new process in the previous PM1 SATISFY CUSTOMER ORDER diagram

  • Transpose Of The Internal Table

    I have The Data In ITAB (Internal Table ) I want To Transpose the Row To Column. Pls Any one Help me Thanks , Vijayakanth.K Moderator Message: Very generic question. Similar questions have been discussed in the forums. Try to implement the solutions