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

Cannot get any values in statement GET CURSOR FIELD...

aris_hidalgo
Contributor
0 Likes
3,839

Hello experts,

I am currently testing my report and I was wondering on why my statement above does

not get any values. After clicking on the hotspot of display, I debugged my at

line-selection event to see if the GET CURSOR FIELD gets any values. Unfortunately it doesn't.

Here is my code:

AT LINE-SELECTION.

DATA: cursor_field(20) TYPE c.

CASE sy-ucomm.

WHEN 'PICK'.

GET CURSOR FIELD cursor_field.

CASE cursor_field.

WHEN '<FS_OUTPUT>-EQUIP_NUM'.

WRITE 'TESTING...'.

ENDCASE.

ENDCASE.

Help would be greatly appreciated. Thanks a lot and take care!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,622

hi viray,

try giving like this...and check...

hi.. Neil is right!!..put it under AT user-command..

<b>AT USER-COMMAND.</b>

CASE sy-ucomm.

WHEN 'PICK'.

DATA: FIELD(20),

VALUE(10).

GET CURSOR FIELD FIELD VALUE VALUE.

IF FIELD = '<FS_OUTPUT>-EQUIP_NUM'.

WRITE 'TESTING...'.

endif.

hope this helps,

do reward if it helps,

priya.

Message was edited by: Priya

Message was edited by: Priya

Hello experts,

I am currently testing my report and I was wondering on why my statement above does

not get any values. After clicking on the hotspot of display, I debugged my at

line-selection event to see if the GET CURSOR FIELD gets any values. Unfortunately it doesn't.

Here is my code:

AT LINE-SELECTION.

DATA: cursor_field(20) TYPE c.

CASE sy-ucomm.

WHEN 'PICK'.

GET CURSOR FIELD cursor_field.

CASE cursor_field.

WHEN '<FS_OUTPUT>-EQUIP_NUM'.

WRITE 'TESTING...'.

ENDCASE.

ENDCASE.

Help would be greatly appreciated. Thanks a lot and take care!

22 REPLIES 22
Read only

Simha_
Product and Topic Expert
Product and Topic Expert
0 Likes
2,622

Hi Viray,

Just try this...

DATA: cursor_field(20) TYPE c,

dummy.

WRITE:/ 'Hi im fine'.

AT LINE-SELECTION.

GET CURSOR FIELD dummy VALUE cursor_field.

IF sy-subrc = 0.

WRITE:/ cursor_field.

ENDIF.

Here in this case we will get the value of what we are printing. Not the field.

Ok, if u want to print the field then pass the value of write statement to one variable and then use that one in GET CURSOR FIELD statement...

Cheers,

Simha.

Read only

former_member186741
Active Contributor
0 Likes
2,622

maybe try event user-command instead of line-selection.

AT USER-COMMAND.

Read only

0 Likes
2,622

Hi again guys,

Thank you for your replies. Unfortunately it still does not get any values. Here is my at line-selection event code:

AT LINE-SELECTION.

DATA: cursor_field(20) TYPE c,

dummy.

CASE sy-ucomm.

WHEN 'PICK'.

GET CURSOR FIELD dummy VALUE cursor_field.

ENDCASE.

Read only

Former Member
0 Likes
2,623

hi viray,

try giving like this...and check...

hi.. Neil is right!!..put it under AT user-command..

<b>AT USER-COMMAND.</b>

CASE sy-ucomm.

WHEN 'PICK'.

DATA: FIELD(20),

VALUE(10).

GET CURSOR FIELD FIELD VALUE VALUE.

IF FIELD = '<FS_OUTPUT>-EQUIP_NUM'.

WRITE 'TESTING...'.

endif.

hope this helps,

do reward if it helps,

priya.

Message was edited by: Priya

Message was edited by: Priya

Read only

0 Likes
2,622

Hi Priya,

I tried doing your suggestion but both field and value does not get any values.

Thanks again!

Read only

0 Likes
2,622

what exactly is happening? Is it reaching the 'get cursor' statement in debug? Does sy-ucomm have 'PICK'?

Read only

0 Likes
2,622

Yes, sy-ucomm has a value of 'PICK' and it gets to the statement GET CURSOR FIELD.

Thanks!

Read only

0 Likes
2,622

perhaps you have to do a 'hide' of the field not just a write?

