Skip to Content
avatar image
Former Member

Problem in Alv Line selesction

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 04, 2008 at 07:53 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 04, 2008 at 08:10 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded