Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV Report

Former Member
0 Likes
1,757

Hi Gurus,

In my report I want to fix some columns fixed when we scroll the horizontal scroll bar. How can I set the columns as fixed when the scroll bar is moved? I have used the fieldcatalog of type LVC_T_FCAT.

Points will be awarded

Regards

SC

1 ACCEPTED SOLUTION
Read only

Former Member
1,641

LVC_T_FCAT-KEY = 'X'. is effecitvely the PK of your table, so as long as these columns are the first columns of your ALV grid then they will remain fixed when scrolling.

For example:

ebeln => LVC_T_FCAT-KEY = 'X'.

ebelp => LVC_T_FCAT-KEY = 'X'.

matnr => LVC_T_FCAT-KEY = ' ' .

etc

Hi Gurus,

In my report I want to fix some columns fixed when we scroll the horizontal scroll bar. How can I set the columns as fixed when the scroll bar is moved? I have used the fieldcatalog of type LVC_T_FCAT.

Points will be awarded

Regards

SC

12 REPLIES 12
Read only

Former Member
0 Likes
1,641

FOr those fields Make

<b>LVC_T_FCAT-KEY = 'X'.</b>

VAsanth

Read only

0 Likes
1,641

Hi Vasanth,

I checked with that option. But its not working.

Regards

SC

Read only

0 Likes
1,641

Hi..

Normally ALV report will display the Key fields as the Fixed columns.

For any other colums we can set the field catalog property

Fix_column = 'X'.

Regards.

Read only

Former Member
0 Likes
1,641

Hi

Try to set the flag FIX_COLUMN of catalog table

Max

Read only

Former Member
0 Likes
1,641

Which type of ALV are you using? cl_gui_alv_grid or cl_salv_table?

Read only

0 Likes
1,641

Hi Nithya,

Am using class cl_gui_alv_grid

Read only

Former Member
0 Likes
1,641

Hi,

at the fieldcatalog add this line for the columns U want to fix,

LVC_T_FCAT-KEY = C_X. "Fixes the column for no-scroll

Award Points if this is helpful.

Regards,

Kiran

Read only

Former Member
1,642

LVC_T_FCAT-KEY = 'X'. is effecitvely the PK of your table, so as long as these columns are the first columns of your ALV grid then they will remain fixed when scrolling.

For example:

ebeln => LVC_T_FCAT-KEY = 'X'.

ebelp => LVC_T_FCAT-KEY = 'X'.

matnr => LVC_T_FCAT-KEY = ' ' .

etc

Read only

varma_narayana
Active Contributor
0 Likes
1,641

Hi..

Normally ALV report will display the Key fields as the Fixed columns.

For any other colums we can set the field catalog property

Fix_column = 'X'.

Regards.

Read only

0 Likes
1,641

Hi Gurus,

I tried all this options. Its not working.

Thanks

Read only

Former Member
0 Likes
1,641

please see this program for scrolling the Horizontal bar and its revavent things


report zavl.
data: ok_code like sy-ucomm,
      save_ok like sy-ucomm,
      g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',
      g_grid  type ref to cl_gui_alv_grid,
      g_custom_container type ref to cl_gui_custom_container,
      gt_fieldcat type lvc_t_fcat,
      gs_layout type lvc_s_layo,
      g_max type i value 100.

data: gt_outtab type table of sbook.


*---------------------------------------------------------------------*
*       MAIN                                                          *
*---------------------------------------------------------------------*
end-of-selection.
  call screen 100.

*---------------------------------------------------------------------*
*       MODULE PBO OUTPUT                                             *
*---------------------------------------------------------------------*
module pbo output.
  set pf-status 'MAIN100'.
  set titlebar 'MAIN100'.
  if g_custom_container is initial.
    perform create_and_init_alv changing gt_outtab
                                         gt_fieldcat.
  endif.

endmodule.
*---------------------------------------------------------------------*
*       MODULE PAI INPUT                                              *
*---------------------------------------------------------------------*
module pai input.
  save_ok = ok_code.
  clear ok_code.
  case save_ok.
    when 'EXIT'.
      perform exit_program.
    when others.
*     do nothing
  endcase.
endmodule.
*---------------------------------------------------------------------*
*       FORM EXIT_PROGRAM                                             *
*---------------------------------------------------------------------*
form exit_program.
  leave program.
endform.
*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_GT_FIELDCAT  text
*----------------------------------------------------------------------*
form build_fieldcat changing pt_fieldcat type lvc_t_fcat.

  data ls_fcat type lvc_s_fcat.

  call function 'LVC_FIELDCATALOG_MERGE'
       exporting
            i_structure_name = 'SBOOK'
       changing
            ct_fieldcat      = pt_fieldcat.

  loop at pt_fieldcat into ls_fcat.
    if    ls_fcat-fieldname eq 'WUNIT'.

*§2.Set status of column WUNIT to editable and set a dropdown handle.
      ls_fcat-edit = 'X'.
      ls_fcat-drdn_hndl = '1'.
      ls_fcat-outputlen = 7.

* Field 'checktable' is set to avoid shortdumps that are caused
* by inconsistend data in check tables. You may comment this out
* when the test data of the flight model is consistent in your system.
      ls_fcat-checktable = '!'.        "do not check foreign keys

      modify pt_fieldcat from ls_fcat.
    endif.
  endloop.

