<?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 Re: USER_COMMAND in alv in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951364#M391867</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;refer code below,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report  z_purchase_req_alv no standard page heading message-id zabc_assg3.

include &amp;lt;icon&amp;gt;.
type-pools: slis.

tables : eban .

type-pools: slis .

types : begin of ty_pr                           ,
          icon(9)  type c                        ,
          banfn    like eban-banfn               ,   " Purachase Requisition Number
          txz01    like eban-txz01               ,   " Short Text
          ernam    like eban-ernam               ,   " CREATED BY
       end of ty_pr.

data : it_pr type standard table of  ty_pr,
       wa_it_pr like line of it_pr.



select-options s_pr for eban-banfn  no-extension obligatory .

data: l_report_id  like sy-repid                                       ,
      l_ws_title   type lvc_title value 'PURCHASE REQUISITION DETAILS' ,
      l_i_layout   type slis_layout_alv                                ,
      l_i_fieldcat type slis_t_fieldcat_alv                            ,
      l_it_events  type slis_t_event with header line                  ,
      l_it_header  type slis_t_listheader with header line             ,
      p_banfn      like eban-banfn                                     ,
      g_formname   type tdsfname value 'ZFM0001'                       ,
      g_fm_name    type rs38l_fnam                                     .


start-of-selection.

  l_report_id = sy-repid.

  perform sub_fetch_data   .   "  s_pr

  perform f1000_layout_init changing l_i_layout.

  perform f2000_fieldcat_init changing l_i_fieldcat.

  perform sub_events.

  call function 'REUSE_ALV_GRID_DISPLAY'
   exporting
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                =
*   I_BUFFER_ACTIVE                   = ' '
      i_callback_program                = l_report_id
      i_callback_pf_status_set          = 'STATUS1'
      i_callback_user_command           = 'USER_CMD'               "&amp;lt;-User command
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   i_structure_name                  = ' '
*   I_BACKGROUND_ID                   = ' '
*   i_grid_title                      = ' '
*   I_GRID_SETTINGS                   =
**     is_layout                          = l_i_layout
     it_fieldcat                        = l_i_fieldcat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
     i_save                            = 'A'
*   IS_VARIANT                        =
     it_events                         = l_it_events[]
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_ADD_FIELDCAT                   =
*   IT_HYPERLINK                      =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    tables
      t_outtab                          = it_pr
   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.

form status1 using rt_extab type slis_t_extab.

  set pf-status 'SCREEN_SMRT_FRM' excluding rt_extab .

endform.                              "STATUS

form user_cmd using cmd  like sy-ucomm
                    self type slis_selfield.

  case cmd.
    when 'PRINT' .
*      PERFORM CALL_SMARTFORM .
      message i022 .
      clear cmd .
    when '&amp;amp;IC1' .
      read table it_pr into wa_it_pr index self-tabindex.
      if sy-subrc = 0.
        p_banfn = wa_it_pr-banfn .
        message i023 with p_banfn.
      endif.
    when 'EXIT'.
        leave to transaction 'z_man'.
    when 'CANCLE'.
        submit z_purchase_req_alv.

*      CLEAR cmd .
    when others .
      clear cmd .
  endcase.
endform.                    "USER_CMD


form sub_fetch_data      .   " s_pr

  clear wa_it_pr .

  select  banfn txz01 ernam
     into corresponding fields of wa_it_pr
  from eban
     where banfn in s_pr .

  wa_it_pr-icon = icon_paw_pu.

  append wa_it_pr to it_pr  .

  endselect.

  clear wa_it_pr .

  sort it_pr by banfn.

  delete adjacent duplicates from it_pr comparing banfn.

endform.                    " sub_fetch_data


form sub_events.
  call function 'REUSE_ALV_EVENTS_GET'
    exporting
      i_list_type     = 0
    importing
      et_events       = l_it_events[]
    exceptions
      list_type_wrong = 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.
  read table l_it_events with key name = 'TOP_OF_PAGE'.
  if sy-subrc = 0.
    l_it_events-form = 'HANDLE_TOP_OF_PAGE'.
    collect l_it_events.
  endif.

  l_it_header-typ  = 'H'.      " H = Header, S = Selection, A = Action
  l_it_header-info = 'LeNatures.'. " 60
  append l_it_header.
  clear  l_it_header.

