*&----------------ALV
PARA :
1 ---- field catalog
I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, OO ----- > LVC_T_FCAT
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV. ------> LVC_S_FCAT
e.g :
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
2------ report header
IT_LISTHEADER TYPE SLIS_T_LISTHEADER, OO -----> LVC_T_HEAD
e.g.:
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'. " character type
append hline to I_LISTHEADER .
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
.
ENDFORM. "
3------ event
V_EVENTS TYPE SLIS_T_EVENT, OO ------> LVC_T_EVTS
WA_EVENT TYPE SLIS_ALV_EVENT. -------> LVC_S_EVTS
e.g :
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME = WA_EVENT-FORM.
ENDIF.
4------ lay out
ALV_LAYOUT TYPE SLIS_LAYOUT_ALV. OO -----> LVC_S_LAYO
e.g.:
alv_loyout- zebra = 'X'
alv_loyout- edit = 'X'
5------- filter
GT_FILT TYPE slis_filter_alv OO ----> LVC_T_FILT,
GS_FILT TYPE slis_filter_alv0/1 ----> LVC_S_FILT,
6------- sort
it_sort type slis_t_sortinfo_alv OO -------> LVC_T_SORT
wa_sort type slis_sortinfo_alv
7------------ start color , if ALV need color , define in table
color(4) type c ,
colinfo TYPE slis_t_specialcol_alv,
e.g. :
gt_color1-fieldname = 'EBELN'.
gt_color1-color-col = 3.
gt_color1-color-int = 1.
gt_color1-color-inv = 0.
APPEND gt_color1.
LOOP AT IT_EKKO into WA_EKKO.
CASE sy-tabix.
WHEN 1.
WA_EKKO-color = 'C200'.
WHEN 2.
WA_EKKO-color = 'C300'.
WHEN 3.
WA_EKKO-color = 'C700'.
WHEN 4.
WA_EKKO-color = 'C600'.
ENDCASE.
WA_EKKO-colinfo[] = gt_color1[].
MODIFY IT_EKKO from WA_EKKO INDEX sy-tabix.
ENDLOOP.
*----------- end
RS_SELFIELD TYPE SLIS_SELFIELD. " * information cursor position ALV when run
FUNC:
*----- 1.
V_REPID = SY-REPID.
data : I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
* I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* i_default = 'ZLAY1'
I_SAVE = 'A'
* is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKKO
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
*----- 2.
GO_GRID TYPE REF TO CL_GUI_ALV_GRID,
GO_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER.
IF GO_GRID IS INITIAL.
CREATE OBJECT GO_GRID
EXPORTING
I_PARENT = CL_GUI_CONTAINER=>SCREEN0.
CREATE OBJECT EVENT_RECEIVER.
SET HANDLER EVENT_RECEIVER->HANDLE_DATA_CHANGED FOR GO_GRID.
IF SY-BATCH IS INITIAL.
CALL METHOD GO_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER. "回车时触发
ENDIF .
ENDIF .
CALL METHOD GO_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_VARIANT = GS_VARIANT
I_SAVE = 'A'
IS_LAYOUT = ALV_LAYOUT
CHANGING
IT_OUTTAB = ITAB[]
IT_FIELDCATALOG = GT_FIELDCAT[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4.
CALL METHOD GO_GRID->SET_READY_FOR_INPUT "处于编辑状态
EXPORTING
I_READY_FOR_INPUT = 1.
CALL METHOD CL_GUI_CONTROL=>SET_FOCUS "设置焦点在go_grid 上
EXPORTING
CONTROL = GO_GRID .
*&----------------SF
PARA :
WA_CONTROL like ssfctrlop, "Smart Forms: Control structure
WA_OPTIONS type ssfcompop, " SAP Smart Forms: Smart Composer (transfer) options
gv_op type ssfcresop, " Smart Forms: Return value at start of form printing
gv_otf type ssfcrescl. " Smart Forms: Return value at end of form printing
WA_CONTROL-no_open = 'X'. " SAP Smart Forms: General Indicator
WA_CONTROL-no_close = 'X'.
WA_CONTROL-no_close = 'X'. " Output DEVICE
WA_CONTROL-preview = 'X'. " Print preview
WA_OPTIONS -tddest = 'LOCL'. " Spool: Output device
WA_OPTIONS -tdimmed = 'X'. " Print Immediately (Print Parameters)
WA_OPTIONS -tddelete = 'X'. " Delete After Printing (Print Parameters)
WA_CONTROL-NO_DIALOG = 'X'."是否显示选择打印机界面
FUNC :
1 .
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = C2_NAME
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = C1_NAME
.
CALL FUNCTION C1_NAME
IMPORTING
CONTROL_PARAMETERS = WA_CONTROL
OUTPUT_OPTIONS = WA_OPTIONS
TABLES
Itab = ITAB .
2.
call function 'SSF_OPEN'
exporting
* ARCHIVE_PARAMETERS =
user_settings = space
output_options = WA_OPTIONS
control_parameters = WA_CONTROL
importing
job_output_options = gv_op
.
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = C2_NAME
* VARIANT = ' '
* DIRECT_CALL = ' '
importing
fm_name = C1_NAME .
CALL FUNCTION C1_NAME
EXPORTING
CONTROL_PARAMETERS = WA_CONTROL
TABLES
T_FO = ITAB
call function 'SSF_CLOSE'
IMPORTING
job_output_info = gv_otf
EXCEPTIONS
.
*&----------------DOI