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
venkat
Hi 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
Similar Messages
-
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
vipinCheck 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 -
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. -
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 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. -
Need clarification regarding the test cable-diagnostics tdr command
Hello,
I've read about the test cable-diagnostics tdr command but I need clarification on the examples listed below to make sure that I am providing the right answer to my co-workers.
Example 1:
CXXX7SW17#show cable-diagnostic tdr int g0/20
TDR test last run on: July 16 10:23:00
Interface Speed Local pair Pair length Remote pair Pair status
Gi0/20 auto Pair A N/A N/A Normal
Pair B 72 +/- 10 meters N/A Open
Pair C 75 +/- 10 meters N/A Short/Crosstalk
Pair D 74 +/- 10 meters N/A Short/Crosstalk
Does this example mean that there's a cable length issue in the line which is causing the device that it's connected to not to work properly?
Example 2:
CXXX2SW140#show cable-diagnostics tdr int g0/21
TDR test last run on: July 16 09:16:22
Interface Speed Local pair Pair length Remote pair Pair status
Gi0/21 100M Pair A N/A Pair A Normal
Pair B N/A Pair B Normal
Pair C N/A Pair C Normal
Pair D N/A Pair D Normal
Does this example state that the cable line is okay for use?
Example 3:
CXXX1SW19#show cable-diagnostics tdr int g0/22
TDR test last run on: July 16 06:36:53
Interface Speed Local pair Pair length Remote pair Pair status
Gi0/22 auto Pair A 1 +/- 10 meters N/A Open
Pair B 39 +/- 10 meters N/A Open
Pair C 72 +/- 10 meters N/A Open
Pair D 1 +/- 10 meters N/A Open
Does this example mean that there isn't a device connected on the other end? No pin-contact?
Thank you very much for any help you could provide.
SI found this article here at supportforums that seemed like the best explanation I've read so far for TDR info.
Hope that helps. -
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 -
Multiple line selection and then capturing the selected values
Dear all
in my alv program ,i need to capture multiple line selections using checkboxes.
I have appended check boxes by adding it in the internal table & filling in field catalog.
but problem is i'm not able to capture multiple selected check boxes dynamically,
i could capture only the last selected check box,
option i found was to use class method get-selected-rows,but i'm unable to use it properly, could anyone explain in detail
i have already gone through the various examples in sdn but i am not able to work out.
like using parameters etc....
CAN ANY ONE HELP ME WITH THE CODE
help reqired immediately,
Thanks in advance.Hi Ankur,
In the PAI, just after the selection of your user event, button or menu,
add this code before getting the selected records.
<b>CALL METHOD grid1->check_changed_data
IMPORTING
e_valid = ws_x.</b>
where grid1 TYPE REF TO cl_gui_alv_grid,
Now fetch the selected records.
Check this code for reference
C O M P A N Y C O N F I D E N T I A L **
Care should be taken to prevent its unauthorized use. **
REPORT zfipost MESSAGE-ID f4 NO STANDARD PAGE HEADING .
AUTHOR : Susmitha Susan Thomas
DATE : August 18, 2005
*Abridged Version : This report generates a list in Abap List Viewer of
all the selected records in VBKPF/VBSEG. * *
(TRANSACTION ZPPD:Modified from transaction FBV0)
-- Class definition--
CLASS lcl_event_receiver DEFINITION DEFERRED.
--Tables--
TABLES: vbkpf. " Belegkopf
TABLES: tsp1d, pri_params, spopli.
TYPE-POOLS slis.
---- Global Variables -
DATA: anzkr(6) TYPE n,
lsind LIKE sy-lsind,
no_output(1) TYPE c,
records(1) TYPE c,
xpick(1) TYPE c,
xpickc(1) TYPE c,
xbinp(1) TYPE c,
rc LIKE syst-subrc,
ok_code LIKE sy-ucomm,
index TYPE i,
char_x(1) TYPE c VALUE 'X',
post TYPE c,
ans TYPE n,
user(40) TYPE c.
DATA :BEGIN OF i_doctype OCCURS 0,
blart LIKE vbkpf-blart,
END OF i_doctype.
--AlV Initialization--
DATA: gs_layout TYPE lvc_s_layo,
gt_fieldcat TYPE lvc_t_fcat,
gs_fieldcat TYPE lvc_s_fcat,
gs_index_rows TYPE lvc_t_row,
l_layout TYPE disvariant,
g_repid LIKE sy-repid,
g_max TYPE i VALUE 100,
ws_row_idx TYPE lvc_t_row ,
ws_row_no TYPE lvc_t_roid,
i_excl_func TYPE ui_functions,
ls_prnt TYPE lvc_s_prnt,
refresh TYPE c,
i_fieldcat TYPE lvc_t_fcat,
post(1) TYPE c,
accr_def(1) TYPE c,
rev_cd(3) TYPE c,
ch(1) TYPE c.
DATA: list_index LIKE sy-lsind,
flag TYPE n VALUE 0,
fl TYPE n VALUE 0,
g_container TYPE scrfname VALUE 'GRID_CONTAINER',
grid_container TYPE REF TO cl_gui_docking_container,
grid1 TYPE REF TO cl_gui_alv_grid,
custom_container1 TYPE REF TO cl_gui_custom_container,
event_receiver TYPE REF TO lcl_event_receiver,
gt_vbkpf1 TYPE STANDARD TABLE OF vbkpf WITH HEADER LINE,
i_vbkpf TYPE TABLE OF vbkpf WITH HEADER LINE,
i_ws_row_idx LIKE ws_row_idx WITH HEADER LINE.
---Internal table containing details of selected documents--
DATA : BEGIN OF gt_vbkpf OCCURS 0,
xpick(1) TYPE c,
belnr LIKE vbkpf-belnr,
gjahr LIKE vbkpf-gjahr,
bukrs LIKE vbkpf-bukrs,
blart LIKE vbkpf-blart,
budat LIKE vbkpf-budat,
bldat LIKE vbkpf-bldat,
bktxt LIKE vbkpf-bktxt,
waers LIKE vbkpf-waers,
usnam LIKE vbkpf-usnam,
xblnr LIKE vbkpf-xblnr,
rev_code(3) TYPE c,
rev_rsn(15) TYPE c,
rev_date(10) TYPE c,
linecolor(4) TYPE c,
END OF gt_vbkpf.
--Table to store long text--
DATA : BEGIN OF inline OCCURS 0,
tdformat TYPE tdformat,
tdline TYPE tdline,
END OF inline.
DATA: thead LIKE thead OCCURS 0 WITH HEADER LINE.
-- Records to be posted--
DATA: BEGIN OF tbkpf OCCURS 5.
INCLUDE STRUCTURE vbkpf.
DATA: END OF tbkpf.
---- Constants -
CONSTANTS: awtyp_bkpf TYPE awtyp VALUE 'BKPF '.
CONSTANTS: awtyp_space TYPE awtyp VALUE ' '.
Selection Screen
PARAMETER: funcl LIKE t020-funcl NO-DISPLAY. "P(ost),D(isplay),U(pd)
SELECTION-SCREEN SKIP 2.
SELECT-OPTIONS:
p_bukrs FOR vbkpf-bukrs,
p_belnr FOR vbkpf-belnr,
p_gjahr FOR vbkpf-gjahr,
p_budat FOR vbkpf-budat,
p_bldat FOR vbkpf-bldat,
p_blart FOR vbkpf-blart,
p_xblnr FOR vbkpf-xblnr,
p_bktxt FOR vbkpf-bktxt,
p_usnam FOR vbkpf-usnam.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK blk
WITH FRAME TITLE text-010 NO INTERVALS.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(35) text-002.
PARAMETER norm_doc TYPE c
RADIOBUTTON GROUP doc DEFAULT 'X' .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(35) text-001.
PARAMETER ad_doc TYPE c
RADIOBUTTON GROUP doc .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(35) text-003.
PARAMETER all_doc TYPE c
RADIOBUTTON GROUP doc .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK blk.
CLASS lcl_event_receiver DEFINITION
For capturing events on the ALV *
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
to capture all recently changed data.
handle_data_changed FOR EVENT data_changed OF
cl_gui_alv_grid
IMPORTING er_data_changed,
for hot spot
handle_hotspot FOR EVENT hotspot_click OF
cl_gui_alv_grid
IMPORTING e_column_id e_row_id.
ENDCLASS. " lcl_event_receiver (Definition)
CLASS lcl_event_receiver (Implementation)
For capturing events on the ALV *
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
PERFORM f2200_handle_data_changed USING er_data_changed.
ENDMETHOD.
METHOD handle_hotspot.
PERFORM f2201_handle_hotspot USING e_column_id e_row_id .
ENDMETHOD.
ENDCLASS. " lcl_event_receiver (Implementation)
AT SELECTION-SCREEN
AT SELECTION-SCREEN.
START-OF-SELECTION
START-OF-SELECTION.
---- Colors -
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
-------------------- Status und Title Bar----------------------------*
SET PF-STATUS funcl.
SET TITLEBAR funcl.
-- Read Records--
SELECT * FROM vbkpf INTO TABLE gt_vbkpf1
WHERE bukrs IN p_bukrs
AND ausbk IN p_bukrs
AND belnr IN p_belnr
AND gjahr IN p_gjahr
AND budat IN p_budat
AND bldat IN p_bldat
AND blart IN p_blart
AND bktxt IN p_bktxt
AND xblnr IN p_xblnr
AND usnam IN p_usnam
AND bstat EQ 'V'
AND ( awtyp IN (awtyp_bkpf, awtyp_space) OR
awtyp IS null )
ORDER BY PRIMARY KEY.
----Call the ALV Screen -
PERFORM alv_display.
END-OF-SELECTION.
FORM BELEG_PICKUP *
Indicate changing of the selected external record *
FORM beleg_pickup.
SET PARAMETER ID 'BUK' FIELD vbkpf-bukrs.
SET PARAMETER ID 'GJR' FIELD vbkpf-gjahr.
SET PARAMETER ID 'BLP' FIELD vbkpf-belnr.
CASE funcl.
WHEN 'P'.
IF anzkr IS INITIAL.
CALL FUNCTION 'ZPRELIMINARY_POSTING_POST_D'
EXPORTING
bukrs = vbkpf-bukrs
belnr = vbkpf-belnr
gjahr = vbkpf-gjahr.
ELSE.
IF sy-ucomm EQ 'BUCH'.
CALL FUNCTION 'ZPRELIMINARY_POSTING_POST_ALL'
EXPORTING
synch = char_x
bupbi = xbinp
TABLES
t_vbkpf = tbkpf.
ELSE.
CALL FUNCTION 'ZPRELIMINARY_POSTING_POST_ALL'
EXPORTING
bupbi = xbinp
TABLES
t_vbkpf = tbkpf.
wait up to 3 seconds.
commit work.
ENDIF.
ENDIF.
WHEN OTHERS.
IF sy-tcode = 'ZPPD'.
funcl = 'P'.
ENDIF.
CALL FUNCTION 'ZPRELIMINARY_POSTING_DISPLAY'
EXPORTING
bukrs = vbkpf-bukrs
belnr = vbkpf-belnr
gjahr = vbkpf-gjahr.
ENDCASE.
ENDFORM.
FORM TBKPF_FUELLEN *
Include records for posting in TBKPF *
FORM tbkpf_fuellen.
records = 'X'.
LOOP AT gt_vbkpf.
IF gt_vbkpf-xpick = 'X'.
CLEAR anzkr.
CLEAR records.
IF sy-subrc = 0.
anzkr = anzkr + 1.
MOVE-CORRESPONDING gt_vbkpf TO tbkpf.
APPEND tbkpf.
ELSE.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
FORM MALL *
Select All documents *
FORM mall.
LOOP AT gt_vbkpf.
gt_vbkpf-xpick = 'X'.
MODIFY gt_vbkpf.
ENDLOOP.
refresh = 'X'.
CALL METHOD grid1->refresh_table_display.
ENDFORM.
FORM EMAL *
Unselect all documents *
FORM emal.
LOOP AT gt_vbkpf.
gt_vbkpf-xpick = ' '.
MODIFY gt_vbkpf.
ENDLOOP.
refresh = 'X'.
CALL METHOD grid1->refresh_table_display.
ENDFORM.
Form alv_display *
To display the details on an ALV. *
FORM alv_display.
CALL SCREEN 100.
ENDFORM. " alv_display
*& Module PB0_100 OUTPUT
MODULE pb0_100 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'POSTDOC'.
--To verify that posting is complete.--
---- Setting the layout -
IF grid1 IS INITIAL.
PERFORM fill_table.
-- Initializing the field catalog--
PERFORM fieldcat_init CHANGING i_fieldcat.
-- Initializing the ALV GRID and CONTAINER--
CLEAR gs_layout.
gs_layout-info_fname = 'linecolor'.
gs_layout-grid_title = 'Parked Documents'(100).
gs_layout-zebra = 'X'.
gs_layout-cwidth_opt = 'X'.
gs_layout-sel_mode = 'A'.
gs_layout-edit = 'X'.
l_layout-report = sy-repid.
------ Create a custom container control for ALV Control----
IF cl_gui_alv_grid=>offline( ) IS INITIAL.
CREATE OBJECT grid_container
EXPORTING
dynnr = '100'
ratio = '100'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
IF sy-subrc NE 0.
MESSAGE i000 WITH text-007. " Error in object creation
LEAVE LIST-PROCESSING.
ENDIF.
-- Create an instance of alv control--
CREATE OBJECT grid1
EXPORTING
i_lifetime = 1
i_parent = grid_container.
---- Disable all unwanted button in the ALV grid -
PERFORM disable_functions TABLES i_excl_func.
---- Call the display function of ALV grid -
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_variant = l_layout
i_save = 'A'
is_layout = gs_layout
is_print = ls_prnt
it_toolbar_excluding = i_excl_func
CHANGING it_outtab = gt_vbkpf[]
it_fieldcatalog = i_fieldcat.
ENDIF. " IF cl_gui_alv_grid=>offline IS INITIAL
CALL METHOD grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CALL METHOD grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
---- Create a reciever object to handle events -
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_data_changed FOR grid1.
SET HANDLER event_receiver->handle_hotspot FOR grid1.
CALL METHOD cl_gui_control=>set_focus EXPORTING control = grid1.
ENDIF. " IF grid1 IS INITIAL.
ENDMODULE. " PB0_100 OUTPUT
*& Form fill_table
Fills the data table to be passed to the ALV grid.
FORM fill_table.
LOOP AT gt_vbkpf1.
MOVE-CORRESPONDING gt_vbkpf1 TO gt_vbkpf.
IF ad_doc = 'X' OR all_doc = 'X'.
thead-tdobject = 'BELEG'.
CONCATENATE gt_vbkpf1-bukrs
gt_vbkpf1-belnr
gt_vbkpf1-gjahr INTO thead-tdname.
thead-tdspras = sy-langu.
thead-tdid = '0004'.
PERFORM read_text.
READ TABLE inline INDEX 1.
gt_vbkpf-rev_code = inline-tdline.
REFRESH inline.
CLEAR inline.
thead-tdid = '0005'.
PERFORM read_text.
READ TABLE inline INDEX 1.
gt_vbkpf-rev_rsn = inline-tdline.
REFRESH inline.
CLEAR inline.
thead-tdid = '0006'.
PERFORM read_text.
READ TABLE inline INDEX 1.
gt_vbkpf-rev_date = inline-tdline.
REFRESH inline.
CLEAR inline.
REFRESH inline.
CLEAR inline.
ENDIF.
APPEND gt_vbkpf.
CLEAR gt_vbkpf.
ENDLOOP.
ENDLOOP.
ENDFORM.
*& Form fieldcat_init
Initialize the field catalog
FORM fieldcat_init CHANGING i_fieldcat TYPE lvc_t_fcat.
DATA: i_fldcat TYPE lvc_t_fcat WITH HEADER LINE.
CHECKBOX
CLEAR i_fldcat.
i_fldcat-fieldname = 'XPICK'.
i_fldcat-checkbox = 'X'.
i_fldcat-key = 'X'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-outputlen = '4'.
i_fldcat-scrtext_l = 'ChkB'.
APPEND i_fldcat TO i_fieldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'BELNR'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-hotspot = 'X'.
i_fldcat-outputlen = '15'.
i_fldcat-scrtext_l = 'Document Number'.
APPEND i_fldcat TO i_fieldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'GJAHR'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-scrtext_l = 'FYear'.
i_fldcat-outputlen = '5'.
APPEND i_fldcat TO i_fieldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'BUKRS'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-scrtext_l = 'CCode'.
i_fldcat-outputlen = '5'.
APPEND i_fldcat TO i_fieldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'BLART'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-scrtext_l = 'Type'.
i_fldcat-outputlen = '6'.
APPEND i_fldcat TO i_fieldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'BLDAT'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-scrtext_l = 'Doc Date'.
i_fldcat-outputlen = '12'.
APPEND i_fldcat TO i_fieldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'BUDAT'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-scrtext_l = 'Park Date'.
i_fldcat-outputlen = '12'.
APPEND i_fldcat TO i_fieldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'BKTXT'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-scrtext_l = 'Document Header Text'.
i_fldcat-outputlen = '25'.
APPEND i_fldcat TO i_fieldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'WAERS'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-scrtext_l = 'Curr'.
i_fldcat-outputlen = '7'.
APPEND i_fldcat TO i_fieldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'USNAM'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-scrtext_l = 'Parked By'.
i_fldcat-outputlen = '13'.
APPEND i_fldcat TO i_fieldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'XBLNR'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-scrtext_l = 'Reference Text'.
i_fldcat-outputlen = '19'.
APPEND i_fldcat TO i_fieldcat.
IF ad_doc = 'X' OR all_doc = 'X'.
CLEAR i_fldcat.
i_fldcat-fieldname = 'REV_CODE'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-scrtext_l = 'RC'.
i_fldcat-outputlen = '2'.
APPEND i_fldcat TO i_fieldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'REV_RSN'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-scrtext_l = 'Rev Reason'.
i_fldcat-outputlen = '15'.
APPEND i_fldcat TO i_fieldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'REV_DATE'.
i_fldcat-tabname = 'GT_VBKPF'.
i_fldcat-key = 'X'.
i_fldcat-scrtext_l = 'Rev Date'.
i_fldcat-outputlen = '10'.
APPEND i_fldcat TO i_fieldcat.
ENDIF.
ENDFORM. " fieldcat_init
*& Module PAI_100 INPUT
MODULE pai_100 INPUT.
CASE ok_code.
WHEN 'BACK'.
IF sy-dynnr = '1000'.
PERFORM exit_program.
ELSEIF sy-dynnr = '0100'.
LEAVE TO TRANSACTION 'ZPPD'.
ENDIF.
WHEN 'EXIT'.
IF sy-dynnr = '1000'.
PERFORM exit_program.
ELSEIF sy-dynnr = '0100'.
LEAVE TO TRANSACTION 'ZPPD'.
ENDIF.
WHEN '%EX'.
IF sy-dynnr = '1000'.
PERFORM exit_program.
ELSEIF sy-dynnr = '0100'.
LEAVE TO TRANSACTION 'ZPPD'.
ENDIF.
WHEN 'BINP'.
DATA : ws_x TYPE c VALUE 'X'.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Posting Documents Via Batch Input'
text_question =
'Are you sure you want to post all the selected documents?'
text_button_1 = 'Yes'
text_button_2 = 'No'
start_column = 25
start_row = 6
IMPORTING
answer = ans.
IF ans = '1'.
CALL METHOD grid1->check_changed_data
IMPORTING
e_valid = ws_x.
xbinp = 'X'.
PERFORM tbkpf_fuellen.
IF records = 'X'.
MESSAGE s999(zv) WITH text-007.
ELSE.
PERFORM beleg_pickup.
ENDIF.
ENDIF.
WHEN 'MALL'.
PERFORM mall.
WHEN 'EMAL'.
PERFORM emal.
WHEN 'RW'.
IF sy-dynnr = '1000'.
PERFORM exit_program.
ELSEIF sy-dynnr = '0100'.
LEAVE TO TRANSACTION 'ZPPD'.
ENDIF.
WHEN 'BUCH'.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Posting Document'
text_question =
'Are you sure you want to post all documents selected?'
text_button_1 = 'Yes'
text_button_2 = 'No'
start_column = 25
start_row = 6
IMPORTING
answer = ans.
IF ans = '1'.
CALL METHOD grid1->check_changed_data
IMPORTING
e_valid = ws_x.
perform tbkpf_fuellen.
IF records = 'X'.
MESSAGE s999(zv) WITH text-007.
ELSE.
PERFORM beleg_pickup.
ENDIF.
ENDIF.
WHEN 'PICK'.
DATA : check TYPE n,
no_rec TYPE c.
check = 0.
no_rec = 'X'.
CALL METHOD grid1->check_changed_data
IMPORTING
e_valid = ws_x.
index = 0.
LOOP AT gt_vbkpf.
funcl = 'D'.
index = index + 1.
IF gt_vbkpf-xpick = 'X'.
check = 1.
CLEAR no_rec.
READ TABLE gt_vbkpf1 INDEX index INTO vbkpf.
PERFORM beleg_pickup.
ENDIF.
ENDLOOP.
IF check = 0.
CALL METHOD grid1->get_selected_rows
IMPORTING
et_index_rows = ws_row_idx.
IF NOT ws_row_idx IS INITIAL.
CLEAR no_rec.
ENDIF.
LOOP AT ws_row_idx INTO i_ws_row_idx.
READ TABLE gt_vbkpf1 INDEX i_ws_row_idx-index INTO vbkpf.
PERFORM beleg_pickup.
ENDLOOP.
IF no_rec = 'X'.
MESSAGE s999(zv) WITH text-007.
ENDIF.
ENDIF.
WHEN '&RNT_PREV'.
CALL METHOD grid1->set_function_code
CHANGING c_ucomm = ok_code.
WHEN '&RNT'.
CALL METHOD grid1->set_function_code
CHANGING c_ucomm = ok_code.
WHEN '%SC'.
CALL METHOD grid1->set_function_code
CHANGING c_ucomm = ok_code.
WHEN '&OL0'.
CALL METHOD grid1->set_function_code
CHANGING c_ucomm = ok_code.
WHEN '&OAD'.
CALL METHOD grid1->set_function_code
CHANGING c_ucomm = ok_code.
WHEN '&AVE'.
CALL METHOD grid1->set_function_code
CHANGING c_ucomm = ok_code.
WHEN '&AQW'.
CALL METHOD grid1->set_function_code
CHANGING c_ucomm = ok_code.
WHEN '&XXL'.
CALL METHOD grid1->set_function_code
CHANGING c_ucomm = ok_code.
WHEN '%PC'.
CALL METHOD grid1->set_function_code
CHANGING c_ucomm = ok_code.
WHEN '&CRTEMPL'.
CALL METHOD grid1->set_function_code
CHANGING c_ucomm = ok_code.
WHEN OTHERS.
do nothing.
ENDCASE.
CLEAR ok_code.
ENDMODULE. " PAI_100 INPUT
*& Form exit_program
Exits from the program after freeing the grid and container *
FORM exit_program.
IF NOT grid_container IS INITIAL.
CALL METHOD grid_container->free.
ENDIF.
IF NOT grid1 IS INITIAL.
CALL METHOD grid1->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
ENDIF.
LEAVE PROGRAM.
ENDFORM. " exit_program
*& Form f2200_handle_data_changed
To handle event of change in data in ALV.
-->P_ER_DATA_CHANGED text
FORM f2200_handle_data_changed USING ir_data_changed
TYPE REF TO
cl_alv_changed_data_protocol.
DATA : ls_mod_cell TYPE lvc_s_modi ,
lv_value TYPE lvc_value,
lflg_check TYPE i.
DATA : wa_vbkpf LIKE LINE OF gt_vbkpf.
SORT ir_data_changed->mt_mod_cells BY row_id .
LOOP AT ir_data_changed->mt_mod_cells
INTO ls_mod_cell
WHERE fieldname = 'I_PICK'.
IF NOT ls_mod_cell-value IS INITIAL .
CALL METHOD ir_data_changed->modify_cell
EXPORTING
i_row_id = ls_mod_cell-row_id
i_fieldname = ls_mod_cell-fieldname
i_value = ls_mod_cell-value.
READ TABLE gt_vbkpf INTO wa_vbkpf
INDEX ls_mod_cell-row_id.
IF ls_mod_cell-fieldname = 'I_PICK'.
wa_vbkpf-xpick = ls_mod_cell-value.
ENDIF.
MODIFY gt_vbkpf FROM wa_vbkpf
INDEX ls_mod_cell-row_id.
ENDIF .
ENDLOOP .
ENDFORM. " f2200_handle_data_changed
*& Form f2201_handle_hotspot
To handle event of clicking on hyperlink
-->P_E_COLUMN_ID text
FORM f2201_handle_hotspot USING p_e_column_id p_e_row_id.
READ TABLE gt_vbkpf1 INDEX p_e_row_id INTO vbkpf.
funcl = 'D'.
PERFORM beleg_pickup.
PERFORM exit_program.
ENDFORM. " f2201_handle_hotspot
Regards,
Susmitha
Dont forget to reward points for useful answers -
Hi Guys,
I need ur help regarding my coding: AT LINE SELECTION.
Here is my codes, but it is not working.
AT LINE-SELECTION.
IF ( wa_list-auart = 'ZCS' AND wa_list-auart = 'ZSA' ).
IF NOT wa_list-sonum IS INITIAL.
SET PARAMETER ID 'AUN' FIELD wa_list-sonum.
CALL TRANSACTION 'VF01' AND SKIP FIRST SCREEN.
CLEAR wa_list-sonum.
ENDIF.
ELSE.
IF NOT wa_list-drnum IS INITIAL.
SET PARAMETER ID 'AUN' FIELD wa_list-drnum.
CALL TRANSACTION 'VF01' AND SKIP FIRST SCREEN.
CLEAR wa_list-drnum.
ENDIF.
ENDIF.
The requirements are:
1. Data selection on column Item + Magnifying Glass Icon click will direct user to transaction code VF01 ====>><b>its working, but the problem is when i click the line item no 1, it wasnt work. Line item no 1 only but the rest items its workin.</b>
2. Sales Order No (VBAK-VBELN) will be the default value on document column of VF01 if Sales Order Type (VBAK-AUART) = ZCS or ZSA else Delivery No (LIKP-VBELN) will be the default value on document column of VF01. ===><b>the problem is when i click the line item, there is no default Sales Order No or Delivery NO on parameter 'AUN' <Document column> based on if statement.</b>
3. Warning Message Select a line item to proceed. will be displayed if no line item selected on magnifying glass icon click. ===> <b>help me on how to codes this one if i click to a non line item, there should be a Warning Message Select a line item to proceed.</b>
Thanks in advance.
zhien.hi joycee
i think one of the command written by u
:-"IF NOT wa_list-sonum IS INITIAL."
shoud be written like
:- IF wa_list-sonum IS NOT INITIAL. -
AT LINE SELECTION AN AT USER-COMMAND IN ONE REPORT
hiiii friends.....
hw can i go for both at line selection an at user comond in one report....
ie if double click on basic list it should shw sm output an when i choose menu optoin it should perform sm other output......You need to crate a PF-Status and in the PF-staus you need to include some essentials buttons and the button for your list on the USER-COMMAND.
Say,
BACK
EXIT
CANC
PICK ... should be assigned to F2 .. to work with LINE-SELECTION.
NEW_LIST ... for USER-COMMAND
In your report:
START-OF-SELECTION.
SET PF-STATUS 'Z_OWN'.
AT LINE-SELECTION.
WRITE : 'I AM LINE SELECTION'.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'NEW_LIST'.
WRITE / 'I AM CALLED FROM USER COMMAND'.
ENDCASE.
Regards,
Naimesh Patel -
How to use AT LINE-SELECTION and AT USER-COMMAND in one report????
Dear all,
I have a problem in reports I want to use AT USER-COMMAND.and AT LINE-SELECTION.both in the one report.
But as soon as I use SET PF-STATUS my AT LINE-SELECTION event stop workingand only AT USER-COMMAND is working.
How can I use both of them in one report for your reference I am giving my test program below.
REPORT ZTEST111 .
SET PF-STATUS '100'.
DO 10 TIMES.
WRITE:/ SY-INDEX.
HIDE SY-INDEX.
ENDDO.
START-OF-SELECTION.
AT LINE-SELECTION.
MESSAGE I002(SY) WITH SY-INDEX.
AT USER-COMMAND.
MESSAGE I002(SY) WITH 'USER COMMAND'.
END-OF-SELECTION.
Thanks in advance
Sachin Gautamhi
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 -
At user-command & At Line-selection
Hi,
I am using ECC5 ver. of ABAP.
Can I use AT USER-COMMAND and AT LINE-SELECTION
in the same report?
I have used it but only At user command works, not At line selection.
When I remove Set pf-Status, At line selection works.
Here is my code.
REPORT PF&ATLINE.
AT LINE-SELECTION.
MESSAGE 'Line Selected' TYPE 'I'.
AT USER-COMMAND.
IF sy-ucomm = 'PUSH'.
MESSAGE 'Button Pushed' type 'I'.
elseif sy-ucomm = 'EXIT'.
LEAVE PROGRAM.
ENDIF.
START-OF-SELECTION.
SET PF-STATUS 'ZRND3'.
DO 10 TIMES.
WRITE:/01 SY-INDEX HOTSPOT.
ENDDO.
END-OF-SELECTION.Hi Rajiv,
Setting the PICK function code to F2 will definitely solve it..
and it triggers the at user-command and at line-selection event as per user interaction...
If it is not working properly... then there might me something wrong in your code...
can you place the code... so that we can know the exact problem
regards
padma
Maybe you are looking for
-
At first i got a problem with my Apple Mobile Device Support, but then after i've done some research browsing the net on how to fix that problem, i've finally found the solution to that problem... However, after I've finish installing and trying to r
-
Hi Guys, When I connect my new Ipad to the PC, it comes up with an error to say that my PC cant connect to itunes, therefore I cant register it? I have tried other Apple devices and they now will not connect either, even if I just try and connect to
-
Which trigger fires after pressing 'Save' button on toolbar.
hi, I wanted to know which triggers get fired after pressing 'save' button on toolbar, and in which sequence it get's fired.
-
Hello I suppose that most of you use Eclipse development platform. But I recently installed Emacs as Java editor. I don't find one thing : How to activate the code completion ? For example : I begin to type JF and by pressing TAB, it fills JFrame tha
-
Qualification catalog translation
Hello , We are planning for translation of catalog in German, French and some other languages. Can anyone please help me with the questions below ? 1. How do we translate the catalog (QK, Q, Proficiency scales , descriptions ) if the language of crea