




免費(fèi)預(yù)覽已結(jié)束,剩余1頁可下載查看
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
(一)ALV_GRID添加自定義的按鈕和響應(yīng)命令 2009-04-29 10:37 我們?cè)贏LV的工具條上增加一些按鈕來增加我們自定義的功能,當(dāng)然也可以在GUI狀態(tài)中增加,2種的處理方式是不一樣的. 我們通過toolbar事件來增加按鈕,然后通過user_command事件來實(shí)現(xiàn)我們自定義的功能. 在TOOLBAR事件里,我們把自定義的按鈕加到參數(shù)e_object的表屬性mt_toolbar中可以了.下面是一段示例代碼:FORM handle_toolbar USING i_object TYPE REF TO cl_alv_event_toolbar_set. DATA: ls_toolbar TYPE stb_button. CLEAR ls_toolbar. MOVE 3 TO ls_toolbar-butn_type. APPEND ls_toolbar TO i_object-mt_toolbar. CLEAR ls_toolbar. MOVE PER TO ls_toolbar-function. MOVE icon_display_text TO ls_toolbar-icon. MOVE Passenger Info(201) TO ls_toolbar-quickinfo.MOVE Passenger Info(201) TO ls_toolbar-text. MOVE TO ls_toolbar-disabled. APPEND ls_toolbar TO i_object-mt_toolbar. CLEAR ls_toolbar. MOVE EXCH TO ls_toolbar-function. MOVE 2 TO ls_toolbar-butn_type. MOVE icon_calculation TO ls_toolbar-icon. MOVE Payment in other Curencies(202) TO ls_toolbar-quickinfo. MOVE TO ls_toolbar-text. MOVE TO ls_toolbar-disapbled. APPEND ls_toolbar TO i_object-mt_toolbar.ENDFORM.增加自定義按鈕的結(jié)構(gòu)如下:FieldDescriptionFUNCTION功能代碼BUTN_TYPE按鈕類型可用的按鈕類型:0 Button(normal)1 Menu and default button2 Menu3 分割符4 Radio button5 Checkbox6 Menu entryICON按鈕圖標(biāo)(可選)TEXT按鈕文本(可選)QUICKINFO按鈕的懸停文本(可選)DISABLED灰化在上面的代碼例子里,我們?cè)黾恿艘粋€(gè)常規(guī)的按鈕和一個(gè)含有菜單的按鈕.通過把按鈕的類型設(shè)置為1或者2,我們可以增加一個(gè)含有菜單的按鈕,在事件menu_button還可以實(shí)現(xiàn)子菜單:FORM handle_menu_button USING i_object TYPE REF TO cl_ctmenuI_ucomm TYPE syucomm.CASE i_ucomm.WHEN EXCH.CALL METHOD i_object-add_function EXPORTING Fcode = EU Text = Euro.CALL METHOD i_object-add_function EXPORTING Fcode = TRL Text = Turkish Lira.ENDCASE.ENDFORM.為了實(shí)現(xiàn)這些自定義的按鈕的功能,我們使用USER_COMMAND事件來處理.FORM handle_user_command USING i_ucomm TYPE syucomm.DATA lt_selected_rows TYPE lvc_t_rowid.DATA ls_selected_row TYPE lvc_s_roid.CALL METHOD gr_alvgrid-get_selected_rows IMPORTING Et_row_no = lt_selected_rows.READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1.If sy-subrc ne 0. MESSAGE S000(su) WITH Select a row(203).ENDIF.CASE i_ucomm.WHEN CAR. READ TABLE gt_list INDEX ls_selected_row-row_id. IF sy-subrc = 0. CALL FUNCTION ZDISPLAY_CARRIER_INFO EXPORTING carrid = gt_list-carrid EXCEPTIONS carrier_not_found = 1 Oters = 2. ENDIF.WHEN EU. READ TABLE gt_list INDEX ls_selected_row-row_id. IF sy-subrc = 0. CALL FUNCTION ZPOPUP_CONV_CURR_ADD_DISPLAY EXPORTING monun = EU Quant = gt_list-paymentsum. ENDIF.ENDCASE.ENDFORM.我們通過方法get_selected_rows來獲取選擇的行.功能EXCH有2個(gè)子功能,所以我們不需要實(shí)現(xiàn)它.為了能顯示ALV附加的一些功能,可以在ALV實(shí)例創(chuàng)建的時(shí)候調(diào)用set_toolbar_interactive方法. CALL METHOD gr_alv_grid-set_toolbar_interactive.(二)在alv_lst中加入按鈕Add Button to ALV Toolbar with REUSE_ALV_LIST_DISPLAY How to add button to ALV toolbar using REUSE_ALV_LIST_DISPLAY? In the program which calls ALV using REUSE_ALV_LIST_DISPLAY, I have to add a new button. I saw the demo program BCALV_GRID_08, which is written using ABAP-Controls. In that example, the button is added using TOOLBAR event of cl_gui_alv_grid. Could you help me to implement the same logic using REUSE_ALV_LIST_DISPLAY parameters. you should copy the STANDARD GUI status from program SAPLKKBL using transaction SE90 -Programming SubObjects- Gui Status. Execute this transaction to get to next screen. select status using checkbox. click on GUI Status - Copy. Enter your Z program name and the name you what for this status - you can keep it as STANDARD to be simple. Then you can edit the new status to add or delete buttons. This will also bring in the standard SAP ALV functionality such as sorting/subtotaling etc. When you call REUSE_ALV_GRID_DISPLAY make sure you pass it the new status name. an example of one of mine: call function REUSE_ALV_GRID_DISPLAY EXPORTING i_callback_program = ZSDBOLST_REPORT i_callback_pf_status_set = STANDARD - i_callback_user_command = USER_COMMAND i_structure_name = I_BOLACT i_grid_title = BOL Action Report(031) is_layout = gs_layout it_fieldcat = gt_fieldcat i_save = A is_variant = v_variant TABLES t_outtab = i_bolact EXCEPTIONS program_error = 1 others = 2. I just tried the same procedure ,but my entire application toolbar disappeared and a lock icon appears next to the application toolbar in my copied pf-status. Could you advice what might have gone wrong ? As identified with the FMs help you can do the following. 1). Using SE80 (I think) you can copy a GUI status from one program to another. It mentions which one in the FMs help. 2). Create a form named like so: Code: * * Form Set_pf_status * Notes: Called by FM REUSE_ALV_GRID_DISPLAY * FORM set_pf_status USING rt_extab TYPE slis_t_extab. SET PF-STATUS ZSTANDARD. ENDFORM. Set_pf_status In the above case the GUI status copied was named ZSTANDARD and adjusted accordingly, adding and removing the desired buttons. A button was added called %DELETE. 3). Create the following report: Code: * * Form User_command * Notes: Called by FM REUSE_ALV_GRID_DISPLAY * Detects whether the icon/button for * Return Tag Deletion has been pressed. If it has then * detect whether any rows have been highlighted and then * set the delete flag. * FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield. DATA: li_count TYPE I. IF r_ucomm EQ %DELETE. LOOP AT %g00 WHERE mark EQ X. ADD 1 TO li_count. ENDLOOP. IF li_count GT 0. gc_delete_flag = X. r_ucomm = &F03. Back arraow ELSE. MESSAGE W000 WITH Please highlight the rows to be deleted!. ENDIF. ENDIF. ENDFORM. User_command As Ive added an extra button to indicate which records should be deleted I need to identify a form to be called to process when this button is chosen. Then when you call the ALV function you to specify the following extra details: Code: call function REUSE_ALV_GRID_DISPLAY exporting i_callback_program = gc_repid I_CALLBACK_PF_STATUS_SET = SET_PF_STATUS I_CALLBACK_USER_COMMAND = US
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 電氣英語考試試題及答案
- 護(hù)士特長考試試題及答案
- 科目理論考試試題及答案
- 基礎(chǔ)班結(jié)業(yè)考試試題及答案
- scratch四級(jí)考試試題及答案
- 建筑結(jié)構(gòu)考試試題及答案
- 《學(xué)前兒童健康照護(hù) 》電子教案-4-4 嘔吐的識(shí)別與照護(hù)-教學(xué)設(shè)計(jì)
- 四川省2023-2024學(xué)年高三下學(xué)期開學(xué)診斷性考試文科綜合高中政治 無答案
- 2024屆高三英語二輪復(fù)習(xí)+寫作專項(xiàng)讀后續(xù)寫美好品質(zhì)類Return the練習(xí)含答案
- 浙江省2024年1月普通高校招生選考科目考試歷史試題 無答案
- 電梯生產(chǎn)質(zhì)量安全總監(jiān)題庫含答案
- 民用無人機(jī)操控員執(zhí)照(CAAC)考試復(fù)習(xí)重點(diǎn)題庫500題(含答案)
- 機(jī)械租賃保障措施
- 中山大學(xué)與吉首大學(xué)聯(lián)合培養(yǎng)本科生項(xiàng)目實(shí)施辦法
- 山東省煙臺(tái)市2024-2025學(xué)年高二地理下學(xué)期期中試題
- 門窗店和裝修公司合作協(xié)議書
- 順豐控股成本問題及對(duì)策分析
- 美的公司存貨管理存在的問題及研究對(duì)策
- 抖音火花合同模板
- 2024年共青團(tuán)入團(tuán)積極分子考試題庫(含答案)
- 初中英語非連續(xù)性文本的閱讀策略分析
評(píng)論
0/150
提交評(píng)論