Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

regarding ediatbel alv

Hi all,

I have a requirement to go for editable alv in this particular program.

like if i click in any of the row and try to go for change mode then the the whole row shuld become editable.

i dont why i m not getting the required output.

below i m giving my code.

<code>

REPORT Z_EDITABLE_ALV.

tables : ztable_12.

types : begin of ty_tab ,

matnr type ztable_12-matnr,

ersda type ztable_12-ersda,

ernam type ztable_12-ernam,

vpsta type ztable_12-vpsta,

mtart type ztable_12-mtart,

mbrsh type ztable_12-mbrsh,

matkl type ztable_12-matkl,

meins type ztable_12-meins,

end of ty_tab.

data : itab type standard table of ty_tab,

wa_tab like line of itab.

data :

ok_code like sy-ucomm,

save_ok like sy-ucomm,

g_container type scrfname value 'GRID_CON',

it_grid1 type ref to cl_gui_alv_grid,

it_container type ref to cl_gui_custom_container,

gt_fieldcat type lvc_t_fcat,

wa_fieldcat like line of gt_fieldcat,

gs_layout type lvc_s_layo.

class c1 definition.

public section.

methods : get_data,

display_data.

endclass.

class c1 implementation.

method get_data.

select matnr ersda ernam vpsta mtart mbrsh matkl meins from ztable_12 into corresponding fields of table itab.

endmethod.

method display_data.

if not itab is initial.

perform build_fldcat.

call screen 1003.

ENDIF.

ENDMETHOD.

endclass.

start-of-selection.

data : obj type ref to c1.

create object obj.

call method obj->get_data.

call method obj->display_data.

&----


*& Module STATUS_1003 OUTPUT

&----


  • text

----


MODULE STATUS_1003 OUTPUT.

SET PF-STATUS 'EDIT'.

  • SET TITLEBAR 'xxx'.

if it_container is initial.

CREATE OBJECT it_container

EXPORTING

  • PARENT =

container_name = g_container

  • STYLE =

  • LIFETIME = lifetime_default

  • REPID =

  • DYNNR =

  • NO_AUTODEF_PROGID_DYNNR =

  • EXCEPTIONS

  • CNTL_ERROR = 1

  • CNTL_SYSTEM_ERROR = 2

  • CREATE_ERROR = 3

  • LIFETIME_ERROR = 4

  • LIFETIME_DYNPRO_DYNPRO_LINK = 5

  • others = 6

.

IF sy-subrc <> 0.

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

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

ENDIF.

CREATE OBJECT it_grid1

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

i_parent = it_container

  • I_APPL_EVENTS = space

  • I_PARENTDBG =

  • I_APPLOGPARENT =

  • I_GRAPHICSPARENT =

  • I_NAME =

  • I_FCAT_COMPLETE = SPACE

  • EXCEPTIONS

  • ERROR_CNTL_CREATE = 1

  • ERROR_CNTL_INIT = 2

  • ERROR_CNTL_LINK = 3

  • ERROR_DP_CREATE = 4

  • others = 5

.

IF sy-subrc <> 0.

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

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

ENDIF.

gs_layout-edit = 'X'.

CALL METHOD it_grid1->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 = gs_layout

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

  • IR_SALV_ADAPTER =

CHANGING

it_outtab = itab

IT_FIELDCATALOG = gt_fieldcat

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

CALL METHOD IT_GRID1->SET_READY_FOR_INPUT

EXPORTING

I_READY_FOR_INPUT = 1.

endif.

ENDMODULE. " STATUS_1003 OUTPUT

&----


*& Module USER_COMMAND_1003 INPUT

&----


  • text

----


MODULE USER_COMMAND_1003 INPUT.

save_ok = sy-ucomm.

case save_ok.

when 'EXIT'.

perform exit_program.

when 'BACK' or 'CANCEL'.

leave to screen 0.

when 'SWITCH'.

perform switch_edit_mode.

endcase.

clear ok_code.

ENDMODULE. " USER_COMMAND_1003 INPUT

&----


*& Form exit_program

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM exit_program .

leave program.

ENDFORM. " exit_program

&----


*& Form switch_edit_mode

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM switch_edit_mode .

if it_grid1->is_ready_for_input( ) eq 0.

CALL METHOD IT_GRID1->SET_READY_FOR_INPUT

EXPORTING

I_READY_FOR_INPUT = 1

.

else.

CALL METHOD IT_GRID1->SET_READY_FOR_INPUT

EXPORTING

