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

problem with at line-selection

Former Member
0 Likes
419

hi mates

i have written a interactive report program, when i click the hotspot in the basic list the event at line-selection is not getting triggered insead my at user-command is geting executed. is there a sequence that i need to follow?. below is my code. thanks in advance.

tables: vbak.

selection-screen begin of block b1 with frame title t1.

select-options: salesdoc for vbak-vbeln.

selection-screen end of block b1.

types: begin of vbak_ty,

vbeln type vbak-vbeln,

erdat type vbak-erdat,

ernam type vbak-ernam,

end of vbak_ty.

types: begin of vbap_type,

vbeln type vbap-vbeln,

posnr type vbap-posnr,

matnr type vbap-matnr,

charg type vbap-charg,

end of vbap_type.

types: begin of vbap_ty,

posnr type vbap-posnr,

matwa type vbap-matwa,

arktx type vbap-arktx,

end of vbap_ty.

data: vbap_wa type vbap_type,

vbap_it type table of vbap_type,

vbak_wa type vbak_ty,

vbak_it type table of vbak_ty,

vbap_wa1 type vbap_ty,

vbap_it1 type table of vbap_type,

fname(20),fvalue(10).

initialization.

t1 = 'enter sales doc header'.

start-of-selection.

set pf-status 'VA01'.

SELECT vbeln

erdat

ernam

from vbak into table vbak_it

where vbeln in salesdoc.

if sy-subrc = 0.

loop at vbak_it into vbak_wa.

write: /25 vbak_wa-vbeln hotspot,

50 vbak_wa-erdat,

75 vbak_wa-ernam.

hide vbak_wa-vbeln.

clear vbak_wa-vbeln.

endloop.

ELSE.

message e000(01) with 'no records found '.

endif.

at line-selection.

case sy-lsind.

when '1'.

perform headerdata.

when '2'.

perform itemdata.

endcase.

at user-command.

case sy-ucomm.

when 'ITEMDATA'.

  • get cursor field fname value fvalue.

  • if fvalue = 'vbap_wa-vbeln'.

perform itemdata.

  • else.

  • message e000(03) with 'click only on hotspots'.

  • endif.

when 'SALEOR'.

  • get cursor field fname value fvalue.

  • if fvalue = 'vbak_wa-vbeln'.

set parameter id 'AUN' field fvalue.

call transaction 'VA01' and skip first screen.

  • else.

  • message e000(04) with 'click only on hotspots'.

  • endif.

endcase.

form headerdata.

set pf-status 'HEADER'.

select vbeln

posnr

matnr

charg

from vbap into table vbap_it

where vbeln = vbak_wa-vbeln.

if sy-subrc = 0.

loop at vbap_it into vbap_wa.

write: /25 vbap_wa-vbeln hotspot,

50 vbap_wa-posnr,

75 vbap_wa-matnr,

90 vbap_wa-charg.

hide vbap_wa-vbeln.

clear vbap_wa-vbeln.

endloop.

else.

message e000(02) with ' no data found'.

endif.

endform.

form itemdata.

select vbeln

posnr

matwa

arktx

from vbap into table vbap_it1

where vbeln = vbap_wa-vbeln.

if sy-subrc = 0.

loop at vbap_it1 into vbap_wa1.

write: /25 vbap_wa1-posnr,

75 vbap_wa1-matwa,

90 vbap_wa1-arktx.

endloop.

else.

message e000(02) with ' no data found'.

endif.

endform.

REGARDS

MANO

2 REPLIES 2
Read only

Former Member
0 Likes
389

I'd suggest you remove the "at line-selection" and put the dependant code into the case statement inside the user-command, based on the function code you have assigned to selection (PICK?)... I'd also suggest you put the whole lot in a form too, but that's just the way I like to organise things perhaps...


*" Events
at user-command.
  perform user_command.

form user_command.
*" Handle any user interactions
  case sy-ucomm.
    when 'PICK'.
      case sy-lsind.
        when '1'.
          perform headerdata.
        when '2'.
          perform itemdata.
      endcase.
*"etc etc
  endcase.
endform.

Jonathan

Read only

Former Member
0 Likes
389

AT LINE-SELECTION.

Effect

This statement defines an event block whose event is triggered by the ABAP runtime environment during the display of a screen list - provided the scren cursor is on a list line and you select a function using the function code PICK. Through the definition of this event block, the standard list status is automatically enhanced in such a way that the function code F2 and, with it, the double-click mouse function is linked up to the function code PICK.

Note

If the function key F2 is linked with a function code different than PICK, each double click will trigger its even, usually AT USER-COMMAND, and not AT LINE-SELECTION.

Example

This program works with the standard list status. A line selection with the left mouse key causes the event AT LINE-SELECTION and creates details lists.


REPORT demo_at_line_selection. 

START-OF-SELECTION. 
  WRITE 'Click me!' COLOR = 5 HOTSPOT. 

AT LINE-SELECTION. 
  WRITE: / 'You clicked list', sy-listi, 
         / 'You are on list',  sy-lsind. 
  IF sy-lsind < 20. 
    SKIP. 
    WRITE: 'More ...' COLOR = 5 HOTSPOT. 
  ENDIF. 

The above sample program works with the standard list status Since your program has the PF-status set, i think AT LINE-SELECTION will not work. So do use AT USER-COMMAND to capture the "PICK" event.

Hope this helps.

Thanks

Balaji