SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Demo: Editable ALV



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Tue Nov 06, 2007 11:57 am    Post subject: Demo: Editable ALV Reply with quote

Switch on and off the ready-for-input status of the entire grid
Code:
PROGRAM Z_BCALV_EDIT_01.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Purpose:
* ~~~~~~~~
* This report illustrates the simplest case of using an
* editable ALV Grid Control.
* Background:
* ~~~~~~~~~~~
* As far as the edit feature is concerned
* a cell of the alv grid control can have the following states:
*    1.non-editable : edit feature not set for this cell
*    2.editable     : edit feature set for this cell
* The second state ("editable") has two substates:
*    2a.editable deactivated : edit feature set but not active
*    3b.editable activated   : edit feature set and active
* In this example, all cells are set "editable".
* You switch between "editable deactivated" and "editable activated"
* using method SET_READY_FOR_INPUT.
*-----------------------------------------------------------------
* To check program behavior
* ~~~~~~~~~~~~~~~~~~~~~~~~~
* Switch the state using the "Display/Change" icon. Initially,
* the whole grid is in state "editable and deactivated".
* After switching the state you may change values and enter new
* lines. No semantic checks are made in this example.
*-----------------------------------------------------------------
* Essential steps (search for 'Ї')
* ~~~~~~~~~~~~~~~
* 1.Set status of all cells to editable using the layout structure.
* 2.Use SET_READY_FOR_INPUT to deactivate the edit feature initially.
*   (state "editable deactivated").
* 3.Use IS_READY_FOR_INPUT to fetch current substate of editable cells.
* 4.Use SET_READY_FOR_INPUT to switch between the substates.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


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,
      gs_layout TYPE lvc_s_layo,
      gt_fieldcat TYPE lvc_t_fcat,
      g_max type i value 100.

DATA: gt_outtab type table of bkpf.

*---------------------------------------------------------------------*
*       MAIN                                                          *
*---------------------------------------------------------------------*
CALL SCREEN 100.

*---------------------------------------------------------------------*
*       MODULE PBO OUTPUT                                             *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
  SET PF-STATUS 'MAIN100'.
  set TITLEBAR 'MAIN100'.
  IF g_custom_container IS INITIAL.
    CREATE OBJECT g_custom_container
           EXPORTING container_name = g_container.
    CREATE OBJECT g_grid
           EXPORTING i_parent = g_custom_container.
*Ї1.Set status of all cells to editable using the layout structure.
    gs_layout-edit = 'X'.

* Build fieldcat and set columns PLANETYPE and SEATSOCC
* edit enabled.
   PERFORM build_fieldcat CHANGING gt_fieldcat.


    select * from bkpf into table gt_outtab up to g_max rows.


    CALL METHOD g_grid->set_table_for_first_display
         EXPORTING i_structure_name = 'BKPF'
                   is_layout        = gs_layout
         CHANGING  it_fieldcatalog  = gt_fieldcat
                   it_outtab        = gt_outtab.
*Ї2.Use SET_READY_FOR_INPUT to deactivate the edit feature initially.
*   (state "editable deactivated").
    CALL METHOD g_grid->set_ready_for_input
          EXPORTING i_ready_for_input = 0.

  ENDIF.
ENDMODULE.
*---------------------------------------------------------------------*
*       MODULE PAI INPUT                                              *
*---------------------------------------------------------------------*
MODULE pai INPUT.
  save_ok = ok_code.
  clear ok_code.
  CASE save_ok.
    WHEN 'EXIT'.
      PERFORM exit_program.
    WHEN 'SWITCH'.
      PERFORM switch_edit_mode.
    WHEN OTHERS.
*     do nothing
  ENDCASE.
ENDMODULE.
*---------------------------------------------------------------------*
*       FORM EXIT_PROGRAM                                             *
*---------------------------------------------------------------------*
FORM exit_program.
  LEAVE PROGRAM.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  SWITCH_EDIT_MODE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <p2>is_ready_for_input( ) EQ 0.
*Ї4.Use SET_READY_FOR_INPUT to switch between the substates.
    CALL METHOD g_grid->set_ready_for_input
                     EXPORTING i_ready_for_input = 1.
  ELSE.
    CALL METHOD g_grid->set_ready_for_input
                     EXPORTING i_ready_for_input = 0.
  ENDIF.
ENDFORM.                               " SWITCH_EDIT_MODE

*&---------------------------------------------------------------------*
*&      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 = 'BKPF'
       CHANGING
            ct_fieldcat      = pt_fieldcat.

  LOOP AT pt_fieldcat INTO ls_fcat.
    IF    ls_fcat-fieldname EQ 'XBLNR'
       OR ls_fcat-fieldname EQ 'KURSF'.

*Ї1.Set status of columns PLANETYPE and SEATSOCC to editable.
      ls_fcat-edit = 'X'.

* 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.


****************************************************************
* This file was generated by Direct Download Enterprise. *
* Please do not change it manually. *
****************************************************************
%_DYNPRO
Z_VGA_BCALV_EDIT_01
0100
46C
40
%_HEADER
Z_VGA_BCALV_EDIT_01 0100 0100 33121192 35 0 0 40122 0G D 20071106085737
%_DESCRIPTION
Initial Screen
%_FIELDS
%#AUTOTEXT001 0 CHAR 68 00 00 00 30 00 1 2 0 0 0 68 0 0 Switch the ready-for-input status of the entire grid on and off
BCALV_GRID_DEMO_0100_CONT1 121 00 30 00 30 00 2 2 0 0 0 32 U 1 1 101
OK_CODE CHAR 20 80 10 00 00 00 255 1 O 0 0 0 0 0 0 ____________________
%_FLOWLOGIC
PROCESS BEFORE OUTPUT.
MODULE PBO.
*
PROCESS AFTER INPUT.
MODULE PAI.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.