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

ALV Report

Former Member
0 Likes
1,115

Hi,

I have one requirement for ALV Report which should display as a checkbox. i have to select some active employees based on some criteria and display it as a report if i want to select a particular employee and save the report means in background it will do some BDC operation how can i do this can any one give some idea

Thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,079

Hi Ravi,

First you create the report as per your requirement. Then build the fieldcat, Event, Heading as per the basic.

while creating Layout

I_LAYOUT-BOX_FIELDNAME = 'CHECK'. Use the FM REUSE_ALV_LIST_DISPLAY in this FM give the export parameters as 'STATUS' and I_CALLBACK_USER_COMMAND = 'CONFIRMATION'

call the subrotine STATUS and CONFIRMATION in the Subrotine confirmation You have to check the condition

ex:

CASE : sy-ucomm.

when : 'SAVE'.

then do the BDC process.

ENDCASE.

Try this one i hope it will help u

Regards,

John

9 REPLIES 9
Read only

Former Member
0 Likes
1,079

Hi Ravi,

i had a similar requirement a month back, we figured out a solution using OO ALV grid.

Following is the way,

Declare this on top---

*----


  • C L A S S E S

*----


CLASS lcl_event_receiver DEFINITION.

PUBLIC SECTION.

METHODS:

handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid

IMPORTING

e_object e_interactive,

handle_user_command FOR EVENT user_command OF cl_gui_alv_grid

IMPORTING e_ucomm.

ENDCLASS.

*----


--

  • CLASS lcl_event_receiver IMPLEMENTATION

*----


--

CLASS lcl_event_receiver IMPLEMENTATION.

METHOD handle_toolbar.

  • Event handler method for event toolbar.

CONSTANTS:

  • Constants for button type

c_button_normal TYPE i VALUE 0,

c_menu_and_default_button TYPE i VALUE 1,

c_menu TYPE i VALUE 2,

c_separator TYPE i VALUE 3,

c_radio_button TYPE i VALUE 4,

c_checkbox TYPE i VALUE 5,

c_menu_entry TYPE i VALUE 6.

DATA:

ls_toolbar TYPE stb_button.

  • Append seperator to the normal toolbar

CLEAR ls_toolbar.

MOVE c_separator TO ls_toolbar-butn_type..

APPEND ls_toolbar TO e_object->mt_toolbar.

  • Append a new button that to the toolbar. Use E_OBJECT of

  • event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.

  • This class has one attribute MT_TOOLBAR which is of table type

  • TTB_BUTTON. The structure is STB_BUTTON

CLEAR ls_toolbar.

MOVE 'CHANGE' TO ls_toolbar-function.

MOVE icon_change TO ls_toolbar-icon.

MOVE 'Change flight' TO ls_toolbar-quickinfo.

MOVE 'Change' TO ls_toolbar-text.

MOVE ' ' TO ls_toolbar-disabled.

APPEND ls_toolbar TO e_object->mt_toolbar.

ENDMETHOD.

METHOD handle_user_command.

  • Handle own functions defined in the toolbar

CASE e_ucomm.

WHEN 'CHANGE'.

PERFORM change_flight.

  • LEAVE TO SCREEN 0.

ENDCASE.

ENDMETHOD.

ENDCLASS.

by this u create a Icon on ALV toolbar.

I will continue with my next post

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,079

One idea is to use the forum and/or wiki search function.

Read only

Former Member
0 Likes
1,079

After then -declare the PBO part of the screen on whcih u display ur alv as-->>>>

-


*

  • MODULE STATUS_0100 OUTPUT

----


*Business Place Wise Document List

----


MODULE STATUS_0100 OUTPUT.

DATA: r_container TYPE REF TO cl_gui_custom_container,

r_alv_grid TYPE REF TO cl_gui_alv_grid,

MYCONTAINER TYPE SCRFNAME VALUE 'CONT',

layout type LVC_S_LAYO.

*data: it_fieldcat type lvc_t_fcat,

  • wa_fieldcat TYPE lvc_s_fcat.

DATA: "event_receiver1 TYPE REF TO lcl_events_d0100,

i_selected_rows TYPE lvc_t_row, "Selected Rows

w_selected_rows TYPE lvc_s_row.

BREAK-POINT.

CREATE OBJECT r_container

EXPORTING

