메뉴 건너뛰기

SAP 한국 커뮤니티

[요청]ALV GRID에서 EDIT기능 이용시 질문요~!

풍운사랑 2008.06.30 03:05 조회 수 : 3854 추천:5

아래 소스와 같이 수정 하고 싶은 필드에만 EDIT을 하였는데요 DATA CHANGE이벤트 같은거 해줘야 ITAB내용이 수정 될꺼 같더라구요 아래 소스같이만 하면 행삽입, 행삭제 , EDIT기능이용해서 ITAB내용 수정 했을시에 ITAB에 반영이 안되는거 같아요.   글구  추가로 행 선택시 마크에 X표시가 걸려야 되는데 아래 소스에서 엇게 처리 해야 하는지요.....


혹시 아시는 분께선 소스나 참고 자료좀 추천 해주시면 감사하겠습니다.  ( 아래 소스는 외국 사이트서 구한건데 연구중이라요 원래 EDIT기능 하기 위해 짠 소스가 아닌데 제가 그걸 해보려다 막혀서여 도와줍쇼~ ㅜㅜ)


 


* 아래 소스에선 GT_MARA_ALL인터널 테이블러 ALV출력 하는것입니다.


 


 

report z_alv_grid_ctrl_refresh_2.

tables : mara.

types:
  begin of ty_s_mara,
    matnr like mara-matnr,
    ernam like mara-ernam,
    ersda like mara-ersda,
    brgew like mara-brgew,
    meins like mara-meins,
  end of ty_s_mara.

class lcl_event_alv definition deferred.

data:
  gt_mara type standard table of mara,
  go_container type ref to cl_gui_docking_container,
  go_alv_grid  type ref to cl_gui_alv_grid,
  go_events    type ref to lcl_event_alv,

  gt_mara_ftr type standard table of mara,   " Data filtered
  gt_mara_all type standard table of mara,   " Data readfrom DB

  okcode    type syucomm,
  gv_okcode type syucomm.

*---------------------------------------------------------------------*
*       CLASS lcl_event_alv DEFINITION
*---------------------------------------------------------------------*
class lcl_event_alv definition.

  public section.
    methods:
      h_user_command for event after_user_command of cl_gui_alv_grid
                     importing e_ucomm
                               sender.

endclass.                              " LCL_EVENT_ALV DEFINITION
*---------------------------------------------------------------------*
*        Class (Implementation)  lcl_event_alv
*---------------------------------------------------------------------*
class lcl_event_alv implementation.

  method h_user_command.
    case e_ucomm.
      when '&SORT_ASC' or '&SORT_DSC'" Sort
        perform f_sort_big_table.
*        PERFORM f_read_data USING c_first_page.
        perform f_refresh_table.
      when '&FILTER'.                  " Filter
        perform f_filter_data.
*        PERFORM f_read_data USING c_first_page.
        perform f_refresh_table.
      when '&DELETE_FILTER'.           " Delete filter
*        gt_mara_ftr[] = gt_mara_all[].
*        PERFORM f_read_data USING c_first_page.
        perform f_refresh_table.
    endcase.
  endmethod.                           " user_command

endclass.                              " LCL_EVENT_ALV
*---------------------------------------------------------------------*
*SELECTION-SCREEN :
*BEGIN OF LINE,COMMENT 10(20) v_1 FOR FIELD p_max.           "#EC NEEDED
*PARAMETERS p_max(2) TYPE n DEFAULT '30' OBLIGATORY.
*SELECTION-SCREEN END OF LINE.
selection-screen : begin of block param with frame title text-t13.
selection-screen skip 1.
select-options : s_matnr for mara-matnr.
selection-screen skip 1.
selection-screen end of block param.
*---------------------------------------------------------------------*
initialization.

*  v_1 = 'Lines per page'.

*---------------------------------------------------------------------*
start-of-selection.

  select *
    into corresponding fields of table gt_mara_all
    from mara
    where matnr in s_matnr.

  loop at gt_mara_all into mara.
*    APPEND  mara TO gt_mara_ftr.

  endloop.
*  gt_mara_ftr = gt_mara_all.
  call screen 100.

*---------------------------------------------------------------------*
*       Module  pbo_0100  OUTPUT
*---------------------------------------------------------------------*
module pbo_0100 output.

  set pf-status 'MAIN'.
  set titlebar 'MAIN1'.

  perform create_and_init_alv.

endmodule.                             " PBO_0100  OUTPUT
*---------------------------------------------------------------------*
*       Module  user_command_0100  INPUT
*---------------------------------------------------------------------*
module user_command_0100 input.

  gv_okcode = okcode.
  clear okcode.

  case gv_okcode.
    when 'BACK'.
      set screen 0.
    when 'EXIT'.
      leave program.
