Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV

Former Member
0 Likes
438

In order to hide some of the functions in ths ALV tool bar we use ..

DATA: lt_exclude TYPE ui_functions,

ls_exclude TYPE ui_func.

and then later we hide as follows..

ls_exclude = cl_gui_alv_grid=>MC_FC_SORT_ASC.

APPEND ls_exclude TO lt_exclude.

now my question is what are ui_functions and ui_func ?

3 REPLIES 3
Read only

Former Member
0 Likes
404

Hi Sriram,

In ALV, UI Functions are like, Change layout, Select Layout, Save Layout buttons from the ALV Toolbar which will effect the UI of ALV

Warm Regards,

Vijay

Read only

Former Member
0 Likes
404

Hi,

If you may want to exclude some of the standard function buttons since they are not useful for your list. To exclude those buttons, you fill a table of type “UI_FUNCTIONS” and pass it to the parameter “IT_TOOLBAR_EXCLUDING” of the method “set_table_for_first_display”. The function codes for the buttons may be acquired by inspecting the constant attributes of the class “cl_gui_alv_grid” or putting a break point into a method, like the event-handling method of the event “after_user_command”, which deals with the ALV command.

To hide the entire toolbar, you can set the field “NO_TOOLBAR” of the layout structure to ‘X’.

regards,

kiran kumar k

Read only

Former Member
0 Likes
404

check this example.

iu_functions

is body of internal table,which stores function codes

iu_func

is header of internal table

try this example

TABLES: ZMARA. .

*for function code variables

DATA : OK_CODE TYPE SY-UCOMM,

SAVE_OK LIKE SY-UCOMM,

*DECLARING CONTAINER NAME

CONTAINER TYPE SCRFNAME VALUE 'ALV_CONTAINER',

*DECLARATION OF CLASS

GRID TYPE REF TO CL_GUI_ALV_GRID,

*THIS CLASS IS USED TO CUSTOMIZE THE CAONTAINER

CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

*DECLARATION OF FIELDCATLOG,IT HOLDS THE FIELD PROPERTIES

FIELDCAT TYPE LVC_T_FCAT,"TABLE OF FCAT

LAYOUT TYPE LVC_S_LAYO,"LAYOUT TABLE

*

G_MAX TYPE I VALUE 100.

DATA : OUTTAB TYPE TABLE OF ZMARA.

END-OF-SELECTION.

CALL SCREEN 100.

*&----


*

*& Module STATUS_0100 OUTPUT

*&----


*

  • text

*----


*

MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'MAIN100'.

  • SET TITLEBAR 'xxx'.

IF CUSTOM_CONTAINER IS INITIAL.

PERFORM CREATE_AND_INIT_ALV CHANGING OUTTAB

FIELDCAT.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

*&----


*

*& Form CREATE_AND_INIT_ALV

*&----


*

  • text

*----


*

  • <--P_OUTTAB text

  • <--P_FIELDCAT text

*----


*

FORM CREATE_AND_INIT_ALV CHANGING PT_OUTTAB

PT_FIELDCAT.

DATA LT_EXCLUDE TYPE UI_FUNCTIONS."FUNCTION CODE

DATA : LT_F4 TYPE LVC_T_F4 WITH HEADER LINE."F4 FIELD REGESTRATION

*CUSTOMIZE THE CUSTOM CONTAINER

CREATE OBJECT CUSTOM_CONTAINER

EXPORTING

  • PARENT =

CONTAINER_NAME = 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 GRID

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

I_PARENT = CUSTOM_CONTAINER

  • I_APPL_EVENTS = space

  • I_PARENTDBG =

  • I_APPLOGPARENT =

  • I_GRAPHICSPARENT =

  • I_NAME =

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

  • Build fieldcat and set column WUNIT

  • edit enabled. Assign a handle for the dropdown listbox

PERFORM BUILD_FIELDCAT CHANGING PT_FIELDCAT.

PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.

PERFORM SET_DRDN_TABLE.

SELECT * FROM ZMARA INTO TABLE OUTTAB UP TO G_MAX ROWS.

IF SY-SUBRC <> 0.

*PERFORM GENERATE_ENTERIES CHANGING PT_OUTTAB.

MESSAGE E000(CXVX) WITH 'NO DATA'.

ENDIF.

CALL METHOD GRID->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 =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

IT_TOOLBAR_EXCLUDING = LT_EXCLUDE

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

