‎2007 Feb 24 5:17 AM
Hey,
I am getting problem with alv interactive code.
-
&----
*& Report ZBPMYALVINTERACTIVE1 *
*& *
&----
*& *
*& *
&----
REPORT ZBPMYALVINTERACTIVE1 no standard page heading line-count 32(2).
TYPE-POOLS: SLIS.
tables: kna1,vbak,vbap.
select-options : cust for kna1-kunnr.
types: begin of t_kna1,
kunnr type kunnr,
name1 type name1,
ort01 type ort01,
land1 type land1,
end of t_kna1.
types: begin of t_vbak,
vbeln type vbeln,
netwr type netwr,
end of t_vbak.
data: i_kna1 type standard table of t_kna1 initial size 100,
w_kna1 type t_kna1,
i_vbak type standard table of t_vbak initial size 100,
w_vbak type t_vbak.
data: repid like sy-repid.
data: w_fcat1 type slis_fieldcat_alv,
t_fcat1 type slis_t_fieldcat_alv,
w_fcat2 type slis_fieldcat_alv,
t_fcat2 type slis_t_fieldcat_alv.
data: t_events type slis_t_event,
s_events type slis_alv_event.
perform getdata.
repid = sy-repid.
select kunnr land1 name1 ort01 from kna1 into table i_kna1 where
kunnr in cust.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'repid'
IT_FIELDCAT = t_fcat1
IT_EVENTS = t_events
TABLES
T_OUTTAB = i_kna1
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
&----
*& Form getdata
&----
text
----
--> p1 text
<-- p2 text
----
FORM getdata .
w_fcat1-fieldname = 'KUNNR'.
w_fcat1-seltext_m = 'Customer'.
append w_fcat1 to t_fcat1.
clear w_fcat1.
w_fcat1-fieldname = 'LAND1'.
w_fcat1-seltext_m = 'Country'.
append w_fcat1 to t_fcat1.
clear w_fcat1.
w_fcat1-fieldname = 'NAME1'.
w_fcat1-seltext_m = 'Name'.
append w_fcat1 to t_fcat1.
clear w_fcat1.
w_fcat1-fieldname = 'ORT01'.
w_fcat1-seltext_m = 'City'.
append w_fcat1 to t_fcat1.
clear w_fcat1.
w_fcat2-fieldname = 'VBELN'.
w_fcat2-seltext_m = 'Order No'.
append w_fcat2 to t_fcat2.
clear w_fcat2.
w_fcat2-fieldname = 'NETWR'.
w_fcat2-seltext_m = 'Net Order Value'.
append w_fcat2 to t_fcat2.
clear w_fcat2.
s_events-name = 'user-command'.
s_events-form = 'val'.
append s_events to t_events.
ENDFORM. " getdata
*perform val.
&----
*& Form val
&----
text
----
--> p1 text
<-- p2 text
----
FORM val using user-command like sy-ucomm sel type slis_selfield .
data: cus(10) type n,
sal(10) type n,
mat(10) type n.
if sel-fieldname = 'KUNNR'.
cus = sel-value.
select vbeln netwr from vbak into table i_vbak where kunnr = cus.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'repid '
IT_FIELDCAT = t_fcat2
IT_EVENTS = t_events
TABLES
T_OUTTAB = i_vbak.
ENDIF.
ENDFORM. " val
-
while executing the code i am getting the following error "call back event user-command does'nt exit". Can i know how to fix the error.
thanks in advance
‎2007 Feb 24 8:45 AM
Hi Ben
Check the following line in your code
s_events-name = '<b>user-command'.</b>
user_command should be in capital.
Replace 'user_command' with 'USER_COMMAND'
Now it doesn't give the error for sure
Regards,
MB
‎2007 Feb 24 5:38 AM
Instead of using this function module you can try this:
FORM user_command USING alv_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: ls_vbeln TYPE vbeln.
DATA: ls_posnr TYPE posnr.
DATA: ls_err_text(80) TYPE c. "Message text
CASE alv_ucomm.
WHEN '&IC1'. "Double Click
CASE rs_selfield-fieldname.
WHEN 'DOCNUM'.
READ TABLE alv_table INDEX rs_selfield-tabindex.
IF sy-subrc EQ 0.
ls_vbeln = alv_table-docnum.
ls_posnr = alv_table-itemno+4(6).
***************
after this do whatever function you want to perform.
When we double click value of sy-ucomm is &Ic1
‎2007 Feb 24 5:39 AM
Hi ,
In the Function Module REUSE_ALV_LIST_DISPLAY pass the parameter
i_callback_usercommand as 'USER_COMMAND'.
Use FM REUSE_EVENTS_GET and append ur events USER_COMMAND AND FORM USER_COMMAND .
then use REUSE_EVENTS_SET .
Please reward if useful.
‎2007 Feb 24 8:05 AM
DATA : IFIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WFIELDCAT TYPE SLIS_FIELDCAT_ALV,
ILAYOUT TYPE SLIS_LAYOUT_ALV,
ievent type slis_t_event,
wevent type slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = ievent
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 ievent into wevent with key name = 'USER_COMMAND'.
if sy-subrc = 0.
wevent-form = 'USER_COMMAND'.
modify ievent from wevent index sy-tabix.
endif.
now call
FORM val using user_command like sy-ucomm sel type slis_selfield .
data: cus(10) type n,
sal(10) type n,
mat(10) type n.
if sel-fieldname = 'KUNNR'.
cus = sel-value.
select vbeln netwr from vbak into table i_vbak where kunnr = cus.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'repid '
IT_FIELDCAT = t_fcat2
IT_EVENTS = t_events
TABLES
T_OUTTAB = i_vbak.
ENDIF.
endform.
regards
shiba dutta
‎2007 Feb 24 8:45 AM
Hi Ben
Check the following line in your code
s_events-name = '<b>user-command'.</b>
user_command should be in capital.
Replace 'user_command' with 'USER_COMMAND'
Now it doesn't give the error for sure
Regards,
MB
‎2007 Feb 24 10:16 AM
... this is one error,
the other is
I_CALLBACK_PROGRAM = 'repid'
must be
I_CALLBACK_PROGRAM = repid
Regards,
Clemens
‎2007 Feb 24 10:30 AM
Hi BEN,
The main problem in your code that i can see is while calling the Function Module:-
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
<b>I_CALLBACK_PROGRAM = 'repid'</b>
IT_FIELDCAT = t_fcat1
IT_EVENTS = t_events
TABLES
T_OUTTAB = i_kna1
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*********************************************************
The parameter: I_CALLBACK_PROGRAM should have the name of the program in all CAPS.
<b>I_CALLBACK_PROGRAM = 'REPID'</b>
Its a case sensitive thing. Also, you can put the name of the callback program in a Variable and pass the name of the variable directly to the parameter.
DATA: lv_program type sy-repid.
lv_program = 'ZTEST_REPORT'.
<b>I_CALLBACK_PROGRAM = lv_program</b>.
NOTE: Please reward points if your are satisfied with the solution :).
Thanks and regards,
Ravi .
‎2007 Feb 24 10:14 PM
The first list is displaying but when i double click on the customer no its not displaying second list. is there any problem with the code. I changed user_command and repid to upper case.
‎2007 Feb 26 5:19 AM
Hi Ben
do the following changes
1)
w_fcat1-fieldname = 'KUNNR'.
w_fcat1-seltext_m = 'Customer'.
<b>w_fcat1-HOTSPOT = 'X'.</b>
append w_fcat1 to t_fcat1.
clear w_fcat1.
2)
s_events-name = 'USER_COMMAND'.
s_events-form = '<b>VAL</b>'.
append s_events to t_events.
3)FORM val using user-command like sy-ucomm sel type slis_selfield .
data: cus(10) type n,
sal(10) type n,
mat(10) type n.
if sel-fieldname = 'KUNNR'.
cus = sel-value.
*use the following function module for conversion
<b> CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = CUS
IMPORTING
OUTPUT = CUS
.</b>
select vbeln netwr from vbak into table i_vbak where kunnr = cus.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPID
IT_FIELDCAT = t_fcat2
IT_EVENTS = t_events
TABLES
T_OUTTAB = i_vbak.
ENDIF.
ENDFORM.
4) make REPID capital where ever you are passing that parameter
Revert back if you still have problem.
Regards,
MB
‎2007 Feb 26 6:23 PM
As I said:
don't change repid to upper case but do not enclose itz in quotes because you defiined it as a field.
Regards,
Clemens
‎2007 Mar 03 3:19 AM
I want to know how to display the grid title with multi lines in alv. I am using I_GRID_TITLE = ' '. In the same way how to display an image in alv. I am using reuse_alv_grid_display function.
‎2007 Mar 03 3:31 AM
Use TOP OF PAGE event to display the headings and logo.
and add this code.
FORM TOP OF PAGE
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
Then Call Function -
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
ENDFORM.
Check the sample by Arun R in this thread.
Regards,
Amit
Reward all helpful replies.
‎2007 Mar 03 4:20 AM
I am not getting the Image and text in the header. I am getting the blank header.My code is
-
REPORT ZBPMYALVINTERACTIVE1 no standard page heading line-count 32(2).
TYPE-POOLS: SLIS.
tables: kna1,vbak,vbap.
select-options : cust for kna1-kunnr.
types: begin of t_kna1,
kunnr type kunnr,
name1 type name1,
ort01 type ort01,
land1 type land1,
end of t_kna1.
types: begin of t_vbak,
vbeln type vbeln,
netwr type netwr,
end of t_vbak.
types: begin of t_vbap,
posnr type posnr,
matnr type matnr,
end of t_vbap.
data: i_kna1 type standard table of t_kna1 initial size 100,
w_kna1 type t_kna1,
i_vbak type standard table of t_vbak initial size 100,
w_vbak type t_vbak,
i_vbap type standard table of t_vbap initial size 100,
w_vbap type t_vbak.
data: repid like sy-repid.
data: w_fcat1 type slis_fieldcat_alv,
t_fcat1 type slis_t_fieldcat_alv,
w_fcat2 type slis_fieldcat_alv,
t_fcat2 type slis_t_fieldcat_alv,
w_fcat3 type slis_fieldcat_alv,
t_fcat3 type slis_t_fieldcat_alv.
data: t_events type slis_t_event,
s_events type slis_alv_event.
perform getdata.
repid = sy-repid.
select kunnr land1 name1 ort01 from kna1 into table i_kna1 where
kunnr in cust.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
I_CALLBACK_USER_COMMAND = 'USER_COMMAND '
I_CALLBACK_TOP_OF_PAGE = 'top_of_page '
IT_FIELDCAT = t_fcat1
IT_EVENTS = t_events
TABLES
T_OUTTAB = i_kna1
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.
&----
*& Form getdata
&----
text
----
--> p1 text
<-- p2 text
----
FORM getdata .
w_fcat1-fieldname = 'KUNNR'.
w_fcat1-outputlen = 7.
w_fcat1-seltext_m = 'Customer'.
append w_fcat1 to t_fcat1.
clear w_fcat1.
w_fcat1-fieldname = 'LAND1'.
w_fcat1-outputlen = 10.
w_fcat1-seltext_m = 'Country'.
append w_fcat1 to t_fcat1.
clear w_fcat1.
w_fcat1-fieldname = 'NAME1'.
w_fcat1-outputlen = 10.
w_fcat1-seltext_m = 'Name'.
append w_fcat1 to t_fcat1.
clear w_fcat1.
w_fcat1-fieldname = 'ORT01'.
w_fcat1-outputlen = 25.
w_fcat1-seltext_m = 'City'.
append w_fcat1 to t_fcat1.
clear w_fcat1.
w_fcat2-fieldname = 'VBELN'.
w_fcat2-seltext_m = 'Order No'.
append w_fcat2 to t_fcat2.
clear w_fcat2.
w_fcat2-fieldname = 'NETWR'.
w_fcat2-seltext_m = 'Net Order Value'.
append w_fcat2 to t_fcat2.
clear w_fcat2.
w_fcat3-fieldname = 'POSNR'.
w_fcat3-outputlen = 20.
w_fcat3-seltext_m = 'Sales Document'.
append w_fcat3 to t_fcat3.
clear w_fcat3.
w_fcat3-fieldname = 'MATNR'.
w_fcat3-outputlen = 20.
w_fcat3-seltext_m = 'Material Number'.
append w_fcat3 to t_fcat3.
clear w_fcat3.
*--- Vivek Begin of comments
s_events-name = 'user_command'.
s_events-form = 'val'.
append s_events to t_events.
*--- Vivek End of comments
*--- Vivek Begin of insertion
s_events-name = slis_ev_user_command.
s_events-name = 'USER_COMMAND'.
APPEND s_events TO t_events.
*--- Vivek End of insertion
ENDFORM. " getdata
&----
*& Form val
&----
text
----
--> p1 text
<-- p2 text
----
FORM user_command using command like sy-ucomm "vivek
sel type slis_selfield .
data: cus(10) type n.
if sel-fieldname = 'KUNNR'.
cus = sel-value.
select vbeln netwr from vbak into table i_vbak where kunnr = cus.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
I_callback_user_command = 'USER_COMMAND1'
IT_FIELDCAT = t_fcat2
IT_EVENTS = t_events
TABLES
T_OUTTAB = i_vbak.
ENDIF.
ENDFORM.
*
FORM user_command1 using command like sy-ucomm "vivek
sel type slis_selfield .
data: sal(10) type n.
if sel-fieldname = 'VBELN'.
sal = sel-value.
select posnr matnr from vbap into table i_vbap where vbeln = sal.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
IT_FIELDCAT = t_fcat3
IT_EVENTS = t_events
TABLES
T_OUTTAB = i_vbap.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
I_BACKGROUND_ID = 'Image '
I_GRID_TITLE = 'This is the Third Grid'
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = t_fcat3
IT_EVENTS = t_events
I_SCREEN_START_COLUMN = 10
I_SCREEN_START_LINE = 5
I_SCREEN_END_COLUMN = 20
I_SCREEN_END_LINE = 5
TABLES
T_OUTTAB = i_vbap
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.
ENDIF.
ENDFORM. " val
top-of-page.
write: 'GCC',
/ 'Hoston','TX'.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = it_list_header
I_LOGO = 'ENJOYSAP_LOGO'.
I_END_OF_LIST_GRID =
-
thanks in advance
.
‎2007 Mar 03 6:05 AM
Ben
Check the following code, it may solve ur problem
<b>DATA: it_list_header type SLIS_T_LISTHEADER.</b>
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
I_CALLBACK_USER_COMMAND = 'USER_COMMAND '
*I_CALLBACK_TOP_OF_PAGE = 'top_of_page '
I_CALLBACK_TOP_OF_PAGE = '<b>TOP_OF_PAGE</b>'
IT_FIELDCAT = t_fcat1
IT_EVENTS = t_events
TABLES
T_OUTTAB = i_kna1
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
<b>FORM TOP_OF_PAGE.</b>
DATA: ls_line TYPE slis_listheader.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = 'GCC'.
APPEND ls_line TO it_list_header.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = 'Hoston'.
APPEND ls_line TO it_list_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
<b> IT_LIST_COMMENTARY = it_list_header</b>
I_LOGO = 'ENJOYSAP_LOGO'.
I_END_OF_LIST_GRID =
ENDFORM.
--MB
‎2007 Mar 03 6:31 PM
Thanks. I want to know can we increase the size of the image/logo.
‎2007 Mar 05 5:46 AM
Hi Ben
When we are working with usual ABAP; logo occupies the space equal to its size. and it is displayed in the area reserved for top-of-page.
Reserve more space for top-of-page so that u can view the logo completely.
IF we display the logo using ABAP Objects, then we have control over it.
..
MB
‎2007 Mar 03 6:32 PM