Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

get cursor command

Former Member
0 Likes
2,310

can anyone give me example on how to use get cursor command?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,021

hi

get cursor is used to store the value of the field on which the cursor is placed

get cursor value f1----


>this stores the value in the field f1

which can b used later

first display the material number on the list from an internal table

loop at it_mara.

write : / it_mara-matnr.

endloop.

after list is diplayed place the cursor on the matnr and click it

that value is stored in field f1.

which can b later used to display on secondary list or any other purpose...

its just like hide statement..

hope this helps....

6 REPLIES 6
Read only

former_member194669
Active Contributor
0 Likes
1,021

Hi,

AT LINE-SELECTION.

GET CURSOR FIELD CURSORFIELD.

Example

demo_list_hide

DEMO_LIST_GET_CURSOR

aRs

Message was edited by:

aRs

Read only

0 Likes
1,021

refer this demo code and click on the any one field value of the output ..

it wil take u to secondary list -



tables pa0001.
data: cursorfield(20).

data: begin of itab occurs 0.
include structure pa0001.
data end of itab.

start-of-selection.
select * from pa0001 up to 2 rows into table itab.

loop at itab.
write:/ itab-pernr.
endloop.

AT LINE-SELECTION.
GET CURSOR FIELD CURSORFIELD.

case cursorfield.
when 'ITAB-PERNR' .
read table itab with key pernr = itab-pernr.
write:/ itab-plans.
endcase. 

Read only

Former Member
0 Likes
1,021

Hi,

Hide & Get Cursor is used in interactive programming ( in the event AT LINE-selection).

Using Hide in Loop..Endloop, you can get the field name At Line-Select

Event While Double Clicking That Line.

***PROG.BEGIN**************************************************************

&----


*& Report ZPREM_INTERACTIVE *

*& *

&----


*& *

*& *

&----


REPORT zprem_interactive .

TYPES : BEGIN OF ty_test,

code TYPE i,

name(10) TYPE c,

amount TYPE p DECIMALS 2,

END OF ty_test.

DATA : it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE INITIAL SIZE 10.

DATA : wa TYPE ty_test,

chk1 TYPE c,

fldname(30), fldval(50).

*set pf-status 'PF01'.

*set titlebar 'PF01'.

*

INITIALIZATION.

it_test-code = 300.

it_test-name = 'Ramesh'.

it_test-amount = 5500.

APPEND it_test.

wa-code = 207.

wa-name = 'Prem'.

wa-amount = 5000.

APPEND wa TO it_test.

it_test-code = 117.

it_test-name = 'James Bond'.

it_test-amount = 9900.

INSERT it_test INDEX 3.

it_test-code = 217.

it_test-name = 'Sivaraman'.

it_test-amount = 9900.

INSERT it_test INDEX 3.

it_test-code = 201.

it_test-name = 'Saravanan'.

it_test-amount = 1000.

APPEND it_test.

it_test-code = 210.

it_test-name = 'Shanmugam'.

it_test-amount = 6000.

APPEND it_test.

WRITE : / 'Loop Display ( Appended rows ) :-'.

LOOP AT it_test.

WRITE : / chk1 AS CHECKBOX,

sy-tabix, sy-vline, it_test-code, it_test-name, it_test-amount.

HIDE : it_test-code, it_test-name.

ENDLOOP.

SKIP.

END-OF-SELECTION.

CLEAR : it_test-code, it_test-name.

WRITE : / 'this from end of selection'.

&----


*& Form DISP1

&----


  • text

----


FORM disp1.

WINDOW STARTING AT 15 10

ENDING AT 80 15.

DO.

CLEAR chk1.

READ LINE sy-index FIELD VALUE chk1.

IF sy-subrc NE 0.

EXIT.

ELSE.

CHECK chk1 NE space.

WRITE : / it_test-code, it_test-name.

MODIFY CURRENT LINE :

FIELD VALUE chk1 FROM ' '

FIELD FORMAT chk1 INPUT OFF.

ENDIF.

ENDDO.

ENDFORM. "DISP1

***line double click ****

AT LINE-SELECTION.

CHECK sy-lsind = 1.

WINDOW STARTING AT 5 4

ENDING AT 85 20.

WRITE: / 'THE USER DOUBLE-CLICKED A LINE IN THE REPORT'.

WRITE: / sy-lisel.

WRITE : / 'Sometime ',it_test-name, ' is good '.

WRITE : / 'Sometime ',it_test-name, ' is bad '.

WRITE : / 'Sometime ',it_test-name, ' is rich '.

WRITE : / 'Sometime ',it_test-name, ' is poor '.

WRITE : / 'Who knows, who is ',it_test-name, ' ? '.

WRITE : /, / 'we can also use this in SELECT statement'.

CLEAR : it_test-code, it_test-name.

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ULINE.

SKIP.

SKIP.

WRITE : / 'Below from Get Cursor Field...'.