*    WHEN c_first_page OR c_next_page OR c_last_page OR c_prev_page.
    when 'REFRESH'.
      call screen 200.
  endcase.

endmodule.                             " USER_COMMAND_0100  INPUT

*---------------------------------------------------------------------*
*       Form  create_and_init_alv
*---------------------------------------------------------------------*
form create_and_init_alv.

* Macro definition
  define m_fieldcat.

    ls_alv_cat-col_pos = 1.
    ls_alv_cat-fieldname = 'ERNAM'.
    ls_alv_cat-ref_table = 'MARA'.
    ls_alv_cat-edit = ' '.
    append ls_alv_cat to lt_alv_cat.

    ls_alv_cat-col_pos = 2.
    ls_alv_cat-fieldname = 'MATNR'.
    ls_alv_cat-ref_table = 'MARA'.
    ls_alv_cat-edit = ' '.
    append ls_alv_cat to lt_alv_cat.

    ls_alv_cat-col_pos = 3.
    ls_alv_cat-fieldname = 'ERSDA'.
    ls_alv_cat-ref_table = 'MARA'.
    ls_alv_cat-edit = 'X'.
    append ls_alv_cat to lt_alv_cat.

    ls_alv_cat-col_pos = 4.
    ls_alv_cat-fieldname = 'BRGEW'.
    ls_alv_cat-ref_table = 'MARA'.
    ls_alv_cat-edit = 'X'.
    append ls_alv_cat to lt_alv_cat.

    ls_alv_cat-col_pos = 5.
    ls_alv_cat-fieldname = 'MEINS'.
    ls_alv_cat-ref_table = 'MARA'.
    ls_alv_cat-no_out = 'X'.

    append ls_alv_cat to lt_alv_cat.
  end-of-definition.

  data:
    ls_variant      type disvariant,
    lt_alv_cat      type lvc_t_fcat,
    ls_alv_cat      type lvc_s_fcat,
    ls_alv_lay      type lvc_s_layo,
    l_offline       type char1.

  check go_container is initial.

  call method cl_gui_alv_grid=>offline
    receiving
      e_offline = l_offline.

  if l_offline eq 0.
    create object go_container
        exporting
            extension = 2000
        exceptions
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5
            others                      = 6.
    if sy-subrc ne 0.
      message e999(zmcmm) with 'The control could not be created'.
    endif.
  endif.

* Create an instance of alv control
  create object go_alv_grid
      exporting i_parent = go_container.

  create object go_events.
  set handler go_events->h_user_command for go_alv_grid.

* Build field catalog
  m_fieldcat.
*  m_fieldcat.
*  m_fieldcat.
*  m_fieldcat.

* Layout
  clear ls_alv_lay.
  ls_alv_lay-zebra      = 'X'.
  ls_alv_lay-cwidth_opt = 'X'.

  ls_variant-report = sy-cprog.

* Display
  call method go_alv_grid->set_table_for_first_display
    exporting
      is_variant      = ls_variant
      is_layout       = ls_alv_lay
      i_save          = 'A'
    changing
      it_outtab       = gt_mara_all
      it_fieldcatalog = lt_alv_cat.

endform.                               " CREATE_AND_INIT_ALV
*---------------------------------------------------------------------*
*      Form  F_REFRESH_TABLE
*---------------------------------------------------------------------*
form f_refresh_table.

  data: ls_layout type lvc_s_layo.

  call method go_alv_grid->get_frontend_layout
    importing
      es_layout = ls_layout.

  ls_layout-cwidth_opt = 'X'.

  call method go_alv_grid->set_frontend_layout
    exporting
      is_layout = ls_layout.

  call method go_alv_grid->refresh_table_display.

endform.                               " F_REFRESH_TABLE
*---------------------------------------------------------------------*
*       Form  F_SORT_BIG_TABLE
*---------------------------------------------------------------------*
form f_sort_big_table.

  data:
    lt_sort_kkblo type kkblo_t_sortinfo,
    lt_sort       type lvc_t_sort.

  call method go_alv_grid->get_sort_criteria
    importing
      et_sort = lt_sort.

  check not lt_sort[] is initial.

* Format LVC --> KKBLO
  call function 'LVC_TRANSFER_TO_KKBLO'
    exporting
      it_sort_lvc   = lt_sort
    importing
      et_sort_kkblo = lt_sort_kkblo.

* The big tables must be sorted like the small one
  perform fb_outtab_sort(saplkkbl) tables gt_mara_ftr
                                          lt_sort_kkblo
                                    using 'X'
                                          'X'.

  perform fb_outtab_sort(saplkkbl) tables gt_mara_all
                                          lt_sort_kkblo
                                    using 'X'
                                          'X'.

