Step 1:
Create a container. There are 2 type of containers: docking and custom.
Go to SE38.Create a program. Use Pattern button to create object for docking container. Click ABAP Object Pattern radio button. Click Create object radio button. Give Instance as o_docking and class as cl_gui_docking_contianer.
Step 2:
Create a grid inside the container.
Use Pattern button to create the same. Make the parent of grid as container.
Click ABAP Object Pattern radio button. Click Create object radio button. Give Instance as o_grid and class as cl_gui_alv_grid. Create object o_grid.
Step 3:
Call the function lvc_fieldcatalog_merge to get the field catalog.
Pass the structure name.
Step 4:
Call the method of grid set_table_for_first_display to display the output.
Click ABAP Object Pattern radio button. Click Call Method radio button. Give Instance as o_grid and Class/Interface as cl_gui_alv_grid and Method as set_table_for_first_display.
w_variant-report = sy-repid.
Call method o_grid->set_table_for_first_display
Step 5:
Fill the internal table itab with values by using logic.
select * from mara into table itab up to 100 rows.
call screen 9000.
Create a screen by double clicking 9000 in the above line. Fill the description for the screen. In the flow logic, uncomment the PBO and PAI module and create those in main program (for simplicity).
Step 6:
Create GUI status. Create GUI Title if required. That can be done by using display object List (Ctrl+Shift+F5).Then in left side, right click the program and create GUI Status and Title.
Step 7:
Free the memory occupied once the BACK, EXIT or CANCEL button is clicked. Use Pattern button to call the method FREE of cl_gui_alv_grid and cl_gui_docking_container.
Click ABAP Object Pattern radio button. Click Call Method radio button. Give Instance as o_grid and Class/Interface as cl_gui_alv_grid and Method as Free.
Similarly Click Call Method radio button. Give Instance as o_docking and Class/Interface as cl_gui_docking_container and Method as Free.
Please check this demo program: BCALV_TREE_DEMO.
Also see this example:
Check the below code....
&---------------------------------------------------------------------
*& Report ZZZ_TEST_501
*&
&---------------------------------------------------------------------
*&
*&
&---------------------------------------------------------------------
REPORT zzz_test_501.
TYPES:BEGIN OF ty_vbak,
vbeln LIKE vbak-vbeln,
auart LIKE vbak-auart,
kunnr LIKE vbak-kunnr,
vkorg LIKE vbak-vkorg,
vtweg LIKE vbak-vtweg,
spart LIKE vbak-spart,
END OF ty_vbak,
BEGIN OF ty_vbap,
posnr LIKE vbap-posnr,
matnr LIKE vbap-matnr,
werks LIKE vbap-werks,
lgort LIKE vbap-lgort,
ntgew LIKE vbap-ntgew,
END OF ty_vbap.
DATA:i_vbak TYPE STANDARD TABLE OF ty_vbak,
i_vbap TYPE STANDARD TABLE OF ty_vbap,
w_vbak TYPE ty_vbak,
w_vbap TYPE ty_vbap.
SELECT-OPTIONS:s_vbeln FOR w_vbak-vbeln.
PARAMETERS:s_date LIKE sy-datum.
*Declarations for ALV
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA:grid1 TYPE REF TO cl_gui_alv_grid,
container TYPE REF TO cl_gui_docking_container,
i_fieldcat TYPE lvc_t_fcat,
w_fieldcat TYPE lvc_s_fcat,
disvar TYPE disvariant,
gs_toolbar TYPE stb_button,
eventreceiver TYPE REF TO lcl_event_receiver,
w_layout TYPE lvc_s_layo.
invariant TYPE disvariant,
i_event TYPE slis_t_event,
w_event TYPE slis_alv_event,
i_header TYPE slis_t_listheader,
w_header TYPE slis_listheader.
CLASS lcl_event_receiver DEFINITION
PUBLIC SECTION.
CLASS-METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm,
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no.
ENDCLASS. "lcl_event_receiver DEFINITION
CLASS lcl_event_receiver IMPLEMENTATION
METHOD HANDLE_USER_COMMAND
DATA:lt_rows TYPE lvc_t_row,
w_row TYPE lvc_s_row.
CASE e_ucomm.
WHEN 'CLICK'.
CLEAR lt_rows.
get selected row
CALL METHOD grid1->get_selected_rows
IMPORTING
et_index_rows = lt_rows.
READ TABLE lt_rows INTO w_row INDEX 1.
READ TABLE i_vbak INTO w_vbak INDEX w_row-index.
SET PARAMETER ID 'AUN' FIELD w_vbak-vbeln.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
CLEAR w_cust_detadd3.
PERFORM f1900_get_selectedrows TABLES lt_rows.
PERFORM f2000_modify_message.
ls_stable-row = 'X'.
ls_stable-col = 'X'.
*
CALL METHOD o_alvgrid->refresh_table_display
EXPORTING
is_stable = ls_stable.
*
CALL METHOD cl_gui_cfw=>flush.
CALL METHOD o_alvgrid->get_selected_rows
IMPORTING et_index_rows = lt_rows.
*
CLEAR w_cust_detadd3.
PERFORM f1900_get_selectedrows TABLES lt_rows.
PERFORM f2000_modify_message.
ls_stable-row = 'X'.
ls_stable-col = 'X'.
*
CALL METHOD o_alvgrid->refresh_table_display
EXPORTING
is_stable = ls_stable.
*
CALL METHOD cl_gui_cfw=>flush.
ENDCASE.
ENDMETHOD. "HANDLE_USER_COMMAND
METHOD HANDLE_TOOLBAR
append a separator to normal toolbar
CLEAR gs_toolbar.
MOVE 3 TO gs_toolbar-butn_type.
APPEND gs_toolbar TO e_object->mt_toolbar.
CLEAR gs_toolbar.
MOVE 'CLICK' TO gs_toolbar-function.
MOVE 'CLICK' TO gs_toolbar-text.
--> This function code is evaluated in 'handle_menu_button'
MOVE 0 TO gs_toolbar-butn_type.
MOVE space TO gs_toolbar-disabled.
APPEND gs_toolbar TO e_object->mt_toolbar.
LOOP AT e_object->mt_toolbar INTO gs_toolbar.
IF gs_toolbar-function = '&MB_SUM'.
gs_toolbar-disabled = space.
MODIFY e_object->mt_toolbar FROM gs_toolbar INDEX sy-tabix.
ENDIF.
ENDLOOP.
ENDMETHOD. "HANDLE_TOOLBAR
METHOD DOUBLE_CLICK
READ TABLE i_vbak INTO w_vbak INDEX e_row-index.
SET PARAMETER ID 'AUN' FIELD w_vbak-vbeln.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDMETHOD. "HANDLE_DOUBLE_CLICK
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
START-OF-SELECTION.
SELECT vbeln
auart
kunnr
vkorg
vtweg
spart FROM vbak
INTO TABLE i_vbak
WHERE vbeln IN s_vbeln.
IF sy-subrc = 0.
ENDIF.
END-OF-SELECTION.
IF NOT i_vbak IS INITIAL.
CALL SCREEN 9001.
ENDIF.
&---------------------------------------------------------------------
*& Module STATUS_9001 OUTPUT
&---------------------------------------------------------------------
text
IF NOT container IS INITIAL.
SET PF-STATUS 'GRID'.
if cl_gui_alv_grid=>offline() is initial.
CREATE OBJECT container
EXPORTING
ratio = 95
name = 'ALV'.
CREATE OBJECT grid1
EXPORTING
i_parent = container
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.
ENDIF.
SET HANDLER eventreceiver->handle_user_command
eventreceiver->handle_toolbar
eventreceiver->handle_double_click FOR grid1.
w_fieldcat-col_pos = 1.
w_fieldcat-fieldname = 'VBELN'.
w_fieldcat-tabname = 'I_VBAK'.
w_fieldcat-reptext = 'Sales Document #'.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
w_fieldcat-col_pos = 2.
w_fieldcat-fieldname = 'AUART'.
w_fieldcat-tabname = 'I_VBAK'.
w_fieldcat-reptext = 'Order Type'.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
w_fieldcat-col_pos = 3.
w_fieldcat-fieldname = 'KUNNR'.
w_fieldcat-tabname = 'I_VBAK'.
w_fieldcat-reptext = 'Customer #'.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
w_fieldcat-col_pos = 4.
w_fieldcat-fieldname = 'VKORG'.
w_fieldcat-tabname = 'I_VBAK'.
w_fieldcat-reptext = 'Sales Org'.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
w_fieldcat-col_pos = 5.
w_fieldcat-fieldname = 'VTWEG'.
w_fieldcat-tabname = 'I_VBAK'.
w_fieldcat-reptext = 'Distribution Channel'.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
w_fieldcat-col_pos = 6.
w_fieldcat-fieldname = 'SPART'.
w_fieldcat-tabname = 'I_VBAK'.
w_fieldcat-reptext = 'Division'.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
it_outtab = i_vbak
it_fieldcatalog = i_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.
*endif.
ENDMODULE. " STATUS_9001 OUTPUT
&---------------------------------------------------------------------
*& Module USER_COMMAND_9001 INPUT
&---------------------------------------------------------------------
text
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
SET SCREEN '0'.
WHEN 'BACK'.
SET SCREEN '0'.
WHEN 'DISP'.
Customer balance in local currency report
Customer open items report in sap abap
Account receivable information system sap abap report
Customer open item analysis report in erp sap
No comments:
Post a Comment