<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Get cursor position from grid in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-cursor-position-from-grid/m-p/3685263#M887433</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there. Could You give me a tip?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a GRID and BUTTON on the SCREEN.&lt;/P&gt;&lt;P&gt;I set cursor on some line/cell inside GRID then press a BUTTON.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I need to get details from GRID line which was matched before pressing BUTTON. How can I do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings. P.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Apr 2008 12:27:32 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-08T12:27:32Z</dc:date>
    <item>
      <title>Get cursor position from grid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-cursor-position-from-grid/m-p/3685263#M887433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there. Could You give me a tip?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a GRID and BUTTON on the SCREEN.&lt;/P&gt;&lt;P&gt;I set cursor on some line/cell inside GRID then press a BUTTON.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I need to get details from GRID line which was matched before pressing BUTTON. How can I do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings. P.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2008 12:27:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-cursor-position-from-grid/m-p/3685263#M887433</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-08T12:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: Get cursor position from grid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-cursor-position-from-grid/m-p/3685264#M887434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here i have example in which i have first column as push button... and o/p is in grid..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when u select any row by pressing push button and press on button, u will get detail info related to selected rows in next screen...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES:     ekko.

TYPE-POOLS: slis.                                 "ALV Declarations
*Data Declaration
*----------------
TYPES: BEGIN OF t_ekko,
  sel,                         "stores which row user has selected
  ebeln TYPE ekpo-ebeln,
  ebelp TYPE ekpo-ebelp,
  statu TYPE ekpo-statu,
  aedat TYPE ekpo-aedat,
  matnr TYPE ekpo-matnr,
  menge TYPE ekpo-menge,
  meins TYPE ekpo-meins,
  netpr TYPE ekpo-netpr,
  peinh TYPE ekpo-peinh,
 END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
      wa_ekko TYPE t_ekko.

*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
      fieldcatalog1 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
      gd_tab_group TYPE slis_t_sp_group_alv,
      gd_layout    TYPE slis_layout_alv,
      gd_repid     LIKE sy-repid.

DATA : BEGIN OF det_tab OCCURS 0,
        ebeln LIKE ekpo-ebeln,
       END OF det_tab.

************************************************************************
*Start-of-selection.
START-OF-SELECTION.

  PERFORM data_retrieval.
  PERFORM build_fieldcatalog.
  PERFORM build_layout.
  PERFORM display_alv_report.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  BUILD_FIELDCATALOG
*&amp;amp;---------------------------------------------------------------------*
*       Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
FORM build_fieldcatalog.

  fieldcatalog-fieldname   = 'EBELN'.
  fieldcatalog-seltext_m   = 'Purchase Order'.
  fieldcatalog-outputlen   = 10.
  fieldcatalog-emphasize   = 'X'.
  fieldcatalog-key         = 'X'.
*  fieldcatalog-do_sum      = 'X'.
*  fieldcatalog-no_zero     = 'X'.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'EBELP'.
  fieldcatalog-seltext_m   = 'PO Item'.
*  fieldcatalog-col_pos     = 1.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'STATU'.
  fieldcatalog-seltext_m   = 'Status'.
*  fieldcatalog-col_pos     = 2.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'AEDAT'.
  fieldcatalog-seltext_m   = 'Item change date'.
*  fieldcatalog-col_pos     = 3.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'MATNR'.
  fieldcatalog-seltext_m   = 'Material Number'.
*  fieldcatalog-col_pos     = 4.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'MENGE'.
  fieldcatalog-seltext_m   = 'PO quantity'.
*  fieldcatalog-col_pos     = 5.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'MEINS'.
  fieldcatalog-seltext_m   = 'Order Unit'.
*  fieldcatalog-col_pos     = 6.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'NETPR'.
  fieldcatalog-seltext_m   = 'Net Price'.
*  fieldcatalog-col_pos     = 7.
  fieldcatalog-outputlen   = 15.
  fieldcatalog-do_sum      = 'X'.        "Display column total
  fieldcatalog-datatype     = 'CURR'.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'PEINH'.
  fieldcatalog-seltext_m   = 'Price Unit'.
*  fieldcatalog-col_pos     = 8.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
ENDFORM.                    " BUILD_FIELDCATALOG

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  BUILD_LAYOUT
*&amp;amp;---------------------------------------------------------------------*
*       Build layout for ALV grid report
*----------------------------------------------------------------------*
FORM build_layout.
  gd_layout-box_fieldname     = 'SEL'.
  "set field name to store row selection
*  gd_layout-edit              = 'X'. "makes whole ALV table editable
  gd_layout-zebra             = 'X'.