Forget the above, it should work with a write. What sort of data are you 'double-clicking' on? What does the associated write staement look like?

Read only

0 Likes
2,622

hey viray...

i tried doing like this...im able to get it..

SET PF-STATUS 'AAA'.

select * from mara into table itab.

AT USER-COMMAND.

IF SY-UCOMM = 'ENTER'.

DATA: FIELD(20),

VALUE(10).

GET CURSOR FIELD FIELD VALUE VALUE.

IF FIELD = 'ITAB-MATNR'.

WRITE 'TESTING...'.

endif.

endif.

Read only

0 Likes
2,622

Hello again experts,

Below is my loop statement. What I did is to put the contents of the field into a variable and then hide that variable.

  • write results

LOOP AT it_output ASSIGNING <fs_output>.

gv_equipment = <fs_output>-equip_num.

HIDE gv_equipment.

IF sy-tabix = 1.

FORMAT COLOR COL_HEADING.

WRITE: / sy-uline(lv_uline_len),

/ sy-vline,

(17) 'Asset' CENTERED,

(17) 'Parent' CENTERED,

(30) 'Functional Location' CENTERED,

(40) 'Description' CENTERED.

IF p_equip = 'X'.

WRITE: (18) 'Equipment No.' CENTERED.

ENDIF.

WRITE: (15) 'Asset Sub-class' CENTERED,

(40) 'Location' CENTERED,

(15) 'Cost' CENTERED,

(20) 'Acc. Depreciation' CENTERED,

(20) 'Net Book Value' CENTERED,

sy-vline,

sy-uline(lv_uline_len) NO-GAP.

FORMAT COLOR OFF.

ENDIF.

AT END OF asset_dum.

lv_subtot = 1.

ENDAT.

AT END OF funcloc.

lv_total = 1.

lv_gtotal = 1.

ENDAT.

AT LAST.

lv_grand = 1.

ENDAT.

lv_new = <fs_output>-funcloc.

IF NOT lv_old IS INITIAL.

IF lv_new <> lv_old.

CLEAR lv_check_func.

SKIP 2.

FORMAT COLOR COL_HEADING.

WRITE: / sy-uline(lv_uline_len),

/ sy-vline,

(17) 'Asset' CENTERED,

(17) 'Parent' CENTERED,

(30) 'Functional Location' CENTERED,

(40) 'Description' CENTERED.

IF p_equip = 'X'.

WRITE: (18) 'Equipment No.' CENTERED.

ENDIF.

WRITE: (15) 'Asset Sub-class' CENTERED,

(40) 'Location' CENTERED,

(15) 'Cost' CENTERED,

(20) 'Acc. Depreciation' CENTERED,

(20) 'Net Book Value' CENTERED,

sy-vline,

sy-uline(lv_uline_len) NO-GAP.

FORMAT COLOR OFF.

ENDIF.

ENDIF.

lv_old = lv_new.

IF lv_color = 1.

lv_color = 2.

ELSE.

lv_color = 1.

ENDIF.

FORMAT INTENSIFIED OFF COLOR = lv_color.

WRITE: / sy-vline.

FORMAT HOTSPOT ON.

IF <fs_output>-parent IS INITIAL.

WRITE: (17) <fs_output>-asset_subnum CENTERED.

ELSE.

WRITE: (17) <fs_output>-asset_subnum RIGHT-JUSTIFIED.

ENDIF.

FORMAT HOTSPOT OFF.

WRITE: (17) <fs_output>-parent_subnum CENTERED,

(30) <fs_output>-funcloc CENTERED,

(40) <fs_output>-description CENTERED.

IF p_equip = 'X'.

FORMAT HOTSPOT ON.

WRITE: (18) <fs_output>-equip_num CENTERED.

FORMAT HOTSPOT OFF.

ENDIF.

WRITE: (15) <fs_output>-asset_sub CENTERED,

(40) <fs_output>-location CENTERED,

(15) <fs_output>-accq_cost CENTERED,

(20) <fs_output>-acc_dep CENTERED,

(20) <fs_output>-asset_book_val CENTERED,

sy-vline.

ADD: <fs_output>-accq_cost TO sub_accq_cost,

<fs_output>-acc_dep TO sub_acc_dep,

<fs_output>-accq_cost TO tot_accq_cost,

