2007 Sep 28 1:21 PM
Hi experts,
I have an ALV list. I'm using the code below, but however I click on a hotspot field in alv it doesn't run to the break-point in FORM user_command. How could it be?
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
...
i_callback_user_command = 'USER_COMMAND'
FORM user_command USING ucomm selfield TYPE slis_selfield..
CASE ucomm.
WHEN '&IC1'.
break-point.
ENDCASE.
ENDFORM.
2007 Sep 28 1:26 PM
Hi
have you populated the EVENTs table properly so that the User Command event will trigger. check it.
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
Regards
Anji
2007 Sep 28 1:26 PM
Hi
have you populated the EVENTs table properly so that the User Command event will trigger. check it.
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
Regards
Anji
2007 Sep 28 1:27 PM
It should go to break-point..
BTW, its CASE SY-UCOMM and not CASE ucomm.
Cheers,
2007 Sep 28 2:38 PM
> It should go to break-point..
>
> BTW, its CASE SY-UCOMM and not CASE ucomm.
>
> Cheers,
Not if it's the form parameter UCOMM he's trying to check against - which it probably is.
2007 Sep 28 1:28 PM
Stripes,
use in this way,
FORM user_command USING ucomm selfield TYPE slis_selfield..
CASE ucomm.
WHEN '&IC1'.
IF selfield-fieldname IS NOT INITIAL
break-point.
endif.
ENDCASE.
ENDFORM.
2007 Sep 28 1:29 PM
hi,
check this.
&----
*& Report ZINT_ALV
*&
&----
*&
*&
&----
REPORT zint_alv.
TYPE-POOLS:slis.
TABLES:mara,
makt,
mseg.
DATA:BEGIN OF itab OCCURS 0,
matnr LIKE mara-matnr,
maktx LIKE makt-maktx,
END OF itab.
DATA:BEGIN OF itab1 OCCURS 0,
mblnr LIKE mseg-mblnr,
menge LIKE mseg-menge,
meins LIKE mseg-meins,
werks LIKE mseg-werks,
END OF itab1.
DATA:fcat TYPE slis_t_fieldcat_alv,
fcat1 TYPE slis_t_fieldcat_alv,
eve TYPE slis_t_event,
eve1 TYPE slis_t_event.
DATA:t_mat LIKE mara-matnr.
SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:mat FOR mara-matnr.
SELECTION-SCREEN:END OF BLOCK blk1.
INITIALIZATION.
PERFORM build_fcat USING fcat.
PERFORM build_eve.
START-OF-SELECTION.
PERFORM get_data.
PERFORM dis_data.
&----
*& Form build_fcat
&----
text
----
-->T_FCAT text
----
FORM build_fcat USING t_fcat TYPE slis_t_fieldcat_alv.
DATA:wa_fcat TYPE slis_fieldcat_alv.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-seltext_m = 'Material'.
wa_fcat-hotspot = 'X'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MAKTX'.
wa_fcat-seltext_m = 'Description'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
ENDFORM. "build_fcat
&----
*& Form build_eve
&----
text
----
FORM build_eve.
DATA:t_eve TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = eve
EXCEPTIONS
LIST_TYPE_WRONG = 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.
READ TABLE eve INTO t_eve WITH KEY name = 'USER_COMMAND'.
IF sy-subrc = 0.
t_eve-form = 'USER_COMMAND'.
MODIFY eve FROM t_eve TRANSPORTING form WHERE name = t_eve-name.
ENDIF.
ENDFORM. "build_eve
&----
*& Form get_data
&----
text
----
FORM get_data.
SELECT maramatnr maktmaktx INTO CORRESPONDING FIELDS OF TABLE itab
FROM mara INNER JOIN makt
ON maramatnr = maktmatnr
WHERE mara~matnr IN mat.
ENDFORM. "get_data
&----
*& Form dis_data
&----
text
----
FORM dis_data.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZINT_ALV'
i_callback_user_command = 'USER_COMMAND'
i_grid_title = 'Interactive ALV'
it_fieldcat = fcat
it_events = eve
TABLES
t_outtab = itab
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. "dis_data
&----
*& Form user_command
&----
text
----
-->U_COM text
----
FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.
CLEAR fcat1.
CASE u_com.
WHEN '&IC1'.
READ TABLE itab INDEX sel_field-tabindex.
IF sel_field-fieldname = 'MATNR'.
IF sy-subrc = 0.
t_mat = itab-matnr.
PERFORM build_cat1 USING fcat1.
PERFORM build_eve1.
PERFORM get_data1.
PERFORM dis_data1.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. "user_command
&----
*& Form build_fcat1
&----
text
----
-->T_FCAT1 text
----
FORM build_cat1 USING t_fcat1 TYPE slis_t_fieldcat_alv.
DATA:wa_fcat1 TYPE slis_fieldcat_alv.
wa_fcat1-tabname = 'ITAB1'.
wa_fcat1-fieldname = 'MBLNR'.
wa_fcat1-seltext_m = 'Material Doc.'.
APPEND wa_fcat1 TO t_fcat1.
CLEAR wa_fcat1.
wa_fcat1-tabname = 'ITAB1'.
wa_fcat1-fieldname = 'MENGE'.
wa_fcat1-seltext_m = 'Quantity'.
APPEND wa_fcat1 TO t_fcat1.
CLEAR wa_fcat1.
wa_fcat1-tabname = 'ITAB1'.
wa_fcat1-fieldname = 'MEINS'.
wa_fcat1-seltext_m = 'UOM'.
APPEND wa_fcat1 TO t_fcat1.
CLEAR wa_fcat1.
wa_fcat1-tabname = 'ITAB1'.
wa_fcat1-fieldname = 'WERKS'.
wa_fcat1-seltext_m = 'Plant'.
APPEND wa_fcat1 TO t_fcat1.
CLEAR wa_fcat1.
ENDFORM. "build_fcat1
&----
*& Form build_eve1
&----
text
----
FORM build_eve1.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = eve1
EXCEPTIONS
list_type_wrong = 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. "build_eve1
&----
*& Form get_data1
&----
text
----
FORM get_data1.
SELECT mblnr menge meins werks FROM mseg
INTO CORRESPONDING FIELDS OF TABLE itab1
WHERE matnr = t_mat.
ENDFORM. "get_data1
&----
*& Form dis_data1
&----
text
----
FORM dis_data1.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZINT_ALV'
it_fieldcat = fcat1
it_events = eve1
TABLES
t_outtab = itab1
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. "dis_data1
2007 Sep 28 1:36 PM
hi
good
Look for set pf-status statement in the code.
YOu wil find a set pf-status 'XXX' statement only if the programmer decides to have his own pf-status to include a custom application toolbar for his alv. Otherwise you will not find a set pf-status statement.
If you find that statement, you can doubleclick on 'XXX' to navigate to se41 transaction where in you can find the function codes of the button.
reward point if helpful.
thanks
mrutyun^
2007 Sep 28 1:44 PM
Dear Mrutyunjaya,
I have no set my own pf-status, my ALV list is automatic. But how can I handle double click anyway?
2007 Sep 28 2:45 PM
I find out that I missed to set I_CALLBACK_PROGRAM in the alv list, but what is it exactly for?
2007 Sep 28 3:20 PM
Hi,
I_CALLBACK_PROGRAM contains the name of the report that call ALV (SY-REPID).
bye
2007 Sep 28 3:58 PM