endform.                               " F_SORT_BIG_TABLE
*---------------------------------------------------------------------*
*      Form  f_filter_data
*---------------------------------------------------------------------*
form f_filter_data.

  data:
    lt_filter_lvc   type lvc_t_filt,
    lt_filter_index type lvc_t_fidx with header line.

  call method go_alv_grid->get_filter_criteria
    importing
      et_filter = lt_filter_lvc.

* Find data to filter
  call function 'LVC_FILTER_APPLY'
    exporting
      it_filter       = lt_filter_lvc
    importing
      et_filter_index = lt_filter_index[]
    tables
      it_data         = gt_mara_all.


  sort lt_filter_index descending.
  loop at lt_filter_index.
    delete gt_mara_all index lt_filter_index.
  endloop.

endform.                               " F_FILTER_DATA
*&---------------------------------------------------------------------*
*&      Module  STATUS_0200  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0200 output.
  set pf-status 'ZKJK1'.
  set titlebar 'xxx'.

endmodule.                 " STATUS_0200  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0200  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0200 input.
  gv_okcode = okcode.
  clear okcode.

  case gv_okcode.
    when 'BACK'.
      set screen 100.
    when 'EXIT'.
      leave program.
  endcase.
endmodule.                 " USER_COMMAND_0200  INPUT
*&---------------------------------------------------------------------*
*&      Module  ITAB_MODIFY  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module itab_modify input.

  loop at screen.
    modify screen.
  endloop.

  loop at gt_mara_all into mara.
    modify  gt_mara_all index sy-tabix from mara.
  endloop.
*  MODIFY  gt_mara_all FROM mara-ernam.
*  MODIFY  gt_mara_all FROM mara-ersda.
*  MODIFY  gt_mara_all FROM mara-brgew.
*  MODIFY  gt_mara_all FROM mara-meins.
endmodule.                 " ITAB_MODIFY  INPUT
*&---------------------------------------------------------------------*
*&      Module  ITAB_MODIFY0  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module itab_modify0 output.

  loop at screen.
    modify screen.
  endloop.


  loop at gt_mara_all into mara.
    modify  gt_mara_all index sy-tabix from mara.
  endloop.
endmodule.                 " ITAB_MODIFY0  OUTPUT

번호 제목 글쓴이 날짜 조회 수
1910 <b>[완료]</b>ALV 함수를 이용한 데이터 처리 시간 [1] 준서기 2008.07.01 1164
1909 <b>[완료]</b>Class ALV에서요....TOP-OF-PAGE할려면요?? [4] 복만돌이 2008.07.01 7264
1908 [요청]서브루틴 관련해서 문의드립니다. [3] 원니컴 2008.07.01 1497
1907 <b>[완료]</b>SAP Script를 이메일로 보내기 질문 드립니다. [3] mean 2008.07.01 1583
1906 <b>[완료]</b>bsp 공부할 수 있는 사이트나 자료 추천 부탁드립니다. [3] hogun 2008.07.01 1228
1905 [요청]checkbox의 class event부분에 대해 문의드립니다. [2] 풍뎅이 2008.07.01 2511
1904 [요청]아흑...bdc 레코딩 뜨는법이요... [2] CoolGuy 2008.06.30 2113
1903 <b>[완료]</b>금액 올림 하는 방법 알려주세요. [1] unicrn 2008.06.30 2047
1902 [요청]T-code SU01에서 사용자 추가시 Badi or user exit 추가방법 [2] 밥돌이 2008.06.30 1825
1901 <img src=3.gif border=0>[요청][SQL] - Open SQL 무진장 연습 좀 해 보고 싶은데요, 방법이 없을 까요 ? [2] 꼬맹이 2008.06.30 1313
1900 [요청]ALV 필드 사이즈 조정에 관한 질문입니다. [4] file SAP아가씨 2008.06.30 3565
1899 [요청]필드에 수를 입력하면 아래 필드에 평균값 자동입력.. file Diem 2008.06.30 1273
1898 <b>[완료]</b>관계연산자의 의미를 알고싶습니다. [3] 다급 2008.06.30 11416
1897 [요청]bdc 첨부파일로했네요 다시올려요~ CoolGuy 2008.06.30 1440
1896 <b>[완료]</b>잠금확인 enqueue에 관해 문의드립니다. [2] 풍뎅이 2008.06.30 1826
1895 [요청]BDC소스인데요 이해가 잘안되네요~ [4] file CoolGuy 2008.06.30 1357
1894 <b>[완료]</b>export/import 관련해서 질문 드립니다.! [4] 수갬 2008.06.30 2007
1893 <b>[완료]</b>스마트폼에서 테두리선 굵기 조절 [2] mean 2008.06.30 2620
1892 [요청]클래스 ALV에서 이기능 들어간 소스좀 알려주세요.. [1] 피크민 2008.06.30 1257
1891 <b>[완료]</b>라디오 버튼를 클릭하면 해당 screen 화면을 호출하고 싶습니다. [2] file SAP아가씨 2008.06.30 1341