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: 

Problem in Alv Line selesction

Former Member
0 Kudos

hi all am using this code

&----


*& Form USER_COMMAND

&----


  • USERCOMMANDS FOR THE ALV PROGRAM.

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

DATA : l_purchase TYPE banfn.

CASE r_ucomm.

WHEN 'DCPR'.

IF rs_selfield-fieldname = 'BANFN'.

l_purchase = rs_selfield-value.

SET PARAMETER ID 'BAN' FIELD l_purchase.

CALL TRANSACTION 'ME53N'.

ENDIF.

ENDCASE.

CLEAR r_ucomm.

ENDFORM.

But here only if user is clicking on the Banfn Field then only i will get the value for the field BANFN but my requirement is irrespective of user clicks anywhere in the ALV Grid output, i need to capture the value for the Field BANFN .IS there any way to capture the value of a particular field if that line is selected the same way like we do in simple interactive reports .? i need help in this

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

U shoudl extract the record of the output table of the selected line:

FORM user_command USING r_ucomm LIKE sy-ucomm
      rs_selfield TYPE slis_selfield.
  
DATA :  l_purchase TYPE banfn,
               wa  LIKE <your output table>.

  READ TABLE <your output table> into wa INDEX rs_selfield-tabindex.
  IF SY-SUBRC <> 0. EXIT. ENDIF.
  CASE r_ucomm.
     WHEN 'DCPR'.
        l_purchase = wa-BANFN.
       SET PARAMETER ID 'BAN' FIELD l_purchase.
       CALL TRANSACTION 'ME53N' AND SKIP FIRST SCRENN.
     WHEN OTHERS.
  ENDCASE.
ENDFORM.

Max

3 REPLIES 3

Former Member
0 Kudos

Hi

U shoudl extract the record of the output table of the selected line:

FORM user_command USING r_ucomm LIKE sy-ucomm
      rs_selfield TYPE slis_selfield.
  
DATA :  l_purchase TYPE banfn,
               wa  LIKE <your output table>.

  READ TABLE <your output table> into wa INDEX rs_selfield-tabindex.
  IF SY-SUBRC <> 0. EXIT. ENDIF.
  CASE r_ucomm.
     WHEN 'DCPR'.
        l_purchase = wa-BANFN.
       SET PARAMETER ID 'BAN' FIELD l_purchase.
       CALL TRANSACTION 'ME53N' AND SKIP FIRST SCRENN.
     WHEN OTHERS.
  ENDCASE.
ENDFORM.

Max

0 Kudos

Hi Max Thaknks it Solved the problem

i have also provided you points for giving back quick response to my question.

Former Member
0 Kudos

Check the value of rs_selfield-TABINDEX

it returns the rown number on which click event took place.

use read table index rs_selfield-TABINDEX to obtain the value.