endform.
*&---------------------------------------------------------------------*
*&      Form  CREATE_AND_INIT_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_GT_OUTTAB  text
*      <--P_GT_FIELDCAT  text
*      <--P_GS_LAYOUT  text
*----------------------------------------------------------------------*
form create_and_init_alv changing pt_outtab like gt_outtab[]
                                  pt_fieldcat type lvc_t_fcat.

  data: lt_exclude type ui_functions,
        lt_f4 type lvc_t_f4 with header line.

  create object g_custom_container
         exporting container_name = g_container.
  create object g_grid
         exporting i_parent = g_custom_container.

* Build fieldcat and set column WUNIT
* edit enabled. Assign a handle for the dropdown listbox.
  perform build_fieldcat changing pt_fieldcat.

* Optionally restrict generic functions to 'change only'.
*   (The user shall not be able to add new lines).
  perform exclude_tb_functions changing lt_exclude.

* Define a drop down table.
  perform set_drdn_table.

  select * from sbook into table pt_outtab up to g_max rows.  "#EC CI_NOWHERE
  if sy-subrc ne 0.
* generate own entries if database table is empty
    perform generate_entries changing pt_outtab.
  endif.

  call method g_grid->set_table_for_first_display
       exporting it_toolbar_excluding  = lt_exclude
       changing  it_fieldcatalog       = pt_fieldcat
                 it_outtab             = pt_outtab.

* Set editable cells to ready for input initially
  CALL METHOD g_grid->set_ready_for_input
   EXPORTING
    I_READY_FOR_INPUT = 1.

  clear lt_f4.
  lt_f4-fieldname = 'WUNIT'.
  lt_f4-register = 'X'.
  append lt_f4.

endform.                               "CREATE_AND_INIT_ALV

*&---------------------------------------------------------------------*
*&      Form  EXCLUDE_TB_FUNCTIONS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_LT_EXCLUDE  text
*----------------------------------------------------------------------*
form exclude_tb_functions changing pt_exclude type ui_functions.
* Only allow to change data not to create new entries (exclude
* generic functions).

  data ls_exclude type ui_func.

  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
  append ls_exclude to pt_exclude.


endform.                               " EXCLUDE_TB_FUNCTIONS
*&---------------------------------------------------------------------*
*&      Form  set_drdn_table
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form set_drdn_table.
*§1.Define a dropdown table and pass it to ALV.
*   One listbox is referenced by a handle, e.g., '1'.
*   For each entry that shall appear in this listbox
*   you have to append a line to the dropdown table
*   with handle '1'.
*   This handle can be assigned to several columns
*   of the output table using the field catalog.
*
  data: lt_dropdown type lvc_t_drop,
        ls_dropdown type lvc_s_drop.

* First listbox (handle '1').
  ls_dropdown-handle = '1'.
  ls_dropdown-value = 'KG'.
  append ls_dropdown to lt_dropdown.

  ls_dropdown-handle = '1'.
  ls_dropdown-value = 'G'.
  append ls_dropdown to lt_dropdown.

  call method g_grid->set_drop_down_table
            exporting it_drop_down = lt_dropdown.

endform.                               " set_drdn_table
*&---------------------------------------------------------------------*
*&      Form  generate_entries
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_LT_SLFIGHT  text
*----------------------------------------------------------------------*
form generate_entries changing pt_sbook type standard table.
*
* This form is only needed if database table sbook is empty.
* It generates some entries so that you may
* still try out this example program.
*
  data: ls_sbook type sbook,
        l_month(2) type c,
        l_day(2) type c,
        l_date(8) type c,
	l_prebookid type i.


  ls_sbook-carrid = 'LH'.
  ls_sbook-connid = '0400'.
  ls_sbook-forcurkey = 'DEM'.
  ls_sbook-loccurkey = 'USD'.
  ls_sbook-custtype = 'B'.

  do 110 times.
    l_prebookid = sy-index.

    ls_sbook-forcuram = sy-index * 10.
    ls_sbook-loccuram = ls_sbook-loccuram * 2.
    ls_sbook-customid = sy-index.
    ls_sbook-counter = 18.
    ls_sbook-agencynum = 11.

    l_month = sy-index / 10 + 1.
    do 2 times.
      l_day = 3 + l_month + sy-index * 2.
      l_date+0(4) = '2000'.
      l_date+4(2) = l_month.
      l_date+6(2) = l_day.
      ls_sbook-fldate = l_date.
      subtract 3 from l_day.
      ls_sbook-order_date+0(6) = l_date+0(6).
      ls_sbook-order_date+6(2) = l_day.
      ls_sbook-bookid = l_prebookid * 2 + sy-index.
      if sy-index eq 1.
        ls_sbook-smoker = 'X'.
      else.
        ls_sbook-smoker = space.
      endif.

      ls_sbook-luggweight = l_prebookid * 10.
      if ls_sbook-luggweight ge 1000.
        ls_sbook-wunit = 'G'.
        ls_sbook-class = 'C'.
      else.
        ls_sbook-wunit = 'KG'.
        ls_sbook-class = 'Y'.
      endif.

      if ls_sbook-bookid > 40 and ls_sbook-wunit eq 'KG'.
        ls_sbook-invoice = 'X'.
      endif.
      if ls_sbook-bookid eq 2.
        ls_sbook-cancelled = 'X'.
        ls_sbook-class = 'F'.
      endif.

      append ls_sbook to pt_sbook.
    enddo.
  enddo.
endform.                               " generate_entries

reward points if it is usefull ...

Girish

Read only

0 Likes
1,641

I found out what is causing the problem, but has not yet found a solution.

When calling the method below for any reason the fieldcat "KEY" option doesn't work:

* Set editable cells to ready for input initially

  CALL METHOD g_grid->set_ready_for_input

   EXPORTING

    I_READY_FOR_INPUT = 1.

Take a test, comment this call.