ALV sums using REUSE_ALV_LIST_DISPLAY
I am working in an old 4.0 system so I am using the function REUSE_ALV_LIST_DISPLAY to output my data, but I can't get teh ALV grid to include the totals button or indeed sum my values despite populating the field cat with 'Do_sum'.
Andy idead
ls_fieldcat-fieldname = 'KWMENG'.
ls_fieldcat-col_pos = '9'.
ls_fieldcat-ref_fieldname = 'KWMENG'.
ls_fieldcat-ref_tabname = 'GIT_DETAIL'.
ls_fieldcat-tabname = 'GIT_DETAIL'.
"ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = '14'.
ls_fieldcat-seltext_l = 'Order Qty'.
ls_fieldcat-do_sum = 'X'.
append ls_fieldcat to lit_fieldcat. clear ls_fieldcat.
* Displays the ALV grid
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = w_repid
it_fieldcat = lit_fieldcat[]
is_layout = x_layout
it_sort = lit_sort[]
i_callback_pf_status_set = w_status
i_callback_user_command = w_comm
i_save = 'X'
it_events = lit_event[]
i_grid_title = w_title
tables
t_outtab = git_detail[]
exceptions
program_error = 1
others = 2.
To display the totals in the grid display add the following logic where you are populating the field catalog.
IF fldname = 'AMOUNT'.
wa_fcat-do_sum = 'X'.
ENDIF.
APPEND wa_fcat TO i_fieldcat.
CLEAR wa_fcat.
To display the subtotals in the grid display.
FORM populate_sort .
Sort on material
wa_sort-spos = '01' .
wa_sort-fieldname = 'MATNR'.
wa_sort-tabname = 'T_MAT'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO it_sort .
CLEAR wa_sort.
ENDFORM. " populate_sort
Get the ALV grid event and pass the form name to subtotal_text event.
FORM get_events .
CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
'SUBTOTAL_TEXT'.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it event
EXCEPTIONS
list_type_wrong = 0
OTHERS = 0.
Subtotal
READ TABLE it_event INTO ls_event
WITH KEY name = slis_ev_subtotal_text.
IF sy-subrc = 0.
MOVE c_formname_subtotal_text TO ls_event-form.
MODIFY it_event FROM ls_event INDEX sy-tabix.
ENDIF.
ENDFORM.
FORM subtotal_text CHANGING
p_total TYPE any
p_subtot_text TYPE slis_subtot_text.
Material level sub total
IF p_subtot_text-criteria = 'MATNR'.
p_subtot_text-display_text_for_subtotal
= 'Material level total'(009).
ENDIF.
ENDFORM. "subtotal_text
After this just pass it_event and it_sort to the ALV grid display.
Hope this helps you.
Similar Messages
-
Read modified ALV Cell Data - REUSE_ALV_LIST_DISPLAY
Hi,
I am using REUSE_ALV_LIST_DISPLAY to display my ALV List. There is one editable field in this ALV output.
When user changes any value, In the ALV User Command, the updated value is not reflected.
I know, we use 'GET_GLOBALS_FROM_SLVC_FULLSCR' Function Module to get the updated data.
However its not working for me, as I am not using ALV Grid , but ALV List.
Please let me know, how to read the modified data while using ALV List.This is old post but i put this info just in case some people have the same issue:
In user command routine i pass two parameters: the command what the user intro and the info of the row was selected. In the info of the row you must update the field refresh with 'X' value and you must update your internal table was referenced in your alv function. this work just if you was set the hotspot and input field setting in the catalog of the ALV (in this example the field "marca")
FORM user_command USING p_ucomm LIKE sy-ucomm
lw_selfield TYPE slis_selfield.
CASE p_ucomm .
WHEN '&M_ALL'.
* mark field "marca" with 'X' value in all rows in it_totales_wf table
LOOP AT it_totales_wf.
lw_selfield-refresh = 'X'.
it_totales_wf-marca = 'X'.
MODIFY it_totales_wf INDEX sy-tabix.
ENDLOOP.
WHEN '&D_ALL'.
LOOP AT it_totales_wf.
* unmark field "marca" in all rows in it_totales_wf table
lw_selfield-refresh = 'X'.
CLEAR it_totales_wf-marca.
MODIFY it_totales_wf INDEX sy-tabix.
ENDLOOP.
WHEN '&IC1'.
lw_selfield-refresh = 'X'.
* mark field "marca" with in the row selected by the user in it_totales_wf table
IF lw_selfield-tabindex NE 0 AND lw_selfield-fieldname = 'MARCA'.
READ TABLE it_totales_wf INDEX lw_selfield-tabindex.
IF it_totales_wf-marca = 'X'.
CLEAR it_totales_wf-marca.
ELSE.
it_totales_wf-marca = 'X'.
ENDIF.
MODIFY it_totales_wf INDEX lw_selfield-tabindex.
ELSE.
LOOP AT it_totales_wf.
it_totales_wf-marca = 'X'.
MODIFY it_totales_wf.
ENDLOOP.
ENDIF.
ENDCASE. -
Can anyone tell me how to Copy a node on an ALV Tree using context menu ?
Hello Vidya
The sample report ZUS_SDN_ALVTREE_CTXMENU demonstrates how to copy nodes on an ALV tree.
Before showing the entire coding I would like to point out a few crucial parts of the coding:
(1) Defintion of OUTTAB list
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE vbak.
TYPES: nkey TYPE lvc_nkey.
TYPES: ntype TYPE lvc_value. " 'VKORG' / 'VTWEG' / 'SPART' / leaf
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
The OUTTAB list contains two additional fields holding the tree key (LVC_NKEY) and the node type.
(2) The main logic of the report is implemented in event handler method handle_node_ctxmenu_sel.
WHEN 'COPY_SUBTREE'.
CALL METHOD go_alvtree->get_subtree
EXPORTING
i_node_key = node_key
IMPORTING
et_subtree_nodes = lt_subtree.
CALL METHOD go_alvtree->get_parent
EXPORTING
i_node_key = node_key
IMPORTING
e_parent_node_key = ld_parent_key.
LOOP AT lt_subtree INTO ld_node_key.
READ TABLE gt_outtab INTO ls_outtab
WITH KEY nkey = ld_node_key.
APPEND ls_outtab TO lt_outtab.
ENDLOOP.
READ TABLE lt_outtab INTO ls_outtab INDEX 1.
ld_ntype = ls_outtab-ntype.
DELETE lt_outtab WHERE ( vbeln IS INITIAL ). " hierarchy nodes
CASE ld_ntype.
WHEN 'VKORG'.
ld_top_key = ld_parent_key.
WHEN 'VTWEG'.
ld_vkorg_key = ld_parent_key.
WHEN 'SPART'.
ld_vtweg_key = ld_parent_key.
WHEN 'LEAF'.
ld_spart_key = ld_parent_key.
ENDCASE.
" Note: similar logic like in routine CREATE_HIERARCHY
SORT lt_outtab BY vkorg vtweg spart kunnr audat.
LOOP AT lt_outtab INTO ls_outtab.
*& Report ZUS_SDN_ALVTREE_CTXMENU
*& Based on: BCALV_TREE_03
REPORT zus_sdn_alvtree_ctxmenu.
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE vbak.
TYPES: nkey TYPE lvc_nkey.
TYPES: ntype TYPE lvc_value. " 'VKORG' / 'VTWEG' / 'SPART' / leaf
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA:
gd_repid TYPE syst-repid,
gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_alvtree TYPE REF TO cl_gui_alv_tree.
DATA:
gt_outtab TYPE ty_t_outtab, " Sales Document
gt_fcat TYPE lvc_t_fcat.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
* §2. Define an event handler method to build up a context menu
* (postfix of event name: _CONTEXT_MENU_REQUEST).
* This event is fired each time the user klick with the right
* mouse button on a node.
CLASS-METHODS:
handle_node_ctxmenu_req
FOR EVENT node_context_menu_request OF cl_gui_alv_tree
IMPORTING
node_key
menu,
* §3. Define an event handler method to respond to a function code
* triggered by your menu (postfix: _CONTEXT_MENU_SELECTED).
* This event is fired when the user selects an entry of the
* build up context menu.
handle_node_ctxmenu_sel
FOR EVENT node_context_menu_selected OF cl_gui_alv_tree
IMPORTING
node_key
fcode
sender.
* 'sender' is an implicit event parameter that is provided by
* ABAP Objects runtime system. It contains a reference to the
* object that fired the event. You may directly use it to
* call methods of this instance.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
* §4. Implement your event handler methods.
METHOD handle_node_ctxmenu_req.
* Event parameter 'menu' holds a reference to the standard context
* menu of ALV Tree (functions 'Expand'/'Collapse' on nodes).
* You may either append your own functions (separated by a line)
* or clear the menu if you do not want to allow standard functions.
* In this case the standard menu is cleared.
CALL METHOD menu->clear.
* The next line defines one line of the context menu.
CALL METHOD menu->add_function
EXPORTING
fcode = 'DEL_SUBTREE'
text = 'Delete Subtree'(901). "Delete Subtree
CALL METHOD menu->add_function
EXPORTING
fcode = 'COPY_SUBTREE'
text = 'Copy Subtree'(902). "Copy Subtree
ENDMETHOD. "handle_node_ctxmenu_req
METHOD handle_node_ctxmenu_sel.
* At this point of execution, the user selected a menu entry of the
* menu build up in event handler method handle_node_cm_req.
* Query your own function codes and react accordingly.
DATA:
l_rc TYPE c,
ld_ntype TYPE lvc_value,
ld_parent_key TYPE lvc_nkey,
ld_node_key TYPE lvc_nkey,
lt_subtree TYPE lvc_t_nkey,
ls_outtab TYPE ty_s_outtab,
ls_last TYPE ty_s_outtab,
lt_outtab TYPE ty_t_outtab.
DATA:
ld_vkorg_key TYPE lvc_nkey,
ld_vtweg_key TYPE lvc_nkey,
ld_spart_key TYPE lvc_nkey,
ld_last_key TYPE lvc_nkey,
ld_top_key TYPE lvc_nkey.
CASE fcode.
WHEN 'DEL_SUBTREE'.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
textline1 = 'Do you really want to delete'(902)
textline2 = 'this node and all its subnodes?'(903)
titel = 'Confirmation'(904)
cancel_display = ' '
IMPORTING
answer = l_rc.
IF l_rc EQ 'J'.
CALL METHOD sender->delete_subtree
EXPORTING
i_node_key = node_key.
* Do not forget to refresh the display when you change the contents
* of your list.
CALL METHOD sender->frontend_update.
ENDIF.
WHEN 'COPY_SUBTREE'.
CALL METHOD go_alvtree->get_subtree
EXPORTING
i_node_key = node_key
IMPORTING
et_subtree_nodes = lt_subtree.
CALL METHOD go_alvtree->get_parent
EXPORTING
i_node_key = node_key
IMPORTING
e_parent_node_key = ld_parent_key.
LOOP AT lt_subtree INTO ld_node_key.
READ TABLE gt_outtab INTO ls_outtab
WITH KEY nkey = ld_node_key.
APPEND ls_outtab TO lt_outtab.
ENDLOOP.
READ TABLE lt_outtab INTO ls_outtab INDEX 1.
ld_ntype = ls_outtab-ntype.
DELETE lt_outtab WHERE ( vbeln IS INITIAL ). " hierarchy nodes
CASE ld_ntype.
WHEN 'VKORG'.
ld_top_key = ld_parent_key.
WHEN 'VTWEG'.
ld_vkorg_key = ld_parent_key.
WHEN 'SPART'.
ld_vtweg_key = ld_parent_key.
WHEN 'LEAF'.
ld_spart_key = ld_parent_key.
ENDCASE.
SORT lt_outtab BY vkorg vtweg spart kunnr audat.
LOOP AT lt_outtab INTO ls_outtab.
IF ( ld_ntype = 'VKORG' ).
" new sales organisation
IF ( ls_outtab-vkorg = ls_last-vkorg ).
ELSE.
PERFORM add_sales_org
USING
ls_outtab
ld_top_key
CHANGING
ld_vkorg_key.
ls_outtab-nkey = ld_vkorg_key.
ls_outtab-ntype = 'VKORG'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ENDIF.
ENDIF.
IF ( ld_ntype = 'VKORG' OR
ld_ntype = 'VTWEG' ).
" new distribution channel
IF ( ls_outtab-vkorg = ls_last-vkorg AND
ls_outtab-vtweg = ls_last-vtweg ).
ELSE.
PERFORM add_distrib_chan
USING
ls_outtab
ld_vkorg_key
CHANGING
ld_vtweg_key.
ls_outtab-nkey = ld_vtweg_key.
ls_outtab-ntype = 'VTWEG'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ENDIF.
ENDIF.
IF ( ld_ntype = 'VKORG' OR
ld_ntype = 'VTWEG' OR
ld_ntype = 'SPART' ).
" new channel
IF ( ls_outtab-vkorg = ls_last-vkorg AND
ls_outtab-vtweg = ls_last-vtweg AND
ls_outtab-spart = ls_last-spart ).
ELSE.
PERFORM add_division
USING
ls_outtab
ld_vtweg_key
CHANGING
ld_spart_key.
ls_outtab-nkey = ld_spart_key.
ls_outtab-ntype = 'SPART'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ENDIF.
ENDIF.
* Leaf:
PERFORM add_complete_line
USING
ls_outtab
ld_spart_key
CHANGING
ld_last_key.
ls_outtab-nkey = ld_last_key.
ls_outtab-ntype = 'LEAF'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ls_last = ls_outtab.
ENDLOOP.
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'REFRESH_TREE'
* IMPORTING
* RC =
ENDCASE.
ENDMETHOD. "handle_node_ctxmenu_sel
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
PERFORM init_controls.
* Link the docking container to the target dynpro
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
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.
CALL SCREEN '0100'.
* NOTE: no screen elements, ok_code -> gd_okcode
** PROCESS BEFORE OUTPUT.
** MODULE STATUS_0100.
** PROCESS AFTER INPUT.
** MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
TRANSLATE gd_okcode TO UPPER CASE. " facilitate manual entries
CASE gd_okcode.
WHEN 'BACK' OR
'EXIT' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
when 'REFRESH_TREE'.
CALL METHOD go_alvtree->update_calculations
* EXPORTING
* NO_FRONTEND_UPDATE =
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form INIT_CONTROLS
* text
* --> p1 text
* <-- p2 text
FORM init_controls .
DATA:
ls_hierarchy_header TYPE treev_hhdr.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
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.
CALL METHOD go_docking->set_extension
EXPORTING
extension = 99999 " full-size screen
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
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 tree control
CREATE OBJECT go_alvtree
EXPORTING
parent = go_docking
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = ' '
no_html_header = 'X'
no_toolbar = ''
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
PERFORM build_hierarchy_header CHANGING ls_hierarchy_header.
* Hide columns and sum up values initially using the fieldcatalog
PERFORM build_fieldcatalog.
* IMPORTANT: Table 'gt_sflight' must be empty. Do not change this table
* (even after this method call). You can change data of your table
* by calling methods of CL_GUI_ALV_TREE.
* Furthermore, the output table 'gt_outtab' must be global and can
* only be used for one ALV Tree Control.
CALL METHOD go_alvtree->set_table_for_first_display
EXPORTING
is_hierarchy_header = ls_hierarchy_header
CHANGING
it_fieldcatalog = gt_fcat
it_outtab = gt_outtab. "table must be empty !
PERFORM init_tree.
ENDFORM. " INIT_CONTROLS
*& Form INIT_TREE
* text
* --> p1 text
* <-- p2 text
FORM init_tree .
PERFORM create_hierarchy.
PERFORM register_events.
* Update calculations which were initially defined by field DO_SUM
* of the fieldcatalog. (see build_fieldcatalog).
CALL METHOD go_alvtree->update_calculations.
* Send data to frontend.
CALL METHOD go_alvtree->frontend_update.
ENDFORM. " INIT_TREE
*& Form build_hierarchy_header
* text
* <--P_LS_HIERARCHY_HEADER text
FORM build_hierarchy_header
CHANGING
cs_hierarchy_header TYPE treev_hhdr.
cs_hierarchy_header-heading =
'SalesOrg/DistChannel/Division'(300).
cs_hierarchy_header-tooltip = 'Customer: Master Sales Data'(400).
cs_hierarchy_header-width = 45.
cs_hierarchy_header-width_pix = ''.
ENDFORM. " build_hierarchy_header
*& Form build_fieldcatalog
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
REFRESH: gt_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'VBAK'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
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.
LOOP AT gt_fcat INTO ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'VBELN' OR
'AUDAT' OR
'AUART' OR
'WAERK' OR
'VKORG' OR
'VTWEG' OR
'SPART' OR
'BSTNK' OR
'KUNNR'.
WHEN 'NETWR'.
ls_fcat-do_sum = 'X'.
ls_fcat-h_ftype = 'SUM'. " or: 'MAX' / 'AVG'
WHEN OTHERS.
ls_fcat-tech = 'X'.
ENDCASE.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
ENDLOOP.
ENDFORM. " build_fieldcatalog
*& Form create_hierarchy
* text
* --> p1 text
* <-- p2 text
FORM create_hierarchy .
* define local data
DATA:
ls_outtab TYPE ty_s_outtab,
ls_last TYPE ty_s_outtab,
lt_outtab TYPE ty_t_outtab.
DATA:
ld_vkorg_key TYPE lvc_nkey,
ld_vtweg_key TYPE lvc_nkey,
ld_spart_key TYPE lvc_nkey,
ld_last_key TYPE lvc_nkey,
ld_top_key TYPE lvc_nkey.
" Select data
SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE lt_outtab
UP TO 1550 ROWS.
" sort table according to conceived hierarchy
SORT lt_outtab BY vkorg vtweg spart kunnr audat.
* Define one top node. In this way it is possible to calculate
* values for the whole hierarchy.
CALL METHOD go_alvtree->add_node
EXPORTING
i_relat_node_key = ''
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = 'Sales Documents'
IMPORTING
e_new_node_key = ld_top_key.
CLEAR: ls_outtab.
ls_outtab-nkey = ld_top_key.
ls_outtab-ntype = 'ROOT'.
MODIFY gt_outtab FROM ls_outtab INDEX 1
TRANSPORTING nkey ntype.
LOOP AT lt_outtab INTO ls_outtab.
" new sales organisation
IF ( ls_outtab-vkorg = ls_last-vkorg ).
ELSE.
PERFORM add_sales_org
USING
ls_outtab
ld_top_key
CHANGING
ld_vkorg_key.
ls_outtab-nkey = ld_vkorg_key.
ls_outtab-ntype = 'VKORG'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ENDIF.
" new distribution channel
IF ( ls_outtab-vkorg = ls_last-vkorg AND
ls_outtab-vtweg = ls_last-vtweg ).
ELSE.
PERFORM add_distrib_chan
USING
ls_outtab
ld_vkorg_key
CHANGING
ld_vtweg_key.
ls_outtab-nkey = ld_vtweg_key.
ls_outtab-ntype = 'VTWEG'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ENDIF.
" new channel
IF ( ls_outtab-vkorg = ls_last-vkorg AND
ls_outtab-vtweg = ls_last-vtweg AND
ls_outtab-spart = ls_last-spart ).
ELSE.
PERFORM add_division
USING
ls_outtab
ld_vtweg_key
CHANGING
ld_spart_key.
ls_outtab-nkey = ld_spart_key.
ls_outtab-ntype = 'SPART'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ENDIF.
* Leaf:
PERFORM add_complete_line
USING
ls_outtab
ld_spart_key
CHANGING
ld_last_key.
ls_outtab-nkey = ld_last_key.
ls_outtab-ntype = 'LEAF'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ls_last = ls_outtab.
ENDLOOP.
ENDFORM. " create_hierarchy
*& Form ADD_SALES_ORG
* text
* -->P_LS_OUTTAB text
* -->P_LD_TOP_KEY text
* <--P_LD_VKORG_KEY text
FORM add_sales_org
USING
value(us_outtab) TYPE ty_s_outtab
value(ud_relat_key) TYPE lvc_nkey
CHANGING
cd_node_key TYPE lvc_nkey.
* define local data
DATA:
ld_nodetext TYPE lvc_value,
ls_outtab TYPE ty_s_outtab.
ld_nodetext = us_outtab-vkorg.
" add node
CALL METHOD go_alvtree->add_node
EXPORTING
i_relat_node_key = ud_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = ld_nodetext
is_outtab_line = ls_outtab
IMPORTING
e_new_node_key = cd_node_key.
ENDFORM. " ADD_SALES_ORG
*& Form add_DISTRIB_CHAN
* text
* -->P_LS_OUTTAB text
* -->P_LD_VKORG_KEY text
* <--P_LD_VTWEG_KEY text
FORM add_distrib_chan
USING
value(us_outtab) TYPE ty_s_outtab
value(ud_relat_key) TYPE lvc_nkey
CHANGING
cd_node_key TYPE lvc_nkey.
* define local data
DATA:
ld_nodetext TYPE lvc_value,
ls_outtab TYPE ty_s_outtab.
ld_nodetext = us_outtab-vtweg.
" add node
CALL METHOD go_alvtree->add_node
EXPORTING
i_relat_node_key = ud_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = ld_nodetext
is_outtab_line = ls_outtab
IMPORTING
e_new_node_key = cd_node_key.
ENDFORM. " add_DISTRIB_CHAN
*& Form add_division
* text
* -->P_LS_OUTTAB text
* -->P_LD_VTWEG_KEY text
* <--P_LD_SPART_KEY text
FORM add_division
USING
value(us_outtab) TYPE ty_s_outtab
value(ud_relat_key) TYPE lvc_nkey
CHANGING
cd_node_key TYPE lvc_nkey.
* define local data
DATA:
ld_nodetext TYPE lvc_value,
ls_outtab TYPE ty_s_outtab.
ld_nodetext = us_outtab-spart.
" add node
CALL METHOD go_alvtree->add_node
EXPORTING
i_relat_node_key = ud_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = ld_nodetext
is_outtab_line = ls_outtab
IMPORTING
e_new_node_key = cd_node_key.
ENDFORM. " add_division
*& Form add_complete_line
* text
* -->P_LS_OUTTAB text
* -->P_LD_SPART_KEY text
* <--P_LD_LAST_KEY text
FORM add_complete_line
USING
value(us_outtab) TYPE ty_s_outtab
value(ud_relat_key) TYPE lvc_nkey
CHANGING
cd_node_key TYPE lvc_nkey.
* define local data
DATA:
ld_nodetext TYPE lvc_value,
ls_outtab TYPE ty_s_outtab.
WRITE us_outtab-kunnr TO ld_nodetext+0 NO-ZERO.
WRITE us_outtab-audat TO ld_nodetext+20 DD/MM/YYYY.
CONDENSE ld_nodetext.
" add node
CALL METHOD go_alvtree->add_node
EXPORTING
i_relat_node_key = ud_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = ld_nodetext
is_outtab_line = us_outtab " !!!
IMPORTING
e_new_node_key = cd_node_key.
ENDFORM. " add_complete_line
*& Form register_events
* text
* --> p1 text
* <-- p2 text
FORM register_events .
DATA:
lt_events TYPE cntl_simple_events,
ls_event TYPE cntl_simple_event.
* The following four tree events registers ALV Tree in the constructor
* method itself.
* - cl_gui_column_tree=>eventid_expand_no_children
* (needed to load data to frontend when a user expands a node)
* - cl_gui_column_tree=>eventid_header_context_men_req
* (needed for header context menu)
* - cl_gui_column_tree=>eventid_header_click
* (allows selection of columns (only when item selection activated))
* - cl_gui_column_tree=>eventid_item_keypress
* (needed for F1-Help (only when item selection activated))
* Nevertheless you have to provide their IDs again if you register
* additional events with SET_REGISTERED_EVENTS (see below).
* To do so, call first method GET_REGISTERED_EVENTS (this way,
* all already registered events remain registered, even your own):
CALL METHOD go_alvtree->get_registered_events
IMPORTING
events = lt_events.
* (If you do not these events will be deregistered!!!).
* You do not have to register events of the toolbar again.
* Register additional events for your own purposes:
* §5. Register first context menu event on frontend (with postfix
* (_REQUEST). The second is registered automatically.
ls_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
APPEND ls_event TO lt_events.
* register events on frontend
CALL METHOD go_alvtree->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
* §6. Register both context menu events on backend (ABAP Objects
* event handling).
SET HANDLER:
lcl_eventhandler=>handle_node_ctxmenu_req FOR go_alvtree,
lcl_eventhandler=>handle_node_ctxmenu_sel FOR go_alvtree.
ENDFORM. " register_events
Regards,
Uwe -
Doubt regarding editable ALV report using Classes
I need to create an ALV report and make few fields editable
and i need to update the changes to the corresponding database tables
for that please suggest me some idea or provide me sample code for that
urgentHi ramesh,
Please check this example program. I think it will help for some extent.
[code]&----
*& Report ZSUMA_INTERACTIVEREPORT *
report zsuma_interactivereport.
tables: vbak.
data :gr_alvgrid type ref to cl_gui_alv_grid,
gr_cc_name type scrfname value 'CC_ALV',
gr_ccontainer type ref to cl_gui_custom_container,
gr_fieldcat type lvc_t_fcat,
gr_layout type lvc_s_layo,
gr_sort type lvc_t_sort,
gr_get_cell type lvc_t_cell,
gr_set_cell type lvc_t_cell,
gr_hyper type lvc_t_hype,
gr_drop_down type lvc_t_drop,
is_variant type disvariant,
line_number type lvc_s_roid-row_id,
line(5) type c ,
cell_value type lvc_value.
data: begin of it_vbak occurs 0,
vbeln type vbak-vbeln,
erdat like vbak-erdat,
erzet like vbak-erzet,
netwr like vbak-netwr,
waerk like vbak-waerk,
*Below field is useful for making the entire row with different colors.
it must be a char of 4.and layout-info_fname should populate with
*this field.
rowcolor(4) type c,
*Below field is useful for making the INDIVIDUAL CELL with different
*colors.for this we have to include structure of type lvc_t_scol.
*layout-ctab_fname should be populate with this field.
cellcolor type lvc_t_scol,
*below field is added for for providing the hyperlinks to perticular
*field. at the time of field catalog , it_fcatalog-web_field should be
*populate with this field.
vbeln_hyper type int4,
*For displaying one cell as button.we have to declare one styles
*internal table .it has to be populate.at layout structure this table
*name has to be populate at layout-stylename.
cellstyle type lvc_t_styl,
end of it_vbak.
*& SELECTION SCREEN
selection-screen begin of block b1 with frame title text-001.
select-options s_vbeln for vbak-vbeln.
selection-screen end of block b1.
start-of-selection.
select vbeln
erdat
erzet
netwr
waerk
from vbak
into corresponding fields of table it_vbak
where vbeln in s_vbeln.
data: wa_cellcolor type lvc_s_scol,
wa_style type lvc_s_styl.
loop at it_vbak.
FOR ROW COLORING
if sy-tabix = 1.
it_vbak-rowcolor = 'C511'.
FOR PUTTING THE HYPERLINKS ON VBELN FIELD
it_vbak-vbeln_hyper = '1'.
modify it_vbak.
endif.
FOR CELL COLORING
if sy-tabix = 2.
wa_cellcolor-fname = 'ERZET'.
wa_cellcolor-color-col = '6'.
wa_cellcolor-color-int = '1'.
wa_cellcolor-color-inv = '1'.
append wa_cellcolor to it_vbak-cellcolor.
modify it_vbak index 2.
endif.
FOR DISPLAYING THE CELL AS A BUTTON
clear it_vbak-cellstyle.
at last.
read table it_vbak index sy-tabix.
wa_style-fieldname = 'NETWR'.
wa_style-style = cl_gui_alv_grid=>mc_style_button.
append wa_style to it_vbak-cellstyle .
modify it_vbak .
endat.
endloop.
if not it_vbak[] is initial.
call screen 100.
endif.
*CLASS DEFINITION FOR HANDLING THE EVENTS IN ALV GRID
class gr_event_handler definition.
public section.
methods:handle_hotspot_click
for event hotspot_click of cl_gui_alv_grid
importing e_row_id e_column_id es_row_no.
endclass.
*CLASS IMPLEMENTATIONFOR HANDLING THE EVENTS IN ALV GRID
class gr_event_handler implementation.
method handle_hotspot_click.
perform handle_hotspot_click using e_row_id e_column_id es_row_no.
endmethod.
endclass.
*& Form BUILDING_FIELDCATALOG
text
<--P_GR_FIELDCAT text
form building_fieldcatalog changing p_gr_fieldcat type lvc_t_fcat.
data s_fieldcat type lvc_s_fcat.
s_fieldcat-fieldname = 'VBELN'.
s_fieldcat-outputlen = '15'.
s_fieldcat-col_pos = '1'.
s_fieldcat-coltext = 'DOCCUMENT NO.'.
s_fieldcat-key = ' '.
s_fieldcat-emphasize = 'C511'.
s_fieldcat-web_field = 'VBELN_HYPER'.
append s_fieldcat to p_gr_fieldcat .
clear s_fieldcat.
s_fieldcat-fieldname = 'ERDAT'.
s_fieldcat-outputlen = '15'.
s_fieldcat-col_pos = '2'.
s_fieldcat-coltext = 'REC CREATE DATE.'.
s_fieldcat-emphasize = 'C311'.
s_fieldcat-hotspot = 'X'.
append s_fieldcat to p_gr_fieldcat .
clear s_fieldcat.
s_fieldcat-fieldname = 'ERZET'.
s_fieldcat-outputlen = '15'.
s_fieldcat-col_pos = '3'.
s_fieldcat-coltext = 'TIME ENTRY.'.
*S_FIELDCAT-EMPHASIZE = 'C311'.
append s_fieldcat to p_gr_fieldcat .
clear s_fieldcat.
s_fieldcat-fieldname = 'NETWR'.
s_fieldcat-outputlen = '15'.
s_fieldcat-col_pos = '4'.
s_fieldcat-emphasize = 'C311'.
s_fieldcat-coltext = 'NET WEIGHT.'.
s_fieldcat-do_sum = 'X'.
append s_fieldcat to p_gr_fieldcat .
clear s_fieldcat.
s_fieldcat-fieldname = 'WAERK'.
s_fieldcat-outputlen = '5'.
s_fieldcat-col_pos = '5'.
s_fieldcat-emphasize = 'C511'.
s_fieldcat-coltext = 'CURR.'.
FOR PUTTING THE DROP DOWN BOX.
s_fieldcat-drdn_hndl = '1'.
s_fieldcat-edit = 'X'.
append s_fieldcat to p_gr_fieldcat .
clear s_fieldcat.
endform. " BUILDING_FIELDCATALOG
*& Form CREATE_CCONTAINER_INSTANCE
text
--> p1 text
<-- p2 text
form create_ccontainer_instance .
create object gr_ccontainer
exporting
container_name = gr_cc_name
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.
endform. " CREATE_CCONTAINER_INSTANCE
*& Form CREATE_ALVGRID_INSTANCE
text
--> p1 text
<-- p2 text
form create_alvgrid_instance .
create object gr_alvgrid
exporting
i_parent = gr_ccontainer
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.
endform. " CREATE_ALVGRID_INSTANCE
*& Form DISPLAYING_ALVGRID
text
--> p1 text
<-- p2 text
form displaying_alvgrid .
call method gr_alvgrid->set_table_for_first_display
exporting
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
is_variant = is_variant
i_save = 'A'
I_DEFAULT = 'X'
is_layout = gr_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
it_hyperlink = gr_hyper
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
changing
it_outtab = it_vbak[]
it_fieldcatalog = gr_fieldcat
it_sort = gr_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.
*CALL METHOD GR_ALVGRID->GET_FRONTEND_LAYOUT
IMPORTING
ES_LAYOUT = GR_LAYOUT
*GR_LAYOUT-GRID_TITLE = 'HAI ALV'.
*CALL METHOD GR_ALVGRID->SET_FRONTEND_LAYOUT
EXPORTING
IS_LAYOUT = GR_LAYOUT
endform. " DISPLAYING_ALVGRID
*& Form REFRESH_DISPLAY_TABLE
text
--> p1 text
<-- p2 text
form refresh_display_table .
call method gr_alvgrid->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
exceptions
finished = 1
others = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " REFRESH_DISPLAY_TABLE
*& Form SETTING_LAYOUT
text
<--P_GR_LAYOUT text
form setting_layout changing p_gr_layout type lvc_s_layo.
p_gr_layout-grid_title = 'ALV GRID USING ABAP OBJECTS'.
p_gr_layout-zebra = 'X'.
p_gr_layout-no_toolbar = ''.
p_gr_layout-sel_mode = 'D'.
p_gr_layout-info_fname = 'ROWCOLOR'.
p_gr_layout-ctab_fname = 'CELLCOLOR'.
p_gr_layout-stylefname = 'CELLSTYLE'.
endform. " SETTING_LAYOUT
*& Module STATUS_0100 OUTPUT
text
module status_0100 output.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
set pf-status 'MENU'.
if gr_alvgrid is initial.
*CREATING THE CONTAINER INSTANCE BY SENDING THE CONTAINER NAME( IT HAS
*TO COINSIDE WITH COSTUM CONTROL NAME OF TRANSACTION SCREEN
perform create_ccontainer_instance.
perform create_alvgrid_instance.
*VARIANT POPULATION.
perform setting_variants changing is_variant.
*BELOW FORM IS USEFUL TO FILL THE HYPER LINK TABLE AND WE PASS THAT
*TABLE TO 'IT_HYPERLINK' PARAMETER IN FIRST DISPLAY METHOD.
perform setting_hyperlinks_field changing gr_hyper.
*TO MAKE THE COLOUMN AS DROP DOWN.
perform setting_dropdown_column changing gr_drop_down.
perform building_fieldcatalog changing gr_fieldcat.
perform setting_layout changing gr_layout.
perform setting_sorting changing gr_sort.
perform setting_cells changing gr_set_cell.
perform displaying_alvgrid.
*PERFORM GETTING_CELL_DETAILS CHANGING GR_GET_CELL. " IT IS NOT WORKING
FOR ME AND I HAVE DOUBT .
perform creating_event_object.
*PERFORM REFRESH_DISPLAY_TABLE.
endif.
endmodule. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
module user_command_0100 input.
case sy-ucomm.
when 'BACK'.
leave to screen 000.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
*& Form SETTING_SORTING
text
<--P_GR_SORT text
form setting_sorting changing p_gr_sort type lvc_t_sort.
data: lr_sort type lvc_s_sort.
lr_sort-spos = '1'.
lr_sort-fieldname = 'VBELN'.
lr_sort-up = 'X'.
append lr_sort to p_gr_sort.
lr_sort-spos = '2'.
lr_sort-fieldname = 'ERDAT'.
lr_sort-up = 'X'.
append lr_sort to p_gr_sort.
endform. " SETTING_SORTING
*& Form GETTING_CELL_DETAILS
text
<--P_GR_GET_CELL text
form getting_cell_details changing p_gr_get_cell.
call method gr_alvgrid->get_selected_cells
importing
et_cell = p_gr_get_cell
*CELL_VALUE = P_GR_GET_CELL-VALUE.
endform. " GETTING_CELL_DETAILS
*& Form SETTING_CELLS
text
<--P_GR_SET_CELL text
form setting_cells changing p_gr_set_cell type lvc_t_cell.
data:s_gr_set_cell type lvc_s_cell.
s_gr_set_cell-col_id-fieldname = 'NETWR'.
s_gr_set_cell-row_id-index = '3'.
append s_gr_set_cell to p_gr_set_cell.
call method gr_alvgrid->set_selected_cells
exporting
it_cells = p_gr_set_cell.
endform. " SETTING_CELLS
*& Form SETTING_HYPERLINKS_FIELD
text
<--P_GR_HYPER text
form setting_hyperlinks_field changing p_gr_hyper type lvc_t_hype.
data: is_hype type lvc_s_hype.
is_hype-handle = '1'.
is_hype-href = 'HTTP://WWW.GOOGLE.CO.IN'.
append is_hype to p_gr_hyper.
is_hype-handle = '2'.
is_hype-href = 'HTTP://SDN.SAP.COM'.
append is_hype to p_gr_hyper.
endform. " SETTING_HYPERLINKS_FIELD
*& Form SETTING_DROPDOWN_COLUMN
text
<--P_GR_DROP_DOWN text
form setting_dropdown_column changing p_gr_drop_down type lvc_t_drop.
data: wa_drop type lvc_s_drop.
wa_drop-handle = '1'.
wa_drop-value = '$'.
append wa_drop to p_gr_drop_down.
wa_drop-handle = '1'.
wa_drop-value = 'Rs'.
append wa_drop to p_gr_drop_down.
wa_drop-handle = '1'.
wa_drop-value = 'CUR'.
append wa_drop to p_gr_drop_down.
call method gr_alvgrid->set_drop_down_table
exporting
it_drop_down = p_gr_drop_down
IT_DROP_DOWN_ALIAS =
endform. " SETTING_DROPDOWN_COLUMN
*& Form SETTING_VARIANTS
text
<--P_IS_VARIANT text
form setting_variants changing p_is_variant type disvariant.
p_is_variant-report = sy-repid.
endform. " SETTING_VARIANTS
*& Form HANDLE_HOTSPOT_CLICK
text
-->P_E_ROW text
-->P_E_COLUMN text
-->P_E_ROW_NO text
form handle_hotspot_click using p_e_row_id type lvc_s_row
p_e_column_id type lvc_s_col
p_es_row_no type lvc_s_roid.
read table it_vbak index p_es_row_no-row_id.
if sy-subrc = 0 and p_e_column_id-fieldname = 'ERDAT'.
line = p_es_row_no-row_id.
line_number = p_es_row_no-row_id.
leave to screen 200.
endif.
endform. " HANDLE_HOTSPOT_CLICK
*& Form CREATING_EVENT_OBJECT
text
--> p1 text
<-- p2 text
form creating_event_object .
data event_handle type ref to gr_event_handler.
create object event_handle.
set handler event_handle->handle_hotspot_click for gr_alvgrid.
endform. " CREATING_EVENT_OBJECT
*& Module STATUS_0200 OUTPUT
text
module status_0200 output.
set pf-status 'BB'.
SET TITLEBAR 'xxx'.
*LINE = LINE_NUMBER.
endmodule. " STATUS_0200 OUTPUT
*& Module USER_COMMAND_0200 INPUT
text
module user_command_0200 input.
if sy-ucomm = 'BACK'.
leave to screen 100.
endif.
endmodule. " USER_COMMAND_0200 INPUT[/code]
Reward points if helpful
Thanks,
Suma. -
One editable cell in alv grid using function module
Hello all,
Any one have an idea how to make a single editable cell in alv grid using function module, i mean to say
with out using object oriented programming.
Regards,
PrakashHi,
Using ALV List display it is possible.
Try this.
TYPE-POOLS:SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:IT_EVENTS TYPE SLIS_T_EVENT.
data: begin of it_chg occurs 0,
index type sy-tabix,
end of it_chg.
DATA: X_EVENTS TYPE SLIS_ALV_EVENT.
DATA: BEGIN OF ITAB OCCURS 0,
NAME(10) TYPE C,
ZTERM TYPE C,
END OF ITAB.
PERFORM FILL_TABLE.
loop at itab where zterm = 'A'.
it_chg-index = sy-tabix + 3.
" addition 3 IS FOR FIELD LABELS
append it_chg.
clear it_chg.
endloop.
DATA:L_POS TYPE I VALUE 1.
CLEAR: L_POS.
L_POS = L_POS + 1.
**fieldcatalog
X_FIELDCAT-FIELDNAME = 'NAME'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-FIELDNAME = 'ZTERM'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
**events
REFRESH:IT_EVENTS.
CLEAR:X_EVENTS,IT_EVENTS.
X_EVENTS-NAME = SLIS_EV_END_OF_LIST.
X_EVENTS-FORM = 'MODIFY_LIST'.
APPEND X_EVENTS TO IT_EVENTS.
CLEAR X_EVENTS.
END-OF-SELECTION.
data lv_repid type sy-repid.
lv_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = lv_REPID
IT_FIELDCAT = IT_FIELDCAT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*& Form FILL_TABLE
text
FORM FILL_TABLE.
ITAB-NAME = 'AAA'.
ITAB-ZTERM = 'A'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'ABC'.
ITAB-ZTERM = 'B'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'TEST'.
ITAB-ZTERM = 'C'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'BBB'.
ITAB-ZTERM = 'D'.
APPEND ITAB.
clear itab.
ITAB-NAME = '123'.
ITAB-ZTERM = 'E'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'GEN'.
ITAB-ZTERM = 'A'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'ALV'.
ITAB-ZTERM = 'F'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'ALVTEST'.
ITAB-ZTERM = 'A'.
APPEND ITAB.
clear itab.
ENDFORM. "FILL_TABLE
*& Form MODIFY_LIST
text
FORM MODIFY_LIST.
data: l_lines type i.
describe table itab lines l_lines.
L_LINES = L_LINES + 3.
"because we have 3 lines extra occupied by lables.
"if we have header,i mean top of page add the no.of lines
"how many ever top of page have + 3 for labels.
DO L_LINES TIMES.
read table it_chg with key INDEX = sy-index.
if sy-subrc = 0.
**This code is for reading the out put line
**and modify accordinlg to our requiremnet.
**don't chnage this.
READ LINE SY-INDEX INDEX SY-LSIND.
IF SY-SUBRC = 0.
MODIFY LINE SY-INDEX INDEX SY-LSIND
FIELD FORMAT ITAB-NAME INPUT.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. "MODIFY_LIST -
How to read a checkbox in ALV (FM used)
Hi Experts,
I have generated an ALV grid using funtion module. There are 9 coloumns with checkbox col at first position. Each row has a checkbox. Now I want to read that particular row for which the checkbox is checked. Kindly tell me the procedure.
Points will be awarded...
Thanks,
Vishal S.Hi
1. You will have to make the field editable. In the field catalog set the EDIT = 'X' for the check box field.
2. Once the check box is checked, call the method CHECK_CHANGED_DATA of the grid in the PAI of the screen which will update the internal table. Now, you can just loop at the internal table with a where clause on the check box field.
loop at itab where checkbox = 'x'.
endloop.
same thread...
Re: Output Format for Amount in SAP Script PO
Re: Checkbox in ALV
Steps..
In the layout you need to have the BOX_FIELDNAME with a value..Let's say BOX
Declare the same value BOX in the internal table that you display in the output..
Then if the check box is selected...automatically the internal table will be filled X in the BOX column..
Check this example..
TYPE-POOLS: slis.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
DATA: s_layout TYPE slis_layout_alv.
DATA: BEGIN OF itab OCCURS 0,
icon TYPE icon-id,
vbeln TYPE vbeln,
kunnr TYPE kunnr,
erdat TYPE erdat,
box TYPE c,
END OF itab.
DATA: v_repid TYPE syrepid.
START-OF-SELECTION.
Get the data.
SELECT vbeln kunnr erdat UP TO 100 ROWS
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE itab.
IF sy-subrc <> 0.
MESSAGE s208(00) WITH 'No data found'.
LEAVE LIST-PROCESSING.
ENDIF.
Modify the record with red light.
itab-icon = '@0A@'.
MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.
v_repid = sy-repid.
Get the field catalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'ICON'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-seltext_l = 'Status'.
s_fieldcatalog-icon = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'VBELN'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'KUNNR'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'KUNNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'ERDAT'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'ERDAT'.
APPEND s_fieldcatalog TO t_fieldcatalog.
Set the layout.
s_layout-box_fieldname = 'BOX'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fieldcatalog[]
TABLES
t_outtab = itab.
FORM SET_PF_STATUS *
--> EXTAB *
FORM set_pf_status USING extab TYPE slis_t_extab.
SET PF-STATUS 'TEST2'.
ENDFORM.
FORM user_command *
--> UCOMM *
--> SELFIELD *
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
Check the ucomm.
IF ucomm = 'DETAIL'.
LOOP AT itab WHERE box = 'X'.
itab-icon = '@08@'.
MODIFY itab TRANSPORTING icon.
ENDLOOP.
ENDIF.
selfield-refresh = 'X'.
ENDFORM.
<b>Reward if usefull</b> -
DIfference between Reusable FM for ALV display and ALV display using class
Hi,
Is there any difference between alv display using Resuable FM and ALV display using classes except the later one uses OO concept.??
One mere thing i want to clarify is that is there any difference exist between REUSE_ALV_GRID_DISPLAY and REUSE_ALV_LIST_DISPLAY? If so, then let me know.
It could be easier to understand me if yuo give scenario where these FM comes into picture
Regards,
ParagHi,
(1) REUSE_ALV_LIST_DISPLAY
Display an ALV list as per parameters defined in the function call
(2) REUSE_ALV_GRID_DISPLAY
Display an ALV grid as per parameters defined in the function call
(3) REUSE_ALV_COMMENTARY_WRITE
List header information is output according to its type. The output information is put in an internal table. Output attributes are assigned to each line via the TYP field.This module outputs formatted simple header information at TOP-OF-PAGE.
(4) REUSE_ALV_HIERSEQ_LIST_DISPLAY
This module outputs two internal tables as a formated hierarchical-sequential list.
(5) REUSE_ALV_VARIANT_F4
Display variant selection dialog box.
(6) REUSE_ALV_VARIANT_EXISTENCE
Checks whether a display variant exists.
Other Useful Link :
Customize ALV grid layout at run time
Download ALV grid Control Tutorial
Understand ALV report ( Just Copy and paste )
Dynamic selection on ALV at run time
Dynamic selection on ALV at run time
Regards
Kiran -
How to place header and footer in OO-ALV program using class
How to place header and footer in OO-ALV program using class tell me wat r the class we shold use and their attributes as well
Hi Venkatesh,
Take a look at this how to [ABAP Objects - ALV Model - Using Header and Footer|https://wiki.sdn.sap.com/wiki/x/xdw]
it's explaining how to define the classes and use it for display an ALV with Header and Footer.
Regards,
Marcelo Ramos -
Hi ,
have been working on a ALV report using the class SALV cl_salv_hierseq_table
I am facing few issues pertaining to two things:
1. Displaying some subtotal text along with the subtotals.
Example refer the standard demo example: SALV_DEMO_HIERSEQ_FORM_EVENTS
Now instead of A 17 and A26 I would like to show text like Subtotal for the Carrid.for subtotals and grand totals
Like Subtotal for A 17 is : XXXXXXX
GrandTotal is : YYYYYY
2. We have a page break and a new page for every purchasing group as in the standard example SALV_DEMO_HIERSEQ_FORM_EVENTS for CARRID.
I need to display some variable values as number of documents ,total number of records etc at the end of each CARRID group before a new page starts for the next CARRID.Please note i do not want it on every page.it should only be diaplyed at the end of page whose next page would be for next CARRID.[basically at end of every carrid]Example:after displaying all details for AA need to display the number of records for that carrid at the end of the page[as page break is based on CARRID]/
Thanks
Jyotsnaat end of page event, for CL_SALV_EVENTS_HIERSEQ, has some useful parameters allowing to know where you are at the time of event
parameter VALUE is of type CL_SALV_FORM which contains public attribute IF_SALV_FORM~ACCDESCRIPTION; you can slo get contents of it
about text of total/subtotal, this is normally set in the layout -
Download alv report using layout variant in background
Hi All,
I want to download an Alv report using layout varaint in background job.
can any one please help me.
i.e...
I am facing a problem in downloading a text file to the Application server.
My requirement is, when the user downloads a file with the layout variant, the file should have only the columns which was selected in the variant.
Will rewards to helpfull ans
regards
Chetanhey seshu,
I am facing a problem in downloading a text file to the Application server.
My requirement is, when the user downloads a file with the layout variant, the file should have only the columns which was selected in the variant. -
ALV report using the field catalog
which is the quickest way to generate an ALV report using the field catalog merge. without needing to build the field catalog manually .
is it easier to create a structure and passe it in the field catalog merge . if yes can i have an example plzzzzhI
Supports the creation of the field catalog for the ALV function modules
based either on a structure or table defined in the ABAP Data
Dictionary, or a program-internal table.
The program-internal table must either be in a TOP Include or its
Include must be specified explicitly in the interface.
The variant based on a program-internal table should only be used for
rapid prototyping since the following restrictions apply:
o Performance is affected since the code of the table definition must
always be read and interpreted at runtime.
o Dictionary references are only considered if the keywords LIKE or
INCLUDE STRUCTURE (not TYPE) are used.
If the field catalog contains more than 90 fields, the first 90 fields
are output in the list by default whereas the remaining fields are only
available in the field selection.
If the field catalog is passed with values, they are merged with the
'automatically' found information.
Below is an example ABAP program which will populate a simple internal table(it_ekpo) with data and
display it using the basic ALV grid functionality(including column total). The example details the main
sections of coding required to implement the ALV grid functionality:
Data declaration
Data retrieval
Build fieldcatalog
Build layout setup
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic requirement for this demo is to display a number of *
*& fields from the EKKO table. *
REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
* fieldcatalog-do_sum = 'X'.
* fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'. "Display column total
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
* i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
* i_callback_user_command = 'USER_COMMAND'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
* IT_EVENTS = GT_XEVENTS
i_save = 'X'
* is_variant = z_template
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
endform. " DATA_RETRIEVAL -
Disbable button on alv report using oops
Hi all,
I have a button to toll bar of alv grid using oops
based on that when the user clicks on that some action is performed and list is displayed again
now when the list is diaplyed i need the button that i added to be disabled so that the user cannot click it agin
i have everything i don't know how to disable the button.
USING THIS STATMENT move 'X' to ls_toolbar-disabled WE CAN DISABLE BUT I DON'T WHERE TO PASS IT..
LOCAL CLASSES: Definition
*===============================================================
class lcl_event_receiver: local class to
define and handle own functions.
Definition:
~~~~~~~~~~~
class lcl_event_receiver definition.
public section.
methods:
handle_toolbar
for event toolbar of cl_gui_alv_grid
importing e_object e_interactive,
handle_user_command
for event user_command of cl_gui_alv_grid
importing e_ucomm.
private section.
endclass.
lcl_event_receiver (Definition)
*===============================================================
LOCAL CLASSES: Implementation
*===============================================================
class lcl_event_receiver (Implementation)
class lcl_event_receiver implementation.
method handle_toolbar.
append a separator to normal toolbar
clear ls_toolbar.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
append an icon to show booking table
clear ls_toolbar.
move 'ADD' to ls_toolbar-function.
move icon_employee to ls_toolbar-icon.
move 'Show Bookings'(111) to ls_toolbar-quickinfo.
move 'Add Material'(112) to ls_toolbar-text.
move '' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
endmethod.
method handle_user_command.
case e_ucomm.
when 'ADD'.
call method g_grid->get_selected_rows
importing et_index_rows = lt_rows.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
add your handling, for example
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
else.
*tHIS IS THE PART IAM HAVING PROBLEM WITH
*class lcl_event_receiver implementation.
method handle_toolbar.
*clear : ls_toolbar.
loop at e_object->mt_toolbar into ls_toolbar WHERE FUNCTION = 'ADD'.
DELETE e_object->mt_toolbar FROM ls_toolbar.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
endloop.
*ENDMETHOD.
*ENDCLASS.
***tHIS IS THE PART
call method g_grid->refresh_table_display.
endif.
endcase.
endmethod.
Thanks in advanceHi
hI ALL,
MY QUESTION IS WHEN method handle_toolbaR WOULD BE TRIGERRED
first time i have the button enabled and when i press the button its get disabled.This is what i need
But iam trying to understand how this is working
Let me know whether iam right or not
when this piece of code would be triggered
method handle_toolbar.
clear ls_toolbar.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
clear ls_toolbar.
move 'ADD' to ls_toolbar-function.
move icon_employee to ls_toolbar-icon.
move 'Show Bookings'(111) to ls_toolbar-quickinfo.
move 'Add Material'(112) to ls_toolbar-text.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
IF FLAG = 'X'.
LOOP AT e_object->mt_toolbar INTO ls_toolbar.
if ls_toolbar-function = 'ADD'.
ls_toolbar-disabled = 'X'.
MODIFY e_object->mt_toolbar FROM ls_toolbar.
endif.
ENDLOOP.
ENDIF.
1 ) would this be triggered
when i call this call method g_grid->refresh_table_display.
2)or
call method g_grid->set_toolbar_interactive
This is my piece of code
class lcl_event_receiver definition.
public section.
methods:
handle_toolbar
for event toolbar of cl_gui_alv_grid
importing e_object e_interactive,
handle_user_command
for event user_command of cl_gui_alv_grid
importing e_ucomm.
private section.
endclass.
class lcl_event_receiver implementation.
method handle_toolbar.
clear ls_toolbar.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
clear ls_toolbar.
move 'ADD' to ls_toolbar-function.
move icon_employee to ls_toolbar-icon.
move 'Show Bookings'(111) to ls_toolbar-quickinfo.
move 'Add Material'(112) to ls_toolbar-text.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
IF FLAG = 'X'.
LOOP AT e_object->mt_toolbar INTO ls_toolbar.
if ls_toolbar-function = 'ADD'.
ls_toolbar-disabled = 'X'.
MODIFY e_object->mt_toolbar FROM ls_toolbar.
endif.
ENDLOOP.
ENDIF.
endmethod.
method handle_user_command.
case e_ucomm.
when 'ADD'.
call method g_grid->get_selected_rows
importing et_index_rows = lt_rows.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
else.
perform test.
call method g_grid->refresh_table_display.
endif.
endcase.
endmethod. "handle_user_command
odule status_0100 output.
SET PF-STATUS 'STATUS'.
set pf-status 'MAIN100'.
set titlebar 'HEADER_CHECK'.
if g_custom_container is initial.
create object g_custom_container
exporting container_name = g_container.
create object g_grid
exporting i_parent = g_custom_container.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'ZTEST'
changing
ct_fieldcat = fieldcat
exceptions
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.
g_layout-sel_mode = 'A'. " TO GET SELECTION BOX
call method g_grid->set_table_for_first_display
exporting
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = g_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
it_toolbar_excluding = pt_exclude
IT_HYPERLINK =
IT_ALV_GRAPHICS =
changing
it_outtab = i_zTEST
it_fieldcatalog = fieldcat
IT_SORT =
IT_FILTER =
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
create object event_receiver.
set handler event_receiver->handle_user_command for g_grid.
set handler event_receiver->handle_toolbar for g_grid.
call method g_grid->set_toolbar_interactive.
endif. "IF grid1 IS INITIAL
call method cl_gui_control=>set_focus exporting control = g_grid.
endmodule. " STATUS_0100 OUTPUT
Thanks
Suchitra -
Displaying items in a single line in ALV grid using ALV_TOP_OF_PAGE.
Hello Guys,
I am having a problem in displaying items in a single line in the ALV Grid using event ALV_TOP_OF_PAGE.
My requirement is to group items on a single line i.e. in the example below, Vendor code and posting date are on the same line. The next line the prints Vendor Name and Document no.
Vendor Code: 123123 Posting Date : 01.01.2011
Vendor Name: ABCD Document No: 152246598.
Here is my code in subroutine 'ALV_TOP_OF_PAGE',
wa_list_comments-typ = 'S'.
wa_list_comments-key = ''.
wa_list_comments-info = 'Vendor Code'.
APPEND wa_list_comments TO it_list_comments.
wa_list_comments-typ = 'S'.
wa_list_comments-key = ''.
wa_list_comments-info = 'Posting Date'.
APPEND wa_list_comments TO it_list_comments.
The above code prints in the following format i.e one below the other,
Vendor Code: 123123
Posting Date : 01.01.2011.
I also tried using HTML_TOP_OF_PAGE, but it didn't work.
Can anybody please help me out with this.
Regards,
Danish.Hi Danish,
Your problem is with the alignment and you need some fix positions .
The solution i feel is u can use as below :
In CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
use
i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE'.
Now on calling routine call use cl_dd_document class :
FORM html_top_of_page USING document TYPE REF TO cl_dd_document .
data : doctable TYPE REF TO cl_dd_table_element,
col1_t1 TYPE REF TO cl_dd_area,
col2_t1 TYPE REF TO cl_dd_area,
col1_t2 TYPE REF TO cl_dd_area,
col2_t2 TYPE REF TO cl_dd_area.
add quick table with five columns
CALL METHOD lw_document->add_table
EXPORTING
no_of_columns = 2
border = '0'
cell_background_transparent = ' '
width = '100%'
IMPORTING
table = doctable.
Filling columns in row
CALL METHOD doctable->add_column
EXPORTING
width = '40%'
IMPORTING
column = col1_t1.
Filling columns in row
CALL METHOD doctable->add_column
EXPORTING
width = '60%'
IMPORTING
column = col2_t1.* Filling columns in row
Call method doctable->new_row.
CALL METHOD doctable->add_column
EXPORTING
width = '40%'
IMPORTING
column = col1_t2.
Filling columns in row
CALL METHOD doctable->add_column
EXPORTING
width = '60%'
IMPORTING
column = col2_t2.
*Now adding the texts
lw_text1 = 'your first text'
CALL METHOD col1_t1->add_text
EXPORTING
text = lw_text.
*Similarly add text for other columns
*Adujust % in width to adjust the column as required
Endform.
Hope this will solve your problem . -
How to make a field manadatory within ALV Grid using methods and classes
Hi,
I am using ALV Grid using set_table_for_first_display
inside my dialog programming. I have a field called project number inside my grid which has to be made as mandatory field.
I have defined a method called catch_data_changed inside my class lcl_event_receiver. This method captures the changes made to one of the fields inside my ALV grid and displays all the default values of the other fields from the grid.
Now, i have to make project number which is one of my fields inside my ALV grid as mandatory. At the field catalog level i did not find any such option for making a field as required field.
Is there any other way, i can accomplish this within the ALV grid?from my understanding from ur question, i understood that u want the editable field inside alvgrid to be mandatory.
i dont know anthing in fieldcat, but u can try the following logic.
FORM DATA_CHANGED USING P_ER_DATA_CHANGED TYPE REF TO
CL_ALV_CHANGED_DATA_PROTOCOL .
DATA: L_VALUE TYPE LVC_VALUE,
ls_mod_cell type lvc_s_modi.
READ TABLE P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
if sy-subrc = 0.
CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
EXPORTING
I_ROW_ID = LS_MOD_CELL-row_id
I_FIELDNAME = LS_MOD_CELL-fieldname
IMPORTING
E_VALUE = L_VALUE.
IF LS_MOD_CELL-FIELDNAME <> 'fieldname what u want'
MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
ENDIF.
ELSE.
MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
ENDIF. -
Error whil adding Header to the ALV grid using OO
Hi Guys,
I want to display the Header for the ALV grid using Splitter .
when i am doing like that .I am getting a screen on the top of that screen I am getting a EMPTY screen .I don't know why likat.
What i need is just to display a Grid with header?Can anybody Please help me reagarding this problem.
the Code is Below.
*& Report Z_TEST_PGM
REPORT Z_TEST_PGM NO STANDARD PAGE HEADING
LINE-SIZE 120 MESSAGE-ID zotc.
Tables : CKMLMV003 , CKMLMV001.
TYPE-POOLS: slis.
Types : Begin of t_CKMLMV003_out,
WERKS type CKMLMV003-WERKS,
MATNR type CKMLMV003-MATNR,
MISCH_VERH type CKMLMV003-MISCH_VERH,
KALNR_BAL type CKMLMV003-KALNR_BAL,
GJAHR type CKMLMV003-GJAHR,
PERIO type CKMLMV003-PERIO,
MGTYP type CKMLMV003-MGTYP,
End of t_CKMLMV003_out,
Begin of t_CKMLMV001_out,
MATNR type CKMLMV001-MATNR,
KALNR type CKMLMV001-KALNR,
LIFNR_ND type CKMLMV001-LIFNR_ND,
EKORG_ND type CKMLMV001-EKORG_ND,
End of t_CKMLMV001_out,
Begin of t_CKMLMV003_Temp,
MATNR type CKMLMV003-MATNR,
GJAHR type CKMLMV003-GJAHR,
PERIO type CKMLMV003-PERIO,
End of t_CKMLMV003_Temp,
Begin of t_Final_out,
MATNR type CKMLMV003-MATNR,
GJAHR type CKMLMV003-GJAHR,
PERIO type CKMLMV003-PERIO,
WERKS type CKMLMV003-WERKS,
LIFNR_ND1 type CKMLMV001-LIFNR_ND,
MISCH_VERH1 type CKMLMV003-MISCH_VERH,
LIFNR_ND2 type CKMLMV001-LIFNR_ND,
MISCH_VERH2 type CKMLMV003-MISCH_VERH,
LIFNR_ND3 type CKMLMV001-LIFNR_ND,
MISCH_VERH3 type CKMLMV003-MISCH_VERH,
LIFNR_ND4 type CKMLMV001-LIFNR_ND,
MISCH_VERH4 type CKMLMV003-MISCH_VERH,
LIFNR_ND5 type CKMLMV001-LIFNR_ND,
MISCH_VERH5 type CKMLMV003-MISCH_VERH,
LIFNR_ND6 type CKMLMV001-LIFNR_ND,
MISCH_VERH6 type CKMLMV003-MISCH_VERH,
LIFNR_ND7 type CKMLMV001-LIFNR_ND,
MISCH_VERH7 type CKMLMV003-MISCH_VERH,
LIFNR_ND8 type CKMLMV001-LIFNR_ND,
MISCH_VERH8 type CKMLMV003-MISCH_VERH,
LIFNR_ND9 type CKMLMV001-LIFNR_ND,
MISCH_VERH9 type CKMLMV003-MISCH_VERH,
LIFNR_ND10 type CKMLMV001-LIFNR_ND,
MISCH_VERH10 type CKMLMV003-MISCH_VERH,
LIFNR_ND11 type CKMLMV001-LIFNR_ND,
MISCH_VERH11 type CKMLMV003-MISCH_VERH,
LIFNR_ND12 type CKMLMV001-LIFNR_ND,
MISCH_VERH12 type CKMLMV003-MISCH_VERH,
LIFNR_ND13 type CKMLMV001-LIFNR_ND,
MISCH_VERH13 type CKMLMV003-MISCH_VERH,
End of t_Final_out,
Begin of t_Final_out1,
MATNR type CKMLMV003-MATNR,
GJAHR type CKMLMV003-GJAHR,
PERIO type CKMLMV003-PERIO,
LIFNR_ND1 type CKMLMV001-LIFNR_ND,
MISCH_VERH1 type CKMLMV003-MISCH_VERH,
LIFNR_ND2 type CKMLMV001-LIFNR_ND,
MISCH_VERH2 type CKMLMV003-MISCH_VERH,
LIFNR_ND3 type CKMLMV001-LIFNR_ND,
MISCH_VERH3 type CKMLMV003-MISCH_VERH,
LIFNR_ND4 type CKMLMV001-LIFNR_ND,
MISCH_VERH4 type CKMLMV003-MISCH_VERH,
LIFNR_ND5 type CKMLMV001-LIFNR_ND,
MISCH_VERH5 type CKMLMV003-MISCH_VERH,
LIFNR_ND6 type CKMLMV001-LIFNR_ND,
MISCH_VERH6 type CKMLMV003-MISCH_VERH,
LIFNR_ND7 type CKMLMV001-LIFNR_ND,
MISCH_VERH7 type CKMLMV003-MISCH_VERH,
LIFNR_ND8 type CKMLMV001-LIFNR_ND,
MISCH_VERH8 type CKMLMV003-MISCH_VERH,
LIFNR_ND9 type CKMLMV001-LIFNR_ND,
MISCH_VERH9 type CKMLMV003-MISCH_VERH,
LIFNR_ND10 type CKMLMV001-LIFNR_ND,
MISCH_VERH10 type CKMLMV003-MISCH_VERH,
LIFNR_ND11 type CKMLMV001-LIFNR_ND,
MISCH_VERH11 type CKMLMV003-MISCH_VERH,
LIFNR_ND12 type CKMLMV001-LIFNR_ND,
MISCH_VERH12 type CKMLMV003-MISCH_VERH,
LIFNR_ND13 type CKMLMV001-LIFNR_ND,
MISCH_VERH13 type CKMLMV003-MISCH_VERH,
End of t_Final_out1.
Global Structures *
Data : i_CKMLMV003_str type t_CKMLMV003_out,
i_CKMLMV001_str type t_CKMLMV001_out,
i_Final_str type t_Final_out,
i_Final_str1 type t_Final_out,
i_CKMLMV003_Temp type t_CKMLMV003_Temp.
Global Internal Tables *
Data : i_CKMLMV003_out type standard table of t_CKMLMV003_out,
i_CKMLMV001_out type standard table of t_CKMLMV001_out,
i_Final_out type standard table of t_Final_out,
i_Final_out1 type standard table of t_Final_out.
ALV Report Internal tables *
DATA : t_fieldcatalog TYPE slis_t_fieldcat_alv,
s_fieldcatalog TYPE slis_fieldcat_alv,
t_basic_fieldcatalog TYPE slis_t_fieldcat_alv,
s_basic_fieldcatalog TYPE slis_fieldcat_alv,
t_sort TYPE slis_t_sortinfo_alv,
v_repid TYPE sy-repid.
*ALV Header declarations
Data: t_header type slis_t_listheader,
i_header_str type slis_listheader,
i_line_event_str TYPE slis_alv_event,
i_events TYPE slis_t_event,
wa_layout type slis_layout_alv.
Data : grid1 type ref to cl_gui_alv_grid,
g_custom_container1 type ref to cl_gui_custom_container,
grid2 type ref to cl_gui_alv_grid,
g_custom_container2 type ref to cl_gui_custom_container,
i_FCAT TYPE LVC_T_FCAT,
i_FCAT_str type lvc_s_fcat,
Structure for layout
i_layout_s TYPE lvc_s_layo,
gt_final1 type table of t_Final_out.
DATA: CCCONTAINER1 TYPE SCRFNAME VALUE 'CCCONTAINER1',
CCCONTAINER2 TYPE SCRFNAME VALUE 'CCCONTAINER2',
G_PARENT_TOP TYPE REF TO CL_GUI_CONTAINER ,
G_SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
G_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT,
G_PARENT_GRID TYPE REF TO CL_GUI_CONTAINER.
Global Variables *
Data :cnt(4) type n value '0',
g_plant type CKMLMV003-WERKS ,
g_QuanTStr type CKMLMV003-MGTYP ,
g_PurchOrg type CKMLMV001-EKORG_ND,
flag type n value '0',
g_cnt6 type n value '0',
g_cnt7 type n value '0',
g_cnt8 type n value '0',
g_cnt9 type n value '0',
g_cnt10 type n value '0',
g_cnt11 type n value '0',
g_cnt12 type n value '0',
g_cnt13 type n value '0'.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-011.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-006 for field s_matnr.
Select-Options : S_MATNR for CKMLMV003-MATNR .
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-007 for field S_WERKS.
SELECT-OPTIONS:S_WERKS for CKMLMV003-WERKS Default '2003'.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-008 for field S_GJAHR.
SELECT-OPTIONS:S_GJAHR for CKMLMv003-GJAHR default Sy-DATUM(4) .
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-009 for field S_PERIO.
SELECT-OPTIONS:S_PERIO for CKMLMV003-PERIO .
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(25) TEXT-010 for field P_MGTYP.
Parameters : P_MGTYP type CKMLMV003-MGTYP .
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN END OF BLOCK b1 .
At Selection-Screen on s_matnr .
Perform Validate_MatNumber.
At Selection-Screen on s_werks .
Perform Validate_CostingPlant.
At Selection-Screen on s_GJAHR .
Perform Validate_FiscalYear.
At Selection-Screen on s_PERIO .
Perform Validate_Period.
At Selection-Screen on p_MGTYP .
Perform Validate_QuantityStrType.
*& Form Validate_MatNumber
text
Form Validate_MatNumber.
DATA l_MATNR TYPE CKMLMV003-MATNR.
IF NOT S_MATNR[] IS INITIAL .
CLEAR L_MATNR.
SELECT single MATNR FROM CKMLMV003
INTO l_MATNR
WHERE MATNR = s_MATNR-LOW or MATNR = s_MATNR-HIGH.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE e999 WITH
'Enter a Valid Material Number'(001).
ENDIF.
ENDIF.
ENDFORM. "Validate_MatNumber
*& Form Validate_CostingPlant
text
Form Validate_CostingPlant.
DATA l_werks TYPE CKMLMV003-WERKS.
IF NOT S_WERKS[] IS INITIAL .
CLEAR L_WERKS.
SELECT single WERKS FROM T001W
INTO l_WERKS
WHERE WERKS = s_WERKS-low or WERKS = s_WERKS-high.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE e999 WITH
'Enter a Valid Costing Plant'(002).
ENDIF.
ENDIF.
ENDFORM. "Validate_CostingPlant
*& Form Validate_FiscalYear
text
Form Validate_FiscalYear.
DATA l_GJAHR TYPE CKMLMV003-GJAHR.
IF NOT S_GJAHR-low IS INITIAL or S_GJAHR-high IS INITIAL.
CLEAR L_GJAHR.
SELECT SINGLE GJAHR FROM CKMLMV003
INTO l_GJAHR
WHERE GJAHR LE sy-DATUM(4) .
IF NOT S_GJAHR-low LE sy-DATUM(4) or S_GJAHR-high LE sy-DATUM(4).
MESSAGE e999 WITH
'Enter a Valid Fiscal year'(003).
ENDIF.
ENDIF.
ENDFORM. "Validate_FiscalYear
*& Form Validate_Period
text
Form Validate_Period.
DATA l_PERIO TYPE CKMLMV003-PERIO.
IF NOT S_PERIO[] IS INITIAL .
CLEAR L_PERIO.
SELECT single PERIO FROM CKMLMV003
INTO l_PERIO
WHERE PERIO GE 1 and PERIO LE 12 .
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE e999 WITH
'Enter a Valid Period'(004).
ENDIF.
ENDIF.
ENDFORM. "Validate_Period
*& Form Validate_QuantityStrType
text
Form Validate_QuantityStrType.
DATA l_MGTYP TYPE CKMLMV003-MGTYP.
IF NOT p_MGTYP IS INITIAL.
CLEAR L_MGTYP.
SELECT SINGLE MGTYP FROM CKMLMV003
INTO l_MGTYP
WHERE MGTYP = p_MGTYP .
IF sy-subrc NE 0.
MESSAGE e999 WITH
'Enter a Valid Quantity Structure Type'(005).
ENDIF.
ENDIF.
ENDFORM. "Validate_QuantityStrType
INITIALIZATION of Fields
Class LCL_EVENT_HANDLER DEFINITION.
Public section.
Methods:
TOP_OF_PAGE for Event TOP_OF_PAGE OF CL_GUI_ALV_GRID
IMPORTING E_DYNDOC_ID.
ENDCLASS. "LCL_EVENT_HANDLER DEFINITION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
METHOD TOP_OF_PAGE.
Top-of-page event <br />
PERFORM EVENT_TOP_OF_PAGE USING G_DYNDOC_ID.
ENDMETHOD. "top_of_page
ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION
Data : G_HANDLER TYPE REF TO LCL_EVENT_HANDLER.
Initialization.
v_repid = sy-repid.
Start-of-Selection.
Perform get_CKMLMV003.
Perform get_CKMLMV001.
Perform Get_Finaldata.
Perform Layout_FieldCatalog.
call screen '101'.
Perform ALVGrid_Final_Display.
*& Form Layout_FieldCatalog
text
Form Layout_FieldCatalog.
s_fieldcatalog-col_pos = 1.
s_fieldcatalog-fieldname = 'MATNR'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-024.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 2.
s_fieldcatalog-fieldname = 'GJAHR'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-012.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 3.
s_fieldcatalog-fieldname = 'PERIO'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-013.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 4.
s_fieldcatalog-fieldname = 'WERKS'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-025.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 5.
s_fieldcatalog-fieldname = 'LIFNR_ND1'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-014.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 6.
s_fieldcatalog-fieldname = 'MISCH_VERH1'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-015.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 7.
s_fieldcatalog-fieldname = 'LIFNR_ND2'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-016.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 8.
s_fieldcatalog-fieldname = 'MISCH_VERH2'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-017.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 9.
s_fieldcatalog-fieldname = 'LIFNR_ND3'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-018.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 10.
s_fieldcatalog-fieldname = 'MISCH_VERH3'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-019.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 11.
s_fieldcatalog-fieldname = 'LIFNR_ND4'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-020.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 12.
s_fieldcatalog-fieldname = 'MISCH_VERH4'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-021.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 13.
s_fieldcatalog-fieldname = 'LIFNR_ND5'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-022.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 14.
s_fieldcatalog-fieldname = 'MISCH_VERH5'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-seltext_l = Text-023.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
if g_cnt6 <> '0'.
s_fieldcatalog-col_pos = 14.
s_fieldcatalog-fieldname = 'LIFNR_ND6'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-022.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 15.
s_fieldcatalog-fieldname = 'MISCH_VERH6'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-023.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
ENDIF.
if g_cnt7 <> '0'.
s_fieldcatalog-col_pos = 16.
s_fieldcatalog-fieldname = 'LIFNR_ND7'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-022.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 17.
s_fieldcatalog-fieldname = 'MISCH_VERH7'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-023.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
ENDIF.
if g_cnt8 <> '0'.
s_fieldcatalog-col_pos = 18.
s_fieldcatalog-fieldname = 'LIFNR_ND8'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-022.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 19.
s_fieldcatalog-fieldname = 'MISCH_VERH8'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-023.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
ENDIF.
if g_cnt9 <> '0'.
s_fieldcatalog-col_pos = 20.
s_fieldcatalog-fieldname = 'LIFNR_ND9'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-022.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 21.
s_fieldcatalog-fieldname = 'MISCH_VERH9'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-023.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
ENDIF.
if g_cnt10 <> '0'.
s_fieldcatalog-col_pos = 22.
s_fieldcatalog-fieldname = 'LIFNR_ND10'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-022.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 23.
s_fieldcatalog-fieldname = 'MISCH_VERH10'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-023.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
ENDIF.
if g_cnt11 <> '0'.
s_fieldcatalog-col_pos = 24.
s_fieldcatalog-fieldname = 'LIFNR_ND11'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-022.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 25.
s_fieldcatalog-fieldname = 'MISCH_VERH11'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-023.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
ENDIF.
if g_cnt12 <> '0'.
s_fieldcatalog-col_pos = 26.
s_fieldcatalog-fieldname = 'LIFNR_ND12'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-022.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 27.
s_fieldcatalog-fieldname = 'MISCH_VERH12'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-023.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
ENDIF.
if g_cnt13 <> '0'.
s_fieldcatalog-col_pos = 29.
s_fieldcatalog-fieldname = 'LIFNR_ND13'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-022.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
s_fieldcatalog-col_pos = 30.
s_fieldcatalog-fieldname = 'MISCH_VERH13'.
s_fieldcatalog-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
s_fieldcatalog-seltext_l = Text-023.
append s_fieldcatalog to t_fieldcatalog.
clear s_fieldcatalog.
ENDIF.
ENDFORM. "Layout_FieldCatalog
*& Form get_CKMLMV003
text
Form get_CKMLMV003.
Select WERKS
MATNR
MISCH_VERH
KALNR_BAL
GJAHR
PERIO
MGTYP
from CKMLMV003
into table i_CKMLMV003_out
Where ( MATNR in s_MATNR and
WERKS in s_WERKS and
GJAHR in s_GJAHR and
PERIO in s_PERIO and
MGTYP = p_MGTYP ).
Sort i_CKMLMV003_out by MATNR KALNR_BAL.
ENDFORM. "get_CKMLMV003
*& Form get_CKMLMV001
text
Form get_CKMLMV001.
If Not i_CKMLMV003_out is Initial.
Select MATNR
KALNR
LIFNR_ND
EKORG_ND
from CKMLMV001
into Table i_CKMLMV001_out
for all entries in i_CKMLMV003_out
Where ( KALNR = i_CKMLMV003_out-KALNR_BAL
and WERKS = i_CKMLMV003_out-WERKS
and MATNR = i_CKMLMV003_out-MATNR ).
sort i_CKMLMV001_out by MATNR KALNR.
ENDIF.
ENDFORM. "get_CKMLMV001
*& Form Get_Finaldata
text
Form Get_Finaldata.
Loop at i_CKMLMV001_out into i_CKMLMV001_str.
Loop at i_CKMLMV003_out into i_CKMLMV003_str.
If ( i_CKMLMV001_str-KALNR = i_CKMLMV003_str-KALNR_BAL and i_CKMLMV003_str-MATNR = i_CKMLMV001_str-MATNR ) .
If ( flag = 0 ).
g_plant = i_CKMLMV003_str-WERKS.
g_PurchOrg = i_CKMLMV001_str-EKORG_ND.
g_quantstr = i_CKMLMV003_str-MGTYP.
flag = 1.
ENDIF.
Move i_CKMLMV003_str-MATNR to i_Final_str-MATNR.
Move i_CKMLMV003_str-WERKS to i_Final_str-WERKS.
Move i_CKMLMV003_str-GJAHR to i_Final_str-GJAHR.
Move i_CKMLMV003_str-PERIO to i_Final_str-PERIO.
Move i_CKMLMV003_str-MISCH_VERH to i_Final_str-MISCH_VERH1.
Move i_CKMLMV001_str-LIFNR_ND to i_Final_str-LIFNR_ND1.
Move-Corresponding i_CKMLMV003_str to i_CKMLMV003_temp.
Append i_Final_str to i_Final_out.
Clear : i_CKMLMV003_str .
ENDIF.
ENDLOOP.
Clear : i_CKMLMV001_str , i_Final_str , i_CKMLMV003_temp.
ENDLOOP.
Sort i_Final_out by WERKS MATNR GJAHR PERIO .
Loop at i_Final_out into i_Final_str.
if i_Final_str-MATNR = i_Final_str1-MATNR and i_Final_str-GJAHR = i_Final_str1-GJAHR and i_Final_str-PERIO = i_Final_str1-PERIO and i_Final_str-WERKS = i_Final_str1-WERKS.
cnt = cnt + 1.
Case cnt.
When 2.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH2.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND2.
When 3.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH3.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND3.
When 4.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH4.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND4.
When 5.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH5.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND5.
When 6.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH6.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND6.
g_cnt6 = 1.
When 7.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH7.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND7.
g_cnt7 = 1.
When 8.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH8.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND8.
g_cnt8 = 1.
When 9.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH9.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND9.
g_cnt9 = 1.
When 10.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH10.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND10.
g_cnt10 = 1.
When 11.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH11.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND11.
g_cnt11 = 1.
When 12.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH12.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND12.
g_cnt12 = 1.
When 13.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH13.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND13.
g_cnt13 = 1.
ENDCASE.
ELSE.
if cnt GE 1 .
append i_Final_str1 to i_Final_out1.
Clear : i_Final_str1.
ENDIF.
Move-Corresponding i_Final_str to i_Final_str1.
cnt = 0.
cnt = cnt + 1.
ENDIF.
Clear : i_Final_str.
Endloop.
append i_Final_str1 to i_Final_out1.
if i_Final_str-MATNR = i_Final_str1-MATNR and i_Final_str-GJAHR = i_Final_str1-GJAHR and i_Final_str-PERIO = i_Final_str1-PERIO .
cnt = cnt + 1.
Case cnt.
When 2.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH2.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND2.
When 3.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH3.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND3.
When 4.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH4.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND4.
When 5.
Move i_Final_str-MISCH_VERH1 to i_Final_str1-MISCH_VERH5.
Move i_Final_str-LIFNR_ND1 to i_Final_str1-LIFNR_ND5.
ENDCASE.
**Move-Corresponding i_Final_str to i_Final_str1.
ELSE.
if cnt GE 1 .
append i_Final_str1 to i_Final_out1.
Clear : i_Final_str1.
ENDIF.
Move-Corresponding i_Final_str to i_Final_str1.
cnt = 0.
cnt = cnt + 1.
ENDIF.
Clear : i_Final_str.
Endloop.
append i_Final_str1 to i_Final_out1.
ENDFORM. "Get_Finaldata
*& Form top_of_page
text
Form top_of_page.
clear t_header.
refresh t_header.
i_header_str-typ = 'H'.
I_header_Str-info = Text-035.
append I_header_str to t_header.
clear I_header_str.
Date
I_header_str-typ = 'S'.
I_header_str-key = Text-036.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO I_header_str-info. "todays date
append I_header_str to t_header.
clear: I_header_str.
i_header_str-typ = 'S'.
I_header_Str-Key = 'Quantity Structure Type :'.
I_header_Str-info = g_QuantStr.
append I_header_str to t_header.
clear I_header_str.
i_header_str-typ = 'S'.
I_header_Str-Key = 'Purchase Org :'.
I_header_Str-info = g_PurchOrg.
append I_header_str to t_header.
clear I_header_str.
i_header_str-typ = 'S'.
I_header_Str-Key = 'Plant :'.
I_header_Str-info = g_Plant.
append I_header_str to t_header.
clear I_header_str.
CLEAR i_line_event_str.
i_line_event_str-name = 'TOP_OF_PAGE'.
APPEND i_line_event_str TO i_events.
call function 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
i_logo = 'Z_LOGO'.
ENDFORM. "top_of_page
*& ALVGrid_Final_Display
Form ALVGrid_Final_Display.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_DEFAULt = c_valx
i_callback_top_of_page = 'TOP_OF_PAGE'
i_Save = c_valx
it_fieldcat = t_fieldcatalog
it_sort = t_sort
it_events = I_events
TABLES
t_outtab = i_final_out1.
ENDFORM. "ALVGrid_Final_Display
*& Form ALVGRID_OO_Display
text
Form ALVGRID_OO_Display.
i_FCAT_str-col_pos = 1.
i_FCAT_str-fieldname = 'MATNR'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_fcat_str-seltext = 'MATERIAL'.
i_fcat_str-scrtext_m = Text-024.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 2.
i_FCAT_str-fieldname = 'GJAHR'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_fcat_str-scrtext_m = Text-012.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 3.
i_FCAT_str-fieldname = 'PERIO'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_fcat_str-scrtext_m = Text-013.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 4.
i_FCAT_str-fieldname = 'WERKS'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_FCAT_str-scrtext_m = Text-025.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 5.
i_FCAT_str-fieldname = 'LIFNR_ND1'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_fcat_str-scrtext_m = Text-014.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 6.
i_FCAT_str-fieldname = 'MISCH_VERH1'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_FCAT_str-scrtext_m = Text-015.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 7.
i_FCAT_str-fieldname = 'LIFNR_ND2'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_FCAT_str-scrtext_m = Text-016.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 8.
i_FCAT_str-fieldname = 'MISCH_VERH2'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_FCAT_str-scrtext_m = Text-017.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 9.
i_FCAT_str-fieldname = 'LIFNR_ND3'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_FCAT_str-scrtext_m = Text-018.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 10.
i_FCAT_str-fieldname = 'MISCH_VERH3'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_FCAT_str-scrtext_m = Text-019.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 11.
i_FCAT_str-fieldname = 'LIFNR_ND4'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_FCAT_str-scrtext_m = Text-020.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 12.
i_FCAT_str-fieldname = 'MISCH_VERH4'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_FCAT_str-scrtext_m = Text-021.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 13.
i_FCAT_str-fieldname = 'LIFNR_ND5'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_FCAT_str-scrtext_m = Text-022.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 14.
i_FCAT_str-fieldname = 'MISCH_VERH5'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
i_FCAT_str-scrtext_m = Text-023.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
if g_cnt6 <> '0'.
i_FCAT_str-col_pos = 15.
i_FCAT_str-fieldname = 'LIFNR_ND6'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
i_FCAT_str-scrtext_m = Text-022.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
i_FCAT_str-col_pos = 16.
i_FCAT_str-fieldname = 'MISCH_VERH6'.
i_FCAT_str-tabname = 'I_FINAL_OUT1'.
s_fieldcatalog-NO_OUT = 'X'.
i_FCAT_str-scrtext_m = Text-023.
append i_FCAT_str to i_FCAT.
clear i_FCAT_str.
ENDIF.
*if not grid1 is Initial.
If sy-SUBRC = 0.
Call Method grid1->set_table_for_first_display
CHANGING
it_outtab = i_final_out1[]
it_fieldcatalog = I_FCAT
EXCEPTIONS
Invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
Others = 4.
If sy-subrc <> 0.
ENDIF.
CALL METHOD G_DYNDOC_ID->INITIALIZE_DOCUMENT
EXPORTING
BACKGROUND_COLOR = CL_DD_AREA=>COL_TEXTAREA.
Processing events <br />
CALL METHOD GRID1->LIST_PROCESSING_EVENTS
EXPORTING
I_EVENT_NAME = 'TOP_OF_PAGE'
I_DYNDOC_ID = G_DYNDOC_ID.
Call Method grid2->set_table_for_first_display
CHANGING
it_outtab = i_final_out1[]
it_fieldcatalog = I_FCAT
EXCEPTIONS
Invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
Others = 4.
If sy-subrc <> 0.
ENDIF.
ENDIF.
ENDIF.
Endform. "ALVGRID_OO_Display
Form EVENT_TOP_OF_PAGE using DG_DYNDOC_ID
TYPE REF TO CL_DD_DOCUMENT.
DATA : DL_TEXT(255) TYPE C.
CALL METHOD DG_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = 'Flight Details'
SAP_STYLE = CL_DD_AREA=>HEADING
SAP_FONTSIZE = CL_DD_AREA=>LARGE
SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
Endform.
*& Module STATUS_0101 OUTPUT
text
MODULE STATUS_0101 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
SET PF-STATUS 'STATUS'.
SET TITLEBAR 'TITLE'.
Create Object G_DYNDOC_ID
EXPORTING STYLE = 'ALV_GRID'.
if g_custom_container1 is initial .
create object g_custom_container1
Exporting
Container_name = CCCONTAINER1
Exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
Others = 5.
Create Object G_SPLITTER
Exporting PARENT = g_custom_container1.
CALL METHOD G_SPLITTER->GET_CONTAINER
EXPORTING
ROW = 1
COLUMN = 1
RECEIVING
CONTAINER = G_PARENT_TOP.
*Assigning the Part 2 to GRID
CALL METHOD G_SPLITTER->GET_CONTAINER
EXPORTING
ROW = 2
COLUMN = 1
RECEIVING
CONTAINER = g_parent_grid.Hi,
Check if any event is triggered from the event handler class, upon selection.
Usually, the events are handled on double click or on hotspot etc.
Regards,
Satish Kanteti
Maybe you are looking for
-
Inserting new rows in a JSP multi-row page
Hi all. I´ve been implementing a JSP multi-row editable page according to the paper: http://www.oracle.com/technology/products/jdev/tips/mills/JSP_Multi_Row_Edits.html I noted that the code provided in the example just considers handling updates fro
-
Can mac mini bitstream HD-audio to a reciver?
Hello, i am realy interested in the mac mini, but i just want to know if it can bitstream HD-audio, what i know it cant play it but how about bitstream, it dont need to do ennything with the audio and the reciver will do the decoding, ? Thanks all
-
10R2 installer 64-bit or 32-bit?
Hi all, I have some doubts here. I have an installation DVD for Oracle Database 10g R2 for HP-UX Itanium, but I am not sure if it is for 64-bit or 32-bit; it's not printed on the DVD. I also went to the 10g download page on OTN, again it is not menti
-
I've got a PDF file that came from a scanned book. Bookmarks have been added, but no OCR performed. The pages are huge (I'm guessing about 100cm x 150cm as I don't know how to check). Acrobat 9 Pro can't do OCR as the pages are too big (see, I told y
-
Hi, I have a table with the following fields: material component a material contents one or more components and it could happen that a material could content itself in whatever level. For example: material component material component materia