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

problem with alv grid using methods

Former Member
0 Likes
284

hi all,

i am using method to display the alv grid. but here i am using editable grid only the non key fields are in editable mode and the key fields are in dispay mode. now when i press the toolbar option for append row it append a new row at the bottom but they key fields are still in dispay mode what i need to do is when append row button is pressed the new row all the field should be editable mode even the key fields which will enable user to enter and save it to the database.

1 REPLY 1
Read only

Former Member
0 Likes
256

Hi,

Just go through the below program,i have done a similar kind of thing.

&----


*& Report ZPR_ENABLE *

*& *

&----


*& *

*& *

&----


REPORT ZPR_ENABLE .

TYPE-POOLS:SLIS.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR TYPE MATNR,

ERSDA TYPE ERSDA,

END OF ITAB.

DATA: WA_FCAT TYPE LVC_S_FCAT,

T_FCAT TYPE LVC_T_FCAT.

DATA : LOC TYPE SCRFNAME VALUE 'CUST',

IDT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

GRD TYPE REF TO CL_GUI_ALV_GRID.

data: lt_exclude type ui_functions,

ls_exclude type ui_func.

START-OF-SELECTION.

CALL SCREEN 001.

&----


*& Module USER_COMMAND_0001 INPUT

&----


  • text

----


MODULE USER_COMMAND_0001 INPUT.

CASE SY-UCOMM.

WHEN 'DISP'.

SELECT MATNR ERSDA FROM MARA INTO TABLE ITAB WHERE MATNR < '648'.

Data: TOOL TYPE LVC_S_LAYO.

CLEAR WA_FCAT.

WA_FCAT-COL_POS = '2'.

WA_FCAT-FIELDNAME = 'MATNR'.

WA_FCAT-REF_FIELD = 'MATNR'.

WA_FCAT-REF_TABLE = 'MARA'.

WA_FCAT-EDIT = 'X'.

APPEND WA_FCAT TO T_FCAT.

CLEAR WA_FCAT.

WA_FCAT-COL_POS = '1'.

WA_FCAT-FIELDNAME = 'ERSDA'.

WA_FCAT-REF_FIELD = 'ERSDA'.

WA_FCAT-REF_TABLE = 'MARA'.

APPEND WA_FCAT TO T_FCAT.

CLEAR WA_FCAT.

WA_FCAT-COL_POS = '3'.

WA_FCAT-SELTEXT = 'CHECK'.

*WA_FCAT-REF_TABLE = 'MARA'.

WA_FCAT-EDIT = 'X'.

WA_FCAT-CHECKBOX = 'X'.

APPEND WA_FCAT TO T_FCAT.

ls_exclude = cl_gui_alv_grid=>MC_FC_SORT_ASC.

append ls_exclude to lt_exclude.

ls_exclude = cl_gui_alv_grid=>MC_FC_SORT_DSC.

append ls_exclude to lt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_SUBTOT.

append ls_exclude to lt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_FILTER.

append ls_exclude to lt_exclude.

CREATE OBJECT IDT

EXPORTING

  • PARENT =

CONTAINER_NAME = LOC.

CREATE OBJECT GRD

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

I_PARENT = IDT.

data : lay type LVC_S_LAYO.

lay-GRID_TITLE = 'NAVEEN'.

CALL METHOD GRD->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME =

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

IS_LAYOUT = lay

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

IT_TOOLBAR_EXCLUDING = LT_EXCLUDE

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

IT_OUTTAB = ITAB[]

IT_FIELDCATALOG = T_FCAT

  • IT_SORT =

  • IT_FILTER =

  • EXCEPTIONS

  • INVALID_PARAMETER_COMBINATION = 1

  • PROGRAM_ERROR = 2

  • TOO_MANY_LINES = 3

  • others = 4

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE.

If helpful pls Reward with points.