SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

ALV double click sample code



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Fri Apr 04, 2008 12:15 pm    Post subject: ALV double click sample code Reply with quote

Code:
REPORT alvintersample NO STANDARD PAGE HEADING LINE-SIZE 650.

TYPE-POOLS: slis.
*type declaration for values from ekko
TYPES: BEGIN OF i_ekko,
ebeln LIKE ekko-ebeln,
aedat LIKE ekko-aedat,
bukrs LIKE ekko-bukrs,
bsart LIKE ekko-bsart,
lifnr LIKE ekko-lifnr,
END OF i_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF i_ekko INITIAL SIZE 0,
wa_ekko TYPE i_ekko.

*type declaration for values from ekpo
TYPES: BEGIN OF i_ekpo,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
menge LIKE ekpo-menge,
meins LIKE ekpo-meins,
netpr LIKE ekpo-netpr,
END OF i_ekpo.

DATA: it_ekpo TYPE STANDARD TABLE OF i_ekpo INITIAL SIZE 0,
wa_ekpo TYPE i_ekpo .

*variable for Report ID
DATA: v_repid LIKE sy-repid .

*declaration for fieldcatalog
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv.


DATA: it_listheader TYPE slis_t_listheader.

* declaration for events table where user comand or set PF status will
* be defined
DATA: v_events TYPE slis_t_event,
wa_event TYPE slis_alv_event.

* declartion for layout
DATA: alv_layout TYPE slis_layout_alv.

* declaration for variant(type of display we want)
DATA: i_variant TYPE disvariant,
i_variant1 TYPE disvariant,
i_save(1) TYPE c.

*PARAMETERS : p_var TYPE disvariant-variant.

*Title displayed when the alv list is displayed
DATA: i_title_ekko TYPE lvc_title VALUE 'FIRST LIST DISPLAYED'.
DATA: i_title_ekpo TYPE lvc_title VALUE 'SECONDRY LIST DISPLAYED'.

INITIALIZATION.
  v_repid = sy-repid.
  PERFORM build_fieldcatlog.
  PERFORM event_call.
  PERFORM populate_event.

START-OF-SELECTION.
  PERFORM data_retrieval.
  PERFORM build_listheader USING it_listheader.
  PERFORM display_alv_report.

*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG
*&--------------------------------------------------------------------*
* Fieldcatalog has all the field details from ekko
*---------------------------------------------------------------------*
FORM build_fieldcatlog.
  wa_fieldcat-tabname = 'IT_EKKO'.
  wa_fieldcat-fieldname = 'EBELN'.
  wa_fieldcat-seltext_m = 'PO NO.'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-tabname = 'IT_EKKO'.
  wa_fieldcat-fieldname = 'AEDAT'.
  wa_fieldcat-seltext_m = 'DATE.'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-tabname = 'IT_EKKO'.
  wa_fieldcat-fieldname = 'BUKRS'.
  wa_fieldcat-seltext_m = 'COMPANY CODE'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-tabname = 'IT_EKKO'.
  wa_fieldcat-fieldname = 'BUKRS'.
  wa_fieldcat-seltext_m = 'DOCMENT TYPE'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-tabname = 'IT_EKKO'.
  wa_fieldcat-fieldname = 'LIFNR'.
  wa_fieldcat-no_out = 'X'.
  wa_fieldcat-seltext_m = 'VENDOR CODE'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.


ENDFORM. "BUILD_FIELDCATLOG

*&--------------------------------------------------------------------*
*& Form EVENT_CALL
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM event_call.
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
  EXPORTING
  i_list_type = 0
  IMPORTING
  et_events = v_events
* EXCEPTIONS
* LIST_TYPE_WRONG = 1
* OTHERS = 2
  .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM. "EVENT_CALL

*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM populate_event.
  READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.
  IF sy-subrc EQ 0.
    wa_event-form = 'TOP_OF_PAGE'.
    MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =
    wa_event-form.
  ENDIF.

  READ TABLE v_events INTO wa_event WITH KEY name = 'USER_COMMAND'.
  IF sy-subrc EQ 0.
    wa_event-form = 'USER_COMMAND'.
    MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =
    wa_event-name.
  ENDIF.
ENDFORM. "POPULATE_EVENT


*&--------------------------------------------------------------------*
*& Form data_retrieval
*&--------------------------------------------------------------------*
* retreiving values from the database table ekko
*---------------------------------------------------------------------*
FORM data_retrieval.
  SELECT ebeln aedat bukrs bsart lifnr FROM ekko INTO TABLE it_ekko.

ENDFORM. "data_retrieval
*&--------------------------------------------------------------------*
*& Form bUild_listheader
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->I_LISTHEADEtext
*---------------------------------------------------------------------*
FORM build_listheader USING i_listheader TYPE slis_t_listheader.
  DATA hline TYPE slis_listheader.
  hline-info = 'this is my first alv pgm'.
  hline-typ = 'H'.
