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

Interactive alv with oops

praveen_hannu
Contributor
0 Likes
725

Hi Friends

Please help me providing the solution to create interactive list using oops.

5 REPLIES 5
Read only

FredericGirod
Active Contributor
0 Likes
586

Transaction DWDM will give you examples

Read only

RaymondGiuseppi
Active Contributor
0 Likes
586

Take a look at [ALV Gird Control (BC-SRV-ALE)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf]

Look at samples via SE83 or DWDM.

Regards

Read only

uwe_schieferstein
Active Contributor
0 Likes
586

Hello Praveen

You will plenty of my simplified sample reports (all beginning with ZUS_SDN_...) in the SDN forums.

Regards,

Uwe

Read only

Former Member
0 Likes
586

please check the fallowing code for interacive report

&----


*& Report ZVEN_INTERACTIVE_OBJ

*&

&----


*&

*&

&----


REPORT ZVEN_INTERACTIVE_OBJ.

*----type ref variables for custom container and alv

data:o_cost type ref to cl_gui_custom_container,

o_cost1 type ref to cl_gui_custom_container,

o_alv1 type ref to cl_gui_alv_grid,

o_alv type ref to cl_gui_alv_grid.

*-----Parameter declarations

parameters:p_vbeln like vbrk-vbeln.

tables:vbrk.

*selection-screen begin of block a with frame title text-001.

*select-options:s_vbeln for vbrk-vbeln.

*selection-screen end of block a.

*-----Internal table for vbrk and vbrp

data:it_vbrk like vbrk occurs 1 with header line,

it_vbrp like vbrp occurs 1 with header line.

data:it_index like LVC_S_ROW occurs 1 with header line,

wa_index like line of it_index.

data:wa_vbrk type vbrk.

*-----declaration for field catalog

data:it_fcat TYPE LVC_T_FCAT with header line.

*----class for handlling the event

class c1 definition.

public section.

methods:handler_HOTSPOT_CLICK for event HOTSPOT_CLICK

of cl_gui_alv_grid.

endclass.

*----implementaion for the enent

class c1 implementation.

method:handler_HOTSPOT_CLICK.

call screen 200.

endmethod.

endclass.

start-of-selection.

*---ref variable

data:obj type ref to c1.

create object obj.

*---Registering the event for the class c1

set handler obj->handler_HOTSPOT_CLICK for all instances.

*----populate the field catalog

perform populate_fieldcat.

set screen 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


module STATUS_0100 output.

SET PF-STATUS 'MENU'.

IF o_cost IS INITIAL.

*----Linking between screen to custom container class

CREATE OBJECT o_cost

EXPORTING

container_name = 'VBRK_COST'

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 I000(Z00) WITH 'Error while linking to custom container'.

ENDIF.

*-----Linking between custom container to alv grid class

CREATE OBJECT o_alv

EXPORTING

i_parent = o_cost

EXCEPTIONS

ERROR_CNTL_CREATE = 1

ERROR_CNTL_INIT = 2

ERROR_CNTL_LINK = 3

ERROR_DP_CREATE = 4

others = 5

.

IF sy-subrc <> 0.

MESSAGE I000(Z00) WITH 'Error while linging to alv frist grid'.

ENDIF.

*---Registering the event for the class c1

*set handler

*---get the data from vbrk

perform get_data_vbrk.

CALL METHOD o_alv->set_table_for_first_display

EXPORTING

I_STRUCTURE_NAME = 'VBRK'

CHANGING

it_outtab = it_vbrk[]

IT_FIELDCATALOG = IT_FCAT[]

EXCEPTIONS

INVALID_PARAMETER_COMBINATION = 1

PROGRAM_ERROR = 2

TOO_MANY_LINES = 3

others = 4

.

IF sy-subrc <> 0.

MESSAGE I000(Z00) WITH 'Data was not display in first alv'.

ENDIF.

endif.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module USER_COMMAND_0100 input.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE PROGRAM.

ENDCASE.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Form get_data_vbrk

&----


  • text

----


form get_data_vbrk .

