Need help in ALV grid editable cells

Hi,
I have created a ALV Grid program in which i made certain cells as editable cells.Now my question is if suppose i have 2 rows in my output then if i change the 2nd rows some cells, then some calculation has to perform till this it is fine but nw i want to modify the 3rd rows some cells as per the changes in 2nd row.
How to do it with ALV oops concepts.
I have refered BCALV_EDIT_02 and BCALV_EDIT_03 these std programs.
Thanks & Regards
Madhuri

Hello Madhuri
I recommend to do any post-processing of the changed data OUTSIDE your event handler method (HANDLE_DATA_CHANGED).
Within the event handler method do all required validations and the trigger PAI by calling method CL_GUI_CFW=>SET_NEW_OK_CODE (for an example refer to my sample report ZUS_SDN_TWO_ALV_GRIDS in alv)
Now at PAI of your screen you can do any kind of post-processing, calculation, etc. within the itab used for the ALV list.
Regards
  Uwe

Similar Messages

  • ALV Grid editing cell cursor position

    Hello !
    i hope i can get the answer to my question here.
    i have an alv-grid with editable cells
    when i click in one cell (it is a textfield) where there is no more written text it marks the hole cell and when i start to write, it overwrites the whole text.
    i would like the cursor to be placed at the end of the field in this case.
    when i click in the cell where there is written text it is ok - it puts the cursor to the clicked position.
    thanks very much for your help
    Helmut

    Hi, i am also facing same probelm.
    after  call method sender->refresh_table_display.
    i am using
    call method sender->set_current_cell_via_id
          exporting
            is_row_id    = l_rowid
            is_column_id = l_colid.
    this will simply select the cell. i am not able to see curser in end or front of the cell.Can anybody please suggest me how to it.
    Thanks
    Sudhakar

  • Need help with ALV Grid

    Hi,
    I am displaying Header and Item details in an ALV Grid. The first row will be having Header info and the next rows contains Item Details. I want to hide some of the columns of the first record only. The titles and the Item Details should remain same.
    Can any body help me.
    Regards,
    Srinivas

    Hello,
    That cannot be done as you are displaying the header and item level data together. Let the fields you do not want to display be blank while you display.
    Hope it helps.
    Thanks,
    Jayant

  • Need help in alv grid output

    Hi ihave a problem in alv grid i want display the longtext which was very long in characters it contains of more than 20 lines as shown below now i want the output the material number and shorttext description only one time but not as many times as there are lines in the long text that is i want to delete the remaining short text and material number for a single material number.
    I'm posting here my ALv grid code also pla consider it and give me solution
    FORM field_catalog.
    ***MATERIAL NO no
      int_cat-tabname       = 'INT_OUT'.
      int_cat-fieldname     = 'MATNR'.
      int_cat-reptext_ddic  = 'MATERIAL NO'.
      APPEND int_cat .
    *vender name
      int_cat-tabname       = 'INT_OUT'.
      int_cat-fieldname     = 'MAKTX'.
      int_cat-reptext_ddic  = 'MATERIAL SHORT DESCRIPTION'.
      APPEND int_cat .
    ** PO No
      int_cat-tabname       = 'INT_OUT'.
      int_cat-fieldname     = 'TDLINE'.
      int_cat-reptext_ddic  = 'MATERIAL LONG DESCRIPTION'.
      int_cat-outputlen = '100'.
      APPEND int_cat .
    endform.
    *&      Form  display_data
    *       text
    FORM display_data.
    DATA : X_SORT TYPE SLIS_SORTINFO_ALV.
    DATA: IT_SORT TYPE SLIS_T_SORTINFO_ALV.
    X_SORT-SPOS = '1'.
    X_SORT-FIELDNAME = 'MATNR'.
    X_SORT-TABNAME = 'INT_OUT'.
    X_SORT-UP = 'X'.
    APPEND X_SORT TO IT_SORT.
    CLEAR X_SORT.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = sy-repid
          it_fieldcat        = int_cat[]
    *      I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
    *      I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    **      IS_LAYOUT = X_LAYOUT
    **      IT_FIELDCAT = IT_FIELDCAT
    **      IT_EVENTS = IT_EVENT
    *      IT_SORT = INT_OUT
        TABLES
          t_outtab           = int_out
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
    ENDFORM.                    "display_data
    <b>
    1000100000 Test material 1 1. DataSet vs DataReader
    1000100000 Test material 1 # DataReader
    1000100000 Test material 1 # Object to access data in a connected, forward-only, read-only
    1000100000 Test material 1 fashion
    1000100000 Test material 1
    1000100000 Test material 1 # DataSet
    1000100000 Test material 1 # Data structure to store schema and data in a disconnected fashion
    1000100000 Test material 1 # Useful for editing data offline and later update to data source
    1000100000 Test material 1
    1000100000 Test material 1 2. What is Microsoft .NET?
    1000100000 Test material 1 .NET represents an advanced new generation of software that will
    1000100000 Test material 1 drive the Next Generation Internet. Its purpose is to make information
    1000100000 Test material 1 available any time, any place, and on any device.
    1000100000 Test material 1 Quick Definition
    1000100000 Test material 1 .NET is an initiative to integrate all Microsoft products with
    1000100000 Test material 1 the #Next Generation# web.
    1000100000 Test material 1
    1000100000 Test material 1 3. Recordset
    1000100000 Test material 1
    1000100000 Test material 1 ? Recordsets are generated one per table. This does not support
    1000100000 Test material 1 hierarchical structure of data access. It will be programmer#s
    1000100000 Test material 1 responsibility to define relationships among different recordsets.
    1000100000 Test material 1 ? Rercordsets can not support data accessing from multiple sources.
    1000100000 Test material 1
    1000100000 Test material 1
    1000100000 Test material 1 4. Connection-oriented Vs Connection-less
    1000100000 Test material 1 ? Connection-oriented
    1000100000 Test material 1 # Keeps the connection to the data base alive
    1000100000 Test material 1 # Intended for applications with:
    1000100000 Test material 1 ? short running transactions
    1000100000 Test material 1 ? only a few parallel accesses
    1000100000 Test material 1 ? up-to-date data
    1000100000 Test material 1
    1000100000 Test material 1 ? Connectionless</b>

    hi shiaba
    i have allredy done like this but same out put is coming as per earlier.
    i want to delete material No and short description  only in one line not all line
    if long description is 50 line
    out ut is coming like this
    MATERIAL NO MATERIAL SHORT DESCRIPTION MATERIAL LONG DESCRIPTION
    1000100000  Test material 1            1.   DataSet vs DataReader
    1000100000  Test material 1            # DataReader
    1000100000  Test material 1            # Object to access data in a connected, forward-only, read-only
    1000100000  Test material 1            fashion
    1000100000  Test material 1
    1000100000  Test material 1            # DataSet
    1000100000  Test material 1            # Data structure to store schema and data in a disconnected fash
    1000100000  Test material 1            # Useful for editing data offline and later update to data sourc
    1000100000  Test material 1
    1000100000  Test material 1            2. What is Microsoft .NET?
    1000100000  Test material 1              .NET represents an advanced new generation of software that wi
    1000100000  Test material 1            drive the Next Generation Internet.  Its purpose is to make info
    1000100000  Test material 1            available any time, any place, and on any device.
    1000100000  Test material 1              Quick Definition
    1000100000  Test material 1              .NET is an initiative to integrate all Microsoft products with
    1000100000  Test material 1            the #Next Generation# web.
    but i want like below
    MATERIAL NO     MATERIAL SHORT DESCRIPTION     MATERIAL LONG DESCRIPTION
    1000100000     Test material 1     1.   DataSet vs DataReader
    DataReader
    Object to access data in a connected, forward-only, read-          fashion
    DataSet
    Data structure to store schema and data in a        
              2. What is Microsoft .NET?
              .NET represents an advanced new generation of software           drive the Next Generation Internet.  Its purpose is to make           available any time, any place, and on any device.
              Quick Definition
              .NET is an initiative to integrate all Microsoft products with
              the #Next Generation# web.
    thanks .

  • Need help on ALV Grid Control

    Hi,
    I have written a program to display the details of customer in ALV Grid. I have also added code to add a hyperlink to the field name - KTOKD of the table KNA1. It would be helpful if anyone could tell me what is wrong with the code. The list is correctly displayed but the hyperlink is not working.
    tables kna1.
    data: BEGIN OF itkna1 OCCURS 0,
             ktokd like kna1-ktokd,
             kunnr like kna1-kunnr,
             name1 like kna1-name1,
             name2 like kna1-name2,
             ktokd_hdl type int4,
          end of itkna1.
    *creating an instance of grid
    data it_custom_control_name type scrfname value 'C_C_ALV'.
    data it_container type ref to cl_gui_custom_container.
    data it_alvgrid type ref to cl_gui_alv_grid.
    data it_lyo type lvc_s_layo.
    data it_fcat type lvc_t_fcat.
    data tmp_fcat like LINE OF it_fcat.
    data it_hype type lvc_t_hype.
    data tmp_hype type lvc_s_hype.
    Selection-screen begin of block Enter_data with frame title text-001.
      PARAMETERS pktokd like KNA1-ktokd OBLIGATORY.
      SELECT-OPTIONS skunnr FOR KNA1-kunnr.
    Selection-screen end of block Enter_data.
    SELECT ktokd kunnr name1 name2
      FROM kna1 into CORRESPONDING FIELDS OF TABLE itkna1
           WHERE ktokd = pktokd AND kunnr IN skunnr.
    *prepare field catalog
    clear: it_fcat, tmp_fcat.
    tmp_fcat-fieldname = 'KTOKD'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'KTOKD'.
    tmp_fcat-col_pos = '1'.
    tmp_fcat-web_field = 'ktokd_hdl'.
    append tmp_fcat to it_fcat.
    tmp_fcat-fieldname = 'KUNNR'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'KUNNR'.
    tmp_fcat-col_pos = '2'.
    append tmp_fcat to it_fcat.
    tmp_fcat-fieldname = 'NAME1'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'NAME1'.
    tmp_fcat-col_pos = '3'.
    append tmp_fcat to it_fcat.
    tmp_fcat-fieldname = 'NAME2'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'NAME2'.
    tmp_fcat-col_pos = '4'.
    append tmp_fcat to it_fcat.
    data: c_lines type I, count type I.
    DESCRIBE table itkna1 LINES c_lines.
    loop at itkna1.
      count = count + 1.
      tmp_hype-handle = count.
      tmp_hype-href = itkna1-ktokd.
      APPEND tmp_hype to it_hype.
      itkna1-ktokd_hdl = count.
      MODIFY itkna1.
    ENDLOOP.
    *prepare layout
    it_lyo-grid_title = 'Custormer details'.
    call screen 200.
    module status_0200 OUTPUT.
    *creating an instance of container class
    CREATE OBJECT it_container
        EXPORTING container_name = it_custom_control_name.
    *creating an instance of the grid
    create OBJECT it_alvgrid
        EXPORTING i_parent = it_container.
    *displaying the grid
    call METHOD it_alvgrid->set_table_for_first_display
       EXPORTING
         is_layout = it_lyo
         it_hyperlink = it_hype
       CHANGING
         it_outtab = itkna1[]
         it_fieldcatalog = it_fcat
       EXCEPTIONS
         invalid_parameter_combination = 1
         others = 2.
    ENDMODULE.

    Try this..
    give the field name in CAPITAL LETTERS..
    *prepare field catalog
    clear: it_fcat, tmp_fcat.
    tmp_fcat-fieldname = 'KTOKD'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'KTOKD'.
    tmp_fcat-col_pos = '1'.
    tmp_fcat-web_field =<b> 'KTOKD_HDL'.</b>
    REGARDS,
    SAI RAMESH

  • Hi regarding how to put f4 help for alv grid editable

    Hi,
    Please guide me with sample program how to pass f4 value for particular selected field . In case i haved kunnr  ,sales org , channel , division  and i select kunnr for selected kunnr i need to exaactact the data for kunnr in kna1 table and place that value in f4 editable field .
    Regarding
    anil

    Hi
    Please check program BCALV_GRID_EDIT_DELTA
    Thanks
    Vishal Kapoor

  • Multiple Input Rows In ALV Grid (Editable)

    Hi,
    I have an editable ALV grid and need to have multiple blank rows ready for input. Something similar to what happens when you click the "New Entries" button in SM30 (Table Maintainance).
    There is a local function for appending lines in the ALV grid toolbar but this only allows a single entry.
    I have replaced the local function with my own button (same icon etc) and on user_command event, I am appending several blank lines to my output table.
    However these lines are not being shown on the screen. I have looked through the layout and field catalog but there is no field to allow blank lines to be shown.
    My 2 questions are:
    1. Is there some standard way of entering multiple entries in ALV Grid Editable.
    2. If not then how to allow blank lines to be shown as ready for input.
    Also if someone could suggest a way to do error checking for all entries on the screen especially duplicate entries I will be extremely grateful.
    Many Thanks,
    Preet

    Hi, Preet!
    You can easily do whatever checks you wish. You should declare an event handling method for event DATA_CHANGED and call the ADD_PROTOCOL_ENTRY method of the ER_DATA_CHANGED event parameter (it's an object of the class CL_ALV_CHANGED_DATA_PROTOCOL). You must not forget to set handler for your ALV grid.
    For example, this piece of code checks for all changed fields resulting in error message if they are initial. In short, this makes all the fields obligatory.
    METHODS: on_data_changed FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING er_data_changed.
    SET HANDLER your_object->on_data_changed FOR your_alv_grid.
    METHOD on_data_changed.
    DATA: s_mod_cell TYPE lvc_s_modi.
    LOOP AT er_data_changed->mt_mod_cells INTO s_mod_cell.
        IF s_mod_cell-value IS INITIAL.
    *       issue message 'Make an entry in all required fields'
            CALL METHOD er_data_changed->add_protocol_entry
              EXPORTING i_msgid     = '00'
                        i_msgno     = '055'
                        i_msgty     = 'E'
                        i_fieldname = s_mod_cell-fieldname
                        i_row_id    = s_mod_cell-row_id.
        ENDIF.
    ENDMETHOD.
    Furthermore, if you make your class inherited from CL_GUI_ALV_GRID you can make use of protected attribute MT_OUTTAB which is a data object referencing your output table. Then you can have:
    FIELD-SYMBOLS: <outtab> TYPE STANDARD TABLE.
    ASSIGN me->mt_outtab->* TO <outtab>.
    * do whatever you want with <outtab>
    Hope this helps.
    Kind regards,
    Igor
    P.S. Regarding the blank lines that you need, what's wrong with standard ALV grid buttons "Append row" and "Insert row" which appear whenever the grid is editable (unless you deliberately remove them)? They work just fine with me (just like on SM30). I don't see reason for programatically appending lines to your internal table.

  • F4 Help in ALV GRID class based

    hi
    you have any idea about how to invoke the F4 help in ALV GRID Class based program.,
    if u have any other related document or program using F4 function in ALV GRId please send to me for reference
    Thanks & Regards
    K.G

    hi for what kind of fields you need to give f4.
    are they std or custom...
    please let me know about the fields..
    try to check my logic which i gave in the below post..
    it will give f4 help to the fields(if thet are standard table fieldS)
    Message was edited by: Vijay Babu Dudla

  • F4 help in ALV grid by using function module?

    Hi,
    I need to get f4 search help in ALV grid for a certain fields by using function module method.
    Please guide me.
    Thank You.

    Hi
    F4IF_INT_TABLE_VALUE_REQUEST  use this fm to get f4 search help for a certain fields .
    Regards
    Divya

  • How to get f4 help in alv grid in container-urgent

    hi,
    how to get f4 help in alv grid in container using abap objects
    ganesh

    Hi Ganesh,
    Did you have a look at sample report BCALV_TEST_GRID_F4_HELP ?
    Here is part of the header documentation:
    *& Report  BCALV_GRID_F4_HELP                                          *
    Purpose:
    ~~~~~~~~
    This report illustrates the use of f4-Help in an alv grid control.
    Background:
    ~~~~~~~~~~~
    There a two possibilities to implement an f4-Help in the alv grid
    control: one can either use standard f4-help or write one by Hand.
    For the former there is nothing to do at all. This report shows how
    to implement user-defined f4-help.
    I am sure you will find within this report the solution you are looking for.
    Reward points if this Helps.
    Manish

  • F4 help in ALV grid using existing search help

    Hi All,
    It would be appreciable , if some help on problem. Thanks in advance.
    How to provide user defined F4 help in ALV grid using existing search help?
    ALV grid has developed using OOPS concept.
    Thanks,
    Sudhakar.

    Hi,
    if you already developed using OO concept, it should be possible to:
    create a handler for event ONF4
    The interface will tell you actual field name and value where F4 is pressed. This will enable you to call your own routine (see FM F4-IF....).
    Please check how the standard handles F4  - if you have standard and customer-F4 mixed you shouldtake care that the standard handling is triggered.
    Regards,
    Clemens

  • Search Help In ALV Grid

    What is shortest way to attach particular Search Help in ALV grid using OOPS ?

    Thanks Gurpreet,
    Through search helps attached to data element it is possible but is there any other way to attach searchhelp differet from from the search help attached to the data element ? The new search-elp is not customized search help as given in the above threads ?
    Eg. - If I want to attach MAT2 to a field named MATNR in the table instead of the MAT1 which is standard.
    Thanks in advance

  • Need help or someone to edit .fla file

    Need help or someone to edit .fla file

    The .fla file I want to edit is the flash in header at www.ridinggigistyle.com I want to remove the event button titled Boot Camp. I can send .fla file and request that edited changes be sent back to me. Direct email [email protected]

  • Need to help in alv grid graph

    Hi All,
       I made alv grid report.I put graph button in screen using pf status(&graph).
    Now when I execute the report output come and my graph button is also working fine.But when I click
    the graph button, the graph shows defalut column wise.Now I right click on graph and select chart type and then select LINES wise then graph shows LINES wise. Can we do default LINES wise so that
    when I click on graph button then it should come LINES wise default.
    Thanks,
    Rakesh

    HI,
    You can do this using the FM GFW_PRES_SHOW
    Check the sample program : DEMO_GFW_PRES_SHOW.
    For more infomation:
    refer to links:
    Re: How to plot graph in ALV?
    http://help.sap.com/saphelp_erp2005/helpdata/en/7e/daf830b46411d2961200a0c9308b1f/frameset.htm
    hope this infromation helps you.
    Thanks!

  • Help on ALV grid needed...

    HI, I am a new comer to SAP and I have some material on ALV grid but not enough to write code to display from an internal table to the grid. I have written the code using 2 methods:
    1. set_table_for_first_display and
    2. reuse_alv_grid_display
    The code with reuse_alv_grid_disply works fine but am not able to add more functionality to the code as I dont have any material explaining the methods to be used with it. The code with set_table_for_first_display has some problem in it. The code for it is:
    tables kna1.
    data: BEGIN OF itkna1 OCCURS 0,
             ktokd like kna1-ktokd,
             kunnr like kna1-kunnr,
             name1 like kna1-name1,
             name2 like kna1-name2,
          end of itkna1.
    *creating an instance of grid
    data it_custom_control_name type scrfname value 'CC_ALV'.
    data it_container type ref to cl_gui_custom_container.
    data it_alvgrid type ref to cl_gui_alv_grid.
    data it_lyo type lvc_s_layo.
    Selection-screen begin of block Enter_data with frame title text-001.
      PARAMETERS pktokd like KNA1-ktokd OBLIGATORY.
      SELECT-OPTIONS skunnr FOR KNA1-kunnr.
    Selection-screen end of block Enter_data.
    SELECT ktokd kunnr name1 name2
      FROM kna1 into CORRESPONDING FIELDS OF TABLE itkna1
           WHERE ktokd = pktokd AND kunnr IN skunnr.
    *loop at itkna1.
    write:/ itkna1-ktokd, itkna1-kunnr, itkna1-name1, itkna1-name2.
    *ENDLOOP.
    *prepare field catalog
    data it_fcat type lvc_t_fcat.
    data tmp_fcat like LINE OF it_fcat.
    clear: it_fcat, tmp_fcat.
    tmp_fcat-fieldname = 'KTOKD'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'KTOKD'.
    tmp_fcat-col_pos = '1'.
    *tmp_fcat-inttype = 'C'.
    *tmp_fcat-coltext = 'Customer Group'.
    *tmp_fcat-seltext = 'Customer Group'.
    *tmp_fcat-outputlen = '4'.
    append tmp_fcat to it_fcat.
    tmp_fcat-fieldname = 'KUNNR'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'KUNNR'.
    tmp_fcat-col_pos = '2'.
    *tmp_fcat-inttype = 'N'.
    *tmp_fcat-coltext = 'Customer Number'.
    *tmp_fcat-seltext = 'Customer Number'.
    *tmp_fcat-outputlen = '10'.
    append tmp_fcat to it_fcat.
    tmp_fcat-fieldname = 'NAME1'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'NAME1'.
    tmp_fcat-col_pos = '3'.
    *tmp_fcat-inttype = 'C'.
    *tmp_fcat-coltext = 'name'.
    *tmp_fcat-seltext = 'name'.
    *tmp_fcat-outputlen = '12'.
    append tmp_fcat to it_fcat.
    tmp_fcat-fieldname = 'NAME2'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'NAME2'.
    tmp_fcat-col_pos = '4'.
    *tmp_fcat-inttype = 'C'.
    *tmp_fcat-coltext = 'name2'.
    *tmp_fcat-seltext = 'name2'.
    *tmp_fcat-outputlen = '12'.
    append tmp_fcat to it_fcat.
    *prepare layout
    it_lyo-grid_title = 'Custormer details'.
    *creating an instance of container class
    create OBJECT it_container
      EXPORTING
        container_name = it_custom_control_name
      EXCEPTIONS
        cntl_error = 1
        create_error = 2
        OTHERS = 3.
    *creating an instance of the grid
    create OBJECT it_alvgrid
      EXPORTING
        i_parent = it_container
      EXCEPTIONS
        error_dp_create = 1
        OTHERS = 2.
    *displaying the grid
    call METHOD it_alvgrid->set_table_for_first_display
       EXPORTING
         is_layout = it_lyo
         i_structure_name = 'KNA1'
       CHANGING
         it_outtab = itkna1[]
         it_fieldcatalog = it_fcat
       EXCEPTIONS
         invalid_parameter_combination = 1
         others = 2.
    It would be really helpful if some one could tell me what is wrong with this code and tell me where to get the material for extending code using type-pools-slis.
    Thanks in advance!!!

    i cant see any call screen in your prog... if you have to display an alv first you have to create a screen and in that screen you have to create a custom control which will contain the grid... pls go thrugh the prog
    here i have changed your code and it is working in my system just try this..
    tables kna1.
    data: BEGIN OF itkna1 OCCURS 0,
    ktokd like kna1-ktokd,
    kunnr like kna1-kunnr,
    name1 like kna1-name1,
    name2 like kna1-name2,
    end of itkna1.
    *creating an instance of grid
    data it_custom_control_name type scrfname value 'CC_ALV'.
    data it_container type ref to cl_gui_custom_container.
    data it_alvgrid type ref to cl_gui_alv_grid.
    data it_lyo type lvc_s_layo.
    DATA : OKCODE LIKE SY-UCOMM.
    Selection-screen begin of block Enter_data with frame title text-001.
    PARAMETERS pktokd like KNA1-ktokd OBLIGATORY.
    SELECT-OPTIONS skunnr FOR KNA1-kunnr.
    Selection-screen end of block Enter_data.
    SELECT ktokd kunnr name1 name2
    FROM kna1 into CORRESPONDING FIELDS OF TABLE itkna1
    WHERE ktokd = pktokd AND kunnr IN skunnr.
    *loop at itkna1.
    * write:/ itkna1-ktokd, itkna1-kunnr, itkna1-name1, itkna1-name2.
    *ENDLOOP.
    *prepare field catalog
    data it_fcat type lvc_t_fcat.
    data tmp_fcat like LINE OF it_fcat.
    clear: it_fcat, tmp_fcat.
    tmp_fcat-fieldname = 'KTOKD'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'KTOKD'.
    tmp_fcat-col_pos = '1'.
    *tmp_fcat-inttype = 'C'.
    *tmp_fcat-coltext = 'Customer Group'.
    *tmp_fcat-seltext = 'Customer Group'.
    *tmp_fcat-outputlen = '4'.
    append tmp_fcat to it_fcat.
    tmp_fcat-fieldname = 'KUNNR'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'KUNNR'.
    tmp_fcat-col_pos = '2'.
    *tmp_fcat-inttype = 'N'.
    *tmp_fcat-coltext = 'Customer Number'.
    *tmp_fcat-seltext = 'Customer Number'.
    *tmp_fcat-outputlen = '10'.
    append tmp_fcat to it_fcat.
    tmp_fcat-fieldname = 'NAME1'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'NAME1'.
    tmp_fcat-col_pos = '3'.
    *tmp_fcat-inttype = 'C'.
    *tmp_fcat-coltext = 'name'.
    *tmp_fcat-seltext = 'name'.
    *tmp_fcat-outputlen = '12'.
    append tmp_fcat to it_fcat.
    tmp_fcat-fieldname = 'NAME2'.
    tmp_fcat-ref_table = 'KNA1'.
    tmp_fcat-ref_field = 'NAME2'.
    tmp_fcat-col_pos = '4'.
    *tmp_fcat-inttype = 'C'.
    *tmp_fcat-coltext = 'name2'.
    *tmp_fcat-seltext = 'name2'.
    *tmp_fcat-outputlen = '12'.
    append tmp_fcat to it_fcat.
    *prepare layout
    it_lyo-grid_title = 'Custormer details'.
    call screen 100.
    *creating an instance of container class
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'ZSPD'.
    *  SET TITLEBAR 'xxx'.
    create OBJECT it_container
    EXPORTING
    container_name = it_custom_control_name
    EXCEPTIONS
    cntl_error = 1
    create_error = 2
    OTHERS = 3.
    *creating an instance of the grid
    create OBJECT it_alvgrid
    EXPORTING
    i_parent = it_container
    EXCEPTIONS
    error_dp_create = 1
    OTHERS = 2.
    *displaying the grid
    call METHOD it_alvgrid->set_table_for_first_display
    EXPORTING
    is_layout = it_lyo
    *i_structure_name = 'KNA1'
    CHANGING
    it_outtab = itkna1[]
    it_fieldcatalog = it_fcat
    EXCEPTIONS
    invalid_parameter_combination = 1
    others = 2.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE USER_COMMAND_0100 INPUT.
    call method cl_gui_cfw=>dispatch.
    CASE OKCODE.
    WHEN 'EXIT' OR 'BACK'.
    LEAVE PROGRAM.
    ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    regards
    shiba dutta

Maybe you are looking for