ENDFORM. "build_listheader

*&--------------------------------------------------------------------*
*& Form display_alv_report
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM display_alv_report.
  v_repid = sy-repid.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
  i_callback_program = v_repid
* I_CALLBACK_PF_STATUS_SET = ' '
  i_callback_user_command = 'USER_COMMAND'
  i_callback_top_of_page = 'TOP_OF_PAGE'
  i_grid_title = i_title_ekko
* I_GRID_SETTINGS =
* IS_LAYOUT = ALV_LAYOUT
  it_fieldcat = i_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* i_default = 'ZLAY1'
  i_save = 'A'
* is_variant = i_variant
  it_events = v_events
  TABLES
  t_outtab = it_ekko
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
  .
  IF sy-subrc <> 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




*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM top_of_page.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
  EXPORTING
  it_list_commentary = it_listheader
* i_logo =
* I_END_OF_LIST_GRID =
  .

ENDFORM. "TOP_OF_PAGE

*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
  CASE r_ucomm.
    WHEN '&IC1'.
      READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
      PERFORM build_fieldcatlog_ekpo.
      PERFORM event_call_ekpo.
      PERFORM populate_event_ekpo.
      PERFORM data_retrieval_ekpo.
      PERFORM build_listheader_ekpo USING it_listheader.
      PERFORM display_alv_ekpo.
  ENDCASE.
ENDFORM. "user_command
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG_EKPO
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM build_fieldcatlog_ekpo.

  wa_fieldcat-tabname = 'IT_EKPO'.
  wa_fieldcat-fieldname = 'EBELN'.
  wa_fieldcat-seltext_m = 'PO NO.'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-tabname = 'IT_EKPO'.
  wa_fieldcat-fieldname = 'EBELP'.
  wa_fieldcat-seltext_m = 'LINE NO'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-tabname = 'I_EKPO'.
  wa_fieldcat-fieldname = 'MATNR'.
  wa_fieldcat-seltext_m = 'MATERIAL NO.'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-tabname = 'I_EKPO'.
  wa_fieldcat-fieldname = 'MENGE'.
  wa_fieldcat-seltext_m = 'QUANTITY'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-tabname = 'I_EKPO'.
  wa_fieldcat-fieldname = 'MEINS'.
  wa_fieldcat-seltext_m = 'UOM'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-tabname = 'I_EKPO'.
  wa_fieldcat-fieldname = 'NETPR'.
  wa_fieldcat-seltext_m = 'PRICE'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.


ENDFORM. "BUILD_FIELDCATLOG_EKPO

*&--------------------------------------------------------------------*
*& Form event_call_ekpo
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM event_call_ekpo.
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
  EXPORTING
  i_list_type = 0
  IMPORTING
  et_events = v_events
* EXCEPTIONS
* LIST_TYPE_WRONG = 1
* OTHERS = 2
  .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM. "event_call_ekpo


*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM populate_event_ekpo.
  READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.
  IF sy-subrc EQ 0.
    wa_event-form = 'TOP_OF_PAGE'.
    MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =
    wa_event-form.
  ENDIF.

ENDFORM. "POPULATE_EVENT

*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM f_top_of_page.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
  EXPORTING
  it_list_commentary = it_listheader
* i_logo =
* I_END_OF_LIST_GRID =
  .

ENDFORM. "TOP_OF_PAGE

*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*

*retreiving values from the database table ekko
FORM data_retrieval_ekpo.
SELECT ebeln ebelp matnr menge meins netpr FROM ekpo INTO TABLE it_ekpo.
ENDFORM.

*---------------------------------------------------------------------*
*       FORM BUILD_LISTHEADER_EKPO                                    *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  I_LISTHEADER                                                  *
*---------------------------------------------------------------------*
FORM build_listheader_ekpo USING i_listheader TYPE slis_t_listheader.
  DATA: hline1 TYPE slis_listheader.
  hline1-typ = 'H'.
  hline1-info = 'CHECKING PGM'.
ENDFORM.


*---------------------------------------------------------------------*
*       FORM DISPLAY_ALV_EKPO                                         *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM display_alv_ekpo.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
  i_callback_program = v_repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
  i_callback_top_of_page = '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_title_ekpo
* I_GRID_SETTINGS =
* IS_LAYOUT =
  it_fieldcat = i_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT =
  i_save = 'A'
* IS_VARIANT =
  it_events = v_events
  TABLES
  t_outtab = it_ekpo
  EXCEPTIONS
  program_error = 1
  OTHERS = 2
  .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.

Original: http: //abapprogramming.blogspot.com/2007/11/alv-double-click-sample-code.html
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.