I_READY_FOR_INPUT = 0

.

endif.

ENDFORM. " switch_edit_mode

&----


*& Form build_fldcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_fldcat .

clear wa_fieldcat.

wa_fieldcat-fieldname = 'MATNR'.

*wa_fieldcat-ref_table = 'ITAB'.

wa_fieldcat-coltext = 'MATERIAL NO'.

wa_fieldcat-seltext = 'vendor no'.

wa_fieldcat-col_pos = 1.

wa_fieldcat-hotspot = 'X'.

*wa_fieldcat-outputlen = 10.

*wa_fieldcat-inttype = 'D'.

*wa_fieldcat-intlen = 10.

append wa_fieldcat to gt_fieldcat.

wa_fieldcat-fieldname = 'ERSDA'.

*wa_fieldcat-ref_table = 'ITAB'.

wa_fieldcat-coltext = 'DATE'.

wa_fieldcat-seltext = 'DATE'.

wa_fieldcat-col_pos = 2.

wa_fieldcat-hotspot = 'X'.

*wa_fieldcat-outputlen = 10.

*wa_fieldcat-inttype = 'D'.

*wa_fieldcat-intlen = 10.

append wa_fieldcat to gt_fieldcat.

wa_fieldcat-fieldname = 'ERNAM'.

*wa_fieldcat-ref_table = 'ITAB'.

wa_fieldcat-coltext = 'NAME'.

wa_fieldcat-seltext = 'NAME'.

wa_fieldcat-col_pos = 3.

wa_fieldcat-hotspot = 'X'.

*wa_fieldcat-outputlen = 10.

*wa_fieldcat-inttype = 'D'.

*wa_fieldcat-intlen = 10.

append wa_fieldcat to gt_fieldcat.

wa_fieldcat-fieldname = 'VPSTA'.

*wa_fieldcat-ref_table = 'ITAB'.

wa_fieldcat-coltext = 'MATERIAL NO'.

wa_fieldcat-seltext = 'vendor no'.

wa_fieldcat-col_pos = 4.

wa_fieldcat-hotspot = 'X'.

*wa_fieldcat-outputlen = 10.

*wa_fieldcat-inttype = 'D'.

*wa_fieldcat-intlen = 10.

append wa_fieldcat to gt_fieldcat.

wa_fieldcat-fieldname = 'MTART'.

*wa_fieldcat-ref_table = 'ITAB'.

wa_fieldcat-coltext = 'MATERIAL NO'.

wa_fieldcat-seltext = 'vendor no'.

wa_fieldcat-col_pos = 5.

wa_fieldcat-hotspot = 'X'.

*wa_fieldcat-outputlen = 10.

*wa_fieldcat-inttype = 'D'.

*wa_fieldcat-intlen = 10.

append wa_fieldcat to gt_fieldcat.

wa_fieldcat-fieldname = 'MBRSH'.

*wa_fieldcat-ref_table = 'ITAB'.

wa_fieldcat-coltext = 'MATERIAL NO'.

wa_fieldcat-seltext = 'vendor no'.

wa_fieldcat-col_pos = 6.

wa_fieldcat-hotspot = 'X'.

*wa_fieldcat-outputlen = 10.

*wa_fieldcat-inttype = 'D'.

*wa_fieldcat-intlen = 10.

append wa_fieldcat to gt_fieldcat.

wa_fieldcat-fieldname = 'MATKL'.

*wa_fieldcat-ref_table = 'ITAB'.

wa_fieldcat-coltext = 'MATERIAL NO'.

wa_fieldcat-seltext = 'vendor no'.

wa_fieldcat-col_pos = 7.

wa_fieldcat-hotspot = 'X'.

*wa_fieldcat-outputlen = 10.

*wa_fieldcat-inttype = 'D'.

*wa_fieldcat-intlen = 10.

append wa_fieldcat to gt_fieldcat.

wa_fieldcat-fieldname = 'MEINS'.

*wa_fieldcat-ref_table = 'ITAB'.

wa_fieldcat-coltext = 'MATERIAL NO'.

wa_fieldcat-seltext = 'vendor no'.

wa_fieldcat-col_pos = 8.

wa_fieldcat-hotspot = 'X'.

*wa_fieldcat-outputlen = 10.

*wa_fieldcat-inttype = 'D'.

*wa_fieldcat-intlen = 10.

append wa_fieldcat to gt_fieldcat.

ENDFORM. " build_fldcat

</code>

I have also created a function key switch.

help required.

Thanks,

sanjay

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question