container_name = MYCONTAINER.

      • create object of class cl_gui_alv_grid to visualize data !

CREATE OBJECT r_alv_grid

EXPORTING

i_parent = r_container.

CREATE OBJECT o_event_receiver.

SET HANDLER o_event_receiver->handle_user_command FOR r_alv_grid.

SET HANDLER o_event_receiver->handle_toolbar FOR r_alv_grid.

layout-SEL_MODE = 'A'.

it_t_final[] = it_final[].

CALL METHOD r_alv_grid->set_table_for_first_display

EXPORTING

"IS_PRINT = 'X'

I_SAVE = 'A'

IS_LAYOUT = layout

  • i_structure_name = wa_final

I_DEFAULT = 'X'

CHANGING

it_outtab = it_t_final[]

it_fieldcatalog = it_fieldcat.

*EXCEPTIONS

*OTHERS = 4.

  • IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  • ENDIF.

CALL METHOD r_alv_grid->set_toolbar_interactive.

  • Set focus to the grid. This is not necessary in this

  • example as there is only one control on the screen

CALL METHOD cl_gui_control=>set_focus EXPORTING control = r_alv_grid.

SET PF-STATUS 'REPORT'.

SET TITLEBAR 'ZTITLE'."Business Place Wise Document List'.

ENDMODULE. " STATUS_0100 OUTPUT

Read only

Former Member
0 Likes
1,079

hi Ravi ,

here is the code for ur requirement....

REPORT zashu_alv_in_popup_mara.

TYPE-POOLS : slis.

----


*Data Declaration

----


DATA:i_repid LIKE sy-repid.

i_repid = sy-repid.

----


  • Declaration for ALV

----


DATA: wa_fcat TYPE slis_fieldcat_alv,

fcat TYPE slis_t_fieldcat_alv,

wa_fcat1 TYPE slis_fieldcat_alv,

fcat1 TYPE slis_t_fieldcat_alv.

----


*Types Declaration

----


TYPES:BEGIN OF ty_mat,

matnr TYPE mara-matnr,

checkbox(1),

END OF ty_mat.

TYPES:BEGIN OF ty_makt,

matnr TYPE mara-matnr,

maktg TYPE makt-maktg,

maktx TYPE makt-maktx,

END OF ty_makt.

----


*Internal table Declaration

----


DATA:it_mat TYPE TABLE OF ty_mat WITH HEADER LINE.

DATA:it_makt TYPE TABLE OF ty_makt WITH HEADER LINE.

----


*Range Declaration

----


RANGES : r_matnr FOR mara-matnr.

----


*Start of Selecdtion

----


START-OF-SELECTION.

PERFORM get_data.

PERFORM display_data.

PERFORM display_alv.

----


  • Form get_data

----


FORM get_data.

  • Read material from MARA

SELECT matnr FROM mara INTO TABLE it_mat.

ENDFORM. " GET_DATA

----


  • Form display_data

----


FORM display_data.

wa_fcat-row_pos = '1'.

wa_fcat-col_pos = '1'.

wa_fcat-fieldname = 'CHECKBOX'.

wa_fcat-tabname = 'IT_MAT'.

wa_fcat-seltext_m = 'SELECT'.

APPEND wa_fcat TO fcat.

CLEAR wa_fcat.

wa_fcat-row_pos = '1'.

wa_fcat-col_pos = '2'.

wa_fcat-fieldname = 'MATNR'.

wa_fcat-tabname = 'IT_MAT'.

wa_fcat-seltext_m = 'MATERIAL'.

wa_fcat-outputlen = 50.

APPEND wa_fcat TO fcat.

  • Display data in a POPUP

CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

EXPORTING

i_selection = 'X'

i_zebra = 'X'

it_fieldcat = fcat

i_tabname = 'IT_MAT'

i_checkbox_fieldname = 'CHECKBOX'

TABLES

t_outtab = it_mat.

IF NOT it_mat[] IS INITIAL.

LOOP AT it_mat WHERE checkbox = 'X'.

r_matnr-sign = 'I'.

r_matnr-option = 'EQ'.

r_matnr-low = it_mat-matnr.

r_matnr-high = ' ' .

APPEND r_matnr.

CLEAR r_matnr.

ENDLOOP.

ENDIF.

select matnr maktx maktg from makt into table it_makt where matnr in