<fs_output>-acc_dep TO tot_acc_dep,

<fs_output>-accq_cost TO gtot_accq_cost,

<fs_output>-acc_dep TO gtot_acc_dep,

<fs_output>-asset_book_val TO subtot,

<fs_output>-asset_book_val TO total,

<fs_output>-asset_book_val TO gtotal,

<fs_output>-accq_cost TO lv_grand_cost,

<fs_output>-acc_dep TO lv_grand_accdep,

<fs_output>-asset_book_val TO lv_grand_net.

  • write subtotal

    • if there is only one record in itab, subtotal would

    • not be displayed

IF lv_total <> 1.

IF lv_subtot = 1 AND lv_flag = 1.

CLEAR lv_subtot.

FORMAT COLOR COL_TOTAL.

WRITE: / sy-vline,

'Sub-total:',

AT lv_cost_len(15) sub_accq_cost CENTERED,

AT lv_dep_len(20) sub_acc_dep CENTERED,

AT lv_net_len(20) subtot CENTERED,

sy-vline.

CLEAR: sub_accq_cost, sub_acc_dep, subtot.

FORMAT COLOR OFF.

ENDIF.

ENDIF.

  • write total for a given parent and child or master data

IF lv_total = 1.

CLEAR lv_total.

FORMAT COLOR COL_TOTAL.

WRITE: / sy-vline,

'Total:',

AT lv_cost_len(15) tot_accq_cost CENTERED,

AT lv_dep_len(20) tot_acc_dep CENTERED,

AT lv_net_len(20) total CENTERED,

sy-vline.

CLEAR: tot_accq_cost, tot_acc_dep, total,

sub_accq_cost, sub_acc_dep, subtot.

FORMAT COLOR OFF.

ENDIF.

  • write total for a given functional location

IF lv_gtotal = 1.

CLEAR lv_gtotal.

FORMAT COLOR COL_TOTAL INTENSIFIED ON.

WRITE: / sy-uline(lv_uline_len),

/ sy-vline,

'Total:', <fs_output>-funcloc,

AT lv_cost_len(15) gtot_accq_cost CENTERED,

AT lv_dep_len(20) gtot_acc_dep CENTERED,

AT lv_net_len(20) gtotal CENTERED,

sy-vline,

sy-uline(lv_uline_len).

CLEAR: gtot_accq_cost, gtot_acc_dep, gtotal,

tot_accq_cost, tot_acc_dep, total,

sub_accq_cost, sub_acc_dep, subtot.

FORMAT COLOR OFF.

ENDIF.

  • Write grand total for all the records

IF lv_check_func <> 1.

IF lv_grand = 1.

CLEAR lv_grand.

SKIP 1.

FORMAT COLOR = 4.

WRITE: / sy-uline(lv_uline_len),

sy-vline,

'Grand Total:',

AT lv_cost_len(15) lv_grand_cost CENTERED,

AT lv_dep_len(20) lv_grand_accdep CENTERED,

AT lv_net_len(20) lv_grand_net CENTERED,

sy-vline,

sy-uline(lv_uline_len).

CLEAR: lv_grand_cost, lv_grand_accdep, lv_grand_net.

FORMAT COLOR OFF.

ENDIF.

ENDIF.

ENDLOOP.

WRITE: / '*Indented assets are child assets'.

Here is my at-line selection event:

AT LINE-SELECTION.

DATA: cursor_field(20) TYPE c,

dummy.

CASE sy-ucomm.

WHEN 'PICK'.

GET CURSOR FIELD dummy VALUE cursor_field.

if dummy = '<FS_OUTPUT>-EQUIP_NUM'.

write 'testing...'.

endif.

ENDCASE.

Read only

0 Likes
2,622

hi,

increase the length od dummy field , u haad declared only of char 1

Read only

0 Likes
2,622

i think here there is no need of CASE sy-ucomm statement also , as u r using AT LINE-SELECTION , u can directly use GET CURSOR STATEMENT

Read only

0 Likes
2,622

Hi,

It still doesn't get any values.Here is my modified code:

AT LINE-SELECTION.

DATA: cursor_field(50) TYPE c,

dummy(50) TYPE c.

GET CURSOR FIELD dummy VALUE cursor_field.

IF sy-subrc = 0.

ENDIF.

Read only

0 Likes
2,622