ENDFORM.                    " BUILD_LAYOUT

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  DISPLAY_ALV_REPORT
*&amp;amp;---------------------------------------------------------------------*
*       Display report using ALV grid
*----------------------------------------------------------------------*
FORM display_alv_report.
  gd_repid = sy-repid.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = gd_repid
      i_callback_user_command  = 'USER_COMMAND'
      i_callback_pf_status_set = 'SET_STAT'
      is_layout                = gd_layout
      it_fieldcat              = fieldcatalog[]
      i_save                   = 'X'
    TABLES
      t_outtab                 = it_ekko
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.
  IF sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    " DISPLAY_ALV_REPORT

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  DATA_RETRIEVAL
*&amp;amp;---------------------------------------------------------------------*
*       Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
FORM data_retrieval.

  SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
   UP TO 10 ROWS
    FROM ekpo
    INTO CORRESPONDING FIELDS OF TABLE it_ekko.
ENDFORM.                    " DATA_RETRIEVAL

*------------------------------------------------------------------*
*       FORM USER_COMMAND                                          *
*------------------------------------------------------------------*
*       --&amp;gt; R_UCOMM                                                *
*       --&amp;gt; RS_SELFIELD                                            *
*------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
                  rs_selfield TYPE slis_selfield.

  CASE r_ucomm.
    WHEN '&amp;amp;IC1'.
      IF rs_selfield-fieldname = 'EBELN'.
        READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
        SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
        CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
      ENDIF.

    WHEN 'DET'.  "user presses SAVE
      CLEAR det_tab.
      REFRESH det_tab.
      LOOP AT it_ekko INTO wa_ekko WHERE sel = 'X'.

        MOVE-CORRESPONDING wa_ekko TO det_tab.
        APPEND det_tab.
      ENDLOOP.
      PERFORM build_cat.
      PERFORM dis_data.

  ENDCASE.
ENDFORM.                    "user_command

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  set_stat
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;RT_EXTAB   text
*----------------------------------------------------------------------*
FORM set_stat USING rt_extab TYPE slis_t_extab.

  SET PF-STATUS 'ZSTAT' EXCLUDING rt_extab.
ENDFORM.                    "set_stat

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  build_cat
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM build_cat.
  CLEAR fieldcatalog1.
  REFRESH fieldcatalog1.
  fieldcatalog1-fieldname = 'EBELN'.
  fieldcatalog1-tabname = 'DET_TAB'.
  fieldcatalog1-seltext_m = 'Order No.'.
  fieldcatalog1-outputlen = 10.
  APPEND fieldcatalog1 TO fieldcatalog1.
  CLEAR fieldcatalog1.

ENDFORM.                    "build_cat

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  dis_data
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM dis_data.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = 'ZTEST_DS'
      it_fieldcat        = fieldcatalog1[]
      i_save             = 'X'
    TABLES
      t_outtab           = det_tab.

ENDFORM.                    "dis_data
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here i have created my own status ZSTAT and have ctreated one button &lt;STRONG&gt;DET&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;&lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Apr 8, 2008 6:17 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2008 12:34:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-cursor-position-from-grid/m-p/3685264#M887434</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-08T12:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Get cursor position from grid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-cursor-position-from-grid/m-p/3685265#M887435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to get the data:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to the grid function module:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'&lt;/P&gt;&lt;P&gt; EXPORTING&lt;/P&gt;&lt;P&gt;   I_CALLBACK_PROGRAM                = SY-REPID&lt;/P&gt;&lt;P&gt;   I_CALLBACK_PF_STATUS_SET          = 'SET_PF'&lt;/P&gt;&lt;P&gt;   &lt;STRONG&gt;I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pass the user command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now write form....endform to that user command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM USER_COMMAND USING U_COMM TYPE SY-UCOMM R_SELFIELD TYPE SLIS_SELFIELD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case u_comm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;when we select 'purreq' button&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;when 'PURREQ'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here write the code, what action to b exected after clicking on the button.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if u want to get the value of a field on which u click, it will b stored in "R_SELFIELD-VALUE"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps u. any doubts plz post them back.&lt;/P&gt;&lt;P&gt;reward if helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2008 04:41:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-cursor-position-from-grid/m-p/3685265#M887435</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-09T04:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Get cursor position from grid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-cursor-position-from-grid/m-p/3685266#M887436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just needed &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CALL METHOD my_grid-&amp;gt;get_current_cell
  IMPORTING es_row_no = L_roid .
LC_row = L_roid-row_id .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    CALL METHOD my_grid-&amp;gt;get_current_cell
      IMPORTING e_row = vylrow .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or sth similar ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2008 09:16:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-cursor-position-from-grid/m-p/3685266#M887436</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-10T09:16:03Z</dc:date>
    </item>
  </channel>
</rss>