endform.                    " sub_events



form f1000_layout_init using l_i_layout type slis_layout_alv.

  clear l_i_layout.
  l_i_layout-colwidth_optimize = 'X'.
  l_i_layout-edit = 'X'.

endform.                    " F1000_Layout_Init



form f2000_fieldcat_init changing l_i_fieldcat type slis_t_fieldcat_alv.

  data: l_line_fieldcat type slis_fieldcat_alv.

  clear l_line_fieldcat.
  l_line_fieldcat-fieldname    = 'ICON'.
  l_line_fieldcat-tabname      = 'IT_PR'.
  l_line_fieldcat-ddictxt      = 'M'.
  l_line_fieldcat-reptext_ddic = ' '.
  l_line_fieldcat-icon         = 'X'.
  l_line_fieldcat-hotspot      = 'X'.
  l_line_fieldcat-outputlen    =  2.
  append l_line_fieldcat to l_i_fieldcat.

  clear l_line_fieldcat.
  l_line_fieldcat-fieldname = 'BANFN'.
  l_line_fieldcat-tabname   = 'IT_PR'.
  l_line_fieldcat-seltext_m = 'PURCHASE REQUISITION NUMBER'.
  append l_line_fieldcat to l_i_fieldcat.

  clear l_line_fieldcat.
  l_line_fieldcat-fieldname = 'TXZ01'.
  l_line_fieldcat-tabname = 'IT_PR'.
  l_line_fieldcat-seltext_m = 'DESCRIPTION'.
  append l_line_fieldcat to l_i_fieldcat.

  clear l_line_fieldcat.
  l_line_fieldcat-fieldname = 'ERNAM'.
  l_line_fieldcat-tabname   = 'IT_PR'.
  l_line_fieldcat-seltext_m = 'CREATED BY'.
  append l_line_fieldcat to l_i_fieldcat.

endform.                    " f2000_fieldcat_init


form handle_top_of_page.

  call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
      i_logo             = ''
      it_list_commentary = l_it_header[].

endform.                    "handle_top_of_page


form call_smartform .

  call function 'SSF_FUNCTION_MODULE_NAME'
    exporting
      formname                 = g_formname
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
    importing
      fm_name                  = g_fm_name
   exceptions
     no_form                  = 1
     no_function_module       = 2
     others                   = 3
            .
  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.

  call function g_fm_name
    exporting
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
*   CONTROL_PARAMETERS         =
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
      i_eban                     = p_banfn
* IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
*   JOB_OUTPUT_INFO            =
*   JOB_OUTPUT_OPTIONS         =

   exceptions
     formatting_error           = 1
     internal_error             = 2
     send_error                 = 3
     user_canceled              = 4
     others                     = 5
            .
  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.                    " CALL_SMARTFORM

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if useful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Feb 2007 07:34:47 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-28T07:34:47Z</dc:date>
    <item>
      <title>USER_COMMAND in alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951360#M391863</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;I want to know how to use USER_COMMAND in alv grid. I want when I click on any field of alv grid columns , it  open different screen as a alv grid format.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Feb 2007 07:10:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951360#M391863</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-28T07:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: USER_COMMAND in alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951361#M391864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi rakesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. In alv we cannot use AT LINE Selection&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. For alv, there is a special syntax, so that when we double-click on alv,&lt;/P&gt;&lt;P&gt;   our FORM / routine is called and there we display another alv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. just copy paste to get a taste of interactive alv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT abc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPE-POOLS : slis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="---------" /&gt;&lt;P&gt; Data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : ITAB LIKE T001 OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA : alvfc TYPE slis_t_fieldcat_alv.&lt;/P&gt;&lt;P&gt;DATA : STAB LIKE T001 OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt; Select Data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM t001 INTO TABLE itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*------- Field Catalogue&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'&lt;/P&gt;&lt;P&gt;  EXPORTING&lt;/P&gt;&lt;P&gt;    i_program_name         = sy-repid&lt;/P&gt;&lt;P&gt;    i_internal_tabname     = 'ITAB'&lt;/P&gt;&lt;P&gt;    i_inclname             = sy-repid&lt;/P&gt;&lt;P&gt;  CHANGING&lt;/P&gt;&lt;P&gt;    ct_fieldcat            = alvfc&lt;/P&gt;&lt;P&gt;  EXCEPTIONS&lt;/P&gt;&lt;P&gt;    inconsistent_interface = 1&lt;/P&gt;&lt;P&gt;    program_error          = 2&lt;/P&gt;&lt;P&gt;    OTHERS                 = 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="----------" /&gt;&lt;P&gt;Display&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;    it_fieldcat             = alvfc&lt;/P&gt;&lt;P&gt;    i_callback_program      = sy-repid "&amp;lt;-------Important&lt;/P&gt;&lt;P&gt;    i_callback_user_command = 'ITAB_USER_COMMAND' "&amp;lt;------ Important&lt;/P&gt;&lt;P&gt;  TABLES&lt;/P&gt;&lt;P&gt;    t_outtab                = itab&lt;/P&gt;&lt;P&gt;  EXCEPTIONS&lt;/P&gt;&lt;P&gt;    program_error           = 1&lt;/P&gt;&lt;P&gt;    OTHERS                  = 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="--------------------------------------------" /&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;CALL BACK FORM&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="--------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE&lt;/P&gt;&lt;P&gt;slis_selfield.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt; IMPORTANT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  READ TABLE ITAB INDEX WHATROW-TABINDEX.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;  CLEAR STAB.&lt;/P&gt;&lt;P&gt;  SELECT * FROM T001&lt;/P&gt;&lt;P&gt;  INTO TABLE STAB&lt;/P&gt;&lt;P&gt;  WHERE BUKRS = ITAB-BUKRS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLEAR ALVFC.&lt;/P&gt;&lt;P&gt;*------- Field Catalogue&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      i_program_name         = sy-repid&lt;/P&gt;&lt;P&gt;      i_internal_tabname     = 'STAB'&lt;/P&gt;&lt;P&gt;      i_inclname             = sy-repid&lt;/P&gt;&lt;P&gt;    CHANGING&lt;/P&gt;&lt;P&gt;      ct_fieldcat            = alvfc&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      inconsistent_interface = 1&lt;/P&gt;&lt;P&gt;      program_error          = 2&lt;/P&gt;&lt;P&gt;      OTHERS                 = 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="----------" /&gt;&lt;P&gt;Display&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;      it_fieldcat        = alvfc&lt;/P&gt;&lt;P&gt;      i_callback_program = sy-repid "&amp;lt;-------Important&lt;/P&gt;&lt;P&gt;    TABLES&lt;/P&gt;&lt;P&gt;      t_outtab           = Stab&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      program_error      = 1&lt;/P&gt;&lt;P&gt;      OTHERS             = 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM. "ITAB_user_command&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;amit m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Feb 2007 07:11:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951361#M391864</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-28T07:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: USER_COMMAND in alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951362#M391865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Refer this&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_ucomm.htm" target="test_blank"&gt;http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_ucomm.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdevelopment.co.uk/reporting/alv/alvgrid.htm" target="test_blank"&gt;http://www.sapdevelopment.co.uk/reporting/alv/alvgrid.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Reward if this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Feb 2007 07:14:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951362#M391865</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-28T07:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: USER_COMMAND in alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951363#M391866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rakesh,&lt;/P&gt;&lt;P&gt;                 Follow the code.&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      = v_repid&lt;/P&gt;&lt;P&gt;      i_callback_user_command = 'USER_COMMAND1'    &amp;lt;-------&lt;/P&gt;&lt;P&gt;      is_layout               = wa_layout&lt;/P&gt;&lt;P&gt;      it_fieldcat             = i_fcat&lt;/P&gt;&lt;P&gt;      i_default               = c_chk&lt;/P&gt;&lt;P&gt;      i_save                  = c_save&lt;/P&gt;&lt;P&gt;      is_variant              = wa_variant&lt;/P&gt;&lt;P&gt;      it_events               = i_events&lt;/P&gt;&lt;P&gt;      is_print                = wa_print&lt;/P&gt;&lt;P&gt;    TABLES&lt;/P&gt;&lt;P&gt;      t_outtab                = i_table&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      program_error           = 1&lt;/P&gt;&lt;P&gt;      OTHERS                  = 2.&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    LEAVE LIST-PROCESSING.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Form user_command1 using rs_selfield type slis_selfield&lt;/P&gt;&lt;P&gt;                                 u_comm like sy-ucomm.&lt;/P&gt;&lt;P&gt;case '%IC1'.&lt;/P&gt;&lt;P&gt;            When '...'.&lt;/P&gt;&lt;P&gt;                 ............&lt;/P&gt;&lt;P&gt;                 ..............&lt;/P&gt;&lt;P&gt;endcase.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Feb 2007 07:20:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951363#M391866</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-28T07:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: USER_COMMAND in alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951364#M391867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;refer code below,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report  z_purchase_req_alv no standard page heading message-id zabc_assg3.

include &amp;lt;icon&amp;gt;.
type-pools: slis.

tables : eban .

type-pools: slis .

types : begin of ty_pr                           ,
          icon(9)  type c                        ,
          banfn    like eban-banfn               ,   " Purachase Requisition Number
          txz01    like eban-txz01               ,   " Short Text
          ernam    like eban-ernam               ,   " CREATED BY
       end of ty_pr.

data : it_pr type standard table of  ty_pr,
       wa_it_pr like line of it_pr.



select-options s_pr for eban-banfn  no-extension obligatory .

data: l_report_id  like sy-repid                                       ,
      l_ws_title   type lvc_title value 'PURCHASE REQUISITION DETAILS' ,
      l_i_layout   type slis_layout_alv                                ,
      l_i_fieldcat type slis_t_fieldcat_alv                            ,
      l_it_events  type slis_t_event with header line                  ,
      l_it_header  type slis_t_listheader with header line             ,
      p_banfn      like eban-banfn                                     ,
      g_formname   type tdsfname value 'ZFM0001'                       ,
      g_fm_name    type rs38l_fnam                                     .


start-of-selection.

  l_report_id = sy-repid.

  perform sub_fetch_data   .   "  s_pr

  perform f1000_layout_init changing l_i_layout.

  perform f2000_fieldcat_init changing l_i_fieldcat.

  perform sub_events.

  call function 'REUSE_ALV_GRID_DISPLAY'
   exporting
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                =
*   I_BUFFER_ACTIVE                   = ' '
      i_callback_program                = l_report_id
      i_callback_pf_status_set          = 'STATUS1'
      i_callback_user_command           = 'USER_CMD'               "&amp;lt;-User command
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   i_structure_name                  = ' '
*   I_BACKGROUND_ID                   = ' '
*   i_grid_title                      = ' '
*   I_GRID_SETTINGS                   =
**     is_layout                          = l_i_layout
     it_fieldcat                        = l_i_fieldcat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
     i_save                            = 'A'
*   IS_VARIANT                        =
     it_events                         = l_it_events[]
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_ADD_FIELDCAT                   =
*   IT_HYPERLINK                      =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    tables
      t_outtab                          = it_pr
   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.

form status1 using rt_extab type slis_t_extab.

  set pf-status 'SCREEN_SMRT_FRM' excluding rt_extab .

endform.                              "STATUS

form user_cmd using cmd  like sy-ucomm
                    self type slis_selfield.

  case cmd.
    when 'PRINT' .
*      PERFORM CALL_SMARTFORM .
      message i022 .
      clear cmd .
    when '&amp;amp;IC1' .
      read table it_pr into wa_it_pr index self-tabindex.
      if sy-subrc = 0.
        p_banfn = wa_it_pr-banfn .
        message i023 with p_banfn.
      endif.
    when 'EXIT'.
        leave to transaction 'z_man'.
    when 'CANCLE'.
        submit z_purchase_req_alv.

*      CLEAR cmd .
    when others .
      clear cmd .
  endcase.
endform.                    "USER_CMD


form sub_fetch_data      .   " s_pr

  clear wa_it_pr .

  select  banfn txz01 ernam
     into corresponding fields of wa_it_pr
  from eban
     where banfn in s_pr .

  wa_it_pr-icon = icon_paw_pu.

  append wa_it_pr to it_pr  .

  endselect.

  clear wa_it_pr .

  sort it_pr by banfn.

  delete adjacent duplicates from it_pr comparing banfn.

