1. 程式人生 > >ooalv設定單元格下拉

ooalv設定單元格下拉

在編輯ooalv的時候,有寫單元格的值是一些固定的值,比如借貸標
識S,H,此時可以設定單元格的屬性為下拉。實現步驟如下:

1.展示內表新增控制控制代碼

TYPES : BEGIN OF T_SHOW,
SHKZG LIKE BSEG-SHKZG, "借貸標識
DD_HNDL TYPE INT4, "控制下拉欄位
END OF T_SHOW.

2.設定fieldcat時指定控制代碼

  WHEN 'SHKZG'.
    "設定下拉欄位
    WA_FIELDCAT-DRDN_FIELD  = 'DD_HNDL'.
    WA_FIELDCAT-DRDN_HNDL   = '1' .

3.設定下拉值

&-----------------------------------------------------
*& Form PRE_DROP_LIST
&-----------------------------------------------------

  •   text  設定下拉欄位值
    

------------------------------------------------------
FORM PRE_DROP_LIST .
"下拉欄位
DATA : IT_LIST TYPE LVC_T_DROP,
WA_LIST TYPE LVC_S_DROP.
"設定ALV下拉欄位的值
IF IT_LIST IS INITIAL.
WA_LIST-HANDLE = ‘1’.
WA_LIST-VALUE = ‘S’.
APPEND WA_LIST TO IT_LIST.
CLEAR : WA_LIST.
WA_LIST-HANDLE = ‘1’.
WA_LIST-VALUE = ‘H’.
APPEND WA_LIST TO IT_LIST.
CLEAR : WA_LIST.
ENDIF.
"呼叫函式設定值
CALL METHOD GF_ALV_GRID->SET_DROP_DOWN_TABLE
EXPORTING
IT_DROP_DOWN = IT_LIST .

ENDFORM.

4.呼叫設定下拉的form

注:在設定了fieldcat之後呼叫

"設定下拉欄位值
PERFORM PRE_DROP_LIST.