Application Development 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: 

what is the use of get cursor command

Former Member
0 Kudos

can anybody tell me what is the use of get cursor command

6 REPLIES 6

Former Member
0 Kudos

hi,

You can use get cursor as follows.

GET CURSOR FIELD <f> [OFFSET <off>]

[LINE <lin>]

[VALUE <val>]

[LENGTH <len>].

This statement transfers the name of the screen element on which the cursor is positioned during a user action into the variable <f>. If the cursor is on a field, the system sets SY-SUBRC to 0, otherwise to 4.

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..

The additions to the GET CURSOR statement have the following functions:

OFFSET writes the cursor position within the screen element to the variable <off>.

LINE writes the line number of the table to the variable <lin> if the cursor is positioned in a table control. If the cursor is not in a table control, <lin> is set to zero.

VALUE writes the contents of the screen field in display format, that is, with all of its formatting characters, as a string to the variable <val>.

LENGTH writes the display length of the screen field to the variable <len>.

Cursor position on the screen.

PROGRAM DEMO_DYNPRO_GET_CURSOR.

DATA: OK_CODE LIKE SY-UCOMM,

SAVE_OK LIKE OK_CODE.

DATA: INPUT_OUTPUT(20) TYPE C,

FLD(20) TYPE C,

OFF TYPE I,

VAL(20) TYPE C,

LEN TYPE I.

CALL SCREEN 100.

MODULE INIT_SCREEN_0100 OUTPUT.

SET PF-STATUS 'STATUS_100'.

ENDMODULE.

MODULE USER_COMMAND_0100 INPUT.

SAVE_OK = OK_CODE.

CLEAR OK_CODE.

CASE SAVE_OK.

WHEN 'CANCEL'.

LEAVE PROGRAM.

WHEN 'SELE'.

GET CURSOR FIELD FLD OFFSET OFF VALUE VAL LENGTH LEN.

ENDCASE.

ENDMODULE.

The screen flow logic is as follows:

PROCESS BEFORE OUTPUT.

MODULE INIT_SCREEN_0100.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.

The module INIT_SCREEN_100 sets the GUI status STATUS_100 during the PBO event. In the status, the cancel icon (F12) is active with the function code CANCEL, and the function key F2 is active with the function code SELE.

When you run the program, the user can select any screen element by double-clicking it, or use any screen element connected to the function code SELE. The output fields on the screen return the cursor position.

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

get cursor and set cursor.....

These two commands are used while creating interactive lists , as the name SET CURSOR suggests , it is used to set the cursor on a line or a feild in a line and the command SET CURSOR is used to get the feild name on which the cursor is placed.

Here is a sample code for the same

do 10 times.

write / 'test'.

enddo.

data : v_test(10).

set cursor line 5.

at line-selection.

get cursor VALUE v_test.

break-point.

check the value of v_test to see how get cursor works to understand set cursor , first comment the line set cursor line 5. execute the program , in the output you will not see the cursor , but when you execuete the program after uncommenting the line , you can see the cursor placed on line 5

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

check the program DEMO_LIST_HIDE for hide technique.

DEMO_LIST_GET_CURSOR for get cursor technique.

HIDE: hide statement buffers the record temporarily that is selected by the user in the previous list,which is then compared at the next level for corresponding details to be displayed.

GET CURSOR: stores the value in the variable we declare in our code.

Check this for HIDE.

http://www.sap-img.com/abap/a-sample-hide-get-cursor-in-interactive-programming.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbabf135c111d1829f0000e829fbfe/content.htm

and have look on this also

&----


*& Report SAPMZMMPO

*&

&----


*&

*&

&----


REPORT SAPMZMMPO no standard page heading.

tables: ekko.

DATA: f(40) TYPE c, off TYPE i, lin TYPE i, val(10) TYPE c, len TYPE i.

data: begin of iekko occurs 0,

bukrs like ekko-bukrs,

bsart like ekko-bsart,

ekorg like ekko-ekorg,

ekgrp like ekko-ekgrp,

ebeln like ekko-ebeln,

lifnr like ekko-lifnr,

bedat like ekko-bedat,

end of iekko.

data: begin of iekpo occurs 0,

ebeln like ekko-ebeln,

ebelp like ekpo-ebelp,

matnr like ekpo-matnr,

menge like ekpo-menge,

meins like ekpo-meins,

netpr like ekpo-netpr,

matkl like ekpo-matkl,