GET CURSOR FIELD fldname VALUE fldval.

CONDENSE fldname.

CONDENSE fldval.

WRITE : / 'You have clicked ', fldname, ' & its value is ', fldval.

***function key press F6 ****

AT PF06.

PERFORM disp1.

regards,

keerthi

Read only

Former Member
0 Likes
1,022

hi

get cursor is used to store the value of the field on which the cursor is placed

get cursor value f1----


>this stores the value in the field f1

which can b used later

first display the material number on the list from an internal table

loop at it_mara.

write : / it_mara-matnr.

endloop.

after list is diplayed place the cursor on the matnr and click it

that value is stored in field f1.

which can b later used to display on secondary list or any other purpose...

its just like hide statement..

hope this helps....

Read only

Former Member
0 Likes
1,021

Hi Shaheen,

see this is how u use Get Cursor command under <b>At Line Selection Event</b>.

**********************************************************************************************

AT LINE-SELECTION.

DATA : f(50),

v(50).

<b>GET CURSOR FIELD f VALUE v.</b>

CASE f.

WHEN 'F1'.

write v.

WHEN 'F2'.

write v.

endcase.

**********************************************************************************************

this code will get the name of the field that u select in the output list into variable 'f' and the contents of that field into variable' v ' which u can use for ur logical purppose as shown.

rewards Points if answer was helpful...

regards,

Tejas

Read only

Former Member
0 Likes
1,021

Hi,

Use the statements GET CURSOR FIELD und GET CURSOR LINE to pass the output field or output line on which the cursor was positioned during the interactive event to the ABAP program.

REPORT zprem_interactive .

TYPES : BEGIN OF ty_test,

code TYPE i,

name(10) TYPE c,

amount TYPE p DECIMALS 2,

END OF ty_test.

DATA : it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE INITIAL SIZE 10.

DATA : wa TYPE ty_test,

chk1 TYPE c,

fldname(30), fldval(50).

*set pf-status 'PF01'.

*set titlebar 'PF01'.

*

INITIALIZATION.

it_test-code = 300.

it_test-name = 'Ramesh'.

it_test-amount = 5500.

APPEND it_test.

wa-code = 207.

wa-name = 'Prem'.

wa-amount = 5000.

APPEND wa TO it_test.

it_test-code = 117.

it_test-name = 'James Bond'.

it_test-amount = 9900.

INSERT it_test INDEX 3.

it_test-code = 217.

it_test-name = 'Sivaraman'.

it_test-amount = 9900.

INSERT it_test INDEX 3.

it_test-code = 201.

it_test-name = 'Saravanan'.

it_test-amount = 1000.

APPEND it_test.

it_test-code = 210.

it_test-name = 'Shanmugam'.

it_test-amount = 6000.

APPEND it_test.

WRITE : / 'Loop Display ( Appended rows ) :-'.

LOOP AT it_test.

WRITE : / chk1 AS CHECKBOX,

sy-tabix, sy-vline, it_test-code, it_test-name, it_test-amount.

HIDE : it_test-code, it_test-name.

ENDLOOP.

SKIP.

END-OF-SELECTION.

CLEAR : it_test-code, it_test-name.

WRITE : / 'this from end of selection'.

&----


*& Form DISP1

&----


  • text

----


FORM disp1.

WINDOW STARTING AT 15 10

ENDING AT 80 15.

DO.

CLEAR chk1.

READ LINE sy-index FIELD VALUE chk1.

IF sy-subrc NE 0.

EXIT.

ELSE.

CHECK chk1 NE space.

WRITE : / it_test-code, it_test-name.

MODIFY CURRENT LINE :

FIELD VALUE chk1 FROM ' '

FIELD FORMAT chk1 INPUT OFF.

ENDIF.

ENDDO.

ENDFORM. "DISP1

***line double click ****

AT LINE-SELECTION.

CHECK sy-lsind = 1.

WINDOW STARTING AT 5 4

ENDING AT 85 20.

WRITE: / 'THE USER DOUBLE-CLICKED A LINE IN THE REPORT'.

WRITE: / sy-lisel.

WRITE : / 'Sometime ',it_test-name, ' is good '.

WRITE : / 'Sometime ',it_test-name, ' is bad '.

WRITE : / 'Sometime ',it_test-name, ' is rich '.

WRITE : / 'Sometime ',it_test-name, ' is poor '.

WRITE : / 'Who knows, who is ',it_test-name, ' ? '.

WRITE : /, / 'we can also use this in SELECT statement'.

CLEAR : it_test-code, it_test-name.

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ULINE.

SKIP.

SKIP.

WRITE : / 'Below from Get Cursor Field...'.

GET CURSOR FIELD fldname VALUE fldval.

CONDENSE fldname.

CONDENSE fldval.

WRITE : / 'You have clicked ', fldname, ' & its value is ', fldval

Regards,

Sreevani