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

Display/Change mode of Editable fields in 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 Jan 15, 2008 2:10 pm    Post subject: Display/Change mode of Editable fields in ALV Reply with quote

Display/Change mode of Editable fields in ALV using Function Modules but not Custom Containers
Chandrasekhar jagarlamudi

When we have an editable field in ALV , we get stuck when we use ALV GRID Function Module regarding how to make an editable field in display mode
To overcome that we go for Custom containers.
Here is a simple solution for that.
The below program will make the first 5 fields disabled and the next 7 enabled.

Code:
REPORT zalv_display_change.

TABLES :t247.

TYPE-POOLS slis. "Type definitions for alv report

DATA: it_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.

DATA: wa_layout TYPE lvc_s_layo.

DATA : BEGIN OF it_final OCCURS 0,
check(1),
celltab TYPE lvc_t_styl, " Switch between display/change
mnr LIKE t247-mnr,
ltx LIKE t247-ltx,
END OF it_final.
DATA : wa_final LIKE it_final.
DATA : w_repid LIKE sy-repid.

w_repid = sy-repid.

REFRESH it_final.
SELECT mnr ltx
FROM t247
INTO CORRESPONDING FIELDS OF TABLE it_final
WHERE spras EQ 'E'.


wa_fieldcat-fieldname = 'CHECK'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-edit = 'X'..
wa_fieldcat-outputlen = '3'.
wa_fieldcat-col_pos = '1'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MNR'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-outputlen = '8'.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-reptext = 'Month'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'LTX'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-outputlen = '20'.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-reptext = 'Month Desc'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

DATA: wa_celltab TYPE lvc_s_styl,
it_celltab TYPE lvc_t_styl,
l_index TYPE i.
CLEAR : wa_celltab,wa_final,it_celltab.
REFRESH it_celltab.

*Initialize the celltab table
LOOP AT it_final INTO wa_final.
  l_index = sy-tabix.
  wa_celltab-fieldname = 'CHECK'.
  wa_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
  INSERT wa_celltab INTO TABLE it_celltab.
  INSERT LINES OF it_celltab INTO TABLE wa_final-celltab.
  MODIFY it_final FROM wa_final INDEX l_index.
ENDLOOP.

*Make the first five 5 rows as disabled
CLEAR l_index.
LOOP AT it_final INTO wa_final.
  l_index = sy-tabix.
  IF sy-tabix LE 5.
    LOOP AT wa_final-celltab INTO wa_celltab.
      IF wa_celltab-fieldname EQ 'CHECK' .
        wa_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
        MODIFY wa_final-celltab FROM wa_celltab.
        MODIFY it_final INDEX l_index FROM wa_final TRANSPORTING celltab.
      ENDIF.
    ENDLOOP.
  ENDIF.
ENDLOOP.


wa_layout-box_fname = 'CHECK'.
wa_layout-no_rowmark = 'X'.
wa_layout-stylefname = 'CELLTAB'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  EXPORTING
    i_callback_program = w_repid
    i_grid_title       = 'GRID DISPLAY'
    is_layout_lvc      = wa_layout
    it_fieldcat_lvc    = it_fieldcat
  TABLES
    t_outtab           = it_final
  EXCEPTIONS
    program_error      = 1
    OTHERS             = 2.
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.