Concrete example of (whole ALV program )

Hi
i did some modification in the ALV program before .  like changing field catalog etc...  but i have never write a whole program in ALV and would like to try one by myself .
could you please in just 2 3 words write the step, and is there a sample program where all that apply to ALV is coded like hotspot , drill down, color, check box etc...

Hi,
go through this code.
Complete code for the ALV grid example
This example shows and ALV grid with flights. After selecting a line a change button can be pushed to display a change screen. After the changes have been saved, the ALV grid screen is displayed again, and the grid is updated with the changes.
The example shows:
How to setup the ALV grid
How to ste focus to the grid
How to set the title of the grid
How to allow a user to save and reuse a grid layout (Variant)
How to customize the ALV grid toolbar
Refresh the grid
Set and get row selection and read line contents
Make and exception field (Traffic light)
Coloring a line
Steps:
Create screen 100 with the ALV grid. Remember to include an exit button
Add a change button to the ALV grid toolbar
Create screen 200 the Change screen
The screens:
The code:
   REPORT sapmz_hf_alv_grid .
Type pool for icons - used in the toolbar
   TYPE-POOLS: icon.
   TABLES: zsflight.
To allow the declaration of o_event_receiver before the
lcl_event_receiver class is defined, decale it as deferred in the
start of the program
   CLASS lcl_event_receiver DEFINITION DEFERRED.
G L O B A L   I N T E R N  A L   T A B L E S
   *DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
To include a traffic light and/or color a line the structure of the
table must include fields for the traffic light and/or the color
   TYPES: BEGIN OF st_sflight.
           INCLUDE STRUCTURE zsflight.
      Field for traffic light
   TYPES:  traffic_light TYPE c.
      Field for line color
   types:  line_color(4) type c.
   TYPES: END OF st_sflight.
   TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
   DATA: gi_sflight TYPE tt_sflight.
G L O B A L   D A T A
   DATA: ok_code         LIKE sy-ucomm,
    Work area for internal table
         g_wa_sflight    TYPE st_sflight,
    ALV control: Layout structure
         gs_layout       TYPE lvc_s_layo.
Declare reference variables to the ALV grid and the container
   DATA:
     go_grid             TYPE REF TO cl_gui_alv_grid,
     go_custom_container TYPE REF TO cl_gui_custom_container,
     o_event_receiver    TYPE REF TO lcl_event_receiver.
   DATA:
Work area for screen 200
     g_screen200 LIKE zsflight.
Data for storing information about selected rows in the grid
   DATA:
Internal table
     gi_index_rows TYPE lvc_t_row,
Information about 1 row
     g_selected_row LIKE lvc_s_row.
C L A S S E S
   CLASS lcl_event_receiver DEFINITION.
     PUBLIC SECTION.
       METHODS:
        handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object e_interactive,
        handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING e_ucomm.
   ENDCLASS.
      CLASS lcl_event_receiver IMPLEMENTATION
   CLASS lcl_event_receiver IMPLEMENTATION.
     METHOD handle_toolbar.
Event handler method for event toolbar.
       CONSTANTS:
Constants for button type
         c_button_normal           TYPE i VALUE 0,
         c_menu_and_default_button TYPE i VALUE 1,
         c_menu                    TYPE i VALUE 2,
         c_separator               TYPE i VALUE 3,
         c_radio_button            TYPE i VALUE 4,
         c_checkbox                TYPE i VALUE 5,
         c_menu_entry              TYPE i VALUE 6.
       DATA:
           ls_toolbar  TYPE stb_button.
  Append seperator to the normal toolbar
       CLEAR ls_toolbar.
       MOVE c_separator TO ls_toolbar-butn_type..
       APPEND ls_toolbar TO e_object->mt_toolbar.
  Append a new button that to the toolbar. Use E_OBJECT of
  event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
  This class has one attribute MT_TOOLBAR which is of table type
  TTB_BUTTON. The structure is STB_BUTTON
       CLEAR ls_toolbar.
       MOVE 'CHANGE'        TO ls_toolbar-function.
       MOVE  icon_change    TO ls_toolbar-icon.
       MOVE 'Change flight' TO ls_toolbar-quickinfo.
       MOVE 'Change'        TO ls_toolbar-text.
       MOVE ' '             TO ls_toolbar-disabled.
       APPEND ls_toolbar    TO e_object->mt_toolbar.
     ENDMETHOD.
     METHOD handle_user_command.
  Handle own functions defined in the toolbar
       CASE e_ucomm.
         WHEN 'CHANGE'.
           PERFORM change_flight.
       LEAVE TO SCREEN 0.
       ENDCASE.
     ENDMETHOD.
   ENDCLASS.
S T A R T - O F - S E L E C T I O N.
   START-OF-SELECTION.
     SET SCREEN '100'.
   *&      Module  USER_COMMAND_0100  INPUT
   MODULE user_command_0100 INPUT.
     CASE ok_code.
       WHEN 'EXIT'.
         LEAVE TO SCREEN 0.
     ENDCASE.
   ENDMODULE.                 " USER_COMMAND_0100  INPUT
   *&      Module  STATUS_0100  OUTPUT
   MODULE status_0100 OUTPUT.
     DATA:
  For parameter IS_VARIANT that is sued to set up options for storing
  the grid layout as a variant in method set_table_for_first_display
       l_layout TYPE disvariant,
  Utillity field
       l_lines TYPE i.
After returning from screen 200 the line that was selected before
going to screen 200, should be selected again. The table gi_index_rows
was the output table from the GET_SELECTED_ROWS method in form
CHANGE_FLIGHT
     DESCRIBE TABLE gi_index_rows LINES l_lines.
     IF l_lines > 0.
       CALL METHOD go_grid->set_selected_rows
           EXPORTING
             it_index_rows = gi_index_rows.
       CALL METHOD cl_gui_cfw=>flush.
       REFRESH gi_index_rows.
     ENDIF.
Read data and create objects
     IF go_custom_container IS INITIAL.
  Read data from datbase table
       PERFORM get_data.
  Create objects for container and ALV grid
       CREATE OBJECT go_custom_container
         EXPORTING container_name = 'ALV_CONTAINER'.
       CREATE OBJECT go_grid
         EXPORTING
           i_parent = go_custom_container.
  Create object for event_receiver class
  and set handlers
       CREATE OBJECT o_event_receiver.
       SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
       SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
  Layout (Variant) for ALV grid
       l_layout-report = sy-repid. "Layout fo report