endform.                    " sub_fetch_data


form sub_events.
  call function 'REUSE_ALV_EVENTS_GET'
    exporting
      i_list_type     = 0
    importing
      et_events       = l_it_events[]
    exceptions
      list_type_wrong = 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.
  read table l_it_events with key name = 'TOP_OF_PAGE'.
  if sy-subrc = 0.
    l_it_events-form = 'HANDLE_TOP_OF_PAGE'.
    collect l_it_events.
  endif.

  l_it_header-typ  = 'H'.      " H = Header, S = Selection, A = Action
  l_it_header-info = 'LeNatures.'. " 60
  append l_it_header.
  clear  l_it_header.

endform.                    " sub_events



form f1000_layout_init using l_i_layout type slis_layout_alv.

  clear l_i_layout.
  l_i_layout-colwidth_optimize = 'X'.
  l_i_layout-edit = 'X'.

endform.                    " F1000_Layout_Init



form f2000_fieldcat_init changing l_i_fieldcat type slis_t_fieldcat_alv.

  data: l_line_fieldcat type slis_fieldcat_alv.

  clear l_line_fieldcat.
  l_line_fieldcat-fieldname    = 'ICON'.
  l_line_fieldcat-tabname      = 'IT_PR'.
  l_line_fieldcat-ddictxt      = 'M'.
  l_line_fieldcat-reptext_ddic = ' '.
  l_line_fieldcat-icon         = 'X'.
  l_line_fieldcat-hotspot      = 'X'.
  l_line_fieldcat-outputlen    =  2.
  append l_line_fieldcat to l_i_fieldcat.

  clear l_line_fieldcat.
  l_line_fieldcat-fieldname = 'BANFN'.
  l_line_fieldcat-tabname   = 'IT_PR'.
  l_line_fieldcat-seltext_m = 'PURCHASE REQUISITION NUMBER'.
  append l_line_fieldcat to l_i_fieldcat.

  clear l_line_fieldcat.
  l_line_fieldcat-fieldname = 'TXZ01'.
  l_line_fieldcat-tabname = 'IT_PR'.
  l_line_fieldcat-seltext_m = 'DESCRIPTION'.
  append l_line_fieldcat to l_i_fieldcat.

  clear l_line_fieldcat.
  l_line_fieldcat-fieldname = 'ERNAM'.
  l_line_fieldcat-tabname   = 'IT_PR'.
  l_line_fieldcat-seltext_m = 'CREATED BY'.
  append l_line_fieldcat to l_i_fieldcat.

endform.                    " f2000_fieldcat_init


form handle_top_of_page.

  call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
      i_logo             = ''
      it_list_commentary = l_it_header[].

endform.                    "handle_top_of_page


form call_smartform .

  call function 'SSF_FUNCTION_MODULE_NAME'
    exporting
      formname                 = g_formname
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
    importing
      fm_name                  = g_fm_name
   exceptions
     no_form                  = 1
     no_function_module       = 2
     others                   = 3
            .
  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.

  call function g_fm_name
    exporting
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
*   CONTROL_PARAMETERS         =
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
      i_eban                     = p_banfn
* IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
*   JOB_OUTPUT_INFO            =
*   JOB_OUTPUT_OPTIONS         =

   exceptions
     formatting_error           = 1
     internal_error             = 2
     send_error                 = 3
     user_canceled              = 4
     others                     = 5
            .
  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.                    " CALL_SMARTFORM

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if useful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Feb 2007 07:34:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951364#M391867</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-28T07:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: USER_COMMAND in alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951365#M391868</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;follow this logic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Perform at_user_command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;first create form at_user_command and pass this formname to the parameter I_AT_user_command of the FM Reuse_alv_grid_display.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form at_user_command using ucomm1 like sy-ucomm&lt;/P&gt;&lt;P&gt;                                            selfield type slis_selfield.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use the code for capturing the code when clicked on a fieldname or line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this should resolve the issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;shamim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Feb 2007 08:29:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-alv/m-p/1951365#M391868</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-28T08:29:37Z</dc:date>
    </item>
  </channel>
</rss>

