Application Development 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: 

interactive ALV

Former Member
0 Kudos

HI all,

if you have sample program of interactive ALV then

please send it.

Regards

Suprith

1 ACCEPTED SOLUTION

Former Member
0 Kudos

refer to the link below:

http://www.sap-img.com/abap/an-interactive-alv-report.htm

search the SDN there are lots of material regarding this:

With luck,

Pritam.

10 REPLIES 10

Former Member
0 Kudos

Hi,

Check the code below.. It will be of great help to you( This is using oops )

Screen 9010: ( Sub screen for display )

process before output.

module status_9010.

loop with control tcontrol1.

module display_data.

endloop.

*

process after input.

module user_command_9010.

loop with control tcontrol1.

endloop.

Screen 9020: ( Sub screen for create )

process before output.

module status_9020.

loop with control tcontrol2.

module display_data_tcontrol2.

endloop.

*

process after input.

  • MODULE USER_COMMAND_9020.

loop with control tcontrol2.

module get_data_from_tcontrol2.

endloop.

Screen 9030: ( Sub screen for edit )

process before output.

module status_9030.

loop with control tcontrol3.

module move_data_to_tcontrol3.

endloop.

process after input.

module user_command_9030.

loop with control tcontrol3.

module get_data_from_tcontrol3.

endloop.

&----


*& Module Pool SAPMZ_MR_MAT_BUDGET_VAL

*&

&----


*&

*&

&----


include mz_mr_1087_mat_budget_val_top. " global Data

include mz_mr_1087_mat_budget_val_pbo. " PBO-Modules

include mz_mr_1087_mat_budget_val_pai. " PAI-Modules

include mz_mr_1087_mat_budget_val_f01. " FORM-Routines

&----


*& Include MZ_MR_1087_MAT_BUDGET_VAL_TOP

&----


program sapmz_mr_1065_mat_budget_val.

tables : zpr_1087_mat.

types : begin of ty_mara,

matnr type mara-matnr,

mtart type mara-mtart,

stlnr type mast-stlnr,

end of ty_mara.

types : begin of ty_stpo,

stlnr type stpo-stlnr,

idnrk type stpo-idnrk,

matnr type mara-matnr,

end of ty_stpo.

types : begin of ty_makt,

matnr type makt-matnr,

maktx type makt-maktx,

end of ty_makt.

types : begin of ty_create,

matnr type zpr_1087_mat-matnr,

maktx type zpr_1087_mat-maktx,

dmbtr type zpr_1087_mat-dmbtr,

end of ty_create.

data : wa_makt type ty_makt,

wa_stpo type ty_stpo,

wa_create type ty_create,

wa_edit type ty_create.

data : it_stpo type table of ty_stpo,

it_mara type standard table of ty_mara,

it_makt type table of ty_makt,

it_create type table of ty_create,

it_edit type table of ty_create,

it_zpr_1087_mat type table of zpr_1087_mat,

wa_zpr_1087_mat type zpr_1087_mat.

data : ok_code type sy-ucomm,

ok_code1 type sy-ucomm,

v_matnr like mara-matnr,

v_werks like t001w-werks,

v_gjahr type gjahr,

v_sflag type c.

data: number(4) type n value '9040'.

controls : tcontrol1 type tableview using screen 9010,

tcontrol2 type tableview using screen 9020,

tcontrol3 type tableview using screen 9030.

----


*& Include MZ_MR_1087_MAT_BUDGET_VAL_PBO

&----


&----


*& Module STATUS_9000 OUTPUT

&----


  • text

----


module status_9000 output.

set pf-status 'STATUS'.

set titlebar 'Budget Material Values'.

if ok_code = space.

number = '9040'.

endif.

endmodule. " STATUS_9000 OUTPUT

&----


*& Module display_data 9010 OUTPUT

&----


  • text

----


module display_data output.

read table it_zpr_1087_mat into wa_zpr_1087_mat index tcontrol1-current_line.

if sy-subrc = 0.

perform move_data_tcontrol1.