werks like ekpo-werks,

lgort like ekpo-lgort,

eeind like rm06e-eeind,

end of iekpo.

data: begin of ilfa1 occurs 0,

lifnr like lfa1-lifnr,

name1 like lfa1-name1,

stras like lfa1-stras,

ort01 like lfa1-ort01,

end of ilfa1.

*parameters: p_ebeln like ekko-ebeln default '4500006130'.

select-options: s_ebeln for ekko-ebeln DEFAULT '4500006130' TO '4500006135'

OPTION bt SIGN i.

*start-of-selection.

start-of-selection.

select bukrs bsart ekorg ekgrp ebeln lifnr bedat

from ekko into corresponding fields of table iekko

where ebeln in s_ebeln.

loop at iekko.

write:/ iekko-ebeln HOTSPOT COLOR 5 INVERSE ON,

iekko-lifnr HOTSPOT COLOR 3 INVERSE ON ,

iekko-bukrs,iekko-bsart,iekko-ekorg,iekko-ekgrp.

hide: iekko-ebeln,iekko-lifnr.

endloop.

  • iekko-lifnr,iekko-ebeln.

at line-selection.

GET CURSOR FIELD f VALUE val .

  • WRITE: / 'Field: ', f,

  • / 'Offset:', off,

  • / 'Line: ', lin,

  • / 'Value: ', (10) val,

  • / 'Length:', len.

case sy-lsind.

when 1.

*if val = iekko-ebeln.

if f = 'IEKKO-EBELN'.

select ebeln ebelp menge meins lgort werks

matnr matkl netpr from ekpo

into corresponding fields of table iekpo

where ebeln = iekko-ebeln.

  • for all entries in iekko where ebeln = iekko-ebeln.

loop at iekpo.

write:/ iekpo-ebelp,iekpo-matnr,iekpo-menge,iekpo-meins,

iekpo-werks,iekpo-lgort,iekpo-matkl,iekpo-netpr.

endloop.

endif.

*if val = iekko-lifnr.

if f = 'IEKKO-LIFNR'.

select lifnr name1 stras ort01 from lfa1

into corresponding fields of table ilfa1

where lifnr = iekko-lifnr.

loop at ilfa1.

write:/ ilfa1-lifnr,ilfa1-name1,ilfa1-stras,ilfa1-ort01.

endloop.

endif.

when others.

leave screen.

endcase.

Former Member
0 Kudos

Hi Sandeep,

Get cursor command is used to transfer the data between the abap memory.

for ex,

YOU ARE IN LIST 0. AND YOU DOUBLE CLICKED ON ONE FIELD.

GET CURSOR FIELD var1 VALUE var2.

If the above command executed the field name & field value of the mouse clicked point will be stored in the var1 & var2.

with the help of this we can do some operatios in the succeding lists.

Former Member
0 Kudos

HI,

After user interaction with the screen, you may need to know the position of the cursor when the action occurred. This is particularly important if the user chooses the Choose function (F2 or mouse double-click).

To find out the cursor position, use the following statement:

GET CURSOR FIELD <f> [OFFSET <off>]

[LINE <lin>]

[VALUE <val>]

[LENGTH <len>].

This statement transfers the name of the screen element on which the cursor is positioned during a user action into the variable <f>. If the cursor is on a field, the system sets SY-SUBRC to 0, otherwise to 4.

The additions to the GET CURSOR statement have the following functions:

OFFSET writes the cursor position within the screen element to the variable <off>.

LINE writes the line number of the table to the variable <lin> if the cursor is positioned in a table control. If the cursor is not in a table control, <lin> is set to zero.

VALUE writes the contents of the screen field in display format, that is, with all of its formatting characters, as a string to the variable <val>.

LENGTH writes the display length of the screen field to the variable <len>.

Regards

Sudheer

Former Member
0 Kudos

get cursor is used to fetch 2 things after output is displayed in a report..

1. variable taht u have clicked on

2. the value of that variable

synatx: GET CURSOR field <d_field> value <d_value>.

u have to declare these 2 variables to get their values

for detailed help write Get cursor in SE38 and press F1

Hope it helps..reward points if it does

hymavathi_oruganti
Active Contributor
0 Kudos

GET CURSOR { {FIELD field [field_properties]}

| {LINE line [line_properties]} }.

we can use this in interactive reports mainly. to get the field value at the cursor position.

Former Member
0 Kudos

thx