r_matnr.

ENDFORM. " DISPLAY_DATA

&----


*& Form DISPLAY_ALV

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_alv .

*ALV Display in a POPUP window

wa_fcat1-row_pos = '1'.

wa_fcat1-col_pos = '1'.

wa_fcat1-fieldname = 'MATNR'.

wa_fcat1-tabname = 'IT_MAKT'.

wa_fcat1-seltext_m = 'Material No'.

APPEND wa_fcat1 TO fcat1.

CLEAR wa_fcat.

wa_fcat1-row_pos = '1'.

wa_fcat1-col_pos = '2'.

wa_fcat1-fieldname = 'MAKTX'.

wa_fcat1-tabname = 'IT_MAKT'.

wa_fcat1-seltext_m = 'DESCRIPTION'.

APPEND wa_fcat1 TO fcat1.

wa_fcat1-row_pos = '1'.

wa_fcat1-col_pos = '3'.

wa_fcat1-fieldname = 'MAKTG'.

wa_fcat1-tabname = 'IT_MAKT'.

wa_fcat1-seltext_m = 'GROUP'.

APPEND wa_fcat1 TO fcat1.

CLEAR wa_fcat1.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = i_repid

i_grid_title = 'Material Description'

it_fieldcat = fcat1

  • I_SCREEN_START_COLUMN = 30

  • I_SCREEN_START_LINE = 10

  • I_SCREEN_END_COLUMN = 70

  • I_SCREEN_END_LINE = 30

TABLES

t_outtab = it_makt

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF sy-subrc <> 0.

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

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

ENDIF.

ENDFORM. " DISPLAY_ALV

thanks

Ashu

Read only

Former Member
0 Likes
1,080

Hi Ravi,

First you create the report as per your requirement. Then build the fieldcat, Event, Heading as per the basic.

while creating Layout

I_LAYOUT-BOX_FIELDNAME = 'CHECK'. Use the FM REUSE_ALV_LIST_DISPLAY in this FM give the export parameters as 'STATUS' and I_CALLBACK_USER_COMMAND = 'CONFIRMATION'

call the subrotine STATUS and CONFIRMATION in the Subrotine confirmation You have to check the condition

ex:

CASE : sy-ucomm.

when : 'SAVE'.

then do the BDC process.

ENDCASE.

Try this one i hope it will help u

Regards,

John

Read only

0 Likes
1,079

Hi,

How can we create the status and whats the purpose i cant get it. Plz give some idea regard this.

Read only

0 Likes
1,079

Hi Ravi,

I posted the resolution to ur issues in 3 parts...look in to them u will get ur solution.

Regards,

Akash Rana

Read only

0 Likes
1,079

Hi Ravi,

PF status is used to create menu. it can be achieved through menu painter(SE41).

Here we have to give name for each and every icon based on this name we have to write code according to this name

example : we create a menu like in save icon we give this as name save. then while coding u have to check the SY-UCOM system field have the name save if its there u will write some code or some condition where you want.

Regards,

John

Read only

Former Member
0 Likes
1,079

Using this layout-SEL_MODE = 'A'.,

U can select multiple rows in ur ALV......after then when u click on the "CHANGE" function we created in top to trigger a BDC or Smart form Or an another report because u can get all the index of the rows u select in the ALV.....after then with those index u can read the table u were passing to the ALV....this is done by the subroutine we defined in top with the CHANGE Functioni.e what would happen if we click CHANGE in ALV toolbar.....Following Form is been called .

FORM change_flight.

CLEAR i_selected_rows.

BREAK-POINT.

CALL METHOD r_alv_grid->get_selected_rows

IMPORTING

et_index_rows = i_selected_rows.

LOOP AT i_selected_rows INTO w_selected_rows.

  • BREAK-POINT.

READ TABLE it_T_FINAL INTO wa_t_FINAL INDEX w_selected_rows-index.

IF sy-subrc EQ 0.

wa_T_FINAL-MARK = 'X'.

MODIFY it_T_FINAL FROM wa_t_FINAL INDEX w_selected_rows-index.

ENDIF.

ENDLOOP.

PERFORM CALL_SMARTFORM.

ENDFORM.

using this subroutine u can read the t_final rows u selected in alv and hence Run the BDC Next.

Hope this resolves ur Issue.

Regards,

Akash Rana