1. which field are you double-clicking on?

2. what values go into 'dummy' and 'cursor' field after the get cursor?

3. what is the value of sy-subrc after the get cursor?

Read only

0 Likes
2,622

Hi Neil,

1. I am clicking on the field EQUIP_NUM which is part of my itab it_output. Here is the code for it:

FORMAT HOTSPOT ON.

WRITE: (18) <fs_output>-equip_num CENTERED.

FORMAT HOTSPOT OFF.

2. No values go into both dummy and cursor variables...

3. I get a value of 0 in sy-subrc after the GET CURSOR statement...

Read only

0 Likes
2,622

check this program

DEMO_LIST_GET_CURSOR

regards

Prabhu

Read only

0 Likes
2,622

i DON'T KNOW WHY BUT i THINK THE PROBLEM IS BECAUSE YOU ARE USING A FIELD-SYMBOL. i WROTE A SIMPLE PROGRAM AND IT HAD THE SAME PROBLEM.

iN FACT THE HELP VERIFIES MY THEORY:

<b>With field symbols, this depends on whether the variable assigned is local or global. An assignment made using LOOP ASSIGNING does not return a field name for the field symbol since a table work area is always local. </b>

To get round this, you could change your 'loop assigning' to a 'loop into variable' and then write from that variable instead.

Read only

0 Likes
2,622

Hi Neil,

Yup, sorry my mistake. I should have declared my internal table as global and not inside a method...endmethod routine. Now it works fine.Thanks a lot!

Read only

Former Member
0 Likes
2,622

Hi,

after basic list is displayed,

i suppose you are clicking the PICK button directly

that's why GET CURSOR FIELD is not holding any values

before clicking PICK ,with the help of mouse click once on the line you required ,

then click PICK button,

and check the value in debug mode you will surely get the value into get cursor field

<b>get cursor means it holds the value at the cursor(on the current line it is placed) </b>

try now

Regards,

sowjanya

Message was edited by: sowjanya suggula

Read only

Former Member
0 Likes
2,622

Hi i forgot to tell you

the event shud be AT USER COMMAND NOT AT LINE SELECTION

AT USER-COMMAND.

CASE SY-UCOMM.

WHEN 'MAT'.

GET CURSOR FIELD F_MATNR.

  • WINDOW STARTING AT 10 10

  • ENDING AT 90 30.

SY-LSIND = 1.

LOOP AT ITAB2 WHERE MATNR = F_MATNR.

WRITE:/ ITAB2-MATNR,20 ITAB2-WERKS,35 ITAB2-MMSTA.

ENDLOOP.

CLEAR SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

CLEAR SY-UCOMM.

WHEN 'EXIT'.

LEAVE PROGRAM.

CLEAR SY-UCOMM.

ENDCASE.

AND DO REMEMBER TO CLOSE THE THREAD AFTER GIVING POINTS

Read only

Former Member
0 Likes
2,622

Hi,

After checking ur code i found one problem in ur code.

U r using get cursor field for the click event i.e. u r cliking some button and checking for the values. But get cursor field is for the click event on the line because at that time ur cursor may be at button so it will not get any value. So use following code.

SET PF-STATUS 'X'.

.....

AT USER-COMMAND.

IF SY-UCOMM = 'PICK'.

DATA: F(20),

V1(10).

GET CURSOR FIELD F VALUE V1.

IF ....

...

endif.

Hope this will help.

-Umesh

Read only

Former Member
0 Likes
2,622

Hi,

Try THIS...

DATA: FNAM TYPE STRING,
      FVAL TYPE STRING.
   .
   .
   .
LOOP AT ITAB.
WRITE:/ ITAB-F1, ITAB-F2.
ENDLOOP.
   .
   .
AT LINE-SELECTION.
GET CURSOR FIELD FNAM VALUE FVAL.

IF FNAM EQ 'ITAB-F1' AND SY-LSIND = 1.
LOOP AT ITAB WHERE F1 EQ FVAL.
WRITE:/ ITAB-F3.
ENDLOOP.

ELSEIF FNAM EQ 'ITAB-F2' AND SY-LSIND = 1.
LOOP AT ITAB WHERE F2 EQ FVAL.
WRITE:/ ITAB-F4.
ENDLOOP.

ENDIF.

Regards:-

<b>Santosh</b>