endif.

endmodule. " display_data OUTPUT

&----


*& Module STATUS_9010 OUTPUT

&----


  • text

----


module status_9010 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

perform display_mat.

endmodule. " STATUS_9010 OUTPUT

&----


*& Module STATUS_9020 OUTPUT

&----


  • text

----


module status_9020 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

endmodule. " STATUS_9020 OUTPUT

&----


*& Module display_data_tcontrol2 OUTPUT

&----


  • text

----


module display_data_tcontrol2 output.

read table it_create into wa_create index tcontrol2-current_line.

if sy-subrc = 0.

perform move_data_tcontrol2.

endif.

endmodule. " display_data_tcontrol2 OUTPUT

&----


*& Module move_data_to_tcontrol3 OUTPUT

&----


  • text

----


module move_data_to_tcontrol3 output.

read table it_edit into wa_edit index tcontrol3-current_line.

if sy-subrc = 0.

perform move_data_tcontrol3.

endif.

endmodule. " move_data_to_tcontrol3 OUTPUT

__________________________________________________________________________

&----


*& Include MZ_MR_1087_MAT_BUDGET_VAL_PAI

&----


&----


*& Module USER_COMMAND_9000 INPUT

&----


  • text

----


module user_command_9000 input.

case ok_code.

when 'DISPLAY'.

number = '9010'.

perform display_data_tcontrol1.

when 'CREATE'.

ok_code1 = ok_code.

number = '9020'.

perform create_mat.

when 'EDIT'.

ok_code1 = ok_code.

number = '9030'.

perform display_data_tcontrol3.

when 'SAVE'.

perform save_data.

endcase.

endmodule. " USER_COMMAND_9000 INPUT

&----


*& Module get_data_from_tcontrol2 INPUT

&----


  • text

----


module get_data_from_tcontrol2 input.

perform get_data_from_tcontrol2.

endmodule. " get_data_from_tcontrol2 INPUT

&----


*& Module get_data_from_tcontrol3 INPUT

&----


  • text

----


module get_data_from_tcontrol3 input.

perform get_data_from_tcontrol3.

endmodule. " get_data_from_tcontrol3 INPUT

&----


*& Module EXIT INPUT

&----


  • text

----


module exit input.

case ok_code.

when 'BACK' or 'EXIT' or 'CANCEL'.

leave to screen 0.

endcase.

endmodule. " EXIT INPUT

____________________________________________________________________________

&----


*& Include MZ_MR_1087_MAT_BUDGET_VAL_F01

&----


&----


*& Form display_mat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_mat .

endform. " display_mat

&----


*& Form move_data_tcontrol1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form move_data_tcontrol1 .

zpr_1087_mat-werks = wa_zpr_1087_mat-werks.

zpr_1087_mat-gjahr = wa_zpr_1087_mat-gjahr.

zpr_1087_mat-matnr = wa_zpr_1087_mat-matnr.

zpr_1087_mat-maktx = wa_zpr_1087_mat-maktx.

zpr_1087_mat-manrf = wa_zpr_1087_mat-manrf.

zpr_1087_mat-dmbtr = wa_zpr_1087_mat-dmbtr.

endform. " move_data_tcontrol1

&----


*& Form create_mat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form create_mat .

refresh : it_mara, it_stpo, it_makt, it_create.

clear : wa_stpo, wa_create.

select single * from zpr_1087_mat

where manrf = v_matnr

and werks = v_werks

and gjahr = v_gjahr.

if sy-subrc <> 0.

select a~matnr

a~mtart

b~stlnr

into table it_mara

from mara as a join mast as b

on amandt = bmandt

and amatnr = bmatnr

where a~matnr = v_matnr

and a~mtart = 'FERT'

and b~werks = v_werks.

if sy-subrc = 0.

sort it_mara by matnr.

select a~stlnr

a~idnrk

b~matnr

into table it_stpo

from stpo as a join mara as b

on amandt = bmandt

and aidnrk = bmatnr