select *

from vbrk

into table it_vbrk

where vbeln = p_vbeln.

endform. " get_data_vbrk

&----


*& Form populate_fieldcat

&----


  • text

----


form populate_fieldcat.

it_fcat-col_pos = 1.

it_fcat-FIELDNAME = 'VBELN'.

it_fcat-TABNAME = 'IT_VBRK'.

it_fcat-KEY = 'X'.

IT_FCAT-HOTSPOT = 'X'.

APPEND IT_FCAT.

CLEAR IT_FCAT.

endform. " populate_fieldcat

&----


*& Module STATUS_0200 OUTPUT

&----


  • text

----


module STATUS_0200 output.

SET PF-STATUS 'MENU'.

IF o_cost1 IS INITIAL.

*----Linking between screen to custom container class

CREATE OBJECT o_cost

EXPORTING

container_name = 'VBRP_COST'

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 I000(Z00) WITH 'Error while linking to custom container'.

ENDIF.

*-----Linking between custom container to alv grid class

CREATE OBJECT o_alv1

EXPORTING

i_parent = o_cost1

EXCEPTIONS

ERROR_CNTL_CREATE = 1

ERROR_CNTL_INIT = 2

ERROR_CNTL_LINK = 3

ERROR_DP_CREATE = 4

others = 5

.

IF sy-subrc <> 0.

MESSAGE I000(Z00) WITH 'Error while linging to alv Second grid'.

ENDIF.

*---get the data from vbrk

perform get_data_vbrp.

CALL METHOD o_alv1->set_table_for_first_display

EXPORTING

I_STRUCTURE_NAME = 'VBRP'

CHANGING

it_outtab = it_vbrp[]

  • IT_FIELDCATALOG = IT_FCAT[]

EXCEPTIONS

INVALID_PARAMETER_COMBINATION = 1

PROGRAM_ERROR = 2

TOO_MANY_LINES = 3

others = 4

.

IF sy-subrc <> 0.

MESSAGE I000(Z00) WITH 'Data was not display in first alv'.

ENDIF.

endif.

endmodule. " STATUS_0200 OUTPUT

&----


*& Form get_data_vbrp

&----


  • text

----


form get_data_vbrp .

select *

from vbrp

into table it_vbrp

where vbeln = p_vbeln.

endform. " get_data_vbrp

&----


*& Module USER_COMMAND_0200 INPUT

&----


  • text

----


module USER_COMMAND_0200 input.

case sy-ucomm.

when 'BACK'.

LEAVE TO SCREEN 100.

endcase.

endmodule. " USER_COMMAND_0200 INPUT

Read only

Former Member
0 Likes
586

Hi, this may help you

report yh645_secndry_alv.

type-pools: slis.

data: fieldcat type slis_t_fieldcat_alv,

fieldcat_ln like line of fieldcat,

fs_layout type slis_layout_alv,

t_layoout like standard table

of fs_layout.

data: begin of fs_spfli,

carrid type spfli-carrid,

connid type spfli-connid,

countryfr type spfli-countryfr,

cityfrom type spfli-cityfrom,

airpfrom type spfli-airpfrom,

countryto type spfli-countryto,

cityto type spfli-cityto,

airpto type spfli-airpto,

fltime type spfli-fltime,

deptime type spfli-deptime,

arrtime type spfli-arrtime,

distance type spfli-distance,

distid type spfli-distid,

fltype type spfli-fltype,

period type spfli-period,

checkbox,

color(3),

end of fs_spfli.

data:

begin of fs_table,

carrid type spfli-carrid,

connid type spfli-connid,

end of fs_table.

data: begin of fs_sflight,

check,

color(3).

include type sflight.

data:end of fs_sflight.

data:

begin of fs_table1,

carrid type sflight-carrid,

connid type sflight-connid,

fldate type sflight-fldate,

end of fs_table1.

data:

t_spfli like standard table

of fs_spfli.

data:

t_table like standard table

of fs_table.

data:

t_table1 like standard table

of fs_table1.

data:

t_sflight like standard table

