Sort Icon/option in ALV tree repot using classes and methods
Hi all,
I have done an alv tree report using the class cl_gui_alv_tree
and i need to let users re-sort the report by using a sort icon(as visible in a normal alv report).Is there any possibility to create an icon and set the functionality such that the entire tree structure gets resorted depending upon the sort criteria?Please give me an example of doing so if there is an option.
if u want without classes then i can give an example of Sort Icon/option.
example:-
DATA: wa_sortinfo TYPE slis_sortinfo_alv.
i_sortcat TYPE slis_t_sortinfo_alv.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = report_id
i_grid_title = ws_title
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = wa_layout
it_fieldcat = i_fieldcat[]
it_sort = i_sortcat
i_save = 'A'
it_events = i_events
TABLES
t_outtab = i_reportdata1
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.
PERFORM sortcat_init CHANGING i_sortcat.
FORM sortcat_init CHANGING i_sortcat TYPE slis_t_sortinfo_alv.
CLEAR wa_sortinfo.
wa_sortinfo-fieldname = 'EBELN'. (sales order)
wa_sortinfo-tabname = 'I_REPORTDATA1'.
wa_sortinfo-spos = 1. " First sort by this field.
wa_sortinfo-up = 'X'. " Ascending
wa_sortinfo-subtot = 'X'. " Subtotal at Name1
APPEND wa_sortinfo TO i_sortcat.
CLEAR wa_sortinfo.
wa_sortinfo-fieldname = 'EBELP'.
wa_sortinfo-tabname = 'I_REPORTDATA1'.
wa_sortinfo-spos = 2. " Sec sort by this field.
wa_sortinfo-up = 'X'. " Ascending
wa_sortinfo-subtot = 'X'. " Subtotal at Name1
APPEND wa_sortinfo TO i_sortcat.
ENDFORM. " sortcat_init
Similar Messages
-
List display for ALV using class and methods
Hi friends
I want the list display for the ALV using Class and methods
which class and methods i can use.
Here we can't use the REUSE_ALV_LIST_DISPLAY and also GRID
I was done GRID display using class and methods but i want only list display for using class.
plz Give me sample code of list display not for grid.
Thanks
Nani.hi
please check with this code...
declare grid and container.
DATA : o_alvgrid TYPE REF TO cl_gui_alv_grid,
o_dockingcontainer TYPE REF TO cl_gui_docking_container,
i_fieldcat TYPE lvc_t_fcat,"fieldcatalogue
w_layout TYPE lvc_s_layo."layout
If any events like double click,etc., are needed we have to add additional functionality.
call the screen in program.
Then , create the container as follows
IF cl_gui_alv_grid=>offline( ) IS INITIAL.
CREATE OBJECT o_dockingcontainer
EXPORTING
ratio = '95'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
ENDIF.
CREATE OBJECT o_alvgrid
EXPORTING
i_parent = o_dockingcontainer.
Build the fieldcatalog
create a output structure in SEll for the ALV output
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = <alv output>
CHANGING
ct_fieldcat = i_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE i030."Error in building the field catalogue
LEAVE LIST-PROCESSING.
ENDIF.
*If you need to modify the field catalog,modify it using field sysmbols
*setting the layout
w_layout-grid_title = title.
w_layout-zebra = 'X'.
then displaying the output
CALL METHOD o_alvgrid->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = w_layout
CHANGING
it_outtab = i_output[]
it_fieldcatalog = i_fieldcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE i032 ."Error in Displaying
LEAVE LIST-PROCESSING.
ENDIF.
*After that in PAI of the screen, you need to free the *object while going back from the screen(according to *your requirement)
MODULE user_command_9001 INPUT.
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
PERFORM f9600_free_objects:
USING o_alvgrid 'ALV' text-e02,
USING o_dockingcontainer 'DOCKING'
text-e01.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT
*in the program, write the follwoing code
FORM f9600_free_objects USING pobject
value(ptype)
value(ptext).
DATA: l_objectalv TYPE REF TO cl_gui_alv_grid.
CASE ptype.
WHEN 'ALV'.
l_objectalv = pobject.
IF NOT ( l_objectalv IS INITIAL ).
CALL METHOD l_objectalv->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CLEAR: pobject, l_objectalv.
PERFORM f9700_error_handle USING ptext.
ENDIF.
WHEN 'DOCKING'.
DATA: lobjectdock TYPE REF TO cl_gui_docking_container.
lobjectdock = pobject.
IF NOT ( lobjectdock IS INITIAL ).
CALL METHOD lobjectdock->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CLEAR: pobject, lobjectdock.
PERFORM f9700_error_handle USING ptext.
ENDIF.
WHEN 'CONTAINER'.
DATA: lobjectcontainer TYPE REF TO cl_gui_container.
lobjectcontainer = pobject.
IF NOT ( lobjectcontainer IS INITIAL ).
CALL METHOD lobjectcontainer->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CLEAR: pobject, lobjectcontainer.
PERFORM f9700_error_handle USING ptext.
ENDIF.
WHEN OTHERS.
sy-subrc = 1.
PERFORM f9700_error_handle USING
text-e04.
ENDCASE.
ENDFORM. " f9600_free_objects
FORM f9700_error_handle USING value(ptext).
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = text-e03
txt2 = sy-subrc
txt1 = ptext.
ENDIF.
endform.
also check with this
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
Hope this helps
if it helped, you can acknowledge the same by rewarding
regards
dinesh -
Can I use classes and methods for a maintenance view events?
Hello experts,
Instead of perform/form, can I instead use classes and methods, etc for a given maintenance view event, lets say for example I want to use event '01' which is before saving records in the database. Help would be greatly appreciated. Thanks a lot guys!Hi viraylab,
1. The architecture provided by maintenance view
for using EVENTS and our own code inside it -
It is provided using FORM/PERFORM
concept only.
2. At this stage,we cannot use classes.
3. However, inside the FORM routine,
we can write what ever we want.
We can aswell use any abap code, including
classes and methods.
(But this classes and methods won't have any
effect on the EVENT provided by maintenance view)
regards,
amit m. -
Automatic Display of NEW Data in ALV Report using Classes and Methods
Hi,
I have developed a ALV Report for displaying data from a set of DB tables using ABAP OO, Classes and Methods. The requirement is to have the report output to be automatically updated with the new entries from the DB table at a regular frequency of tiem may be every two minutes.
Could anyone please tell me how can this be acheived.
Thanks and regards,
Raghavendra Goutham P.Yes its possible.
Take a look at this thread
Auto refresh of ALV Grid, without user interaction
Or Rich's blog
/people/rich.heilman2/blog/2005/10/18/a-look-at-clguitimer-in-46c
Regards,
Ravi
Note : Please mark all the helpful answers -
How we can use class and methods for the FM of reuse_alv_list_display
Hi Abapers,
Please provide the sample code of class and method of REUSE_ALV_LIST_DISPLAY.
Which Class i can use for this Function module.
I need to write a code using OOPS concept.
I was done the GRID display using this class cl_gui_alv_grid.
But i want only List Display using the class & methods.
Plz provide sample code.
Thanks
Nani.Hi Nani,
This is the sample code..
*& Report Z_OO_ALV
*& We can Use Two containers in OOALV
REPORT z_oo_alv LINE-COUNT 50.
*types gt_struct type sflight.
DATA BEGIN OF gt_struct.
INCLUDE STRUCTURE sflight.
DATA rcol(4) TYPE c.
DATA colors TYPE lvc_t_scol.
DATA END OF gt_struct.
*ALV GRIDs
DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid.
DATA gr_alvgrid1 TYPE REF TO cl_gui_alv_grid.
DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
DATA gc_custom_control_name1 TYPE scrfname VALUE 'CC_ALV1'.
*CONTAINERs
DATA gr_ccontainer TYPE REF TO cl_gui_custom_container.
DATA gr_ccontainer1 TYPE REF TO cl_gui_custom_container.
*FIELDCATALOGs
DATA gt_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
DATA gt_fieldcat1 TYPE lvc_t_fcat WITH HEADER LINE.
*LAYOUTs
DATA gs_layout TYPE lvc_s_layo.
DATA gs_layout1 TYPE lvc_s_layo.
DATA pt_exclude TYPE ui_functions. "internal table declaration to be passed.
*DATA pt_cell TYPE lvc_t_cell with header line.
DATA : gt_list LIKE gt_struct OCCURS 50 WITH HEADER LINE,
gt_list1 LIKE gt_struct OCCURS 50 WITH HEADER LINE.
*DATA v_ucomm TYPE sy-ucomm.
CALL SCREEN 100.
*& Module display_alv OUTPUT
text
MODULE display_alv OUTPUT.
PERFORM display_alv.
ENDMODULE. " display_alv OUTPUT
*& Module PAI INPUT
text
MODULE pai INPUT.
CASE sy-ucomm.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'PICK'.
PERFORM cell_info.
ENDCASE.
ENDMODULE. " PAI INPUT
*& Form display_alv
text
FORM display_alv.
PERFORM prepare_field_catalog CHANGING gt_fieldcat[].
PERFORM prepare_layout CHANGING gs_layout.
PERFORM data_retrival.
IF gr_alvgrid IS INITIAL.
CREATE OBJECT gr_ccontainer
EXPORTING
container_name = gc_custom_control_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.
ENDIF.
CREATE OBJECT gr_alvgrid
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = gr_ccontainer
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
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.
PERFORM exclude_tb_functions CHANGING pt_exclude.
PERFORM set_col.
CALL METHOD gr_alvgrid->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 = gs_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
it_toolbar_excluding = pt_exclude "excluding toolbar functions
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
it_outtab = gt_list[]
it_fieldcatalog = gt_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.
ELSE.
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.
ENDIF.
PERFORM prepare_field_catalog1 CHANGING gt_fieldcat1[].
PERFORM prepare_layout1 CHANGING gs_layout1.
PERFORM data_retrival1.
IF gr_alvgrid1 IS INITIAL.
CREATE OBJECT gr_ccontainer1
EXPORTING
container_name = gc_custom_control_name1
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.
ENDIF.
CREATE OBJECT gr_alvgrid1
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = gr_ccontainer1
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
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.
PERFORM set_col1.
CALL METHOD gr_alvgrid1->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 = gs_layout1
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
it_outtab = gt_list1[]
it_fieldcatalog = gt_fieldcat1[]
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.
ELSE.
CALL METHOD gr_alvgrid1->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.
ENDIF.
ENDFORM. "display_alv
*& Form prepare_field_catalog
text
-->GT_FIELDCAT text
FORM prepare_field_catalog CHANGING pgt_fieldcat TYPE lvc_t_fcat.
DATA ls_fieldcat TYPE lvc_s_fcat.
ls_fieldcat-tabname = 'gt_list'.
ls_fieldcat-fieldname = 'CARRID'.
ls_fieldcat-scrtext_m = 'Air line code'.
ls_fieldcat-col_pos = 0.
ls_fieldcat-outputlen = 10.
ls_fieldcat-emphasize = 'C400'.
ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO pgt_fieldcat.
ls_fieldcat-tabname = 'gt_list'.
ls_fieldcat-col_pos = 1.
ls_fieldcat-fieldname = 'CONNID'.
ls_fieldcat-scrtext_m = 'Connection code'.
ls_fieldcat-emphasize = 'C900'.
APPEND ls_fieldcat TO pgt_fieldcat.
ls_fieldcat-tabname = 'gt_list'.
ls_fieldcat-fieldname = 'PRICE'.
ls_fieldcat-scrtext_m = 'PRICE'.
APPEND ls_fieldcat TO pgt_fieldcat.
ENDFORM. "prepare_field_catalog
*& Form prepare_layout
text
-->GS_LAYOUT text
FORM prepare_layout CHANGING gs_layout TYPE lvc_s_layo.
gs_layout-stylefname = 'FIELD_STYLE'.
gs_layout-zebra = 'X'.
gs_layout-grid_title = 'FLIGHT'.
gs_layout-sel_mode = 'A'.
gs_layout-ctab_fname = 'COLORS'.
ENDFORM. "prepare_layout
*& Form data_retrival
text
FORM data_retrival.
SELECT carrid
connid
price
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE gt_list
UP TO 50 ROWS.
ENDFORM. "data_retrival
FORM EXIT_PROGRAM *
FORM exit_program.
CALL METHOD gr_ccontainer->free.
CALL METHOD gr_ccontainer1->free.
LEAVE TO SCREEN 0.
ENDFORM. "exit_program
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STAT'.
SET TITLEBAR 'xxx'.
IF W_CUSTOM_CONTAINER IS INITIAL.
**sets TITLEBAR
PERFORM TITLEBAR.
ENDMODULE. " STATUS_0100 OUTPUT
*& Form prepare_field_catalog1
text
-->GT_FIELDCAT text
FORM prepare_field_catalog1 CHANGING pgt_fieldcat1 TYPE lvc_t_fcat.
DATA ls_fieldcat TYPE lvc_s_fcat.
ls_fieldcat-tabname = 'gt_list1'.
ls_fieldcat-fieldname = 'SEATSMAX'.
ls_fieldcat-scrtext_m = 'MAX. SEATS'.
ls_fieldcat-col_pos = 0.
ls_fieldcat-outputlen = 10.
ls_fieldcat-emphasize = 'C400'.
ls_fieldcat-key = ' '.
APPEND ls_fieldcat TO pgt_fieldcat1.
ls_fieldcat-tabname = 'gt_list1'.
ls_fieldcat-col_pos = 1.
ls_fieldcat-fieldname = 'SEATSOCC'.
ls_fieldcat-scrtext_m = 'SEATS OCCUPIED'.
APPEND ls_fieldcat TO pgt_fieldcat1.
ENDFORM. "prepare_field_catalog
*& Form prepare_layout1
text
-->GS_LAYOUT text
FORM prepare_layout1 CHANGING gs_layout1 TYPE lvc_s_layo.
gs_layout1-stylefname = 'FIELD_STYLE'.
gs_layout1-zebra = 'X'.
gs_layout1-grid_title = 'DETAILS'.
gs_layout-sel_mode = 'C'.
gs_layout1-info_fname = 'RCOL'.
gs_layout-no_toolbar = 'X'.
ENDFORM. "prepare_layout
*& Form data_retrival1
text
FORM data_retrival1.
SELECT seatsmax
seatsocc
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE gt_list1
UP TO 50 ROWS.
ENDFORM. "data_retrival
*& Form exclude_tb_functions
&---- subroutine to exclude toolbar options -
text
-->PT_EXCLUDE text
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
DATA ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_maximum.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_minimum.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_subtot.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_sort.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_subtot.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_sum.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_filter.
APPEND ls_exclude TO pt_exclude.
ENDFORM. "data_retrival1
*& Form cell_info
text
FORM cell_info. "CHANGING pt_cell TYPE lvc_t_cell.
DATA lt_cell TYPE lvc_t_cell WITH HEADER LINE.
CALL METHOD gr_alvgrid->get_selected_cells
IMPORTING
et_cell = lt_cell[].
LOOP AT lt_cell.
WRITE : lt_cell-col_id , lt_cell-row_id.
ENDLOOP.
MODIFY pt_cell[] from lt_cell[].
ENDFORM. "cell_info
*& Form set_col
text
FORM set_col .
DATA ls_cellcolor TYPE lvc_s_scol.
LOOP AT gt_list.
IF gt_list-price GT 500.
ls_cellcolor-fname = 'PRICE'.
ls_cellcolor-color-col = 5.
ls_cellcolor-color-int = 1.
ls_cellcolor-color-inv = 0.
APPEND ls_cellcolor TO gt_list-colors.
else.
ls_cellcolor-fname = 'PRICE'.
ls_cellcolor-color-col = 3.
ls_cellcolor-color-int = 1.
APPEND ls_cellcolor TO gt_list-colors.
ENDIF.
MODIFY gt_list.
ENDLOOP.
ENDFORM. "set_col
*& Form set_col1
text
FORM set_col1.
data : ind type sy-tabix,
indx type sy-tabix.
loop at gt_list1.
ind = sy-tabix / 2.
indx = sy-tabix - ind.
if indx eq ind.
gt_list1-rcol = 'C500'.
endif.
MODIFY gt_list1.
endloop.
ENDFORM. "set_col
*FORM TITLEBAR.
*SET TITLEBAR 'TITLE'.
*ENDFORM.
*double click on TITLE and write ur title
Thanks,
Samantak.
Rewards points for useful answers. -
Hi Experts,
I am studying ABAP Objects, before that I need to know How to use the exsiting classes and Methods in our program and how to search for particular class and methods?
If it explanied with example well and good.
Thanks
saiHi Saikar,
Here i am sending you very useful content for the usage of classes and its methods.
It helped me a lot.
If you find it useful then do not forget to award points.
Table of Contents
Applies to:......................................................................................................................................1
Summary........................................................................................................................................1
Author Bio......................................................................................................................................1
Main Class CL_SALV_TABLE......................................................................................................3
Functions CL_SALV_FUNCTIONS..............................................................................................4
Display Settings CL_SALV_DISPLAY_SETTINGS......................................................................4
Columns CL_SALV_COLUMNS_TABLE and CL_SALV_COLUMN_TABLE..............................5
Sorts CL_SALV_SORTS..............................................................................................................8
Aggregations CL_SALV_AGGREGATIONS..............................................................................10
Filters CL_SALV_FILTERS........................................................................................................12
Layouts CL_SALV_LAYOUT......................................................................................................14
Related Content...........................................................................................................................15
Disclaimer and Liability Notice.......................................................................................................16
ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 3
Main Class CL_SALV_TABLE
The main class used to create the simple 2D table is the class CL_SALV_TABLE. Create a reference variable for this class. Create an internal table and fill this internal table with data as show below.
REPORT ZALVOM_DEMO1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. start-of-selection. select * into table ispfli from spfli.
Next we need to create the ALV object for the 2D table. The FACTORY method allows you to create the ALV object in 3 ways. You can create the ALV Grid, as a classical list display, as a full screen grid, and finally embedded into a screen container. For this example, we will be working with the full screen grid. Create the call to the FACTORY method. We are importing the object reference into GR_TABLE and passing the internal table ISPFLI.
cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ).
Next we need to display the grid, for this we use the DISPLAY method . Simply call it.
gr_table->display( ).
ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 4
Functions CL_SALV_FUNCTIONS
Next, add functions to the application toolbar. For this, use the CL_SALV_FUNCTIONS class. Create the object reference variable and receive the object using the GET_FUNCTIONS method of the GR_TABLE object. Call the method SET_ALL to force the ALV grid to show all standard functions.
report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_table->display( ).
The result is now you have the standard buttons on the application toolbar.
Display Settings CL_SALV_DISPLAY_SETTINGS
Next, we can change some display settings using the class CL_SALV_DISPLAY_SETTINGS. Create the object reference variable and receive the object using the GET_DISPLAY_SETTINGS method of the GR_TABLE object. In this example, we are setting the Striped Pattern for the ALV Grid rows, and setting the heading in the title bar.
report zalvom_demo1.
ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 5
). data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' gr_table->display( ).
Columns CL_SALV_COLUMNS_TABLE and CL_SALV_COLUMN_TABLE
Next, we can change some of the attributes of a specific column in the ALV grid. In this example we will change the Heading Text of a column as well as the color of a column. Create the object reference variable and receive the object using the GET_COLUMNS method of the GR_TABLE object. This will pass you the object for all columns of the ALV grid. To access just one column, call the method GET_COLUMN from the GR_COLUMNS object. In this example, we are accessing the CITYTO column and the CITYFROM column.
report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions.
ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 6
data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table.
data: color type lvc_s_colo.
start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ).
gr_table->display( ).
ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 7 ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 8
Sorts CL_SALV_SORTS
Next, we can add some sorting to the ALV grid. Create the object reference variable and receive the object using the GET_SORTS method of the GR_TABLE object. Next, add the sort by calling the ADD_SORT method of the GR_SORTS object.
report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: gr_sorts type ref to cl_salv_sorts.
data: color type lvc_s_colo.
start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort 'CITYTO' ). gr_table->display( ).
ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 9 ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 10
Aggregations CL_SALV_AGGREGATIONS
Since we sorted by CITYTO, we can add an aggregation to subtotal the DISTANCE by CITYTO. Create the object reference variable and receive the object using the GET_AGGREGATIONS method of the GR_TABLE object. Next, add the aggregation by calling the ADD_AGGREGATION method of the GR_SORTS object. We also need to modify the call to ADD_SORT to set the SUBTOTAL = ABAP_TRUE.
report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: gr_sorts type ref to cl_salv_sorts. data: gr_agg type ref to cl_salv_aggregations.
data: color type lvc_s_colo.
start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ). gr_agg = gr_table->get_aggregations( ). gr_agg->add_aggregation( 'DISTANCE' ).
ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 11
gr_table->display( ).
ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 12
Filters CL_SALV_FILTERS
Using the CL_SALV_FILTERS class we can setup some filters for the data in our ALV GRID. Create the object reference variable and receive the object using the GET_FILTERS method of the GR_TABLE object, and then simply called the method ADD_FILTER with the parameters.
report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: gr_sorts type ref to cl_salv_sorts. data: gr_agg type ref to cl_salv_aggregations. data: gr_filter type ref to cl_salv_filters.
data: color type lvc_s_colo.
start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ). gr_agg = gr_table->get_aggregations( ). gr_agg->add_aggregation( 'DISTANCE' ).
ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 13
gr_filter = gr_table->get_filters( ). gr_filter->add_filter( columnname = 'CARRID' low = 'LH' ). gr_table->display( ).
ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 14
Layouts CL_SALV_LAYOUT
If you want to allow the user to manage layouts of the ALV grid, you must use the class CL_SALV_LAYOUT. Create the object reference variable and receive the object using the GET_LAYOUT method of the GR_TABLE object. Then simply call the method SET_KEY with the parameters and set the save restriction using the SET_SAVE_RESTRICTION method.
report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: gr_sorts type ref to cl_salv_sorts. data: gr_agg type ref to cl_salv_aggregations. data: gr_filter type ref to cl_salv_filters. data: gr_layout type ref to cl_salv_layout. data: color type lvc_s_colo. data: key type salv_s_layout_key. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ). gr_agg = gr_table->get_aggregations( ).
ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 15
gr_filter = gr_table->get_filters( ). gr_layout = gr_table->get_layout( ). gr_layout->set_key( ). gr_table->display( ). gr_agg->add_aggregation( 'DISTANCE' ). gr_filter->add_filter( columnname = 'CARRID' low = 'LH' ). key-report = sy-repid. key gr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
Related Content
Help - ALV Object Model
Utilizing the New ALV Object Model
SDN ABAP Forum
ALV Object Model Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 16
Disclaimer and Liability Notice
This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.
Regards,
Mandeep.
Note: Award points if contents are useful. -
Development of alv tree report using classes from basics
Hi,
Need a simple ALV tree report by showing the reason for why we are using the classse so that i can build a ALV report in the same manner.
i have the data from MARA for given materials and their descriptions.Now in the basiv out put MARA information should come and tree out put for the material description when the user selects the maerial.
A hot spot should come on the material and if he opts click the material then MM03 out put should come.
Help me out in this regard
Regards
NarenOk, but the importance of ABAP OO, should not be taken from an example ALV tree, but more in general. There are several good articles on this on SCN. But for example in this particular case (ALV Tree), you should already see the importance as far as object instances and inheritance is concerned. Without much work, you can create an instance of an ALV tree, and all the attributes, methods etc. are there for use. Some of the methods / attributes are inherited from other superclasses.
There are propably even more things to be mentioned here which emphasizes the importance of ABAP OO in ALV tree, but as far as I'm concerned, this is about it for me. -
Creating of Notes for Transaction Code RECN(Using Classes and Methods)
Hi Experts,
I want to Create Notes for Transaction Code RECN, This should not done manually but should be done programatically.
I had used the Class CL_GOS_SRV_NOTE_CREATE to create the notes.....but here comes the doubt for me.....note will be created by using this class and how this can be created for the Tcode RECN........
I am using the Real Estate Module.....Plz help me....awaiting for ur helpful answers....
Thanks in Advance.....!
BrahmaHi kanagaraja,
Thanks...!
The BADI which u have given is not existing in my system...i had gone through the se18 and se19 tcodes....
Awaiting for ur response......!
Thanks,
Brahma... -
Hi all,
I have developed a program for ALV Tree Hierarchy using OOPs.I followed the SAP demo program.I am not able to get the values in the output.Please can anyone guide me where to correct my program. I am placing the entire code so that you all can also debug and see what is wrong.
*& Report ZZHIERARCHY_TEST1
REPORT zzhierarchy_test1.
DATA : alv_container TYPE REF TO cl_gui_custom_container,
alv_tree TYPE REF TO cl_gui_alv_tree,
gt_fcat TYPE lvc_t_fcat,
gt_vbrk TYPE vbrk OCCURS 0. "Output Table
DATA : gs_hirarchy_header TYPE treev_hhdr.
START-OF-SELECTION.
END-OF-SELECTION.
CALL SCREEN 9100.
*& Module STATUS_9100 OUTPUT
MODULE status_9100 OUTPUT.
SET PF-STATUS 'ALV_TREE'.
IF alv_container IS INITIAL.
PERFORM tree_dev.
ENDIF.
ENDMODULE. " STATUS_9100 OUTPUT
*& Form tree_dev
text
FORM tree_dev .
DATA lv_container_name(20) TYPE c.
lv_container_name = 'ALV_TREE'.
CREATE OBJECT alv_container
EXPORTING
container_name = lv_container_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.
CREATE OBJECT alv_tree
EXPORTING
parent = alv_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
no_toolbar = ''
no_html_header = 'X'
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
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
PERFORM build_hirarchy_header CHANGING gs_hirarchy_header.
PERFORM buid_fieldcatalog.
CALL METHOD alv_tree->set_table_for_first_display
EXPORTING
is_hierarchy_header = gs_hirarchy_header
CHANGING
it_outtab = gt_vbrk "Table Must be Empty
it_fieldcatalog = gt_fcat.
PERFORM create_hierarchy.
CALL METHOD alv_tree->frontend_update.
ENDFORM. " tree_dev
*& Form build_hirarchy_header
<--P_GS_HIRARCHY_HEADER text
FORM build_hirarchy_header CHANGING p_gs_hirarchy_header TYPE treev_hhdr.
p_gs_hirarchy_header-heading = 'Company Code'(001).
p_gs_hirarchy_header-tooltip = 'Comapny Code'(002).
p_gs_hirarchy_header-width = 35.
p_gs_hirarchy_header-width_pix = ''.
ENDFORM. " build_hirarchy_header
*& Form buid_fieldcatalog
FORM buid_fieldcatalog .
DATA ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'VBRK'
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 'NETWR'.
ls_fcat-do_sum = 'X'.
ls_fcat-h_ftype = 'MAX'.
ENDCASE.
MODIFY gt_fcat FROM ls_fcat.
ENDLOOP.
ENDFORM. " buid_fieldcatalog
*& Form create_hierarchy
FORM create_hierarchy .
DATA : lt_vbrk TYPE TABLE OF vbrk,
ls_vbrk TYPE vbrk.
DATA : top_key TYPE lvc_nkey,
company_key TYPE lvc_nkey,
bzirk_key TYPE lvc_nkey.
DATA : lv_bukrs TYPE bukrs,
lv_bukrs_prv TYPE bukrs,
lv_bzirk TYPE bzirk,
lv_bzirk_prv TYPE bzirk.
SELECT * FROM vbrk INTO TABLE lt_vbrk UP TO 500 ROWS.
SORT lt_vbrk BY bukrs .
CALL METHOD alv_tree->add_node
EXPORTING
i_relat_node_key = ''
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = 'Company Code'
IMPORTING
e_new_node_key = top_key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 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 lt_vbrk INTO ls_vbrk.
lv_bukrs = ls_vbrk-bukrs .
lv_bzirk = ls_vbrk-bzirk .
IF lv_bukrs <> lv_bukrs_prv.
lv_bukrs_prv = lv_bukrs.
PERFORM add_node USING lv_bukrs
top_key
CHANGING company_key.
ENDIF.
IF lv_bzirk <> lv_bzirk_prv.
lv_bzirk_prv = lv_bzirk.
PERFORM add_posnr USING lv_bzirk
company_key
CHANGING bzirk_key.
ENDIF.
ENDLOOP.
ENDFORM. " create_hierarchy
*& Form add_node
-->P_LV_BUKRS text
-->P_TOP_KEY text
<--P_COMPANY_KEY text
FORM add_node USING p_lv_bukrs TYPE bukrs
p_top_key TYPE lvc_nkey
CHANGING p_company_key TYPE lvc_nkey .
DATA: l_node_text TYPE lvc_value,
ls_vbrk TYPE vbrk.
l_node_text = 'Company' .
CALL METHOD alv_tree->add_node
EXPORTING
i_relat_node_key = p_top_key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = ls_vbrk
i_node_text = l_node_text
IMPORTING
e_new_node_key = p_company_key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 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.
ENDFORM. " add_node
*& Form add_posnr
text
-->P_LV_POSNR text
-->P_COMPANY_KEY text
<--P_POSNR_KEY text
FORM add_posnr USING p_lv_bzirk TYPE bzirk
p_company_key TYPE lvc_nkey
CHANGING p_bzirk_key TYPE lvc_nkey.
DATA ls_vbrk TYPE vbrk.
CALL METHOD alv_tree->add_node
EXPORTING
i_relat_node_key = p_company_key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = ls_vbrk
i_node_text = 'Sales District'
IMPORTING
e_new_node_key = p_bzirk_key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 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.
ENDFORM. " add_posnr
*& Module USER_COMMAND_9100 INPUT
MODULE user_command_9100 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
CALL METHOD alv_container->free.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_9100 INPUTCheck this forum there are many threads on this.
-
Editable field in alv tree output using cl_gui_alv_tree
Hi,
i need Editable field with F4 help in alv tree output using cl_gui_alv_tree.
regards,
Nareshsadly, this is not possible. An ALV Tree cannot by editable.
Regards -
Editable field with F4 help in alv tree output using cl_gui_alv_tree
HI
i need Editable field with F4 help in alv tree output using cl_gui_alv_tree
Regards
NareshHi Naresh,
Pass the field catalog with the additional parameter (ls_fcat-edit = 'X'.).
for F4 help if the data element have the search help it automatically will come. other wise include the additional parameter in the field catalog (ls_fcat-F4AVAILABL = 'X')
Reward if found helpful.
Regards,
Boobalan Suburaj -
ALV tree without using abap objects---------urgent
hi
can anybody send me code for making alv tree without using ABAP objects.
thanks in advance
AdityaHI
goto this link
you will get all ALV TREE programs
follow that code you can understand very easily
http://www.sapdev.co.uk/reporting/alv/alvtree.htm
<b>Reward if usefull</b> -
ALV Tree list output using the Class and method
Hi,
How to get the internal table values of ALV Tree List in classes.
My requirement is i need to store the output values in Ztable of a SAP Transaction of CK86_99.
for this, i copied the SAP Standard Transaction into Z tcode and i am trying to poplulate the output display into Ztable. But this standard tcode CK86_99 is using the classes of ALV tree list to display output.
CL_STRUCTURE_EXPLOSION_TREE -- Class
CONSTRUCTOR - method
Finally in the above mentioned method, i am able to see the output values of ALV tree list in the internal table of mt_output_table.
But these are SAP Standard Class and method.
My doubt is, How to get these internal table values in my Zprogram.
is there any user exit or badi can we use in the method of class???? Actually my system is 4.6C
Please suggest me on this problem.
Thanks in advance
KBS ReddyFirst your getInstance() method returns 'singleton' which you havent declared/init anywhere.
your getAll() method needs to be static if you need to call it the way you are doing.
In your getAll() method u are passing a parameter called patientRecord ... where have you declared/init it.
i think you have to do something like this ... if i have understood you correctly.
/* THIS IS IN YOUR SERVLET*/
Collections c = database.getAll();
out.println(C);
/* YOUR FlatfileDatabase CLASS HAS SOMETHING LIKE THIS*/
public static FlatfileDatabase getInstance() {
return new FlatfileDatabase();
public static Collections getAll() { -
Hi all
how can i use alv 's for reading data from table mara and dispyaing 10 records on out put screen as a grid using classes or methods
thanks in advanceHi,
look into the sample code:
TYPE-POOLS *
TYPE-POOLS: slis.
TRANSPARENT TABLES *
TABLES: rbkp,rbco,sscrfields,t009b.
CLASS cl_event_receiver DEFINITION
CLASS cl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS: handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column,
handle_top_of_page
FOR EVENT print_top_of_page OF cl_gui_alv_grid.
PRIVATE SECTION.
ENDCLASS.
CLASS CL_EVENT_RECEIVER IMPLEMENTATION
CLASS cl_event_receiver IMPLEMENTATION.
*--Method double click
METHOD :handle_double_click.
PERFORM drill_down USING e_column-fieldname
e_row-index .
ENDMETHOD.
*--Method top of page
METHOD handle_top_of_page.
PERFORM event_top_of_page.
ENDMETHOD. "top_of_page
ENDCLASS.
DATA: event_receiver TYPE REF TO cl_event_receiver.
Global Variables *
DATA:
v_xblnr LIKE rbkp-xblnr, " Refernce Doc No
v_lifnr LIKE lfa1-lifnr, " Vendor
v_bukrs LIKE t001-bukrs, " Company Code
v_zzmprd LIKE mara-matnr, " MPM
v_monat LIKE t009b-poper. " Fiscal Period
GLOBAL TYPES *
*-Structure for Invoice details
TYPES:BEGIN OF y_invoice,
belnr LIKE rbkp-belnr, " Invoice Doc No
gjahr LIKE rbkp-gjahr, " Fiscal Year
blart LIKE rbkp-blart, " Document type
bldat LIKE rbkp-bldat, " Document date
budat LIKE rbkp-budat, " Posting date
xblnr LIKE rbkp-xblnr, " Refernce Doc no
bukrs LIKE rbkp-bukrs, " Company Code
lifnr LIKE rbkp-lifnr, " Vendor
waers LIKE rbkp-waers, " Local Currency
bktxt LIKE rbkp-bktxt, " Doc header text
zlspr LIKE rbkp-zlspr, " payment block
buzei LIKE rseg-buzei, " Invoice Item No
ebeln LIKE rseg-ebeln, " PO
ebelp LIKE rseg-ebelp, " PO line item
matnr LIKE rseg-matnr, " SAP Material
bwtar LIKE rseg-bwtar, " Valuation type
wrbtr LIKE rseg-wrbtr, " Inv Value
menge LIKE rseg-menge, " Inv Qty
END OF y_invoice,
*-Structure for Material details
BEGIN OF y_material,
matnr LIKE mara-matnr, " Material No
normt LIKE mara-normt, " Article Number
ismconttype LIKE mara-ismconttype, " Window
ismdesign LIKE mara-ismdesign, " No of disc in MPM
werks LIKE marc-werks, " Plant
mfrgr LIKE marc-mfrgr, " Product Line
END OF y_material,
Structure for Costtype data
BEGIN OF y_costtype,
bukrs LIKE zsn0325_costtype-bukrs, " Company Code
land1 LIKE zsn0325_costtype-land1, " Country key
window LIKE zsn0325_costtype-window, " Window
ewlnr LIKE zsn0325_costtype-ewlnr, " Cost type
distmeth LIKE zsn0325_costtype-distmeth, " Distribution type
zvalfrom LIKE zsn0325_costtype-zvalfrom, " Posting date from
zvalto LIKE zsn0325_costtype-zvalto, " Posting Date TO
disc1pr LIKE zsn0325_costtype-disc1pr, " Disc price
disc2pr LIKE zsn0325_costtype-disc2pr, " Disc price
END OF y_costtype,
Structure for Distmeth data
BEGIN OF y_distmeth,
distmeth LIKE zsn0325_distmeth-distmeth, " Distribution Methods
distext LIKE zsn0325_distmeth-distext, " Description
END OF y_distmeth,
*-structure for rbco
BEGIN OF y_rbco,
belnr LIKE rbco-belnr, " Account Doc#
gjahr LIKE rbco-gjahr, " Fiscal year
buzei LIKE rbco-buzei, " Doc item in inv doc
cobl_nr LIKE rbco-cobl_nr, " 4 Character
" Seq No for Coding
wrbtr LIKE rbco-wrbtr, " Amt in doc currency
saknr LIKE rbco-saknr, " G/L Account Number
sgtxt LIKE rbco-sgtxt, " Item text
zzcou LIKE rbco-zzcou, " Country
zzmprd LIKE rbco-zzmprd, " MPM Product
menge LIKE rbco-menge, " Quantity
bukrs LIKE rbco-bukrs, " Company Code
xnegp LIKE rbco-xnegp, " Variance Flag
matnr LIKE mara-matnr, " MPM Product
land1 LIKE zsop_fame-sop_cnt, " SOP country code
END OF y_rbco,
*-structure for rbco_tmp
BEGIN OF y_rbco_tmp,
bukrs LIKE rbco-bukrs, " Company Code
sgtxt LIKE rbco-sgtxt, " Item text
ewlnr LIKE zsn0325_costtype-ewlnr, " Cost type
distmeth LIKE zsn0325_costtype-distmeth, " Distribution type
land1 LIKE zsop_fame-sop_cnt, " SOP country code
END OF y_rbco_tmp,
*-Structure for setleaf
BEGIN OF y_setleaf,
setname LIKE setleaf-setname,
valsign LIKE setleaf-valsign,
valoption LIKE setleaf-valoption,
valfrom LIKE setleaf-valfrom,
valto LIKE setleaf-valto,
END OF y_setleaf,
*-Structure for Output data
BEGIN OF y_output,
bukrs LIKE rbkp-bukrs, " Company Code
gjahr LIKE rbkp-gjahr, " Fiscal year
lifnr LIKE rbkp-lifnr, " Vendor
zlspr LIKE rbkp-zlspr, " Payment block
xblnr LIKE rbkp-xblnr, " Refernece Doc no
bldat LIKE rbkp-bldat, " Document date
budat LIKE rbkp-budat, " Posting date
belnr LIKE rbkp-belnr, " Invoice Doc No
bktxt LIKE rbkp-bktxt, " Invoice Type
normt LIKE mara-normt, " Article Number
ismconttype LIKE mara-ismconttype, " Window
zzcou LIKE rbco-zzcou, " Country
zzmprd LIKE rbco-zzmprd, " MPM Product
xnegp LIKE rbco-xnegp, " Cost type variance
cobl_nr LIKE rbco-cobl_nr, " 4 Character
" Seq No for Coding
invfqty LIKE rbco-menge, " Inventory Fee Qty
discqty LIKE rbco-menge, " Dist Cost Qty
disrqty LIKE rbco-menge, " Dist Return Qty
sseqty LIKE rbco-menge, " Special Services Qty
sgtxt LIKE rbco-sgtxt, " Item Text
ismdesign LIKE mara-ismdesign, " No of disc on MPM
mfrgr LIKE marc-mfrgr, " Product Line
ddeal(3), " Distribution DEAL
distmeth LIKE zsn0325_costtype-distmeth, " Distribution type
distext LIKE zsn0325_distmeth-distext, " Description
ndisc(2) TYPE c, " NO of disc on INV
rifval LIKE rbco-wrbtr, " Inv fee value
stdrif LIKE zsn0325_costtype-disc1pr, " STD Inv fee
rfvar LIKE zsn0325_costtype-disc1pr, " Inv Fee Variance
dicval LIKE rbco-wrbtr, " Dist cost Value
stddico LIKE zsn0325_costtype-disc1pr, " STD Dis cost
dicvar LIKE zsn0325_costtype-disc1pr, " Dist Cost Variance
disrev LIKE rbco-wrbtr, " Dist Return Value
stdirco LIKE zsn0325_costtype-disc1pr, " STD Dis Return cost
drevar LIKE zsn0325_costtype-disc1pr, " Dist Ret Variance
adj_qty_ct LIKE rbco-menge, " Adjustments Qty
adj_pr_ct LIKE rbco-wrbtr, " Adjustments Value
ssval LIKE rbco-wrbtr, " Special Value
color_cell TYPE lvc_t_scol, " Cell Color
END OF y_output,
*-Structure for Temporary Output data
BEGIN OF y_output_tmp,
bukrs LIKE rbkp-bukrs, " Company Code
gjahr LIKE rbkp-gjahr, " Fiscal year
lifnr LIKE rbkp-lifnr, " Vendor
zlspr LIKE rbkp-zlspr, " Payment block
xblnr LIKE rbkp-xblnr, " Refernece Doc no
bldat(10) TYPE c, " Document Date
budat(10) TYPE c, " Posting date
belnr LIKE rbkp-belnr, " Invoice Doc No
bktxt LIKE rbkp-bktxt, " Invoice Type
normt(18) TYPE c, " Article Number
ismconttype LIKE mara-ismconttype, " Window
zzcou LIKE rbco-zzcou, " Country
zzmprd LIKE rbco-zzmprd, " MPM Product
xnegp LIKE rbco-xnegp, " Cost type variance
cobl_nr LIKE rbco-cobl_nr, " 4 Character
" Seq No for Coding
invfqty LIKE rbco-menge, " Inventory Fee Qty
discqty LIKE rbco-menge, " Dist Cost Qty
disrqty LIKE rbco-menge, " Dist Return Qty
sseqty LIKE rbco-menge, " Special Services Qty
sgtxt LIKE rbco-sgtxt, " Item Text
ismdesign(2) TYPE c, " No of disc on MPM
mfrgr LIKE marc-mfrgr, " Product Line
ddeal(3), " Distribution DEAL
distmeth LIKE zsn0325_costtype-distmeth, " Distribution type
distext LIKE zsn0325_distmeth-distext, " Description
ndisc(2) TYPE c, " NO of disc on INV
rifval LIKE rbco-wrbtr, " Inv fee value
stdrif LIKE zsn0325_costtype-disc1pr, " STD Inv fee
rfvar LIKE zsn0325_costtype-disc1pr, " Inv Fee Variance
dicval LIKE rbco-wrbtr, " Dist cost Value
stddico LIKE zsn0325_costtype-disc1pr, " STD Dis cost
dicvar LIKE zsn0325_costtype-disc1pr, " Dist Cost Variance
disrev LIKE rbco-wrbtr, " Dist Return Value
stdirco LIKE zsn0325_costtype-disc1pr, " STD Dis Return cost
drevar LIKE zsn0325_costtype-disc1pr, " Dist Ret Variance
adj_qty_ct LIKE rbco-menge, " Adjustments Qty
adj_pr_ct LIKE rbco-wrbtr, " Adjustments Value
ssval LIKE rbco-wrbtr, " Special Value
color_cell TYPE lvc_t_scol, " Cell Color
END OF y_output_tmp.
GLOBAL DATA -INTERNAL TABLES *
DATA: i_invoice TYPE STANDARD TABLE OF y_invoice,
i_output TYPE STANDARD TABLE OF y_output,
i_output_tmp TYPE STANDARD TABLE OF y_output_tmp,
i_rbco TYPE STANDARD TABLE OF y_rbco,
i_rbco_tmp TYPE STANDARD TABLE OF y_rbco_tmp,
i_setleaf TYPE STANDARD TABLE OF y_setleaf,
i_material TYPE STANDARD TABLE OF y_material,
i_costtype TYPE STANDARD TABLE OF y_costtype,
i_distmeth TYPE STANDARD TABLE OF y_distmeth,
i_toolbar_excluding TYPE ui_functions,
i_fieldcatalog TYPE lvc_t_fcat.
WORK AREAS *
DATA: w_invoice TYPE y_invoice,
w_material TYPE y_material,
w_output TYPE y_output,
w_output_tmp TYPE y_output_tmp,
w_costtype TYPE y_costtype,
w_distmeth TYPE y_distmeth,
w_rbco TYPE y_rbco,
w_rbco_tmp TYPE y_rbco_tmp,
w_setleaf TYPE y_setleaf,
w_toolbar_excluding TYPE ui_func,
w_fieldcatalog TYPE lvc_s_fcat.
*--Ranges
RANGES: r_setinv FOR setleaf-valfrom,
r_matnr FOR mara-matnr.
DATA DECLARATION FOR ALV *
*--Data declaration for ALV Grid
DATA :w_alvgrid TYPE REF TO cl_gui_alv_grid,
w_ccontainer TYPE REF TO cl_gui_custom_container,
w_okcode LIKE sy-ucomm.
*--Color cell
DATA: i_color TYPE lvc_t_scol,
w_color TYPE lvc_s_scol.
*--- Layout structure
DATA w_layout TYPE lvc_s_layo .
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-055.
SELECT-OPTIONS:
s_bukrs FOR rbkp-bukrs, " Company Code
s_lifnr FOR rbkp-lifnr, " Vendor
s_xblnr FOR rbkp-xblnr, " Reference Doc No
s_gjahr FOR rbkp-gjahr OBLIGATORY, " Fiscal Year
s_monat FOR t009b-poper, " Period
s_budat FOR rbkp-budat, " Posting date
s_bldat FOR rbkp-bldat, " Document date
s_zzmprd FOR rbco-zzmprd. " MPM
SELECTION-SCREEN END OF BLOCK blk1.
AT SELECTION SCREEN *
Validating Company Code
AT SELECTION-SCREEN ON s_bukrs.
IF NOT s_bukrs[] IS INITIAL.
SELECT bukrs " Company Code
UP TO 1 ROWS
INTO v_bukrs
FROM t001
WHERE bukrs IN s_bukrs.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Invalid Company Code'(e06).
ENDIF.
ENDIF.
Validating ODS Invoice Document No.
AT SELECTION-SCREEN ON s_xblnr.
IF NOT s_xblnr[] IS INITIAL.
SELECT xblnr " Reference Document number
UP TO 1 ROWS
INTO v_xblnr
FROM rbkp
WHERE xblnr IN s_xblnr.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Invalid ODS Invoice No.'(e05).
ENDIF.
ENDIF.
Validating Vendor Number
AT SELECTION-SCREEN ON s_lifnr.
IF NOT s_lifnr[] IS INITIAL.
SELECT lifnr " Vendor Number
UP TO 1 ROWS
INTO v_lifnr
FROM lfa1
WHERE lifnr IN s_lifnr.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Invalid Vendor Number'(e04).
ENDIF.
ENDIF.
Validating MPM
AT SELECTION-SCREEN ON s_zzmprd.
REFRESH r_matnr.
LOOP AT s_zzmprd.
MOVE-CORRESPONDING s_zzmprd TO r_matnr.
IF NOT s_zzmprd IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = s_zzmprd-low
IMPORTING
output = r_matnr-low
EXCEPTIONS
length_error = 1
OTHERS = 2.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = s_zzmprd-high
IMPORTING
output = r_matnr-high
EXCEPTIONS
length_error = 1
OTHERS = 2.
APPEND r_matnr.
ENDIF.
ENDLOOP.
SELECT matnr " MPM
UP TO 1 ROWS
INTO v_zzmprd
FROM mara
WHERE matnr IN r_matnr.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Invalid MPM'(e09).
ENDIF.
Validating Fiscal Period
IF NOT s_monat[] IS INITIAL.
SELECT poper " Fiscal Period
UP TO 1 ROWS
INTO v_monat
FROM t009b
WHERE periv = 'K4'
AND poper IN s_monat
AND bdatj IN s_gjahr.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Invalid Fiscal Period'(e02).
ENDIF.
ENDIF.
*For Company Code & Vendor
AT SELECTION-SCREEN.
MOVE sy-ucomm TO sscrfields-ucomm.
IF sy-ucomm EQ 'ONLI'
AND s_bukrs[] IS INITIAL
AND s_lifnr[] IS INITIAL.
MESSAGE i000 WITH
'Either Company code or Vendor must be selected'(e03).
STOP.
ENDIF.
IF ( NOT s_budat[] IS INITIAL OR NOT s_bldat IS INITIAL )
AND NOT s_monat[] IS INITIAL.
MESSAGE i000 WITH
'Select either Period or Posting date,Document date'(e01).
STOP.
ENDIF.
START OF SELECTION *
START-OF-SELECTION.
*-Retrieve Invoice Details from RBKP & RSEG
PERFORM get_invoice.
IF NOT i_invoice[] IS INITIAL.
*-Retrieve Invoice Details from RBCO
PERFORM get_rbco.
ENDIF.
IF NOT i_rbco[] IS INITIAL.
*-Retrieve Material Document details from MARA & MARC
PERFORM get_material.
ENDIF.
IF NOT i_invoice[] IS INITIAL.
*-Retrieve costtype details from zsn0325_costtype & zsn0325_distmeth
PERFORM get_costtype.
PERFORM get_distmeth.
ENDIF.
*-Populate internal table for output
PERFORM populate_output.
END OF SELECTION *
END-OF-SELECTION.
*-TO Display Output
IF NOT i_invoice[] IS INITIAL
AND NOT i_output[] IS INITIAL.
PERFORM display_report.
CALL SCREEN 100.
ENDIF.
*& Form get_Invoice
Retrieve Invoice Details from RBKP & RSEG
FORM get_invoice.
DATA : lv_monat LIKE bkpf-monat.
*-Get Value form set zsn_doc_types_inv
SELECT setname
valsign
valoption
valfrom
valto
FROM setleaf
INTO TABLE i_setleaf
WHERE setclass = '0000'
AND setname = 'ZSN_DOC_TYPES_INV'.
IF sy-subrc = 0.
LOOP AT i_setleaf INTO w_setleaf.
r_setinv-sign = w_setleaf-valsign.
r_setinv-option = w_setleaf-valoption.
r_setinv-low = w_setleaf-valfrom.
r_setinv-high = w_setleaf-valto.
APPEND r_setinv.
ENDLOOP.
ENDIF.
Get Invoice Doc details
SELECT a~belnr " Document number of an invoice
a~gjahr " Fiscal Year
a~blart " Document type
a~bldat " Document Date in Document
a~budat " Posting Date in the Document
a~xblnr " Reference Document Number
a~bukrs " Company Code
a~lifnr " Different invoicing party
a~waers " Currency Key
a~bktxt " Document header text
a~zlspr " Payment Block Key
b~buzei " Document item in invoice
b~ebeln " Purchasing Document Number
b~ebelp " Item Number of PO Document
b~matnr " Material Number
b~bwtar " Valuation type
b~wrbtr " Amount in document currency
b~menge " Quantity
INTO TABLE i_invoice
FROM rbkp AS a
LEFT OUTER JOIN rseg AS b
ON abelnr EQ bbelnr
WHERE a~bukrs IN s_bukrs
AND a~gjahr IN s_gjahr
AND a~bldat IN s_bldat
AND a~blart IN r_setinv
AND a~budat IN s_budat
AND a~xblnr IN s_xblnr
AND a~lifnr IN s_lifnr.
IF sy-subrc NE 0.
MESSAGE i000 WITH 'No Invoice exists for this selection'(e07)
'criteria'(e08).
STOP.
ELSE.
SORT i_invoice BY belnr gjahr.
LOOP AT i_invoice INTO w_invoice.
CALL FUNCTION 'FI_PERIOD_DETERMINE'
EXPORTING
i_budat = w_invoice-budat
i_bukrs = w_invoice-bukrs
i_periv = 'K4'
i_gjahr = w_invoice-gjahr
I_MONAT = 00
X_XMO16 = ' '
IMPORTING
E_GJAHR =
e_monat = lv_monat
E_POPER =
EXCEPTIONS
fiscal_year = 1
period = 2
period_version = 3
posting_period = 4
special_period = 5
version = 6
posting_date = 7
OTHERS = 8.
IF sy-subrc <> 0.
DELETE i_invoice.
ELSE.
IF lv_monat IN s_monat.
ELSE.
DELETE i_invoice.
ENDIF.
ENDIF.
ENDLOOP.
IF i_invoice[] IS INITIAL.
MESSAGE i000 WITH 'No Invoice exists for this selection'(e07)
'criteria'(e08).
STOP.
ENDIF.
ENDIF.
ENDFORM. " get_Invoice
*& Form get_rbco
Retrieve Invoice Details from RBCO
FORM get_rbco.
SELECT belnr
gjahr
buzei
cobl_nr
wrbtr
saknr
sgtxt
zzcou
zzmprd
menge
bukrs
xnegp
FROM rbco
INTO TABLE i_rbco
FOR ALL ENTRIES IN i_invoice
WHERE belnr = i_invoice-belnr
AND gjahr = i_invoice-gjahr
AND wrbtr <> 0
AND zzmprd IN s_zzmprd.
IF sy-subrc NE 0.
MESSAGE i000 WITH 'No Distribution Data Exists'(e10).
STOP.
ELSE.
SORT i_rbco BY belnr gjahr.
ENDIF.
ENDFORM. " get_rbco
*& Form get_material
Retrieve Material Document details from MARA & MARC
FORM get_material.
LOOP AT i_rbco INTO w_rbco.
SELECT SINGLE sop_cnt
INTO w_rbco_tmp-land1
FROM zsop_fame
WHERE fame_cnt = w_rbco-zzcou.
IF sy-subrc = 0.
w_rbco_tmp-bukrs = w_rbco-bukrs.
w_rbco_tmp-ewlnr = w_rbco-sgtxt+7(2).
w_rbco_tmp-distmeth = w_rbco-sgtxt+0(3).
ENDIF.
w_rbco-land1 = w_rbco_tmp-land1.
APPEND w_rbco_tmp TO i_rbco_tmp.
CLEAR w_rbco_tmp.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = w_rbco-zzmprd
IMPORTING
output = w_rbco-matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
MODIFY i_rbco FROM w_rbco.
CLEAR w_rbco.
ENDLOOP.
SELECT a~matnr " Material Number
a~normt " Article Number
a~ismconttype " Window
a~ismdesign " No of discs in MPM
b~werks " Plant
b~mfrgr " Product Line
INTO TABLE i_material
FROM mara AS a
INNER JOIN
marc AS b
ON amatnr = bmatnr
FOR ALL ENTRIES IN i_rbco
WHERE a~matnr = i_rbco-matnr.
IF sy-subrc = 0.
SORT i_material BY matnr.
ENDIF.
ENDFORM. " get_material
*& Form get_costtype
Retrieve costtype details from zsn0325_costtype
FORM get_costtype.
SELECT bukrs " Company code
land1 " Country key
window " Window
ewlnr " Cost type
distmeth " Distribution type
zvalfrom " Invoice date
zvalto " Invoice date
disc1pr " Disc Price
disc2pr " Additional DiscPrice
FROM zsn0325_costtype
INTO TABLE i_costtype
FOR ALL ENTRIES IN i_rbco_tmp
WHERE bukrs = i_rbco_tmp-bukrs
AND ewlnr = i_rbco_tmp-ewlnr
AND distmeth = i_rbco_tmp-distmeth
AND land1 = i_rbco_tmp-land1.
IF sy-subrc = 0.
SORT i_costtype BY bukrs land1 window ewlnr distmeth.
ENDIF.
ENDFORM. " get_costtype
*& Form get_distmeth
Retrieve costtype details from zsn0325_distmeth
FORM get_distmeth.
SELECT distmeth
distext
FROM zsn0325_distmeth
INTO TABLE i_distmeth
FOR ALL ENTRIES IN i_costtype
WHERE distmeth = i_costtype-distmeth.
IF sy-subrc = 0.
SORT i_distmeth BY distmeth.
ENDIF.
ENDFORM. " get_distmeth
*& Form display_report
TO Display Output
FORM display_report.
IF NOT i_output[] IS INITIAL.
SORT i_output BY xblnr.
PERFORM build_fieldcat.
ENDIF.
ENDFORM. " display_report
*& Form build_fieldcat
Build Field Catalog
FORM build_fieldcat.
PERFORM fill_fieldcat USING 'BUKRS' 'I_OUTPUT'
'Company Code'(001) 12.
PERFORM fill_fieldcat USING 'LIFNR' 'I_OUTPUT'
'Vendor'(002) 6.
PERFORM fill_fieldcat USING 'ZLSPR' 'I_OUTPUT'
'Payment Block'(003) 13.
PERFORM fill_fieldcat USING 'XBLNR' 'I_OUTPUT'
'Vendor Invoice No'(004) 17.
PERFORM fill_fieldcat USING 'BLDAT' 'I_OUTPUT'
'Invoice Date'(005) 12.
PERFORM fill_fieldcat USING 'BUDAT' 'I_OUTPUT'
'Posting Date'(006) 12.
PERFORM fill_fieldcat USING 'BKTXT' 'I_OUTPUT'
'Invoice Type'(007) 12.
PERFORM fill_fieldcat USING 'BELNR' 'I_OUTPUT'
'R/3 Invoice No'(008) 14.
PERFORM fill_fieldcat USING 'COBL_NR' 'I_OUTPUT'
'Line Item'(009) 9.
PERFORM fill_fieldcat USING 'NORMT' 'I_OUTPUT'
'Article No'(010) 10.
PERFORM fill_fieldcat USING 'ZZMPRD' 'I_OUTPUT'
'MPM Product'(034) 11.
PERFORM fill_fieldcat USING 'ISMCONTTYPE' 'I_OUTPUT'
'Window'(011) 6.
PERFORM fill_fieldcat USING 'NDISC' 'I_OUTPUT'
'No of Discs on invoice'(012) 22.
PERFORM fill_fieldcat USING 'ISMDESIGN' 'I_OUTPUT'
'No of discs on MPM'(013) 10.
PERFORM fill_fieldcat USING 'DISTMETH' 'I_OUTPUT'
'Distribution type'(014) 17.
PERFORM fill_fieldcat USING 'DISTEXT' 'I_OUTPUT'
'Description'(015) 11.
PERFORM fill_fieldcat USING 'DDEAL' 'I_OUTPUT'
'Distribution Deal'(016) 17.
PERFORM fill_fieldcat USING 'MFRGR' 'I_OUTPUT'
'MPM Product Line'(017) 16.
PERFORM fill_fieldcat USING 'ZZCOU' 'I_OUTPUT'
'Country'(018) 7.
PERFORM fill_fieldcat USING 'XNEGP' 'I_OUTPUT'
'Qty Var flag'(019) 12.
PERFORM fill_fieldcat USING 'INVFQTY' 'I_OUTPUT'
'Inv fee Qty'(020) 11.
PERFORM fill_fieldcat USING 'RIFVAL' 'I_OUTPUT'
'Inv fee Value'(021) 13.
PERFORM fill_fieldcat USING 'STDRIF' 'I_OUTPUT'
'Std Inv fee'(022) 11.
PERFORM fill_fieldcat USING 'RFVAR' 'I_OUTPUT'
'Inv fee Var'(023) 11.
PERFORM fill_fieldcat USING 'DISCQTY' 'I_OUTPUT'
'Dis cost Qty'(024) 11.
PERFORM fill_fieldcat USING 'DICVAL' 'I_OUTPUT'
'Dist Cost Value'(025) 15.
PERFORM fill_fieldcat USING 'STDDICO' 'I_OUTPUT'
'Std Dist Cost'(026) 11.
PERFORM fill_fieldcat USING 'DICVAR' 'I_OUTPUT'
'Dist Cost Var'(027) 13.
PERFORM fill_fieldcat USING 'DISRQTY' 'I_OUTPUT'
'Dis Ret Qty'(028) 11.
PERFORM fill_fieldcat USING 'DISREV' 'I_OUTPUT'
'Dis Ret Value'(029) 11.
PERFORM fill_fieldcat USING 'STDIRCO' 'I_OUTPUT'
'Std Dis Ret cost'(030) 11.
PERFORM fill_fieldcat USING 'DREVAR' 'I_OUTPUT'
'Dis Ret Var'(031) 11.
PERFORM fill_fieldcat USING 'ADJ_QTY_CT' 'I_OUTPUT'
'Adjustments Qty'(035) 15.
PERFORM fill_fieldcat USING 'ADJ_PR_CT' 'I_OUTPUT'
'Adjustments Value'(036) 17.
PERFORM fill_fieldcat USING 'SSEQTY' 'I_OUTPUT'
'Special Ser Qty'(032) 15.
PERFORM fill_fieldcat USING 'SSVAL' 'I_OUTPUT'
'Special Ser Value'(033) 17.
ENDFORM. " build_fieldcat
*& Form fill_fieldcat
Fill fieldcatalog for ALV *
FORM fill_fieldcat USING value(p_fieldname)
value(p_tabname)
value(p_seltext_m)
value(p_outputlen).
w_fieldcatalog-fieldname = p_fieldname.
w_fieldcatalog-ref_table = p_tabname.
w_fieldcatalog-coltext = p_seltext_m.
w_fieldcatalog-outputlen = p_outputlen.
APPEND w_fieldcatalog TO i_fieldcatalog.
CLEAR w_fieldcatalog.
ENDFORM. " fill_fieldcat
*& Module STATUS_0100 OUTPUT
Process Before output
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN1'.
SET TITLEBAR 'TITLE'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module alV_display OUTPUT
ALv Display in PBO *
MODULE alv_display OUTPUT.
IF w_ccontainer IS INITIAL.
PERFORM create_objects.
Excluding unnecessary function codes from the grid
PERFORM exclude_fcodes.
PERFORM display_alv_grid.
ENDIF.
ENDMODULE. " alV_display OUTPUT
*& Form create_objects
Create ALV Objects
FORM create_objects.
IF w_alvgrid IS INITIAL .
*----Creating custom container instance
CREATE OBJECT w_ccontainer
EXPORTING
container_name = 'CONTAINER'
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.
*--Exception handling
ENDIF.
*----Creating ALV Grid instance
CREATE OBJECT w_alvgrid
EXPORTING
i_parent = w_ccontainer
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5 .
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
*--Create Event Receiver
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_top_of_page FOR w_alvgrid.
ENDIF.
ENDFORM. " create_objects
*& Form display_alv_grid
Display ALV Grid
FORM display_alv_grid.
w_layout-grid_title = 'Distribution Report'(042).
IF NOT w_alvgrid IS INITIAL .
MOVE 'COLOR_CELL' TO w_layout-ctab_fname.
CALL METHOD w_alvgrid->set_table_for_first_display
EXPORTING
is_layout = w_layout
it_toolbar_excluding = i_toolbar_excluding[]
I_DEFAULT = 'X'
CHANGING
it_outtab = i_output_tmp[]
it_fieldcatalog = i_fieldcatalog[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4 .
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
ELSE .
CALL METHOD w_alvgrid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2 .
IF sy-subrc <> 0.
ENDIF.
ENDIF .
*--handler for ALV grid
SET HANDLER event_receiver->handle_double_click FOR w_alvgrid.
ENDFORM. " display_alv_grid
*& Module USER_COMMAND_0100 INPUT
At User Command
MODULE user_command_0100 INPUT.
MOVE sy-ucomm TO w_okcode.
CASE w_okcode.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form populate_output
Populate internal table for output
FORM populate_output.
DATA: lv_invval TYPE rbco-wrbtr.
LOOP AT i_rbco INTO w_rbco.
*-Check whether ndisc is numeric value.
IF w_rbco-sgtxt+4(2) CO '0123456789'.
MOVE: w_rbco-sgtxt+4(2) TO w_output-ndisc.
ENDIF.
MOVE:w_rbco-cobl_nr TO w_output-cobl_nr,
w_rbco-zzcou TO w_output-zzcou,
w_rbco-zzmprd TO w_output-zzmprd,
w_rbco-xnegp TO w_output-xnegp.
For Invoice
READ TABLE i_invoice INTO w_invoice WITH KEY belnr = w_rbco-belnr
gjahr = w_rbco-gjahr
BINARY SEARCH.
IF sy-subrc = 0.
MOVE: w_invoice-bukrs TO w_output-bukrs,
w_invoice-lifnr TO w_output-lifnr,
w_invoice-zlspr TO w_output-zlspr, -
F4 help in ALV Grid Control (using classes)
Hi All,
I have created a report using ALV Grid control (using classes). I need to provide F4 help for some of the fields in the Grid control. I couldn't understand the standard demo program BCALV_GRID_F4_HELP. So Can anyone please provide me sample code for the same.
Regards
Jaker.hi check this..programs also
BCALV_GRID_EDIT_DELTA
BCALV_TEST_GRID_F4_HELP
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/how%2bto%2bimplement%2bf4%2bsearch%2bhelp%2bin%2boo%2balv%2bgrid
Struggling with f4 handling in ALV grid - Minisap 46D
regards,
venkat
Maybe you are looking for
-
Every single time I reboot, I have to enter passwords for Apple ID's
When I reboot my MBP, it tells me that this computer is not authorized to play, sync, etc.. with my iPod (or iPhone) and asks me for my password. With I enter it, I get a message that says "This computer is already authorized". I have 4 Apple ID's
-
Two people with the same comcast email adresses on two phones
It used to be that My wife and I shared the same Comcast email address and the mail came to both of our Windows phones. Something happened and she does not get Comcast mail anymore
-
Hi experts, About the adobe signature functionality. Whenever I signed the PDF file all fields will be in read only. Now the problem is, when I send the PDF file to another user, the recipient can easily clear my signature, thus the recipient can mo
-
PSHFT - Shift Schedule Structure details
I am supposed to get the details in this structure (PSHFT). This contains work schedule details. I am supposed to publish these schedules every day through a mail to employees. Is there anyway that I can read this structure.
-
Make cost centre transactional?
Hi All, I have a requirement in payroll reporting to make the cost centre of an employee 'as was'. e.g Jan 07 Emp1 cost ctr1 £1000 Feb 07 Emp1 cost ctr1 £1000 Mar 07 Emp1 cost ctr 2 £1000 So if in March I run a report I will see £2000 against cost ct