for all entries in it_mara

where a~stlnr = it_mara-stlnr

and b~mtart = 'HALB'.

if sy-subrc = 0.

sort it_stpo by matnr.

select matnr maktx from makt into table it_makt

for all entries in it_stpo

where matnr = it_stpo-matnr.

endif.

endif.

loop at it_stpo into wa_stpo.

move-corresponding wa_stpo to wa_create.

read table it_makt into wa_makt with key matnr = wa_stpo-matnr.

if sy-subrc = 0.

wa_create-maktx = wa_makt-maktx.

endif.

append wa_create to it_create.

endloop.

else.

data : p_ans type c,

parameters like spar occurs 0 with header line.

call function 'POPUP_TO_CONFIRM'

exporting

titlebar = 'Confirm'

diagnose_object = 'Z1087_TEXT'

text_question = 'Material is already created in Budget, Do you want to Edit'

text_button_1 = 'Yes'

icon_button_1 = 'ICON_OKAY'

text_button_2 = 'No'

icon_button_2 = 'ICON_CANCEL'

default_button = '1'

display_cancel_button = 'X'

start_column = 25

start_row = 6

importing

answer = p_ans

tables

parameter = parameters

exceptions

text_not_found = 1

others = 2.

if p_ans = '1'.

number = '9030'.

perform display_data_tcontrol3.

else.

number = '9010'.

perform display_data_tcontrol1.

endif.

endif.

endform. " create_mat

&----


*& Form move_data_tcontrol2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form move_data_tcontrol2 .

zpr_1087_mat-matnr = wa_create-matnr.

zpr_1087_mat-maktx = wa_create-maktx.

zpr_1087_mat-dmbtr = wa_create-dmbtr.

endform. " move_data_tcontrol2

&----


*& Form get_data_from_tcontrol2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data_from_tcontrol2 .

wa_create-matnr = zpr_1087_mat-matnr.

wa_create-maktx = zpr_1087_mat-maktx.

wa_create-dmbtr = zpr_1087_mat-dmbtr.

modify it_create from wa_create index tcontrol2-current_line.

endform. " get_data_from_tcontrol2

&----


*& Form save_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form save_data .

if ok_code1 = 'CREATE'.

loop at it_create into wa_create.

zpr_1087_mat-werks = v_werks.

zpr_1087_mat-gjahr = v_gjahr.

zpr_1087_mat-matnr = wa_create-matnr.

zpr_1087_mat-maktx = wa_create-maktx.

zpr_1087_mat-manrf = v_matnr.

zpr_1087_mat-dmbtr = wa_create-dmbtr.

insert zpr_1087_mat.

if sy-subrc = 0.

v_sflag = 'X'.

endif.

endloop.

if v_sflag = 'X'.

message 'Data has saved' type 'S'.

else.

message 'Error in Data' type 'E'.

endif.

clear v_sflag.

endif.

if ok_code1 = 'EDIT'.

loop at it_edit into wa_edit.

zpr_1087_mat-dmbtr = wa_edit-dmbtr.

update zpr_1087_mat set dmbtr = wa_edit-dmbtr

where werks = v_werks

and gjahr = v_gjahr

and matnr = wa_edit-matnr.

endloop.

endif.

endform. " save_data

&----


*& Form DISPLAY_DATA_TCONTROL1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_data_tcontrol1 .

select * from zpr_1087_mat

into table it_zpr_1087_mat

where manrf = v_matnr "ZPR_1087_MAT-matnr

and werks = v_werks "ZPR_1087_MAT-werks

and gjahr = v_gjahr. "ZPR_1087_MAT-GJAHR.

endform. " DISPLAY_DATA_TCONTROL1

&----


*& Form get_data_from_tcontrol3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data_from_tcontrol3 .

wa_edit-matnr = zpr_1087_mat-matnr.

wa_edit-maktx = zpr_1087_mat-maktx.

wa_edit-dmbtr = zpr_1087_mat-dmbtr.

modify it_edit from wa_edit index tcontrol3-current_line.