of fs_sflight.

data:

t_sbook like standard table

of sbook.

data t_layout type slis_layout_alv.

select *

into corresponding fields of table t_spfli

from spfli.

perform start_list_viewer.

perform get_spfli_details.

&----


*& Form SUB1

&----


  • text

----


  • -->RT_EXTAB text

----


form sub1 using rt_extab type slis_t_extab.

data: flight type slis_extab.

flight-fcode = 'SFLIGHT'.

append flight to rt_extab.

set pf-status 'SFLIGHT'. " EXCLUDING RT_EXTAB.

endform. "SUB1

&----


*& Form START_LIST_VIEWER

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form start_list_viewer .

data: pgm like sy-repid.

pgm = sy-repid.

fs_layout-box_fieldname = 'CHECKBOX'.

fs_layout-info_fieldname = 'COLOR'.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = pgm

i_callback_pf_status_set = 'SUB1'

i_callback_user_command = 'USER_COMMAND'

i_structure_name = 'SPFLI'

is_layout = fs_layout

tables

t_outtab = t_spfli

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. " START_LIST_VIEWER

*******Process Call Back Events (Begin)**************************

form user_command using ucomm like sy-ucomm

selfield type slis_selfield.

case ucomm.

when 'SFLIGHT'.

selfield-refresh = 'X'.

perform get_spfli_details.

select *

from sflight

into corresponding fields of table t_sflight

for all entries in t_table

where carrid eq t_table-carrid

and connid eq t_table-connid.

perform display_sflight.

when 'SBOOK'.

selfield-refresh = 'X'.

perform get_sflight_details.

select *

from sbook

into corresponding fields of table t_sbook

for all entries in t_table1

where carrid eq t_table1-carrid

and connid eq t_table1-connid

and fldate eq t_table1-fldate.

perform display_sbook.

endcase.

endform. "USER_COMMAND

&----


*& Form SUB2

&----


  • text

----


  • -->RT_EXTAB text

----


form sub2 using rt_extab type slis_t_extab.

data: flight type slis_extab.

flight-fcode = 'SBOOK'.

append flight to rt_extab.

set pf-status 'SBOOK'. " EXCLUDING RT_EXTAB.

endform. "SUB2

&----


*& Form DISPLAY_SFLIGHT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_sflight .

data: pgm like sy-repid.

pgm = sy-repid.

clear t_layout.

fs_layout-box_fieldname = 'CHECK'.

fs_layout-info_fieldname = 'COLOR'.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = pgm

i_callback_pf_status_set = 'SUB2'

i_callback_user_command = 'USER_COMMAND'

i_structure_name = 'SFLIGHT'

is_layout = fs_layout

tables

t_outtab = t_sflight

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_SFLIGHT

&----


*& Form GET_SPFLI_DETAILS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_spfli_details .

loop at t_spfli into fs_spfli.

if fs_spfli-checkbox = 'X'.

fs_spfli-color = 'C51'.

fs_spfli-checkbox = '1'.

fs_table-carrid = fs_spfli-carrid.

fs_table-connid = fs_spfli-connid.

append fs_table to t_table.

modify t_spfli from fs_spfli.

endif.

endloop.

endform. " GET_SFLIGHT_DETAILS

&----


*& Form GET_SFLIGHT_DETAILS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_sflight_details .

loop at t_sflight into fs_sflight.

if fs_sflight-check = 'X'.

fs_sflight-color = 'C71'.

fs_sflight-check = '1'.

fs_table1-carrid = fs_sflight-carrid.

fs_table1-connid = fs_sflight-connid.

fs_table1-fldate = fs_sflight-fldate.

append fs_table1 to t_table1.

modify t_sflight from fs_sflight.

endif.

endloop.

endform. " GET_SFLIGHT_DETAILS

&----


*& Form DISPLAY_SBOOK

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_sbook .

data: pgm like sy-repid.

pgm = sy-repid.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = pgm

i_structure_name = 'SBOOK'

tables

t_outtab = t_sbook

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_SBOOK

Regards

Madhu