Using class's methods
Dear All,
I have a question related to using a method of a class with parameters.
What is wrong with my code ?
DATA ref_Var TYPE REF TO CL_ABAP_STRING_UTILITIES.
Data sour(5) type c value 'First'.
Data dest type string.
CL_ABAP_STRING_UTILITIES->C2STR_PRESERVING_BLANKS( sour dest ).
Regards
Ilhan
It should be = not -
CL_ABAP_STRING_UTILITIES<b>=></b>C2STR_PRESERVING_BLANKS( sour dest ).
and the code should be
<b>call method CL_ABAP_STRING_UTILITIES<b>=></b>C2STR_PRESERVING_BLANKS
exporting
source = source
importing
DEST = dest.</b>
or
dest = CL_ABAP_STRING_UTILITIES<b>=></b>C2STR_PRESERVING_BLANKS( sour ).
Regards,
Ravi
Message was edited by:
Ravi Kanth Talagana
Similar Messages
-
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. -
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 -
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. -
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 -
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. -
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... -
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 -
How to add push button in alv display with out class or method
Hai,
How to add push buttons in out put screen of ALV (tool bar) with out using classes or methods .I want to know using normal ALV .
Thanks in advance .
kiranYou should post your question in the ABAP forum.
ABAP Development -
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, -
Query on Class.forName() method
What is the difference between instantiating using Class.forName() method and instantiating using the new operator?
You can do one of them at runtime.
For example:
public static void main(String[] args) {
String className = args[0];
Object o = Class.forName(className).newInstance();
}It's essentially a part of the reflection API which is generally used when you don't know exactly what you want to manipulate at compile time. -
Instantiating object using Class.forName()
What is the difference between instantiating using Class.forName() method and instantiating using the new operator?
The difference is that you can use the new operator to instantiate an object, but you can't do it using Class.forName().
But seriously folks...
Presumably you're talking about Class.newInstance()--which often appears right on the heels of Class.forName().
New gives you compile-time checks you don't get with Class.forName(). If it compiles with new, then you know the constructor in question exists on the class in question.
With Class.newInstance() (and it's cousin (also called newInstance, I think) in the Constructor class), you can't be sure until you actually execute it whether that constructor even exists.
New requires you to know the class at compile time. NewInstance lets you defer the specific class until runtime.
New is simpler and more direct.
(Did I just do your homwork for you? Hope not.) -
Creation of Material using BDC Session method & global class
Hi
Creation of Material using BDC Session method & global class by using oops.
can anyone plz help me outHi,
it looks like it's not possible to call this BAPI wihtout material number. Here is a quote from BAPI documentation.
When creating material master data, you must transfer the material
number, the material type, and the industry sector to the method. You
must also enter a material description and its language.
Cheers -
ALV Reports using Class Methods
Hi Experts,
How can we generate ALV report using class and in that How can we define SLIS_EVENTS.
Can I provide all the that functionality the way I used to by calling FM
SLIS_ALV_REUSE_LIST_DISPLAY ?
- Like Header comment, event, data grouping , sort etc.
You may please send any url or document or any example.
Thanks in advance.
Regards,
Tushar ChoksiHi,
The ALV object Grid methods allow the same functionality as ALV grid report function modules but are displayed within
a screen (dialog program). SAP has provided a suit of programs which demonstrate how to For examples see standard SAP
programs as detailed below:
BCALV_EDIT_01 This report illustrates the simplest case of using an editable/noneditable ALV Grid Control.
BCALV_EDIT_02 This report illustrates how to set chosen cells of an ALV Grid Control editable.
BCALV_EDIT_03 In this example the user may change values of fields SEATSOCC (occupied seats) and/or PLANETYPE.
The report checks the input value(s) semantically and provides protocol messages in case of error
BCALV_EDIT_04 This report illustrates how to add and remove lines to a table using the ALV Grid Control and how to
implement the saving of the new data.
BCALV_EDIT_05 This example shows how to use checkboxes within an ALV Grid Control. You learn:
(1) how to define a column for editable checkboxes for an attribute of your list
(2) how to evaluate the checked checkboxes
(3) how to switch between editable and non-editable checkboxes
BCALV_EDIT_06 This example shows how to define a dropdown listbox for all cells of one column in an editable ALV
Grid Control.
BCALV_EDIT_07 This example shows how to define dropdown listboxes for particular cells of your output table.
BCALV_EDIT_08 This report implements an ALV Grid Control with an application specific F4 help. The following aspects
are dealt with:
(1) how to replace the standard f4 help
(2) how to pass the selected value to the ALV Grid Control
(3) how to build an f4 help, whose value range depend on a value of another cell.
some links.
www.sapgenie.com
www.abap4u.com
http://help.sap.com/saphelp_nw2004s/helpdata/en/5e/88d440e14f8431e10000000a1550b0/frameset.htm
download the PDF from following link.
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
Regards,
Satish -
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() {
Maybe you are looking for
-
Having two itunes accounts in two different countriesntries
Hopefully this hasn't been answered before - I couldn't find it using a search. I spend my time living between Australia and Canada. I currently use the Australian itunes store with an Australian credit card (with an Australian billing address). How
-
Itunes/ipod updating HELP!
whenever i plug my ipod into the computer it updates my ipod, however once that update is done if i change a setting and hit sync or apply nothing happens..itunes say it is updating but my ipod doesn't respond and it says that it is updating for a go
-
I have a Flash form connected to a formmail.pl script. The formmail opens a new generic thank you page. Does anyone know how to stop this or otherwise suppress the perl's redirect? Thanks
-
WRT54GX4 has problem. Please read! Can solved? Not Tested from linksys?
Recently just bought WRT54GX4. I discovered that this wireless router from linksys did not cover the range that i want. Previously i own WRT54Gv5 which still is better can connect to internet until when i was in my garden. However, this router when i
-
Advice on DVD labels and printing
After looking at various posts, I've decided to get a printer that prints directly on DVDs. Currently looking at Epson R220 (£55), R300 (£80), R340 (£117) I don't really need the card reader or screen capablity. Is the R220 otherwise the same spec an