endform. " get_data_from_tcontrol3

&----


*& Form move_data_tcontrol3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form move_data_tcontrol3 .

zpr_1087_mat-matnr = wa_edit-matnr.

zpr_1087_mat-maktx = wa_edit-maktx.

zpr_1087_mat-dmbtr = wa_edit-dmbtr.

endform. " move_data_tcontrol3

&----


*& Form DISPLAY_DATA_TCONTROL3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_data_tcontrol3 .

select matnr maktx dmbtr from zpr_1087_mat

into table it_edit

where manrf = v_matnr "ZPR_1087_MAT-matnr

and werks = v_werks "ZPR_1087_MAT-werks

and gjahr = v_gjahr. "ZPR_1087_MAT-GJAHR.

endform.

_____________________________________________________________________

Cheers,

Ram.

Former Member
0 Kudos

Hi Dude,

Here Is the Code,

Execute as it is, it will work.

report z_alv_interactive.

tables: vbrk,vbrp.

data: begin of it_vbrk occurs 0,

vbeln like vbrk-vbeln,

waerk like vbrk-waerk,

fkdat like vbrk-fkdat,

vtweg like vbrk-vtweg,

end of it_vbrk.

data: begin of it_vbrp occurs 0,

fkimg like vbrp-fkimg,

meins like vbrp-meins,

ntgew like vbrp-ntgew,

brgew like vbrp-brgew,

end of it_vbrp.

type-pools: slis.

data: fc type slis_t_fieldcat_alv.

data: fc1 type slis_t_fieldcat_alv.

data: ka like line of fc1.

select-options: doc_num for vbrk-vbeln.

select vbeln waerk fkdat vtweg from vbrk

into table it_vbrk where vbeln in doc_num.

select fkimg meins ntgew brgew from vbrp

into table it_vbrp where vbeln in doc_num.

ka-fieldname = 'FKIMG'.

ka-seltext_m = 'Actual Invoiced Quantity'.

append ka to fc1.

clear ka.

ka-fieldname = 'MEINS'.

ka-seltext_m = 'Base Unit of Measure'.

append ka to fc1.

clear ka.

ka-fieldname = 'NTGEW'.

ka-seltext_m = 'Net weight'.

append ka to fc1.

clear ka.

ka-fieldname = 'BRGEW'.

ka-seltext_m = 'Actual Invoiced Quantity'.

append ka to fc1.

clear ka.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = sy-repid

i_internal_tabname = 'IT_VBRK'

i_inclname = sy-repid

changing

ct_fieldcat = fc.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = sy-repid

i_callback_user_command = 'GBT'

it_fieldcat = fc

i_grid_title = 'BASIC LIST'

tables

t_outtab = it_vbrk.

form gbt using r_ucomm like sy-ucomm rs_selfield type slis_selfield.

if r_ucomm = '&IC1'.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

it_fieldcat = fc1

i_grid_title = 'SECONDARY LIST'

tables

t_outtab = it_vbrp.

endif.

endform.

Former Member
0 Kudos

refer to the link below:

http://www.sap-img.com/abap/an-interactive-alv-report.htm

search the SDN there are lots of material regarding this:

With luck,

Pritam.

Former Member
0 Kudos

Hi,

Check the link,get Example

Former Member
0 Kudos

hi,

Logon to SAPtechnical.com and Click ALv there.

You will find Good Sample codes there.

Regards

Sumit Agarwal

Former Member
0 Kudos

hi suprith kumar

USE slis_selfield and Sy-UCOMM as '&IC1'.

Regards

Deva

Former Member
0 Kudos

Hi ,

Check this link .

http://www.sapdev.co.uk/reporting/alvhome.htm

Regards,

Chitra

Former Member
0 Kudos

peter_ruiz2
Active Contributor
0 Kudos

hi,

there are many sample programs in SAP for interactive ALV including Drag and Drop functionality. Try searching for BCALV* in SE38.

regards,

Peter

Former Member
0 Kudos

closed