IT_OUTTAB = PT_OUTTAB

IT_FIELDCATALOG = PT_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.

  • Set editable cells to ready for input initially

CALL METHOD GRID->SET_READY_FOR_INPUT

EXPORTING

I_READY_FOR_INPUT = 1

.

clear lt_f4.

lt_f4-fieldname = 'MTART'.

lt_f4-register = 'X'.

append lt_f4.

ENDFORM. " CREATE_AND_INIT_ALV

*&----


*

*& Form EXCLUDE_TB_FUNCTIONS

*&----


*

  • text

*----


*

  • <--P_LT_EXCLUDE text

*----


*

FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE

TYPE UI_FUNCTIONS..

  • Only allow to change data not to create new entries (exclude

  • generic functions).

DATA LS_EXCLUDE TYPE UI_FUNC.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

ENDFORM. " EXCLUDE_TB_FUNCTIONS

*&----


*

*& Form BUILD_FIELDCAT

*&----


*

  • text

*----


*

  • <--P_PT_FIELDCAT text

*----


*

FORM BUILD_FIELDCAT CHANGING PT_FIELDCAT TYPE LVC_T_FCAT.

DATA LS_FCAT TYPE LVC_S_FCAT.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

  • I_BUFFER_ACTIVE =

I_STRUCTURE_NAME = 'ZMARA'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_BYPASSING_BUFFER =

  • I_INTERNAL_TABNAME = OUT

CHANGING

CT_FIELDCAT = FIELDCAT

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

*§2.Set status of column WUNIT to editable and set a dropdown handle.

LOOP AT PT_FIELDCAT INTO LS_FCAT.

IF LS_FCAT-FIELDNAME EQ 'MTART'.

LS_FCAT-EDIT = 'X'.

LS_FCAT-DRDN_HNDL = '1'.

LS_FCAT-OUTPUTLEN = 7.

LS_FCAT-CHECKTABLE = '!'.

MODIFY PT_FIELDCAT FROM LS_FCAT.

ENDIF.

ENDLOOP.

ENDFORM. " BUILD_FIELDCAT

*&----


*

*& Form SET_DRDN_TABLE

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM SET_DRDN_TABLE .

*§1.Define a dropdown table and pass it to ALV.

  • One listbox is referenced by a handle, e.g., '1'.

  • For each entry that shall appear in this listbox

  • you have to append a line to the dropdown table

  • with handle '1'.

  • This handle can be assigned to several columns

  • of the output table using the field catalog.

*

DATA :LT_DROPDOWN TYPE LVC_T_DROP,

LS_DROPDOWN TYPE LVC_S_DROP.

*FIRST LISTBOX HANDEL '1'

LS_DROPDOWN-HANDLE = '1'.

LS_DROPDOWN-VALUE = 'KG'.

APPEND LS_DROPDOWN TO LT_DROPDOWN.

LS_DROPDOWN-HANDLE = '1'.

LS_DROPDOWN-VALUE = 'G'.

APPEND LS_DROPDOWN TO LT_DROPDOWN.

CALL METHOD GRID->SET_DROP_DOWN_TABLE

EXPORTING

IT_DROP_DOWN = LT_DROPDOWN

  • IT_DROP_DOWN_ALIAS =

.

ENDFORM. " SET_DRDN_TABLE

*&----


*

*& Form GENERATE_ENTERIES

*&----


*

  • text

*----


*

  • <--P_PT_OUTTAB text

*----


*

FORM GENERATE_ENTERIES CHANGING P_PT_OUTTAB.

*

  • This form is only needed if database table sbook is empty.

  • It generates some entries so that you may

  • still try out this example program.

DATA : LS_MARA TYPE ZMARA,

L_MONTH(2) TYPE C,

L_DAY(2) TYPE C,

L_DATE(8) TYPE C.

ENDFORM. " GENERATE_ENTERIES

module pai input.

endmodule.

*&----


*

*& Form exit_program

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM exit_program .

LEAVE PROGRAM.

ENDFORM. " exit_program

*&----


*

*& Module PAI_INPUT INPUT

*&----


*

  • text

*----


*

MODULE PAI_INPUT INPUT.

OK_CODE = SY-UCOMM.

save_ok = ok_code.

clear ok_code.

case save_ok.

when 'EXIT'.

LEAVE TO SCREEN 0.

perform exit_program.

when others.

  • do nothing

endcase.

ENDMODULE. " PAI_INPUT INPUT