06-28-2007 9:40 AM
hi,
i have a view CAUFV. when declaring fields can write as follows.
types:begin of ty_caufv,
aufnr like caufv-aufnr,
sowrk like caufv-sowrk,
auart like caufv-auart,
gstrp like caufv-gstrp,
rsnum like caufv-rsnum,
end of ty_caufv.
i have a table RESB as follows.
types:begin of ty_resb,
matnr like resb-matnr,
bdmng like resb-bdmng,
meins like resb-meins,
end of ty_resb.
how should i declare internal tables and should i write select statement and how to pass it to ALV grid.i want coding plz...
very very urgent.
thanks in advance full points will be awarded.if useful.
regards,
kiran
06-28-2007 9:44 AM
Hi,
data: T_caufv type table of ty_cuafv.
data: wa_caufv type ty_caufv.
same with resb.
Regards, Dieter
06-28-2007 9:42 AM
Hi
See the sample code
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
Reward points for useful Answers
Regards
Anji
06-28-2007 9:43 AM
Hello Kiran,
Very good site for alv grid
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid.htm
Regards,
Neelambari
06-28-2007 9:44 AM
Hi,
data: T_caufv type table of ty_cuafv.
data: wa_caufv type ty_caufv.
same with resb.
Regards, Dieter
06-28-2007 9:48 AM
HI,
*internal table declaration
data : it_caufv type standard table of ty_caufv,
it_resb type standartd table of ty_resb.
Yes you need to write select statements
EG: select rsnum
matnr.. (your fields)
from resb where <cond>..
Let say you have two internal table and combination of these two table you need to populate in the list output..
Now define a final internal table..(output fields) and work area for final table
Loop on first table.
move required contents to final work area
read the second table with key = first table key.
move contents of second table to final workarea.
Now append final work area to final internal tba;e.
endloop.
call function 'reuse_alv_grid_display'
pass you internal table and other fields parameters..
Execute the program..
If you are not clear please tell us the requirement wioth the input we shall help you
rewards if useful,
regards,
nazeer