Setup the grid layout using a variable of structure lvc_s_layo
  Set grid title
       gs_layout-grid_title = 'Flights'.
  Selection mode - Single row without buttons
  (This is the default  mode
       gs_layout-sel_mode = 'B'.
  Name of the exception field (Traffic light field) and the color
  field + set the exception and color field of the table
       gs_layout-excp_fname = 'TRAFFIC_LIGHT'.
       gs_layout-info_fname = 'LINE_COLOR'.
       LOOP AT gi_sflight INTO g_wa_sflight.
         IF g_wa_sflight-paymentsum < 100000.
      Value of traffic light field
           g_wa_sflight-traffic_light = '1'.
      Value of color field:
      C = Color, 6=Color 1=Intesified on, 0: Inverse display off
           g_wa_sflight-line_color    = 'C610'.
         ELSEIF g_wa_sflight-paymentsum => 100000 AND
                g_wa_sflight-paymentsum < 1000000.
           g_wa_sflight-traffic_light = '2'.
         ELSE.
           g_wa_sflight-traffic_light = '3'.
         ENDIF.
         MODIFY gi_sflight FROM g_wa_sflight.
       ENDLOOP.
  Grid setup for first display
       CALL METHOD go_grid->set_table_for_first_display
         EXPORTING i_structure_name = 'SFLIGHT'
                   is_variant       = l_layout
                   i_save           = 'A'
                   is_layout        = gs_layout
         CHANGING  it_outtab        = gi_sflight.
   *-- End of grid setup -
  Raise event toolbar to show the modified toolbar
       CALL METHOD go_grid->set_toolbar_interactive.
  Set focus to the grid. This is not necessary in this
  example as there is only one control on the screen
       CALL METHOD cl_gui_control=>set_focus EXPORTING control = go_grid.
     ENDIF.
   ENDMODULE.                 " STATUS_0100  OUTPUT
   *&      Module  USER_COMMAND_0200  INPUT
   MODULE user_command_0200 INPUT.
     CASE ok_code.
       WHEN 'EXIT200'.
         LEAVE TO SCREEN 100.
         WHEN'SAVE'.
         PERFORM save_changes.
     ENDCASE.
   ENDMODULE.                 " USER_COMMAND_0200  INPUT
   *&      Form  get_data
   FORM get_data.
Read data from table SFLIGHT
     SELECT *
       FROM zsflight
       INTO TABLE gi_sflight.
   ENDFORM.                    " load_data_into_grid
   *&      Form  change_flight
Reads the contents of the selected row in the grid, ans transfers
the data to screen 200, where it can be changed and saved.
   FORM change_flight.
     DATA:l_lines TYPE i.
     REFRESH gi_index_rows.
     CLEAR   g_selected_row.
Read index of selected rows
     CALL METHOD go_grid->get_selected_rows
       IMPORTING
         et_index_rows = gi_index_rows.
Check if any row are selected at all. If not
table  gi_index_rows will be empty
     DESCRIBE TABLE gi_index_rows LINES l_lines.
     IF l_lines = 0.
       CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
            EXPORTING
                 textline1 = 'You must choose a line'.
       EXIT.
     ENDIF.
Read indexes of selected rows. In this example only one
row can be selected as we are using gs_layout-sel_mode = 'B',
so it is only ncessary to read the first entry in
table gi_index_rows
     LOOP AT gi_index_rows INTO g_selected_row.
       IF sy-tabix = 1.
        READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
       ENDIF.
     ENDLOOP.
Transfer data from the selected row to screenm 200 and show
screen 200
     CLEAR g_screen200.
     MOVE-CORRESPONDING g_wa_sflight TO g_screen200.
     LEAVE TO SCREEN '200'.
   ENDFORM.                    " change_flight
   *&      Form  save_changes
Changes made in screen 200 are written to the datbase table
zsflight, and to the grid table gi_sflight, and the grid is
updated with method refresh_table_display to display the changes
   FORM save_changes.
     DATA: l_traffic_light TYPE c.
Update traffic light field
Update database table
     MODIFY zsflight FROM g_screen200.
Update grid table , traffic light field and color field.
Note that it is necessary to use structure g_wa_sflight
for the update, as the screen structure does not have a
traffic light field
     MOVE-CORRESPONDING g_screen200 TO g_wa_sflight.
     IF g_wa_sflight-paymentsum < 100000.
       g_wa_sflight-traffic_light = '1'.
  C = Color, 6=Color 1=Intesified on, 0: Inverse display off
       g_wa_sflight-line_color    = 'C610'.
     ELSEIF g_wa_sflight-paymentsum => 100000 AND
            g_wa_sflight-paymentsum < 1000000.
       g_wa_sflight-traffic_light = '2'.
       clear g_wa_sflight-line_color.
     ELSE.
       g_wa_sflight-traffic_light = '3'.
       clear g_wa_sflight-line_color.
     ENDIF.
     MODIFY gi_sflight INDEX g_selected_row-index FROM g_wa_sflight.
Refresh grid
     CALL METHOD go_grid->refresh_table_display.
     CALL METHOD cl_gui_cfw=>flush.
     LEAVE TO SCREEN '100'.
   ENDFORM.                    " save_changes

Similar Messages

  • Whole ALV Report

    Hi Experts,
                I want to send ALV report output via mail to customer.In that it displaying only 255 characters bcoz i'm using Fuction Module SO_NEW_DOCUMENT_ATT_SEND_API1 and in the field content_bin i'm passing internal table.....i want to send the whole ALV report.

    hi
    Pls edit the mail id..before executing.
    *& Report  ZSENDEMAIL                                                  *
    *& Example of sending external email via SAPCONNECT                    *
    REPORT  zsendemail                    .
    PARAMETERS: psubject(40) type c default  'Testing',
                p_email(40)   type c default '[email protected]'.
    data:   it_packing_list like sopcklsti1 occurs 0 with header line,
            it_contents like solisti1 occurs 0 with header line,
            it_receivers like somlreci1 occurs 0 with header line,
            it_attachment like solisti1 occurs 0 with header line,
            gd_cnt type i,
            gd_sent_all(1) type c,
            gd_doc_data like sodocchgi1,
            gd_error type sy-subrc.
    data:   it_message type standard table of SOLISTI1 initial size 0
                    with header line.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Perform populate_message_table.
    *Send email message, although is not sent from SAP until mail send
    *program has been executed(rsconn01)
    PERFORM send_email_message.
    *Instructs mail send program for SAPCONNECT to send email(rsconn01)
    perform initiate_mail_execute_program.
    *&      Form  POPULATE_MESSAGE_TABLE
          Adds text to email text table
    form populate_message_table.
      Append 'Line1' to it_message.
      Append 'Line2' to it_message.
      Append 'Line3' to it_message.
      Append 'Test- 1' to it_message.
    endform.                    " POPULATE_MESSAGE_TABLE
    *&      Form  SEND_EMAIL_MESSAGE
          Send email message
    form send_email_message.
    Fill the document data.
      gd_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      gd_doc_data-obj_langu = sy-langu.
      gd_doc_data-obj_name  = 'SAPRPT'.
      gd_doc_data-obj_descr = psubject.
      gd_doc_data-sensitivty = 'F'.
    Describe the body of the message
    Information about structure of data tables
      clear it_packing_list.
      refresh it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      describe table it_message lines it_packing_list-body_num.
      it_packing_list-doc_type = 'RAW'.
      append it_packing_list.
    Add the recipients email address
      clear it_receivers.
      refresh it_receivers.
      it_receivers-receiver = p_email.
      it_receivers-rec_type = 'U'.
      append it_receivers.
    Call the FM to post the message to SAPMAIL
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           exporting
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
           importing
                sent_to_all                = gd_sent_all
           tables
                packing_list               = it_packing_list
                contents_txt               = it_message
                receivers                  = it_receivers
           exceptions
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                others                     = 8.
    Store function module return code
      gd_error = sy-subrc.
    Get it_receivers return code
      loop at it_receivers.
      endloop.
    endform.                    " SEND_EMAIL_MESSAGE
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    form initiate_mail_execute_program.
      wait up to 2 seconds.
      if gd_error eq 0.
          submit rsconn01 with mode = 'INT'
                        with output = 'X'
                        and return.
      endif.
    endform.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    If your SAPCONNECT is proper, it will trigger a mail.
    You need to associate the exchange server to the SAP system to send the mail outsise. This is called SAPconnect. You can use transaction SCOT in R/3 system. Contact your basis team about setting up this.
    Also, pls make sure that your user id has a valid email address attached to it via Transaction SU01
    also check the following threads
    http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm(for changing sender address)
    http://www.sap-img.com/fu016.htm
    http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html
    http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp
    http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
    <b>please reward if useful</b>
    Regards
    dinesh

  • How to check the layout defined for an ALV program

    Hi All,
    I have an ALV-program which uses radio buttons to display the list either in an Hierarchical format or in a Simple list format. In the selection screen there is a field for specifying the layout.
    Now the problem is, if a layout is created for Hierachical display and that layout is used to display the list in a simple list format the program doesn't give the desired output and vice versa.
    So i need to put a check in the program, to check whether the layout given in the selection screen is meant for a Simple List display or for an Hierarchical display and accordingly throw an error message regarding the mismatch if any.
    Is there any standard Function Module to check whether the layout is defined for a Simple List display or an Hieracrchical List display? Or is there any other way to do this checking????
    Thanks in Advance!!!
    Anindya

    Hi Venkat,
    The problem is:
    I need to know whether the LAYOUT(given in the selection screen) is defined for a SIMPLE LIST DISPLAY or an HIERARCHICAL LIST DISPLAY. Now say for example user has selected a layout which has been defined for a Hierarchical List display but by mistake he has selected the radio button for a Simple List display. So, here is a mismatch and the program should detect this and throw some error message. Instead it is now displaying a wrong output which is resulting from the mismatch.

  • How to place header and footer  in OO-ALV program using class

    How to place header and footer  in OO-ALV program using class tell me wat r the class we shold use and their attributes as well

    Hi Venkatesh,
    Take a look at this how to [ABAP Objects - ALV Model - Using Header and Footer|https://wiki.sdn.sap.com/wiki/x/xdw]
    it's explaining how to define the classes and use it for display an ALV with Header and Footer.
    Regards,
    Marcelo Ramos

  • Example of  Interactive ALV Report

    Hi all,
    Can anyone give me simplest example of Interactive ALV Report.
    Please give some description with that so that i can understand it ..
    Thanks
    Raj

    REPORT  ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650
    MESSAGE-ID ZZ_9838                      .
    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 USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
    DATA: HLINE1 TYPE SLIS_LISTHEADER.
    HLINE1-TYP = 'H'.
    HLINE1-INFO = 'CHECKING PGM'.
    ENDFORM.
    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.
    another sample code
    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 USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
    DATA: HLINE1 TYPE SLIS_LISTHEADER.
    HLINE1-TYP = 'H'.
    HLINE1-INFO = 'CHECKING PGM'.
    ENDFORM.
    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.
    REPORT Z_PO_ALV_R02 NO STANDARD PAGE HEADING MESSAGE-ID ZROJA.
    *-----tables declaration
    TABLES:EKKO.
    TYPE-POOLS:SLIS.
    *-----data declaration
    TYPES:BEGIN OF X_EKKO,
    EBELN type EKKO-EBELN, "PO Number
    BUKRS type EKKO-BUKRS, "Company code
    BSART type EKKO-BSART, "Purchasing Document type
    LIFNR type EKKO-LIFNR, "Vendor
    SPRAS type EKKO-SPRAS, "Language Key
    ZTERM type EKKO-ZTERM, "Terms of payment key
    END OF X_EKKO,
    BEGIN OF X_EKPO,
    EBELN type EKPO-EBELN,
    EBELP type EKPO-EBELP, "Item number
    WERKS type EKPO-WERKS, "Plant
    MATNR type EKPO-MATNR, "Material Number
    MATKL type EKPO-MATKL, "Material Group
    END OF X_EKPO.
    DATA:IT_EKKO TYPE STANDARD TABLE OF X_EKKO,
    IT_EKPO TYPE STANDARD TABLE OF X_EKPO,
    WA_EKKO TYPE X_EKKO,
    WA_EKPO TYPE X_EKPO, "#EC *
    IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
    IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
    WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
    WA_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV.
    *-----Selection-screen design
    SELECTION-SCREEN BEGIN OF BLOCK B1.
    SELECT-OPTIONS:S_EBELN FOR EKKO-EBELN.
    SELECTION-SCREEN END OF BLOCK B1.
    *-----SELECTION-SCREEN VALIDATION
    AT SELECTION-SCREEN.
    SELECT EBELN
    FROM EKKO
    INTO TABLE IT_EKKO
    WHERE EBELN IN S_EBELN.
    *-----if there are no values display an error
    IF SY-SUBRC NE 0.
    MESSAGE E009.
    ENDIF.
    *-----Data retrieval
    START-OF-SELECTION.
    *-----retrieving data from the PO header
    SELECT EBELN BUKRS BSART LIFNR SPRAS ZTERM
    FROM EKKO
    INTO TABLE IT_EKKO
    WHERE EBELN IN S_EBELN.
    *-----if there are no records display an error
    IF SY-SUBRC NE 0.
    MESSAGE E003.
    ENDIF.
    *-----Field catalog for the PO Header
    REFRESH IT_FIELDCAT[].
    WA_FIELDCAT-COL_POS = '1'.
    WA_FIELDCAT-FIELDNAME = 'EBELN'.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
    WA_FIELDCAT-KEY = 'X'.
    WA_FIELDCAT-HOTSPOT = 'X'.
    WA_FIELDCAT-REF_FIELDNAME = 'EBELN'.
    WA_FIELDCAT-REF_TABNAME = 'EKKO'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-COL_POS = '2'.
    WA_FIELDCAT-FIELDNAME = 'BUKRS'.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
    WA_FIELDCAT-REF_FIELDNAME = 'BUKRS'.
    WA_FIELDCAT-REF_TABNAME = 'EKKO'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-COL_POS = '3'.
    WA_FIELDCAT-FIELDNAME = 'BSART'.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
    WA_FIELDCAT-REF_FIELDNAME = 'BSART'.
    WA_FIELDCAT-REF_TABNAME = 'EKKO'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-COL_POS = '4'.
    WA_FIELDCAT-FIELDNAME = 'LIFNR'.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
    WA_FIELDCAT-REF_FIELDNAME = 'LIFNR'.
    WA_FIELDCAT-REF_TABNAME = 'EKKO'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-COL_POS = '5'.
    WA_FIELDCAT-FIELDNAME = 'SPRAS'.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
    WA_FIELDCAT-REF_FIELDNAME = 'SPRAS'.
    WA_FIELDCAT-REF_TABNAME = 'EKKO'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-COL_POS = '6'.
    WA_FIELDCAT-FIELDNAME = 'ZTERM'.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
    WA_FIELDCAT-REF_FIELDNAME = 'ZTERM'.
    WA_FIELDCAT-REF_TABNAME = 'EKKO'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    *-----to display the header details
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    IT_FIELDCAT = IT_FIELDCAT[]
    TABLES
    T_OUTTAB = IT_EKKO[].
    *& Form USER_COMMAND
    text
    -->UCOMM text
    -->FIELD1 text
    FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM FIELD1 TYPE "#EC CALLED
    SLIS_SELFIELD. "#EC *
    READ TABLE IT_EKKO INTO WA_EKKO INDEX FIELD1-TABINDEX.
    *-----retrieving item details from the PO Item table
    SELECT EBELN EBELP WERKS MATNR MATKL
    FROM EKPO
    INTO TABLE IT_EKPO
    WHERE EBELN = WA_EKKO-EBELN.
    *-----to display an error if other than PO Number is clicked
    IF SY-SUBRC NE 0.
    MESSAGE E001.
    ENDIF.
    *-----Fieldcatalog for the PO item details
    REFRESH IT_FIELDCAT1[].
    WA_FIELDCAT1-COL_POS = '1'.
    WA_FIELDCAT1-FIELDNAME = 'EBELN'.
    WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
    WA_FIELDCAT1-REF_FIELDNAME = 'EBELN'.
    WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
    CLEAR WA_FIELDCAT1.
    WA_FIELDCAT1-COL_POS = '2'.
    WA_FIELDCAT1-FIELDNAME = 'EBELP'.
    WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
    WA_FIELDCAT1-REF_FIELDNAME = 'EBELP'.
    WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
    CLEAR WA_FIELDCAT1.
    WA_FIELDCAT1-COL_POS = '3'.
    WA_FIELDCAT1-FIELDNAME = 'WERKS'.
    WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
    WA_FIELDCAT1-REF_FIELDNAME = 'WERKS'.
    WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
    CLEAR WA_FIELDCAT1.
    WA_FIELDCAT1-COL_POS = '4'.
    WA_FIELDCAT1-FIELDNAME = 'MATNR'.
    WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
    WA_FIELDCAT1-REF_FIELDNAME = 'MATNR'.
    WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
    CLEAR WA_FIELDCAT1.
    WA_FIELDCAT1-COL_POS = '5'.
    WA_FIELDCAT1-FIELDNAME = 'MATKL'.
    WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
    WA_FIELDCAT1-REF_FIELDNAME = 'MATKL'.
    WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
    CLEAR WA_FIELDCAT1.
    *-----to display the item details
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IT_FIELDCAT = IT_FIELDCAT1[]
    TABLES
    T_OUTTAB = IT_EKPO[].
    ENDFORM. "user_command_form
    regards,
    srinivas
    <b>*reward for useful answers*</b>

  • ALV Programming and Sapscript...

    Hi,
    Till date i have only worked in standard reports, now i have to work on ALV report and Sapscript, so if any one have any basic tutorial on ALV and Sapscript, pls email me.
    Thanks in advance.

    Hi arup,
    1. This is the most simple form of alv.
    2. Minimum, this much coding is required for a normal alv.
    The two main FMs for any alv programming are.
    <b>REUSE_ALV_LIST_DISPLAY
    REUSE_ALV_FIELDCATALOG_MERGE</b>
    3. just copy paste to get a taste of it.
    4.
    report abc.
    TYPE-POOLS : slis.
    DATA : alvfc TYPE slis_t_fieldcat_alv.
    DATA : alvfcwa TYPE slis_fieldcat_alv.
    data : begin of itab occurs 0.
            include structure usr02.
    data : end of itab.
    START-OF-SELECTION.
      select * from usr02
      into table itab.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = sy-repid
          i_internal_tabname     = 'ITAB'
          i_inclname             = sy-repid
        CHANGING
          ct_fieldcat            = alvfc
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
    IMPORTANT
      LOOP AT ALVFC INTO ALVFCWA.
        IF ALVFCWA-FIELDNAME = 'USTYP'.
          ALVFCWA-NO_CONVEXT = 'X'.
          MODIFY ALVFC FROM ALVFCWA.
        ENDIF.
      ENDLOOP.
    Display
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          it_fieldcat   = alvfc
        TABLES
          t_outtab      = itab
        EXCEPTIONS
          program_error = 1
          OTHERS        = 2.
    regards,
    amit m.

  • Why do we use cl_gui_cfw= flush method in Object Oriented ALV programming

    Dear Friends,
    Please solve my query regarding control framework. Why do we use cl_gui_cfw=>flush method in Object Oriented ALV programming. I studied and found that this method transfers automation queue to Front end.  But I could not find any further update on this.
    Thanks & Regards
    Amit Sharma

    Generally this is to restrict the traffic b/w frontend and backend. This means that every operation in Control Framework should be first buffered in the backend and synchronized with the frontend at certain points (one of this point is calling synchronization method cl_gui_cfw=>flush ). This explicit order of synchronization is due to RFC call needed for every communication b/w front/back end. So to avoid to many RFC calls we do it only at certain time.
    Please refer [Automation Queue|http://help.sap.com/saphelp_wp/helpdata/en/9b/d080ba9fc111d2bd68080009b4534c/frameset.htm]. I think it explains the concept quite well.
    Regards
    Marcin

  • All ALV Programs

    Dear Gurus,
                I am new to ABAP . Please provide me sample report code for all possible combinations in ALV like grid , hierachical , basic , intreactive & combination of all...etc..
                Thanks in advance . Points will be rewarded
    Regards,
    Lakshmiraj

    Check the below links :
    http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
    http://www.sap-img.com/abap-function.htm
    http://www.sap-basis-abap.com/sapab034.htm
    http://www.erpgenie.com/abap/example_code.htm
    These all are very simple ALV programs ,good luck
    Thanks
    Seshu

  • ALV program with Field Catalog

    Hi ,
    Can any body please provide me sample ALV programs with Field Catalog and GRID DISPLAY. and also please give me the steps for writing the program.
    Thanks in advance.
    KP

    Hi,
    For ALV GRID DISPLAY (using <b>OOPS</b>),
    1)Create an object of the <b>container</b>(an instance of a class like cl_gui_custom_container).
    2)Create an object of the <b>ALV using class cl_gui_alv_grid</b> and give the CONTAINER name that you define in your screen layout as the parent of the ALV.
    3)Call the method <b>SET_TABLE_FOR_FIRST_DISPLAY</b> of the class cl_gui_alv_grid.
    4)<b>Field catalog</b> is used when you want a variation of the standard structure to be displayed on your ALV.A  variable of table type <b>LVC_T_FCAT</b> is defined and variations can be made as per the requirements.The variable is then passed in the method SET_TABLE_FOR_FIRST_DISPLAY.
    <b>A SAMPLE PROGRAM:</b>
    REPORT SAMPLE:
    *-- GLOBAL DATA DECLARATIONS FOR ALV
    <b>DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid.</b>
    DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
    <b>DATA gr_ccontainer TYPE REF TO cl_gui_custom_container.</b>
    DATA gt_fieldcat TYPE lvc_t_fcat.
    Data:i_spfli type table of spfli.
    *The value CC_ALV is given to the custom container in the screen layout
    START-OF-SELECTION.
    select * from spfli into table i_spfli.
    Call screen 100.
    MODULE STATUS_0100 OUTPUT
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'SCREEN_100'.
    *Create container
    <b>CREATE OBJECT gr_ccontainer
    EXPORTING container_name = gc_custom_control_name.</b>
    *Create ALV
    <b>CREATE OBJECT gr_alvgrid
    EXPORTING i_parent = gr_ccontainer.</b>
    *field catalog
    <b>PERFORM prepare_field_catalog CHANGING gt_fieldcat.</b>
    *to display the ALV
    <b>CALL METHOD gr_alvgrid->set_table_for_first_display</b>
    EXPORTING
      I_STRUCTURE_NAME              = 'SPFLI'
    CHANGING
    it_outtab = i_spfli[]
    it_fieldcatalog = gt_fieldcat.
    ENDMODULE.                    "display_alv OUTPUT
    MODULE USER_COMMAND_0100 INPUT
    MODULE user_command_0100 INPUT.
    IF sy-ucomm = 'BACK' OR
         sy-ucomm = 'EXIT' OR
         sy-ucomm = 'CANCEL'.
        LEAVE PROGRAM.
      ENDIF.
    ENDMODULE.
    *& Form prepare_field_catalog
    FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
    DATA ls_fcat TYPE lvc_s_fcat.
    ls_fcat-ref_table = 'SPFLI'.
    ls_fcat-fieldname = 'CARRID'.
    APPEND ls_fcat TO pt_fieldcat.
    CLEAR ls_fcat.
    ls_fcat-fieldname = 'CONNID'.
    ls_fcat-ref_table = 'SPFLI'.
    APPEND ls_fcat TO pt_fieldcat.
    CLEAR ls_fcat.
    ls_fcat-fieldname = 'DEPTIME'.
    ls_fcat-ref_table = 'SPFLI'.
    APPEND ls_fcat TO pt_fieldcat.
    CLEAR ls_fcat.
    ls_fcat-fieldname = 'ARRTIME'.
    ls_fcat-ref_table = 'SPFLI'.
    APPEND ls_fcat TO pt_fieldcat.
    CLEAR ls_fcat.
    endform.
    <b>For more sample programs refer:</b>http://www.geocities.com/victorav15/sapr3/abap_ood.html#d_grid
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm
    http://www.sapdevelopment.co.uk/reporting/alvhome.htm
    <b>-->download the PDF from following link.</b>
    www.abap4.it/download/ALV.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    <b>Some more:</b>
    http://www.sap-hefte.de/download/dateien/1025/087_leseprobe.pdf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    http://www.alvgmbh.de/dwnload/gonio_t.pdfhttp://
    <b>You can get all demo programs for ALV:</b>Go to se38 and type BCALV* and press F4 for all demo porgrams.
    Regards,
    Beejal
    **Reward if this helps

  • How to write code  for totals and subtotals in alv programing?

    how to write code  for totals and subtotals in alv programing?

    hi,
    1. <u><b>TOTAL.</b></u>
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm
    2. <u><b>How do I add subtotals</b></u>
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    Regards
    Anver

  • Example of PL/SQL PROGRAM USING  BLOB datatype

    give me one example of PL/SQL PROGRAM BY USING BLOB DATATYPE

    Try this link
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96591/toc.htm
    Best Regards
    Krystian Zieja / mob

  • Data Merge Closes the whole InDesign program

    I have a page that I used the data merge feature (with excel) and saved. But now when I open the page it does not show me the data merge window, but when I go to windows-automation-data merge it close the whole Indesign Program. No error message or anything! It just closes the whole program. I am stumped! Anyone know whats going on?

    The Data merge window doesn't open automatically, so that'ts no surprise if you closed it. If ID crashes, though, you have a problem. Does it do it only when the file is open? See: Remove minor corruption by exporting Or does it happen even with no documents open? See: Replace Your Preferences

  • Example of creating  ALV double click event that can be used in ANY Program

    Once you get the hang of OO you can really create useful generalized code that can be used in a huge number of situtations.
    Double click on ALV is often wanted
    Right  here goes to implement a generalized double click action that returns the row, column and column name back to the caller.
    In your CLASS  in the DEFINITION part code as follows.
    CLASS zcl_dog DEFINITION.
    PUBLIC SECTION.
    METHODS:
      constructor
          IMPORTING       z_object type ref to zcl_dog,
                         i_parent     type ref to  cl_gui_custom_container,
    PRIVATE SECTION.
    on_dubbelklik FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row
                    e_column
                    es_row_no,
    dubbleklik
          IMPORTING
                     e_row  type  LVC_S_ROW
                     e_column   TYPE LVC_S_COL
                     es_row_no  type lvc_s_ROID
                     program type sy-repid.
    code here any extra any methods you need.
    In the CONSTRUCTOR method of the implementation
    CLASS zcl_dog IMPLEMENTATION.
    METHOD constructor.
       CREATE OBJECT grid_container1
           EXPORTING
                   container_name = 'CCONTAINER1'.
        CREATE OBJECT  grid1
            EXPORTING
                  i_parent = grid_container1.
        SET HANDLER z_object->on_user_command for grid1.
        SET HANDLER z_object->on_toolbar for grid1.
        SET HANDLER Z_OBJECT->handle_data_changed_finished FOR grid1.
        SET HANDLER Z_OBJECT->on_dubbelklik FOR grid1.
    endmethod.
    METHOD on_dubbelklik.
    CALL METHOD me->dubbleklik
    exporting
                     e_row  = e_row
                     e_column =  e_column
                     es_row_no = es_row_no
                     program  = sy-repid.
    break-point 1.
    method dubbleklik.
      perform dubbleklik IN PROGRAM (program)
        using
        e_row
        e_column
        es_row_no.
      ENDMETHOD.
    endclass.
    This will now perform a routine called dubbleklik  in your application program whenever you double click a cell in the grid.
    In the application program just code the following
    DATA:  z_object type ref to zcl_dog,  "Instantiate our class
           grid_container1 type ref to cl_gui_custom_container,
    CREATE OBJECT z_object EXPORTING z_object = z_object.
    call ANY method in the class  which eventually displays the grid
    CALL METHOD z_object->build_dynamic_structures
            CHANGING it_fldcat = it_fldcat.
    form dubbleklik using
            e_row   type LVC_S_ROW
            e_column type LVC_S_col
            es_row_no type lvc_s_roid.
    break-point 1.
    endform.
    When you double click a cell you'should be at the break point in your routine in the application program.
    You've got the cell that was clicked so by reading your table you can examine the data and take the appropriate action.
    Cheers
    Jimbo

    I suggest you purchase a case and have a dedicated support engineer work with you directly:
    http://www.sdn.sap.com/irj/boc/gettingstarted
    Or
    http://store.businessobjects.com/store/bobjects/Content/pbPage.CSC_map_countyselector/pgm.67024400?resid=jFmmLgoBAlcAAALO-iYAAAAP&rests=1278687224728
    If this is a bug you'll get a refund, if not post your enhancement request in the Idea Place. Or the Rep will suggest a better way to create your report.

  • Example of class-alv

    i'm looking for simple example of alv with class (this is OO)
    and with events
    thanks

    Hi Guys -- all the replies and demos so far in this thread  point to the OLD ALV grid
    Any examples on using the NEW ALV API (6.40 and above)
    There's quite a lot of stuff under packet type SALV and some SALV_DEMO* programs but they seem far too complicated to understand easily.
    I've got an ABAP here which basically shows the Grid but How do I add the standard function buttons etc on it. I'm tyring to avoid extra screens with PAI and PBO processing or SE41 define menu statuses etc..
    <b>
    Program  ZALV_TEST1.
    include <color>.
    include <icon>.
    include <symbol>.
    display stuff in alv grid easily using new simple alvgrid with new api's
    no screen  / pbo /pai needs to be defined anymore for just simple display with no events etc.
    No field catalog needed either
    tables: eine,
            eina.
    Data:
            gr_table TYPE REF TO cl_salv_table.
    data : begin of s_einea,
                  infnr  type eina-infnr,
                  ekorg  type eine-ekorg,
                  werks  type eine-werks,
                  lifnr  type eina-lifnr,
                  loekz  type eina-loekz,
                  ebeln  type eine-ebeln,
                  ebelp  type eine-ebelp,
                  matnr  type eina-matnr,
                  testfield(10) type c,     "Own fields just for test
                  url(255) type c,
           end of s_einea.
      data   t_einea
            like table of s_einea.
    data:   s_name  type tabname.
       s_name = 'S_EINEA'.
    get data
    want data from both eina and eine where BOTH delete flags (LOEKZ) are 'X'
    using the same info rec as primary key for the join (1 EINA ===> several EINE)
       select ainfnr alifnr amatnr aloekz bekorg bwerks bebeln bebelp
          into corresponding fields of  table t_einea
          up to 50 rows
          from  ( eina   as a
            inner join eine as b on ainfnr eq binfnr
                             and  aloekz eq bloekz  )
                      where  a~loekz eq 'X'.
    add user data (non ddic) into internal table
    Just to test NON DDIC fields
    Note No Field catalog needed.
    loop at t_einea into s_einea.
          s_einea-testfield = 'UserData'.
          modify  t_einea from s_einea index sy-tabix.
          endloop.
    Instead of if_salv_c_bool_sap=>false, you can pass the
    value if_salv_c_bool_sap=>true to this method to
    see your ALV as a list.
    display data in Grid / List
      TRY.
          CALL METHOD cl_salv_table=>factory
            EXPORTING
              list_display   = if_salv_c_bool_sap=>false
            IMPORTING
              r_salv_table   = gr_table
            CHANGING
              t_table    = t_einea.
        CATCH cx_salv_msg.
      ENDTRY.
    data: lr_functions type ref to cl_salv_functions_list.
    constants: gc_true  type sap_bool value 'X',
               gc_false type sap_bool value space.
    add for colour displays
       data: ls_color type lvc_s_colo.
       DATA : LV_SALV_COLUMNS_TABLE TYPE REF TO CL_SALV_COLUMNS_TABLE.
      data: lr_columns type ref to cl_salv_columns_table,
            lr_column  type ref to cl_salv_column_table.
    LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'TESTFIELD' ).
          ls_color-col = col_negative.
          ls_color-int = 0.
          ls_color-inv = 0.
          lr_column->set_color( ls_color ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'INFNR' ).
    ls_color-col = col_negative.
          ls_color-int = 1.
          ls_color-inv = 1.
          lr_column->set_color( ls_color ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'TESTFIELD' ).
    lr_column->set_short_text( 'Short' ).
    lr_column->set_medium_text( 'Medium' ).
    lr_column->set_long_text( 'This is a test' ).
    this statement actually does the display.
      gr_table->display( ).</b>
    Any help appreciated
    Thanks

  • Need an example of server / client program with swing interface

    Hi!
    After a lot of trying i still haven't managed to create a server client program using swing components ...
    can someone write a mini application to demonstrate how this can be done?
    i would like to have a frame with a button a texField for input and a textAread for the output
    What i have in mind is the following ..
    say im the server
    i write something in the textField and then i press the button
    then the information written in the textFiled is passed to the client who shows it in his textArea
    The same thing goes on with the client (he can write something in his own textField and when he presses the button the info is passed at the
    server who puts it in his textArea) and vice versa.
    i have written many classes that trying unsuccessfully to do that ... below i show my last attempt ...
    I would appreciate if you could write a small application which it could to this.
    The whole idea is to create a turn based game ( i have implemented the game engine and graphics and i try to add the internet function)
    Here is the code ...( i would appreciate if you write a new code instead of trying to correct mine ( which i think it's impossible) in order to use it as a general example)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    @SuppressWarnings("serial")
    *  In order to have a more gereral program instead of passing strings between the server
    *  and the client a pass an MyObjext object.  The MyObject class has an integer and a String
    *  (which is always the same) field . At the textField i write an integer number and i
    *  make a new MyObject which i want to pass to the server or the client and vice versa.
    *  The textArea shows the integer value of the MyObject which was passed from the server /client
    public class MyUserInterface extends JFrame {
         MyObject returnObject;
         JTextField myTextField;
         JTextArea te ;
         ClientGame cg;
         ServerGame sg;
          * used to determine if the current instance is running as a client or host
         boolean isHost;
         //The constructor of the client
         public MyUserInterface(ClientGame cg){
              this("Client");
              this.cg = cg;
              isHost = false;
         //The constructor of the server
         public MyUserInterface(ServerGame sg){
              this("Server");
              this.sg = sg;
              isHost = true;
         //The general constructor used both by client and server ..
         // it initializes the GUi components and add an actionListenr to the button
         public MyUserInterface(String str) {
              super(str);
              myTextField = new JTextField(2);
              te = new JTextArea();
              te.setPreferredSize(new Dimension(100,100));
              JButton okButton = new JButton("Ok");
              okButton.addActionListener(new ActionListener() {
                   @Override
                   public void actionPerformed(ActionEvent e) {
                        try{
                             int a = Integer.parseInt(MyUserInterface.this.myTextField.getText());
                             System.out.println(a);   //used to control the flow of the program
                                  MyUserInterface.this.returnObject = new MyObject(a);
                             //sends the data
                             sendData();
                             //waiting for response...
                             getData();
                             catch(Exception ex){System.out.println("Error in the UI action command" +
                                                                ex.printStackTrace();}
              JPanel panel =  new JPanel(new FlowLayout());
              panel.add(okButton);
              panel.add(myTextField);
              panel.add(te);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              getContentPane().add(panel);
              pack();
              setVisible(true);
         protected MyObject getReturnObject() {
              return returnObject;
         public void sendData(){
              new Thread(new Runnable() {
                   @Override
                   public void run() { 
                        if (!isHost)cg.sentData(returnObject);    //using the Servers out and in methods
                        else sg.sentData(returnObject);                    //using the Clients out and in methods
                        System.out.println("data sending");
         public MyObject getData(){
              MyObject obj;
              System.out.println("Retrieveing Data");
              if (!isHost)obj = (MyObject)cg.getData();
              else obj = (MyObject)sg.getData();
              System.out.println(" data retrieved  = "+ obj.getInt());  //just to control how the code flows
              te.setText(obj.getInt()+"");       
              return obj;
         public static void main(String[] args) {
              *Initiating the Server
              new Thread(new Runnable() {
                   @Override
                   public void run() {
                        ServerGame sg = new ServerGame();
                        new MyUserInterface(sg);
              }).start();     
               * Initiating the Client
              new Thread(new Runnable() {
                   @Override
                   public void run() {
                        ClientGame cg = new ClientGame("192.168.178.21");   //<----in case you run my code
                                                                          //..don't forget to change to your
                        new MyUserInterface(cg);                              //ip
              }).start();
    import java.io.*;
    import java.net.*;
    public class ClientGame {
         String ipAddress;
         Socket clientSocket = null;
        ObjectOutputStream out = null;
        ObjectInputStream in = null;
         public ClientGame(String ipAddress) {
              this.ipAddress = ipAddress;
              try {
                   System.out.println("Connecting To Host");
                 clientSocket = new Socket(InetAddress.getByName(ipAddress),4444);
                System.out.println("Host Found ...Io initializaton");
                out = new ObjectOutputStream(clientSocket.getOutputStream());
                in = new ObjectInputStream(clientSocket.getInputStream());
            } catch (UnknownHostException e) {
                System.err.println("Don't know about host: taranis.");
                System.exit(1);
            } catch (IOException e) {
                System.err.println("Couldn't get I/O for the connection to: taranis.");
                System.exit(1);
         public Object getData(){
              Object fromServer = null ;
              do{
                 try {
                      fromServer = in.readObject();
                 catch(ClassNotFoundException ex){}
                  catch(IOException e){}
              }while(fromServer==null);
              return fromServer;        
         public void sentData(final Object obj){
              new Thread(new Runnable() {
                   @Override
                   public void run() {
                        try{
                             out.writeObject(obj);
                        catch(IOException e){}
              }).start();
         public void terminateConnection(){
              try{
                   out.close();
                   in.close();
                   clientSocket.close();
              catch (IOException e){}
    public class ServerGame {
         ServerSocket serverSocket;
         Socket clientSocket;
         ObjectOutputStream out = null;
        ObjectInputStream in = null;
         public ServerGame() {
              try{
                   serverSocket = new ServerSocket(4444);
                   clientSocket = serverSocket.accept();
                   out =  new ObjectOutputStream(clientSocket.getOutputStream());
                in = new ObjectInputStream(clientSocket.getInputStream());
              catch(IOException e){System.out.println("IOException in ServerGame");}
         public Object getData(){
              Object fromClient = null ;
              do{
                 try {
                      fromClient = in.readObject();
                 catch(ClassNotFoundException ex){}
                  catch(IOException e){}
              }while(fromClient==null);
             return fromClient;        
         public void sentData(final Object obj){
              new Thread(new Runnable() {
                   @Override
                   public void run() {
                        try{
                   out.writeObject(obj);
              catch(IOException e){}
              }).start();
         public void terminateConnection(){
              try{
                   out.close();
                   in.close();
                   clientSocket.close();
                   serverSocket.close();
              catch (IOException e){}
         public static void main(String[] args) {
              new ServerGame();
    import java.io.Serializable;
    * this is a test object
    * it has a String field and a value
    *  The string is always the same but the integer value is defined in the constructor
    public class MyObject implements Serializable{
         private static final long serialVersionUID = 1L;
         String str;
         int myInt;
         MyObject(int a){
              str = "A String";
              myInt = a;
         public int getInt(){
              return myInt;
    }

    Pitelk wrote:
    I believe that a good code example can teach you things ;that you would need many days of searching; in no timeSo lets write one small example.. Ill help a little, but you do most of the work.
    jverd approach is deffenetly the way to go.
    jverd wrote:
    * Write a very small, simple Swing program with an input area, an output area, and a button. When you click the button, what's in the input area gets copied over to the output area.This part is partially done.
    * Write a very small, simple client/server program without Swing. It should just send a couple of hardcoded messages back and forth.And this part is for you(Pitelk) to continue on. I cannot say that this is the best way. or that its good in any way. I do however like to write my client/server programs like this. And perhaps, and hopefully, Ill learn something new from this as well.
    This is how far I got in about 10-20min..
    package client;
    * To be added;
    * A connect method. That connects the client to the server and
    * opens up both the receive and transmit streams. After doing that
    * the an instance of the ServerListener class should be made.
    * Also an disconnect method could be usable. But thats a later part.
    public class TestClass1 {
    package utils;
    import java.io.ObjectInputStream;
    import client.TestClass1;
    * This class is meant to be listening to all responses given from
    * the server to the client. After a have received data from the
    * server. It should be forwarded to the client, in this case
    * TestClass1.
    public class ServerListener implements Runnable {
         public ServerListener(ObjectInputStream in, TestClass1 tc) {
         @Override
         public void run() {
              while(true) {
    package server;
    import java.io.ObjectOutputStream;
    import java.net.Socket;
    import java.util.ArrayList;
    import java.util.List;
    * This class should handle all data sent to the server from the clients.
    class Server implements Runnable {
         private static List<ObjectOutputStream> outStreams = new ArrayList<ObjectOutputStream>();
         private Socket client = null;
         public Server(Socket client) {
              this.client = client;
         @Override
         public void run() {
              while(true) {
    * The meaning of this class is to listen for clients trying to connect
    * to the server. Once connection is achieved a new thread for that client
    * should be made to listen for data sent by the client to the server.
    public class ChatServer implements Runnable {
         @Override
         public void run() {
              while(true) {
    package utils;
    import java.io.Serializable;
    @SuppressWarnings("serial")
    public class MyObject implements Serializable {
         private String mssg;
         private String clientID;
         private String clientName;
         public MyObject(String mssg, String clientID, String clientName) {
              this.mssg = mssg;
              this.clientID = clientID;
              this.clientName = clientName;
         //Generate getters and setters..
    }Continue on this, and when you get into problems etc post them. Also show with a small regular basis how far you have gotten with each class or it might be seen as you have lost intresst and then this thread is dead.
    EDIT: I should probably also say that Im not more than a java novice, at the verry most. So I cannot guarantee that I alone will be able to solve all the problems that might occure during this. But Im gonna try and help with the future problems that may(most likely will) occure atleast(Trying to reserve my self incase of misserable failiure from me in this attempt).
    Edited by: prigas on Jul 7, 2008 1:47 AM

Maybe you are looking for

  • IPhone 5 and voice memos

    I moved my iTunes library over to another hard drive, and had to resync my playlists.  My voice memos are now all on my computer and showing up in iTunes but they're not on my iPhone 5.  I'm running Windows and iTunes 11 (latest version).  I keep che

  • Scanner Sharing Only Working With a User Logged Into Host Computer

    I have been able to get my Brother MFC7020 to work perfectly with the network. I have gotten the scanning to work over the sharing system as well but with a weird glitch. I must have a user logged into the host computer in order for the shared scanne

  • Application that requires Classic but there's no box to uncheck!

    I am using Tiger (updated) and there is an application I am trying to open (it's a medical cd-rom, LCP-system, an interactive presentation of a product) that informs me to start Classic. I don't have Classic, so the system tells me that I don't have

  • Note 951952 - Incorrect excise values if batch split in MIGO for import PO

    Dear participants, We have applied Note 951952 - Incorrect excise values if batch split in MIGO for import PO, for following issue, While doing import goods receipt for batch split quantity, excise base value is calculating for entire amount not by s

  • Something in dba_segments but not in dba_objects

    Hi, I think I met a bug. It's Oracle 11.1.0.7.0 Enterprise Edition 64bit on Oracle Enterprise Linux Server Release 5 Update 6. I tried to drop a tablespace but cannot. The 'drop tablespace' returned error ORA-1561 saying there're some objects in the