At line-selection & at user-command event issue
hi
i am working on a interactive report,with at line & at user command event,on list 3 i have used a pf status,to trigger the at user command event,till that i was working with at line selection,which are working fine,but on list 3,i am able to see my pf status,but at user command event is not working properly,its still working like at line selection event,if i clk on record,it take to for nxt action,which i want to do through the action button of pf status.
In debugging i checked that it coming to at user command,but the action in sy-user is 'PICK' & its doing the operation.
WHEN '3'.
IF itab4[] IS NOT INITIAL.
SET PF-STATUS 'Z203'.
LOOP AT itab4.
AT FIRST.
WRITE:/1 'Material' ,18 'Name'.
ENDAT.
WRITE:/1 itab4-matnr,8 itab4-maktx.
HIDE:itab4-matnr.
ENDLOOP.
ELSE.
WRITE:/ 'No Data Found'.
ENDIF.
ENDCASE.
BREAK-POINT.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'CALL'.
PERFORM bdc_mm02.
ENDCASE.
pls tel me how to use at line selection & at user command in same report to make both events working efficiently.
regds
vipin
Check whether you have assigned Function Key F2 to your function code 'CALL'. If so change that function key. The function key F2 is always linked to function code 'PICK'.
Regards
Sathar
Similar Messages
-
At line-selection & At user-command
Hi friends,
I have a small doubt. Can we user AT LINE-SELECTION & AT USER-COMMAND in one report..plz gimme an example.
Thanks is advance,
regards,
Ramhi, try these with example i have given.
Write the set pf-status under start-of-selection,
In the set pf-status under the function keys give
F2 Pick Choose.
u can validate the at line-selection by taking..
At line-selection.
case sy-lsind.
when 1.
message....
when 2.
message....
endcase.
similarly, for At user-command.
case sy-ucomm.
when 'back'.
message...
when...
endcase.
Syntax
AT USER-COMMAND.
Effect
This statement defines an event block whose event is triggered by the ABAP runtime environment if, during the display of a screen list, a function with a self-defined function code was chosen.
Note
Self-defined function codes are all those that include character combinations, except for the following:
The function codes PICK and PF## ("##" stands for 01 to 24) do not cause the event AT USER-COMMAND, but the events AT LINE-SELECTION and AT PF##.
All function codes that start with the character "%" are interpreted as system functions and do not cause the event AT USER-COMMAND. The system functions for lists are listed in the following table 1.
The function codes in the following table 2, likewise, do not cause the event AT USER-COMMAND, but are handled by the list processor.
Table 1
Function code Function
%CTX Call a context menu
%EX Exit
%PC Save to file
%PRI Print
%SC Search for ...
%SC+ Find next
%SL Search in office
%ST Save to report tree
Table 2
Function code Function
BACK Back
P- Scroll to previous page
P-- Scroll to first page
P+ Scroll to next page
P++ Scroll to last page
PFILE name Store list lines in a text file named abap.lst in standard character representation in the standard directory of the application server. If a name is entered using name, this is converted to lowercase letters and used as the file name.
PL- Scroll to first line of the page
PL-n Scroll n lines back
PL+ Scroll to last line of the page
PL+n Scroll n lines up
PNOP No effect
PP- Scroll back one page
PP-n Scroll n pages back
PP+ Scroll one page forward
PP+n Scroll n pages forwad
PPn Scroll to beginning of page n
PRI, PRINT Print
PS-- Scroll to first column
PS++ Scroll to last column
PS- Scroll one column to the left
PS-n Scroll n columns to the left
PS+ Scroll one column to the right
PS+n Scroll n columns to the right
PSn Scroll to column n
PZn Scroll to line n
RW Cancel
here is an example handling both the commands in a program.
EXAMPLE:
START-OF-SELECTION.
WRITE: 'Basic List',
/ 'SY-LSIND:', sy-lsind.
TOP-OF-PAGE.
WRITE 'Top-of-Page'.
ULINE.
TOP-OF-PAGE DURING LINE-SELECTION.
CASE sy-pfkey.
WHEN 'TEST'.
WRITE 'Self-defined GUI for Function Codes'.
ULINE.
ENDCASE.
AT LINE-SELECTION.
SET PF-STATUS 'TEST' EXCLUDING 'PICK'.
PERFORM out.
sy-lsind = sy-lsind - 1.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'FC1'.
PERFORM out.
WRITE / 'Button FUN 1 was pressed'.
WHEN 'FC2'.
PERFORM out.
WRITE / 'Button FUN 2 was pressed'.
WHEN 'FC3'.
PERFORM out.
WRITE / 'Button FUN 3 was pressed'.
WHEN 'FC4'.
PERFORM out.
WRITE / 'Button FUN 4 was pressed'.
WHEN 'FC5'.
PERFORM out.
WRITE / 'Button FUN 5 was pressed'.
ENDCASE.
sy-lsind = sy-lsind - 1.
FORM out.
WRITE: 'Secondary List',
/ 'SY-LSIND:', sy-lsind,
/ 'SY-PFKEY:', sy-pfkey.
ENDFORM.
Hope this may be helpful.
Sri.
pls:award points. -
Need clarification on AT LINE SELECTION & AT USER COMMAND
Hi all,
can we use AT LINE SELECTION and AT USER COMMAND events in the same report? If yes what r the precautions that we have to take?
Thanks in advance
venkatHi Venkat,
I had written this code while I was learning Menu Painter. It will help help you.
*& Report YTEST_MENUPAINTER *
REPORT ztest.
*Consider a scenario when the user asks for Material Details(Table : MARA )
*displayed in one List and based on the Material selected he wants the corresponding
*Storage Location Data for that Material (Table : MARD ).
TABLES : mara.
TYPES : BEGIN OF tp_mara,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
mbrsh TYPE mara-mbrsh,
matkl TYPE mara-matkl,
END OF tp_mara.
TYPES : BEGIN OF tp_marc,
matnr TYPE marc-matnr,
werks TYPE marc-werks,
pstat TYPE marc-pstat,
ekgrp TYPE marc-ekgrp,
dispr TYPE marc-dispr,
END OF tp_marc.
TYPES : BEGIN OF tp_mard,
matnr TYPE mard-matnr,
werks TYPE mard-werks,
lgort TYPE mard-lgort,
lfgja TYPE mard-lfgja,
labst TYPE mard-labst,
umlme TYPE mard-umlme,
END OF tp_mard.
DATA : t_mara TYPE STANDARD TABLE OF tp_mara,
t_marc TYPE STANDARD TABLE OF tp_marc,
t_mard TYPE STANDARD TABLE OF tp_mard,
wa_mara TYPE tp_mara,
wa_marc TYPE tp_marc,
wa_mard TYPE tp_mard.
DATA : w_werks TYPE werks .
DATA : itab TYPE TABLE OF sy-ucomm.
START-OF-SELECTION.
*Collecting the material details form Table MARA
SELECT matnr
mtart
mbrsh
matkl
FROM mara
INTO TABLE t_mara
UP TO 200 ROWS.
END-OF-SELECTION.
SET PF-STATUS 'DETAIL'.
*Now I am Dispalying the Material Details in the Primary List
CLEAR wa_mara.
LOOP AT t_mara INTO wa_mara.
IF sy-tabix EQ 1.
FORMAT INTENSIFIED ON.
FORMAT COLOR COL_KEY.
WRITE : /5(16) 'Material Number'.
FORMAT COLOR COL_NORMAL.
WRITE : 24(15) 'Material Type',
40(18) 'Industry Sector',
58(18) 'Material Group' .
ENDIF.
FORMAT INTENSIFIED OFF.
FORMAT COLOR COL_KEY.
WRITE : /5(16) wa_mara-matnr.
FORMAT COLOR COL_NORMAL.
WRITE : 24(15) wa_mara-mtart,
40(18) wa_mara-mbrsh,
58(18) wa_mara-matkl.
*You can assume some sort of buffer is created in the memory and the values of
* wa_mara-matnr are put into it when you use the HIDE command
HIDE wa_mara-matnr.
ENDLOOP.
*Now when user Double clicks a line (AT LINE-SELECTION event is trigerred) and
*the line contents of the line selected and the contents buffered using
*command interact and the value for the hidden variable is got into the variable
*refrenced using the HIDE command i.e.. wa_mara-matnr in our case
AT LINE-SELECTION.
IF sy-lsind = 1.
FORMAT INTENSIFIED ON.
WRITE: 'Plant Data for Material ' COLOR COL_NORMAL,
35 wa_mara-matnr COLOR COL_TOTAL.
REFRESH t_marc.
* Now I have the value of the Material in my hidden variable wa_mara-matnr
* Based on this I am selecting the Storage Location Data
SELECT matnr
werks
pstat
ekgrp
dispr
FROM marc
INTO TABLE t_marc
WHERE matnr = wa_mara-matnr.
CLEAR wa_marc.
FORMAT INTENSIFIED OFF.
FORMAT COLOR COL_NORMAL.
LOOP AT t_marc INTO wa_marc.
IF sy-tabix EQ 1.
FORMAT INTENSIFIED ON.
FORMAT COLOR COL_NORMAL.
WRITE : /24(6) 'Plant',
30(22) 'Maintenance status',
52(20) 'Purchasing Group',
72(27) 'Material: MRP profile'.
ENDIF.
WRITE : /24(6) wa_marc-werks,
30(22) wa_marc-pstat,
52(20) wa_marc-ekgrp,
72(27) wa_marc-dispr.
CLEAR wa_marc.
ENDLOOP.
SKIP 5.
FORMAT INTENSIFIED ON.
WRITE: 'Storage Data for Material ' COLOR COL_NORMAL,
35 wa_mara-matnr COLOR COL_TOTAL.
REFRESH t_mard.
SELECT matnr
werks
lgort
lfgja
labst
umlme
FROM mard
INTO TABLE t_mard
WHERE matnr = wa_mara-matnr.
CLEAR wa_mard.
FORMAT COLOR COL_NORMAL.
* Display the Storage Location Data in the Secondary List
LOOP AT t_mard INTO wa_mard.
IF sy-tabix EQ 1.
FORMAT INTENSIFIED ON.
FORMAT COLOR COL_NORMAL.
WRITE : /24(6) 'Plant',
30(20) 'Storage Location',
50(12) 'Fiscal Year',
62(15) 'Valuated stock',
77(20) 'Stock in transfer'.
ENDIF.
WRITE : /24(6) wa_mard-werks,
30(20) wa_mard-lgort,
50(12) wa_mard-lfgja,
62(15) wa_mard-labst,
77(20) wa_mard-labst.
ENDLOOP.
ENDIF.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'PLANT'.
REFRESH itab. CLEAR itab.
APPEND 'PLANT' TO itab.
APPEND 'STORAGE' TO itab.
SET PF-STATUS 'DETAIL' EXCLUDING itab .
FORMAT INTENSIFIED ON.
WRITE: 'Plant Data for Material ' COLOR COL_NORMAL,
35 wa_mara-matnr COLOR COL_TOTAL.
REFRESH t_marc.
SELECT matnr
werks
pstat
ekgrp
dispr
FROM marc
INTO TABLE t_marc
WHERE matnr = wa_mara-matnr.
CLEAR wa_marc.
FORMAT INTENSIFIED OFF.
FORMAT COLOR COL_NORMAL.
LOOP AT t_marc INTO wa_marc.
IF sy-tabix EQ 1.
FORMAT INTENSIFIED ON.
FORMAT COLOR COL_NORMAL.
WRITE : /24(6) 'Plant',
30(22) 'Maintenance status',
52(20) 'Purchasing Group',
72(27) 'Material: MRP profile'.
ENDIF.
WRITE : /24(6) wa_marc-werks,
30(22) wa_marc-pstat,
52(20) wa_marc-ekgrp,
72(27) wa_marc-dispr.
CLEAR wa_marc.
ENDLOOP.
WHEN 'STORAGE'.
REFRESH itab. CLEAR itab.
APPEND 'PLANT' TO itab.
APPEND 'STORAGE' TO itab.
SET PF-STATUS 'DETAIL' EXCLUDING itab .
FORMAT INTENSIFIED ON.
WRITE: 'Storage Data for Material ' COLOR COL_NORMAL,
35 wa_mara-matnr COLOR COL_TOTAL.
REFRESH t_mard.
SELECT matnr
werks
lgort
lfgja
labst
umlme
FROM mard
INTO TABLE t_mard
WHERE matnr = wa_mara-matnr.
CLEAR wa_mard.
FORMAT COLOR COL_NORMAL.
LOOP AT t_mard INTO wa_mard.
IF sy-tabix EQ 1.
FORMAT INTENSIFIED ON.
FORMAT COLOR COL_NORMAL.
WRITE : /24(6) 'Plant',
30(20) 'Storage Location',
50(12) 'Fiscal Year',
62(15) 'Valuated stock',
77(20) 'Stock in transfer'.
ENDIF.
WRITE : /24(6) wa_mard-werks,
30(20) wa_mard-lgort,
50(12) wa_mard-lfgja,
62(15) wa_mard-labst,
77(20) wa_mard-labst.
ENDLOOP.
ENDCASE.
My SE41 settings are.
Application toolbar Test for Material Detail Display
Items 1 - 7 STORAGE PLANT
STORAG PLANT
Items 8 - 14
Items 15 - 21
Items 22 - 28
Items 29 - 35
Function keys Test for Material Detail Display
Standard Toolbar
SAVE BACK EXIT CANCEL PRINT FIND FIND NEXT
Recommended function key settings
F2 PICK Choose
F9 <..> Select
Shift-F2 <..> Delete
Shift-F4 <..> Save without check
Shift-F5 <..> Other <object>
Freely assigned function keys
F5 STORAGE STORAGE
F6 PLANT PLANT
F7
F8
Shift-F1
Hope this will help you.
Regards,
Arun Sambargi.
Message was edited by: Arun Sambargi -
At line-selection and user command
hi,
is it possible to use both at line selecion and at user command at a time.Hi Kiran,
Yes, it is possible to use both at line selecion and at
user command at a time.
AT LINE-SELECTION.
Event in interactive reporting
This event is processed whenever the user chooses a valid line in the list (i.e. a line generated by statements such as WRITE,ULINE, or SKIP) with the cursor and presses the function key which has the function PICK in the interface definition. This should normally be the function key F2, because it has the same effect as double-clicking the mouse, or clicking once in the case of a hotspot.
The processing for the event AT LINE-SELECTION usually generates further list output (the details list) which completely covers the current list display. If you want the current list display to remain visible (to aid user orientation), you can do this with the key word WINDOW.
AT USER-COMMAND.
Event in interactive reporting
This event is executed whenever the user presses a function key in the list or makes an entry in the command field.
DATA: NUMBER1 TYPE I VALUE 20,
NUMBER2 TYPE I VALUE 5,
RESULT TYPE I.
START-OF-SELECTION.
WRITE: / NUMBER1, '?', NUMBER2.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'ADD'.
RESULT = NUMBER1 + NUMBER2.
WHEN 'SUBT'.
RESULT = NUMBER1 - NUMBER2.
WHEN 'MULT'.
RESULT = NUMBER1 * NUMBER2.
WHEN 'DIVI'.
RESULT = NUMBER1 / NUMBER2.
WHEN OTHERS.
WRITE 'Unknown function code'.
EXIT.
ENDCASE.
WRITE: / 'Result:', RESULT.
After entry of a function code, the appropriate processing is performed under the event AT USER-COMMAND and the result is displayed in the details list.
Reward points if helpful,
Rgds,
Sumana -
Set PF Status and At-Line Selection & At User-Command
Hi All
I've used set PF status, at user command and at-line selection in my program. initially when i click on the material number it was not drilling further that is it was not taking to secondary list. i commented the PF status and tried. then it was working fine. Later, after checking on couple of doc i added F.code PICK in my PF status and uncommented the set-PF status in my program it was working fine. Now my question is why this kind of behaviour. When i uncomment the PF status and run the program without the f.code PICK in my PF status(se41) it was not working but after inlcuding the F.code in my PF it is working. Any good explanation?
thks
Prabhuhi,
generally fuction code is useful for the system to find on which button or in which area the user has clicked in. based on the function code the system executes the satatements that are in user command. in your case i think u didnt gave any functionality in user-command. when at-user command is a event in interactive reporting which is triggered based on the button u had clicked.
at line-selection event uses two system variables
1. sy-lsind [ current list index number ]
2. sy-lisel [ contains the current area in which user ckicked ].
3. sy-ucomm [ function code of clicked button ].
using these 3 vars we can drill down to 21 lists [ including 1st list ]
if helpful reward some points.
with regards,
suresh. -
At line-selection /at user-command in alv
hai ,
i used layout-listappend to output 3 alv's in one page .but
after using layout-listappend i_usercommand in reuse_alv_.. is not working .so i tried to use at line selection . please guide me to solve this problem how to use at line-selection in this prob or is there any other suitable way.hi,
try this code it will help you
*& Report ZP_ALV8
REPORT zp_alv8.
TABLES: kna1, mara, vbak, mard.
TYPE-POOLS: slis.
**TYPE DECLERATION
TYPES: BEGIN OF ty_kna1,
kunnr LIKE kna1-kunnr,
land1 LIKE kna1-land1,
name1 LIKE kna1-name1,
ort01 LIKE kna1-ort01,
END OF ty_kna1.
TYPES: BEGIN OF ty_mara,
matnr LIKE mara-matnr,
ersda LIKE mara-ersda,
ernam LIKE mara-ernam,
END OF ty_mara.
TYPES: BEGIN OF ty_vbak,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
ernam LIKE vbak-ernam,
END OF ty_vbak.
TYPES: BEGIN OF ty_mard,
matnr LIKE mard-matnr,
werks LIKE mard-werks,
lgort LIKE mard-lgort,
END OF ty_mard.
**DATA DECLERATION
DATA: it_kna1 TYPE STANDARD TABLE OF ty_kna1,
wa_kna1 TYPE ty_kna1.
DATA: it_mara TYPE STANDARD TABLE OF ty_mara,
wa_mara TYPE ty_mara.
DATA: it_vbak TYPE STANDARD TABLE OF ty_vbak,
wa_vbak TYPE ty_vbak.
DATA: it_mard TYPE STANDARD TABLE OF ty_mard,
wa_mard TYPE ty_mard.
DATA: it_fieldcat_kna1 TYPE slis_t_fieldcat_alv,
wa_fieldcat_kna1 TYPE slis_fieldcat_alv,
it_fieldcat_mara TYPE slis_t_fieldcat_alv,
wa_fieldcat_mara TYPE slis_fieldcat_alv,
it_fieldcat_vbak TYPE slis_t_fieldcat_alv,
wa_fieldcat_vbak TYPE slis_fieldcat_alv,
it_fieldcat_mard TYPE slis_t_fieldcat_alv,
wa_fieldcat_mard TYPE slis_fieldcat_alv.
DATA: it_event_kna1 TYPE slis_t_event,
wa_event_kna1 TYPE slis_alv_event,
it_event_mara TYPE slis_t_event,
wa_event_mara TYPE slis_alv_event,
it_event_vbak TYPE slis_t_event,
wa_event_vbak TYPE slis_alv_event,
it_event_mard TYPE slis_t_event,
wa_event_mard TYPE slis_alv_event.
DATA: wa_layout TYPE slis_layout_alv,
it_listheader TYPE slis_t_listheader,
wa_listheader TYPE slis_listheader.
selection-screen begin of block b1 with frame title text-001.
select-options: s_kunnr for kna1-kunnr default '1000' to '1050'.
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-002.
select-options: s_matnr for mara-matnr default '1' to '100'.
selection-screen end of block b2.
**INITIALIZATION
INITIALIZATION.
PERFORM layout.
PERFORM fieldcat_kna1.
PERFORM fieldcat_mara.
PERFORM event_kna1.
PERFORM event_mara.
PERFORM eventpopulate_kna1.
PERFORM eventpopulate_mara.
**START OF SELECTION AND FIRST LIST DISPLAY
START-OF-SELECTION.
SELECT kunnr land1 name1 ort01
FROM kna1
INTO TABLE it_kna1
where kunnr in s_kunnr.
UP TO 10 ROWS.
SELECT matnr ersda ernam
FROM mara
INTO TABLE it_mara
where matnr in s_matnr.
UP TO 20 ROWS.
PERFORM display.
**FORM LAYOUT
*& Form layout
text
--> p1 text
<-- p2 text
FORM layout .
wa_layout-zebra ='X'.
wa_layout-get_selinfos = 'X'.
wa_layout-key_hotspot = 'X'.
ENDFORM. " layout
*FIELD CATALOUGE*******************************
*& Form fieldcat_kna1
text
--> p1 text
<-- p2 text
FORM fieldcat_kna1 .
REFRESH it_fieldcat_kna1.
CLEAR wa_fieldcat_kna1.
wa_fieldcat_kna1-fieldname = 'KUNNR'.
wa_fieldcat_kna1-seltext_l = 'CUSTOMER NUMBER'.
wa_fieldcat_kna1-datatype = 'CHAR'.
wa_fieldcat_kna1-outputlen = 30.
wa_fieldcat_kna1-tabname = 'IT_KNA1'.
wa_fieldcat_kna1-key = 'X'.
wa_fieldcat_kna1-hotspot = 'X'.
wa_fieldcat_kna1-col_pos = 1.
wa_fieldcat_kna1-emphasize = 'C21'.
APPEND wa_fieldcat_kna1 TO it_fieldcat_kna1.
CLEAR wa_fieldcat_kna1.
wa_fieldcat_kna1-fieldname = 'LAND1'.
wa_fieldcat_kna1-seltext_l = 'COUNTRY CODE'.
wa_fieldcat_kna1-datatype = 'CHAR'.
wa_fieldcat_kna1-outputlen = 30.
wa_fieldcat_kna1-tabname = 'IT_KNA1'.
wa_fieldcat_kna1-hotspot = 'X'.
wa_fieldcat_kna1-col_pos = 2.
wa_fieldcat_kna1-emphasize = 'C31'.
APPEND wa_fieldcat_kna1 TO it_fieldcat_kna1.
CLEAR wa_fieldcat_kna1.
wa_fieldcat_kna1-fieldname = 'NAME1'.
wa_fieldcat_kna1-seltext_l = 'CUSTOMER NAME'.
wa_fieldcat_kna1-datatype = 'CHAR'.
wa_fieldcat_kna1-outputlen = 30.
wa_fieldcat_kna1-tabname = 'IT_KNA1'.
wa_fieldcat_kna1-hotspot = 'X'.
wa_fieldcat_kna1-col_pos = 3.
wa_fieldcat_kna1-emphasize = 'C71'.
APPEND wa_fieldcat_kna1 TO it_fieldcat_kna1.
CLEAR wa_fieldcat_kna1.
wa_fieldcat_kna1-fieldname = 'ORT01'.
wa_fieldcat_kna1-seltext_l = 'COUNTRY '.
wa_fieldcat_kna1-datatype = 'CHAR'.
wa_fieldcat_kna1-outputlen = 30.
wa_fieldcat_kna1-tabname = 'IT_KNA1'.
wa_fieldcat_kna1-hotspot = 'X'.
wa_fieldcat_kna1-col_pos = 4.
wa_fieldcat_kna1-emphasize = 'C51'.
APPEND wa_fieldcat_kna1 TO it_fieldcat_kna1.
CLEAR wa_fieldcat_kna1.
ENDFORM. " fieldcat_kna1
*& Form fieldcat_kna2
text
FORM fieldcat_mara .
wa_fieldcat_mara-fieldname = 'MATNR'.
wa_fieldcat_mara-seltext_l = 'MATERIAL NUMBER'.
wa_fieldcat_mara-datatype = 'CHAR'.
wa_fieldcat_mara-outputlen = 30.
wa_fieldcat_mara-tabname = 'IT_MARA'.
wa_fieldcat_mara-key = 'X'.
wa_fieldcat_mara-hotspot = 'X'.
wa_fieldcat_mara-col_pos = 1.
wa_fieldcat_mara-emphasize = 'C21'.
APPEND wa_fieldcat_mara TO it_fieldcat_mara.
CLEAR wa_fieldcat_mara.
wa_fieldcat_mara-fieldname = 'ERSDA'.
wa_fieldcat_mara-seltext_l = 'CREATED ON'.
wa_fieldcat_mara-datatype = 'CHAR'.
wa_fieldcat_mara-outputlen = 30.
wa_fieldcat_mara-tabname = 'IT_MARA'.
wa_fieldcat_mara-hotspot = 'X'.
wa_fieldcat_mara-col_pos = 2.
wa_fieldcat_mara-emphasize = 'C41'.
APPEND wa_fieldcat_mara TO it_fieldcat_mara.
CLEAR wa_fieldcat_mara.
wa_fieldcat_mara-fieldname = 'ERNAM'.
wa_fieldcat_mara-seltext_l = 'CREATED BY'.
wa_fieldcat_mara-datatype = 'CHAR'.
wa_fieldcat_mara-outputlen = 30.
wa_fieldcat_mara-tabname = 'IT_MARA'.
wa_fieldcat_mara-hotspot = 'X'.
wa_fieldcat_mara-col_pos = 3.
wa_fieldcat_mara-emphasize = 'C61'.
APPEND wa_fieldcat_mara TO it_fieldcat_mara.
CLEAR wa_fieldcat_mara.
ENDFORM. "fieldcat_kna2
*& Form FIELDCAT_VBAK
text
FORM fieldcat_vbak.
wa_fieldcat_vbak-fieldname = 'VBELN'.
wa_fieldcat_vbak-seltext_l = 'SALES ORDER'.
wa_fieldcat_vbak-datatype = 'CHAR'.
wa_fieldcat_vbak-outputlen = 30.
wa_fieldcat_vbak-tabname = 'IT_VBAK'.
wa_fieldcat_vbak-hotspot = 'X'.
wa_fieldcat_vbak-col_pos = 3.
wa_fieldcat_vbak-emphasize = 'C31'.
APPEND wa_fieldcat_vbak TO it_fieldcat_vbak.
CLEAR wa_fieldcat_vbak.
wa_fieldcat_vbak-fieldname = 'ERDAT'.
wa_fieldcat_vbak-seltext_l = 'CREATED ON'.
wa_fieldcat_vbak-datatype = 'DATS'.
wa_fieldcat_vbak-outputlen = 30.
wa_fieldcat_vbak-tabname = 'IT_VBAK'.
wa_fieldcat_vbak-hotspot = 'X'.
wa_fieldcat_vbak-col_pos = 3.
wa_fieldcat_vbak-emphasize = 'C41'.
APPEND wa_fieldcat_vbak TO it_fieldcat_vbak.
CLEAR wa_fieldcat_vbak.
wa_fieldcat_vbak-fieldname = 'ERNAM'.
wa_fieldcat_vbak-seltext_l = 'CREATED BY'.
wa_fieldcat_vbak-datatype = 'CHAR'.
wa_fieldcat_vbak-outputlen = 30.
wa_fieldcat_vbak-tabname = 'IT_VBAK'.
wa_fieldcat_vbak-hotspot = 'X'.
wa_fieldcat_vbak-col_pos = 3.
wa_fieldcat_vbak-emphasize = 'C51'.
APPEND wa_fieldcat_vbak TO it_fieldcat_vbak.
CLEAR wa_fieldcat_vbak.
ENDFORM. "FIELDCAT_VBAK
*& Form fieldcat_mard
text
FORM fieldcat_mard.
wa_fieldcat_mard-fieldname = 'MATNR'.
wa_fieldcat_mard-seltext_l = 'MATERIAL NUMBER'.
wa_fieldcat_mard-datatype = 'CHAR'.
wa_fieldcat_mard-outputlen = 30.
wa_fieldcat_mard-tabname = 'IT_MARD'.
wa_fieldcat_mard-hotspot = 'X'.
wa_fieldcat_mard-col_pos = 1.
wa_fieldcat_mard-emphasize = 'C31'.
APPEND wa_fieldcat_mard TO it_fieldcat_mard.
CLEAR wa_fieldcat_mard.
wa_fieldcat_mard-fieldname = 'WERKS'.
wa_fieldcat_mard-seltext_l = 'PLANT'.
wa_fieldcat_mard-datatype = 'CHAR'.
wa_fieldcat_mard-outputlen = 30.
wa_fieldcat_mard-tabname = 'IT_MARD'.
wa_fieldcat_mard-hotspot = 'X'.
wa_fieldcat_mard-col_pos = 2.
wa_fieldcat_mard-emphasize = 'C61'.
APPEND wa_fieldcat_mard TO it_fieldcat_mard.
CLEAR wa_fieldcat_mard.
wa_fieldcat_mard-fieldname = 'LGORT'.
wa_fieldcat_mard-seltext_l = 'STORAGE LOCATION'.
wa_fieldcat_mard-datatype = 'CHAR'.
wa_fieldcat_mard-outputlen = 30.
wa_fieldcat_mard-tabname = 'IT_MARD'.
wa_fieldcat_mard-hotspot = 'X'.
wa_fieldcat_mard-col_pos = 3.
wa_fieldcat_mard-emphasize = 'C81'.
APPEND wa_fieldcat_mard TO it_fieldcat_mard.
CLEAR wa_fieldcat_mard.
ENDFORM . "fieldcat_mard
**FORM DISPLAY
*& Form Display
text
--> p1 text
<-- p2 text
FORM display .
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'.
IT_EXCLUDING =
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = wa_layout
it_fieldcat = it_fieldcat_kna1
i_tabname = 'IT_KNA1'
it_events = it_event_kna1
IT_SORT =
I_TEXT = ' '
TABLES
t_outtab = it_kna1
EXCEPTIONS
program_error = 1
maximum_of_appends_reached = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = wa_layout
it_fieldcat = it_fieldcat_mara
i_tabname = 'IT_MARA'
it_events = it_event_mara
IT_SORT =
I_TEXT = ' '
TABLES
t_outtab = it_mara
EXCEPTIONS
program_error = 1
maximum_of_appends_reached = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
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
**EVENTS FOR KNA1 AND MARA
*& Form EVENT_KNA1
text
--> p1 text
<-- p2 text
FORM event_kna1 .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_event_kna1
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. " EVENT_KNA1
*& Form EVENT_MARA
text
--> p1 text
<-- p2 text
FORM event_mara .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_event_mara
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. " EVENT_MARA
**POPULATING EVENTS
*& Form eventpopulate_kna1
text
--> p1 text
<-- p2 text
FORM eventpopulate_kna1 .
READ TABLE it_event_kna1 INTO wa_event_kna1 WITH KEY name = 'TOP_OF_PAGE'.
IF sy-subrc = 0.
wa_event_kna1-form = 'TOP_OF_PAGE_KNA1'.
MODIFY it_event_kna1 FROM wa_event_kna1 TRANSPORTING form WHERE name = wa_event_kna1-name.
ENDIF.
READ TABLE it_event_kna1 INTO wa_event_kna1 WITH KEY name = 'USER_COMMAND'.
IF sy-subrc = 0.
wa_event_kna1-form = 'USER_COMMAND_KNA1'.
MODIFY it_event_kna1 FROM wa_event_kna1 TRANSPORTING form WHERE name = wa_event_kna1-name.
ENDIF.
ENDFORM. " eventpopulate_kna1
*& Form eventpopulate_mara
text
--> p1 text
<-- p2 text
FORM eventpopulate_mara .
READ TABLE it_event_mara INTO wa_event_mara WITH KEY name = 'TOP_OF_PAGE'.
IF sy-subrc = 0.
wa_event_mara-form = 'TOP_OF_PAGE_MARA'.
MODIFY it_event_mara FROM wa_event_mara TRANSPORTING form WHERE name = wa_event_mara-name.
ENDIF.
READ TABLE it_event_mara INTO wa_event_mara WITH KEY name = 'USER_COMMAND'.
IF sy-subrc = 0.
wa_event_mara-form = 'USER_COMMAND_MARA'.
MODIFY it_event_mara FROM wa_event_mara TRANSPORTING form WHERE name = wa_event_mara-name.
ENDIF.
ENDFORM. " eventpopulate_mara
**TOP OF PAGE
*& Form TOP_OF_PAGE_KNA1
text
FORM top_of_page_kna1.
wa_listheader-typ = 'H'.
wa_listheader-info = 'CUSTOMER DETAILS' .
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
WRITE:/ 'CUSTOMER DETAILS'.
ENDFORM. "TOP_OF_PAGE_KNA1
*& Form TOP_OF_PAGE_MARA
text
FORM top_of_page_mara.
wa_listheader-typ = 'H'.
wa_listheader-info = 'MATERIAL DETAILS' .
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
WRITE:/ 'MATERIAL DETAILS' .
ENDFORM. "TOP_OF_PAGE_KNA1
**CODE FOR SECOND LIST DISPLAY FOR VBAK
*& Form USER_COMMAND
text
-->UCOMM text
-->R_SELFIELD text
FORM user_command
USING ucomm LIKE sy-ucomm
r_selfield TYPE slis_selfield.
CASE UCOMM.
when '&IC1'.
CASE R_SELFIELD-TABNAME.
WHEN 'IT_KNA1'.
DATA: CUST(10) TYPE n.
CUST = r_selfield-value.
SELECT vbeln erdat ernam
FROM vbak
INTO TABLE it_vbak
WHERE kunnr = cust.
PERFORM fieldcat_vbak.
PERFORM display_vbak.
WHEN 'IT_MARA'.
DATA: MAT(18) TYPE N.
MAT = R_selfield-value.
SELECT matnr werks lgort
FROM mard
INTO TABLE it_mard
WHERE matnr = mat.
PERFORM fieldcat_mard.
PERFORM display_mard.
ENDCASE.
ENDCASE.
ENDFORM. "USER_COMMAND
**& Form USER_COMMAND_MARA
text
-->UCOMM text
-->S_SELFIELD text
*FORM user_command_mara
USING ucomm LIKE sy-ucomm
s_selfield TYPE slis_selfield.
SELECT matnr werks lgort
FROM mard
INTO TABLE it_mard
WHERE matnr = s_selfield-value.
PERFORM fieldcat_mard.
PERFORM display_mard.
*ENDFORM. "USER_COMMAND_MARA
*& Form DISPLAY_VBAK
text
--> p1 text
<-- p2 text
FORM display_vbak .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = wa_layout
IT_FIELDCAT = it_fieldcat_vbak
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_vbak
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_VBAK
*& Form display_mard
text
FORM display_mard .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'USER_COMMAND_MARD'
I_STRUCTURE_NAME =
is_layout = wa_layout
it_fieldcat = it_fieldcat_mard
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = it_event_mard
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IR_SALV_LIST_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_mard
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_mard
regards
prasanth -
AT USER COMMAND event in interactive reports
hi experts,
Can anyone explain me about AT USER COMMAND event with one practical ex.
thanks in advance
R.vijaiHi vijaya kumar,
If the user chooses a function code during list processing that is neither processed by the system, or PICK or PF<nn>, the system triggers the event AT USER-COMMAND. For this event, you must define your own GUI status for a list. To react to your own function codes in a program, you must define the following event block:
AT USER-COMMAND.
<statements>.
In this event block, you can use an IF or CASE structure to tell the function codes apart. They are available in the system field SY-UCOMM. There are further system fields that are filled in list events, such as SY-LSIND and SY-PFKEY, that allow you to make further case distinctions.
REPORT Test_program.
START-OF-SELECTION.
SET PF-STATUS 'TEST'.
WRITE: 'Basic list, SY-LSIND =', sy-lsind.
AT LINE-SELECTION.
WRITE: 'LINE-SELECTION, SY-LSIND =', sy-lsind.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'TEST'.
WRITE: 'TEST, SY-LSIND =', sy-lsind.
ENDCASE.
With this code double click on 'TEST' and define your own PF status and give user command as TEST and check out this useful programe.
All the very best to you.
Regards,
Mohan Vamsi Krishna.A -
At line selection & at user comand help?
hi
i had an req like,to disply an list 1,than perform the BDC for the selected material with check box from list 1,than after BDC,the data is displaed on list 2 with the VBELN no.,along with there BDC msg,now user want to click on each VBELN records as per as his wish & go into the VA32,to see the BDC changes,please tell how to call this VA32,from list 2.
my code is like this:
start of selection.
perfrom selctiom.
perform list1.
at user command.
when 'BDC'. -
> with records selected with check box on list 1.
perfor BDC.
perform DATA. -
> to display the records,with BDC message,which will be list 2.
endcase.
now i need to call VA32,for the slected VBELN records,from list 2.
but within perfrom,its not taking at-line selection.
even,when i write at line selection after PERFORM DATA,its not accepting,please telll how to do tis.
if any thing not clear please tell.
regdsSTART-OF-SELECTION.
PERFORM RETRIEVE.
perform display.
at USER-COMMAND.
case sy-ucomm.
when 'PUSH'.
clear:itab3,itab3[],ch.
IF SY-LSIND = '1'.
do.
clear:ch.
READ LINE SY-INDEX FIELD VALUE ch.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
IF ch eq 'X'.
MOVE itab1-vbeln TO ITab3-vbeln.
MOVE itab1-AUDAT TO ITab3-AUDAT.
MOVE itab1-posnr TO ITab3-posnr.
MOVE itab1-matnr TO ITab3-matnr.
MOVE itab1-arktx TO ITab3-arktx.
MOVE ITab1-zmeng TO ITab3-zmeng.
MOVE ITab1-RFMNG TO ITab3-RFMNG.
MOVE ITab1-qty TO ITab3-qty.
APPEND ITab3.
CLEAR:itab1,itab3.
endif.
enddo.
ENDIF.
if itab3[] is not initial.
clear:d.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TEXT_QUESTION = 'You want to Contuine.'
TEXT_BUTTON_1 = 'YES'
TEXT_BUTTON_2 = 'NO'
DISPLAY_CANCEL_BUTTON = ''
IMPORTING
ANSWER = d.
if d = '1'.
perform BDC.
perform data.
at line-selection.
READ LINE SY-INDEX.
check not itab5-vbeln is initial.
set parameter ID 'AUN' field itab5-vbeln.
call transaction 'VA32' and skip first screen.
clear:itab5-vbeln.
else.
endif.
endif.
when 'SA'.
IF SY-LSIND = '1'.
do.
clear:ch.
READ LINE SY-INDEX FIELD VALUE ch.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
IF ch eq ''.
CH = 'X'.
modify LINE SY-INDEX FIELD VALUE ch.
endif.
enddo.
ENDIF.
when 'DSA'.
IF SY-LSIND = '1'.
do.
clear:ch.
READ LINE SY-INDEX FIELD VALUE ch.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
IF ch eq 'X'.
CH = ''.
modify LINE SY-INDEX FIELD VALUE ch.
endif.
enddo.
ENDIF.
endcase.
end-of-selection. -
Use of at PF AND AT USER COMMAND EVENTS
can i know the use of at pf and at usercommand
hi,
pf-status.
for example : i am displaying ouput using function module 'REUSE_ALV_LIST_DISPLAY' when u see the output of this there u will find standarad pf status. if requirement is not necesary to display all these buttons means u will create ur own pf status and keep required buttons insideit.
at user command :
for example u have one button in ur pf status : select_all
when u click this button necessary action has to perform. this code u will write under this command.
hope u got the point.
thanks,
maheedhar.t -
User command event is not working ........
Hi ,
class event_class definition.
public section.
methods:
handle_user_command
for event after_user_command of cl_gui_alv_grid
importing e_ucomm.
methods:handle_hotspot
for event hotspot_click of cl_gui_alv_grid
importing e_row_id.
endclass. "event_class DEFINITION
******selection screen**************************
call screen 100.
CLASS event_class IMPLEMENTATION
********class implimentations********************
class event_class implementation.
method handle_user_command.
case e_ucomm.
when 'SAVE'.
wa_default-checkbox = 'X'.
ENDCASE.
endmethod. "handle_user_command
method handle_hotspot.
wa_default-checkbox = 'X'.
lv_layout-zebra = 'X'.
lv_hotspot = lv_hotspot + 1.
modify lit_default
index e_row_id
from wa_default
transporting checkbox.
lv_id = e_row_id.
*************refreshing tables************
call method wa_alv->refresh_table_display
EXPORTING
is_stable =
i_soft_refresh =
EXCEPTIONS
finished = 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.
endmethod.
"handle_user_command
method user_command.
*****some code i will write with help of e_ucomm**********( control not comming here)
endmethod.
endclass.
Hi,Here i have one alv grid display if i click on grid checkbox method (hotspot) will triggers properly,,,,but if i select any button like save ,modify i have created on screen method user_command is not triggering ,control is going to pai of that screen.my question is it shold trigger usr_command right??????
any help appriciated.
ThanksHi, Lingaraj.
Check your events handlers is registered
SET HANDLER go_event_receiver->handle_double_click FOR go_grid.
SET HANDLER go_event_receiver->handle_toolbar FOR go_grid.
SET HANDLER go_event_receiver->handle_user_command FOR go_grid.
SET HANDLER go_event_receiver->handle_menu_button FOR go_grid.
SET HANDLER go_event_receiver->handle_context_menu FOR go_grid.
SET HANDLER go_event_receiver->on_f4 FOR go_grid.
SET HANDLER go_event_receiver->handle_data_changed FOR go_grid.
before calling an ALV:
go_grid->set_table_for_first_display(
EXPORTING is_layout = ls_layout
is_variant = ls_variant
i_save = 'A'
CHANGING it_outtab = gt_outtab
it_fieldcatalog = lt_fieldcat
Hope it will be helpful for you.
Best regards,
George Shlyahov. -
How to use both At USER-COMMAND and AT LINE-SELECTION in one abap program
I am trying out a program where I need to use both line selection and user command events in one program. Suggest me how to do it.
USE the okcode 'PICK'. (I mean add a 'PICK' in the GUI staus or the menu.) When ever u use both the events u have to use PICK to trigger the at line selection.
U just need to add the PICK in the GUI status and ofcourse write code in the program.
AT LINE-SELECTION.
CASE sy-ucomm.
WHEN 'PICK'.
write:/ 'HELLO WORLD'.
ENDCASE. -
how to handle at user commads in alv's?
Hi Praveen
Interactive Reports
As the name suggests, the user can Interact with the report. We can have a drill down into the report data. For example, Column one of the report displays the material numbers, and the user feels that he needs some more specific data about the vendor for that material, he can HIDE that data under those material numbers.
And when the user clicks the material number, another report (actually sub report/secondary list) which displays the vendor details will be displayed.
We can have a basic list (number starts from 0) and 20 secondary lists (1 to 21).
Events associated with Interactive Reports are:
AT LINE-SELECTION
AT USER-COMMAND
AT PF<key>
TOP-OF-PAGE DURING LINE-SELECTION.
HIDE statement holds the data to be displayed in the secondary list.
sy-lisel : contains data of the selected line.
sy-lsind : contains the level of report (from 0 to 21)
<u><b>Interactive Report Events:</b></u>
AT LINE-SELECTION : This Event triggers when we double click a line on the list, when the event is triggered a new sublist is going to be generated. Under this event what ever the statements that are been return will be displayed on newly generated sublist.
AT PFn: For predefined function keys...
<u><b>AT USER-COMMAND :</b></u> It provides user functions keys.
TOP-OF-PAGE DURING LINE-SELECTION :top of page event for secondary list.
<b>check this sample code</b>
TYPE-POOLS: slis. " ALV Global Types
DATA :
gt_user LIKE uinfo OCCURS 0 WITH HEADER LINE. " User info in SM04
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
* Form F_LIRE_DATA
FORM f_read_data.
REFRESH gt_user.
* Get User's info
CALL FUNCTION 'THUSRINFO'
TABLES
usr_tabl = gt_user.
* Wait in a task
PERFORM f_call_rfc_wait.
ENDFORM. " F_READ_DATA
* Form F_DISPLAY_DATA
FORM f_display_data.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DEFINE m_event_exit.
clear ls_event_exit.
ls_event_exit-ucomm = &1.
ls_event_exit-after = 'X'.
append ls_event_exit to lt_event_exit.
END-OF-DEFINITION.
DATA :
ls_layout TYPE slis_layout_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
lt_event_exit TYPE slis_t_event_exit,
ls_event_exit TYPE slis_event_exit.
* Build Sort Table
m_sort 'ZEIT'.
* Build Event Exit Table
m_event_exit '&NTE'. " Refresh
ls_layout-zebra = 'X'.
ls_layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
is_layout = ls_layout
i_structure_name = 'UINFO'
it_sort = lt_sort
it_event_exit = lt_event_exit
TABLES
t_outtab = gt_user.
ENDFORM. " F_DISPLAY_DATA
* FORM USER_COMMAND *
FORM user_command USING i_ucomm TYPE syucomm
is_selfield TYPE slis_selfield. "#EC CALLED
CASE i_ucomm.
WHEN '&NTE'.
PERFORM f_read_data.
is_selfield-refresh = 'X'.
SET USER-COMMAND '&OPT'. " Optimize columns width
ENDCASE.
ENDFORM. " USER_COMMAND
* Form F_CALL_RFC_WAIT
FORM f_call_rfc_wait.
DATA lv_mssg(80). "#EC NEEDED
* Wait in a task
CALL FUNCTION 'RFC_PING_AND_WAIT' STARTING NEW TASK '001'
PERFORMING f_task_end ON END OF TASK
EXPORTING
seconds = 5 " Refresh time
busy_waiting = space
EXCEPTIONS
RESOURCE_FAILURE = 1
communication_failure = 2 MESSAGE lv_mssg
system_failure = 3 MESSAGE lv_mssg
OTHERS = 4.
ENDFORM. " F_CALL_RFC_WAIT
* Form F_TASK_END
FORM f_task_end USING u_taskname.
DATA lv_mssg(80). "#EC NEEDED
* Receiving task results
RECEIVE RESULTS FROM FUNCTION 'RFC_PING_AND_WAIT'
EXCEPTIONS
RESOURCE_FAILURE = 1
communication_failure = 2 MESSAGE lv_mssg
system_failure = 3 MESSAGE lv_mssg
OTHERS = 4.
CHECK sy-subrc EQ 0.
SET USER-COMMAND '&NTE'. " Refresh
ENDFORM. " F_TASK_END
*************** END OF PROGRAM Z_ALV_AUTO_REFRESH *********************
check this link too
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-AddUsercommandfunctionalitytoALVgridreport&
Reward all helpfull answers
Regards
Pavan -
At line-selection and At-user command
Hi friends,
Can we use both those events at a time in report?
If so can any body provide me sample code?
Regards<b>Example for AT LINE-SELECTION</b>
REPORT demo_list_at_line_selection.
START-OF-SELECTION.
WRITE 'Basic List'.
AT LINE-SELECTION.
WRITE: 'Secondary List by Line-Selection',
/ 'SY-UCOMM =', sy-ucomm.
When you run the program, the basic list appears with the standard list status. The detail list shows that SY-UCOMM has the value PICK.
<b>Example for AT USER-COMMAND</b>
REPORT demo_list_at_user_command NO STANDARD PAGE HEADING.
START-OF-SELECTION.
WRITE: 'Basic List',
/ 'SY-LSIND:', sy-lsind.
TOP-OF-PAGE.
WRITE 'Top-of-Page'.
ULINE.
TOP-OF-PAGE DURING LINE-SELECTION.
CASE sy-pfkey.
WHEN 'TEST'.
WRITE 'Self-defined GUI for Function Codes'.
ULINE.
ENDCASE.
AT LINE-SELECTION.
SET PF-STATUS 'TEST' EXCLUDING 'PICK'.
PERFORM out.
sy-lsind = sy-lsind - 1.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'FC1'.
PERFORM out.
WRITE / 'Button FUN 1 was pressed'.
WHEN 'FC2'.
PERFORM out.
WRITE / 'Button FUN 2 was pressed'.
WHEN 'FC3'.
PERFORM out.
WRITE / 'Button FUN 3 was pressed'.
WHEN 'FC4'.
PERFORM out.
WRITE / 'Button FUN 4 was pressed'.
WHEN 'FC5'.
PERFORM out.
WRITE / 'Button FUN 5 was pressed'.
ENDCASE.
sy-lsind = sy-lsind - 1.
FORM out.
WRITE: 'Secondary List',
/ 'SY-LSIND:', sy-lsind,
/ 'SY-PFKEY:', sy-pfkey.
ENDFORM.
When you run the program, the system displays the following basic list with a the page header defined in the program:
You can trigger the AT LINE-SELECTION event by double-clicking a line. The system sets the status TEST and deactivates the function code PICK. The status TEST contains function codes FC1 to FC5. These are assigned to pushbuttons in the application toolbar. The page header of the detail list depends on the status.
Here, double-clicking a line no longer triggers an event. However, there is now an application toolbar containing five user-defined pushbuttons. You can use these to trigger the AT USER-COMMAND event. The CASE statement contains a different reaction for each pushbutton.
For each interactive event, the system decreases the SY-LSIND system field by one, thus canceling out the automatic increase. All detail lists now have the same level as the basic list and thus overwrite it. While the detail list is being created, SY-LSIND still has the value 1.
I hope it helps.
For more details have a look at below link.
http://help.sap.com/saphelp_di471/helpdata/EN/9f/dba3ae35c111d1829f0000e829fbfe/content.htm
Best Regards,
Vibha
*Please mark all the helpful answers -
In my report,from basic list I want to call my customized transaction and want to fill that clicked field to that customised transaction.
problem is :
I am using at line selection.
In basic list I have header then many no of rows of data.
When I click header also it its taking me to cutomise transaction which I dont want.
I want to call my customise transactions after the header information and when i double click it it should take me to customise transaction and that row data should be filled in that transaction.
Can any body suggest me how to do it ?
thanks
kumarHi Kumar,
Try to refer the following code :
*" Table declarations...................................................
TABLES :
vbak, " Sales Document: Header Data
vbap. " Sales Document: Item Data
*" Selection Screen Elements...........................................
SELECT-OPTIONS :
s_kunnr FOR vbak-kunnr. " Customer Number
*" Data declarations...................................................
* Work Variables *
DATA :
w_fname(20) TYPE c. " Holds Fieldname
* Structure to hold Sales Document: Header Data *
DATA :
BEGIN OF fs_vbak,
vbeln LIKE vbak-vbeln, " Sales Document
kunnr LIKE vbak-kunnr, " Customer Number
bstnk LIKE vbak-bstnk, " Customer Purchase Order Number
END OF fs_vbak.
* Structure to hold Sales Document: Item Data *
DATA :
BEGIN OF fs_vbap,
vbeln LIKE vbap-vbeln, " Sales Document
posnr LIKE vbap-posnr, " Sales Document Item
matnr LIKE vbap-matnr, " Material Number
kwmeng LIKE vbap-kwmeng, " Cumulative Order Quantity
netpr LIKE vbap-netpr, " Price
END OF fs_vbap.
* Structure to hold General Data in Customer Master *
DATA :
BEGIN OF fs_kna1,
kunnr LIKE kna1-kunnr, " Customer Number
name LIKE kna1-name1, " Customer Name
END OF fs_kna1.
* Internal table to hold Sales Document: Header Data *
DATA :
t_vbak LIKE
STANDARD TABLE
OF fs_vbak.
* Internal table to hold Sales Document: Item Data *
DATA :
t_vbap LIKE
STANDARD TABLE
OF fs_vbap.
* Internal table to hold General Data in Customer Master *
DATA :
t_kna1 LIKE
STANDARD TABLE
OF fs_kna1.
* TOP-OF-PAGE EVENT *
TOP-OF-PAGE.
PERFORM top_of_page.
* TOP-OF-PAGE DURING LINE-SELECTION EVENT *
TOP-OF-PAGE DURING LINE-SELECTION.
PERFORM topofpage_during_linesel.
* AT SELECTION-SCREEN EVENT *
AT SELECTION-SCREEN.
PERFORM at_selection_screen.
* START-OF-SELECTION EVENT *
START-OF-SELECTION.
PERFORM start_of_selection.
* AT USER-COMMAND EVENT *
AT USER-COMMAND.
PERFORM user_command.
* AT LINE-SELECTION EVENT *
AT LINE-SELECTION.
PERFORM at_line_selection.
*& Form top_of_page
* This Subroutine Performs the Event Top-Of-Page *
* There are no interface parameters to be passed to this subroutine. *
FORM top_of_page .
WRITE :/50 'Customer Information'(001).
ULINE.
FORMAT COLOR 1.
WRITE :/10 'Customer Number'(002),
40 'Customer Name'(003),
80 'Order number'(004),
100 space.
ENDFORM. " FORM TOP_OF_PAGE
*& Form TOPOFPAGE_DURING_LINESEL *
* This Subroutine Performs the Event Top-Of-Page During Line-Selection *
* There are no interface parameters to be passed to this subroutine. *
FORM topofpage_during_linesel .
WRITE :/50 'Item Details'(007).
ULINE.
FORMAT COLOR 1.
WRITE :/5 'Sales Doc No.'(008),
23 'Sales Doc Item'(009),
42 'Material No.'(010),
59 'Order Qty'(011),
73 'Price'(012),
83 space.
ENDFORM. " FORM TOPOFPAGE_DURING_LINESEL
*& Form AT_SELECTION_SCREEN *
* This Subroutine Performs the Required Input Validations *
* There are no interface parameters to be passed to this subroutine. *
FORM at_selection_screen .
SELECT SINGLE kunnr
FROM vbak
INTO fs_vbak-kunnr
WHERE kunnr IN s_kunnr.
IF sy-subrc NE 0.
MESSAGE e184(bc_global) WITH text-013.
ENDIF. " IF SY-SUBRC NE 0
IF s_kunnr IS INITIAL.
MESSAGE e184(bc_global) WITH text-014.
ENDIF. " IF S_KUNNR IS INITIAL
ENDFORM. " FORM AT_SELECTION_SCREEN
*& Form start_of_selection
* This Subroutine Performs the Event START-OF-SELECTION *
* There are no interface parameters to be passed to this subroutine. *
FORM start_of_selection .
SET PF-STATUS 'YMENU1'.
SELECT vbeln " Sales Document
kunnr " Customer Number
bstnk " Customer Purchase Order Number
FROM vbak
INTO TABLE t_vbak
WHERE kunnr IN s_kunnr.
IF sy-subrc EQ 0.
SELECT kunnr " Customer Number
name1 " Customer Name
FROM kna1
INTO TABLE t_kna1
FOR ALL ENTRIES IN t_vbak
WHERE kunnr = t_vbak-kunnr.
IF sy-subrc EQ 0.
LOOP AT t_vbak INTO fs_vbak.
LOOP AT t_kna1 INTO fs_kna1 WHERE kunnr = fs_vbak-kunnr.
WRITE :/ fs_vbak-kunnr UNDER text-002,
fs_kna1-name UNDER text-003,
fs_vbak-bstnk UNDER text-004.
HIDE : fs_vbak-kunnr,
fs_vbak-bstnk,
fs_vbak-vbeln.
ENDLOOP. " LOOP AT KNA1 INTO FS_KNA1
ENDLOOP. " LOOP AT T_VBAK INTO FS_VBAK
ENDIF. " IF SY-SUBRC EQ 0
ENDIF. " IF SY-SUBRC EQ 0
ENDFORM. " FORM START_OF_SELECTION
*& Form AT_LINE_SELECTION
* This Subroutine performs AT LINE-SELECTION Event *
* There are no interface parameters to be passed to this subroutine. *
FORM at_line_selection .
IF sy-lsind = 1.
SET PF-STATUS space.
SELECT vbeln " Sales Doc No.
posnr " Sales Doc Item
matnr " Material Number
kwmeng " Cumulative Order Quantity
netpr " Net Price
FROM vbap
INTO TABLE t_vbap
WHERE vbeln = fs_vbak-vbeln.
IF sy-subrc EQ 0.
LOOP AT t_vbap INTO fs_vbap.
WRITE :/ fs_vbap-vbeln UNDER text-008,
fs_vbap-posnr UNDER text-009,
fs_vbap-matnr UNDER text-010,
49 fs_vbap-kwmeng,
67 fs_vbap-netpr,
83 space.
ENDLOOP. " LOOP AT T_VBAP INTO FS_VBAP
ENDIF. " IF SY-SUBRC EQ 0
ENDIF. " IF SY-LSIND = 1
ENDFORM. " FORM AT_LINE_SELECTION
*& Form USER_COMMAND *
* This Subroutine performs operations according to the User Command *
* There are no interface parameters to be passed to this subroutine. *
FORM user_command .
GET CURSOR FIELD w_fname.
CASE sy-ucomm.
WHEN 'CUSTINFO'.
IF w_fname EQ 'FS_KNA1-KUNNR'.
SET PARAMETER ID 'KUN' FIELD fs_kna1-kunnr.
CALL TRANSACTION 'XD03'.
ELSE.
MESSAGE e184(bc_global) WITH text-005.
ENDIF. " IF W_FNAME EQ 'FS_KNA1-KUNNR'
WHEN 'ORDERINFO'.
IF w_fname EQ 'FS_VBAK-BSTNK'.
SET PARAMETER ID 'AUN' FIELD fs_vbak-bstnk.
CALL TRANSACTION 'VA03'.
ELSE.
MESSAGE e184(bc_global) WITH text-006.
ENDIF. " IF W_FNAME EQ 'FS_VBAK-BSTNK'
ENDCASE. " CASE SY-UCOMM
ENDFORM. " FORM USER_COMMAND
This report is used to Fetch & Display the Customer Number, Name and the Customer Purchase Order Number from Tables VBAK & KNA1.When the user places the cursor on the customer and clicks on the button u2018Customer Infou2019,the User is taken to the Transaction 'XD03'. When the user places the cursor on the order & clicks on the button u2018Order Infou2019, the User is taken to the transacion 'VA03'. When the User selects a line on the List the order details are Displayed
Please relate this to your requirement.
Regards,
Swapna. -
User command is not getting triggered in interactive ALV with LIST display
Hi experts,
I have developed an interactive ALV report with LIST display. Here, the issue is, when i double click a record in the primary ALV list, the control must go to the USER COMMAND event which i have written in my report. But the user command event is not getting triggered at all when i double click any record.
It gives the following information instead.
"Choose a valid function".
(My user command name and its respective form name are same.)
Here is my code..
START-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
i_callback_user_command = 'TST1'
i_callback_pf_status_set = 'SET_PF_STATUS'
TABLES
t_outtab = <dyn_table>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
FORM tst1 USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Local data declaration
DATA: li_tab TYPE REF TO data,
l_line TYPE REF TO data.
* Local field-symbols
FIELD-SYMBOLS:<l_tab> TYPE table,
<l_wa> TYPE ANY.
* Create table
CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN li_tab->* TO <l_tab>.
* Create workarea
CREATE DATA l_line LIKE LINE OF <l_tab>.
ASSIGN l_line->* TO <l_wa>. CASE r_ucomm.
* When a record is selected
WHEN '&IC1'.
* Read the selected record
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
rs_selfield-tabindex. IF sy-subrc = 0.
* Store the record in an internal table
APPEND <dyn_wa> TO <l_tab>.
* Fetch the field catalog info
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = 'Z_DEMO_PDF_JG'
i_structure_name = p_table
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
Please advice what is the msitake i have done here..Read the following code:
pass the i_callback_user_command = g_user_command to the ALV function module and write the FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
as shown below.
thanx
Data for ALV display
DATA : gt_fieldcat TYPE slis_t_fieldcat_alv,
gt_events TYPE slis_t_event,
g_variant LIKE disvariant,
g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
g_status TYPE slis_formname VALUE 'SET_PF_STATUS',
gt_list_top_of_page TYPE slis_t_listheader,
g_repid LIKE sy-repid,
gf_pos TYPE i
Data for ALV display
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_program = sy-repid
it_fieldcat = gt_fieldcat[]
it_events = gt_events[]
i_callback_user_command = g_user_command
i_save = 'A'
is_variant = g_variant
TABLES
t_outtab = it_print.
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
CASE ucomm.
WHEN '&IC1'.
CASE selfield-sel_tab_field.
WHEN '1-KUNNR'.
READ TABLE it_print INTO wa_print INDEX selfield-tabindex.
IF sy-subrc = 0.
SET PARAMETER ID 'BPA' FIELD wa_print-kunnr.
CALL TRANSACTION 'BP'.
ENDIF.
WHEN '1-MATNR'.
READ TABLE it_print INTO wa_print INDEX selfield-tabindex.
IF sy-subrc = 0.
SET PARAMETER ID 'JP_ISS' FIELD wa_print-matnr.
CALL TRANSACTION 'JP29' AND SKIP FIRST SCREEN..
GET PARAMETER ID 'WRK' FIELD wa_zprint-werks.
SET PARAMETER ID 'VKO' FIELD wa_zprint-vkorg.
SET PARAMETER ID 'VTW' FIELD wa_zprint-vtweg.
CALL TRANSACTION 'JP29' AND SKIP FIRST SCREEN.
ENDIF.
Endcase.
Endform.
Maybe you are looking for
-
Spry Menu Bar - Different Background Image Wanted for menu items
Hi, I've looked everywhere for help with this and just haven't found any answers yet ... I want my Dreamweaver CS5.5 menu to look like this design I've done in PhotoShop ... It's a simple one level list with no sub-levels. Everything is good, except
-
Connecting Samsung Blue Ray Player to wireless network
I have a Linksys network with two wireless desktops, a laptop and a ROKU player connected to a WRT54G router. I was told to purchase a WAP54G Access Point to connect my Samsung Player to the internet. I setup the software on the WAP54G. When conne
-
A Bug I haven;t Seen Mentioned
Also, I reported it to Adobe. Here it is: I run F-Secure Firewall and Anti-virus s/w. When you use the LR Upload in the Web Module and the F-Secure is running, the photos and other files get truncated [at least some of them, not consistent]. I was tu
-
I just reinstalled win 7 on a laptop that came with vista. I can't find drivers. Mainly looking for Wi-Fi driver. As the others were installed except for video. I looked on the HP site and entered the model....f700.....I also tried by searching the p
-
Question realated to iPhone register
I registerd my iPhone in register page(http://register.apple.com) by mistake. No problem?