ABAP OOABAP ALV GRID

Hi Experts,
  i have one requirement. i need to Develop Alvgrid in one Screen.in the Same Screen another Grid.in First i need to Display Summary information.if we Double Click on First Grid of line Detail output of paricular contract.How to Acheive using classes.
plz send me the material Regarding this.and give me Some examples.How to approach.
Thanks,
Venkat.

Hi,
Here is a code for a single grid.
In the screen layout,make a custom container (Icon with C ) and name it in Capital letters as CONTAINER.The code below in bold letters is what exactly you want.I ve given a small example on how to use ALV:
REPORT SAMPLE.
DATA: alv type ref to cl_gui_alv_GRID,
cont type ref to cl_gui_custom_container,
itab_spfli type table of spfli.
START-OF-SELECTION.
select * from spfli into table itab_spfli.
call screen 100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
seT PF-STATUS 'GUI'.
SET TITLEBAR 'xxx'.
if cont is initial.
CREATE OBJECT cont
EXPORTING
CONTAINER_NAME = 'CONTAINER'.
CREATE OBJECT ALV
EXPORTING
I_PARENT = CONT.
CALL METHOD ALV->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'SPFLI'
CHANGING
IT_OUTTAB = itab_spfli
Now for your requirement,you can create two custom containers in the screen layout and two different alv grid instances.ie:
DATA: alv1 type ref to cl_gui_alv_GRID,
cont1 type ref to cl_gui_custom_container
alv2 type ref to cl_gui_alv_GRID,
cont2 type ref to cl_gui_custom_container.
To select data from first grid,you can use events on double_click and fetch information and then display it in the second grid.
<b>SOME MATERIAL REGARDING ALV:</b>
www.abap4.it/download/ALV.pdf <b>(very useful)</b>
http://www.sapdevelopment.co.uk/reporting/alvhome.htm
<b>-->download the PDF from following link.</b>
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm
<b>SAMPLE PROGRAMS IN ALV:</b>http://www.geocities.com/victorav15/sapr3/abap_ood.html#d_grid
<b>DEMO PROGRAMS IN ALV:</b>BCALV*
Regards,
Beejal
**Reward if this helps

Similar Messages

  • Not triggering PBO in OOABAP ALV grid

    Hi all.
    I want to create drop down for Document type BSART.for that iam using OOABAP but my program is not triggering PBO module itself.I have seen so many examples but iam unable to fetch data.what are the changes i have to do here.i have reduced some code here.i have written my final internal table select query before this stataement.
    loop at it_git_final into wa_git_final.
    APPEND wa_git_final TO it_git_final.
    ENDLOOP.
    *Call to ALV
      CALL SCREEN 600.
    MODULE status_0600 OUTPUT.
    SET PF-STATUS 'DISP'.
    SET TITLEBAR 'ALVF4'.
    ENDMODULE.                 " STATUS_0600  OUTPUT
    calling the PBO module ALV_GRID.
    MODULE pbo OUTPUT.
    *Creating objects of the container
      *  SET field for ALV
      if g_custom_container is initial.
      perform create_and_init_alv changing it_git_final
                                             gt_fieldcat.
    PERFORM alv_build_fieldcat.
      endif.
      * Set ALV attributes FOR LAYOUT
    PERFORM alv_report_layout.
       CHECK NOT c_alvgd IS INITIAL.
    Call ALV GRID
       CALL METHOD c_alvgd->set_table_for_first_display
        EXPORTING
          is_layout                     = it_layout
          i_save                        = 'A'
        CHANGING
          it_outtab                     = it_git_final
          it_fieldcatalog               = it_fcat
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
       ENDMODULE.                 " PBO  OUTPUT
          MODULE PAI INPUT                                              *
    MODULE pai INPUT.
       ENDMODULE.                    "pai INPUT
    *subroutine to build fieldcat
    FORM alv_build_fieldcat changing pt_fieldcat type lvc_t_fcat..
       DATA lx_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'IT_GIT_FINAL'
        CHANGING
          ct_fieldcat      = gt_fieldcat.
    * To assign dropdown in the fieldcataogue
    LOOP AT gt_fieldcat INTO lx_fcat.
       DATA : lx_fcat TYPE lvc_s_fcat.
      lx_fcat-row_pos   = '1'.
      lx_fcat-col_pos   = '1'.
    lx_fcat-fieldname = 'CHECK1'.
    lx_fcat-ref_field = 'CHECK1'
      lx_fcat-EDIT = 'X'.
      lx_fcat-coltext = 'Check Box'.
    lx_fcat-seltext = text-c01.
    APPEND lx_fcat TO Gt_fieldcat.
    CLEAR lx_fcat.
    lx_fcat-row_pos   = '1'.
      lx_fcat-col_pos   = '15'.
      lx_fcat-fieldname = 'BSART'.
      lx_fcat-ref_field = 'BSART'.
      lx_fcat-ref_table = 'T161P'.
      lx_fcat-coltext = 'Document Type'.
    lx_fcat-drdn_hndl = '1'.
      lx_fcat-outputlen = 15.
      lx_fcat-edit = 'X'.
      append  lx_fcat to gt_fieldcat.
      CLEAR lx_fcat.
       DATA: lt_dropdown TYPE lvc_t_drop,
            ls_dropdown TYPE lvc_s_drop.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '01 ZFC Vesselchart Contract'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '02 ZQTY QTY Contract(SESA)'.
      APPEND ls_dropdown TO lt_dropdown.   ls_dropdown-handle = '1'.
    *method to display the dropdown in ALV
      CALL METHOD g_grid->set_drop_down_table
        EXPORTING
          it_drop_down = lt_dropdown.
    LOOP AT it_fcat INTO lx_fcat.
        CASE lx_fcat-fieldname.
    To assign dropdown in the fieldcataogue
          WHEN 'BSART'.
            lx_fcat-drdn_hndl = '1'.
            lx_fcat-outputlen = 15.
            MODIFY it_fcat FROM lx_fcat.
        ENDCASE.
      ENDLOOP.
          endform.
    form ALV_OUTPUT .
    *Create object for container
    CREATE OBJECT g_custom_container
            EXPORTING container_name = 'CCONT'.
    *create object for grid
    CREATE OBJECT g_grid
            EXPORTING i_parent = g_custom_container.
      CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          is_layout       = it_layout
        CHANGING
          it_fieldcatalog = gt_fieldcat
          it_outtab       = it_git_final.
    endform.                    " ALV_OUTPUT
    form ALV_REPORT_LAYOUT .
      it_layout-cwidth_opt = 'X'.
      it_layout-col_opt = 'X'.
      it_layout-zebra = 'X'.
    endform.                    " ALV_REPORT_LAYOUT
    form CREATE_AND_INIT_ALV  changing p_it_git_final
                                       p_gt_fieldcat.
      create object g_custom_container
             exporting container_name = g_container.
      create object g_grid
             exporting i_parent = g_custom_container.
    endform.

    Hello Raj
      Actually all the code is described in PBO module, so you need to invoke this module in PBO when defining the screen.
    For example, access transaction SE51, start in Change mode and inser line
        MODULE PBO.
    Then activate the object
    Best regards
    Carlos Machad o

  • ABAP Query - ALV Grid Calculation

    Can anybody tell me whether in ABAP Query when you execute the Query in SQ01 its shows the report in ALV Grid format. In ALV Grid format there are some standard calculation are available like
    TOtal
    Mean value
    Minmum
    Maximum
    Count
    The above calculation can be done for each column.
    My Query is it possible to put our own simple calculation
    through some coding for overall summation fields instead of this std. calculation.
    Example : Unrestricted moved Qty Summation divided by INspection lot qty summation * 100
    The output of this calculation is called First pass yield.
    This calculation i done for each line item by creating a Additional field with ABAP coding.The overall meanvalue calcualtion of this addtional fields column is not suits the customer expectation.They want the calculation to be done by the system like what i had explained in the example.

    Hi,
    Here is a code for a single grid.
    In the screen layout,make a custom container (Icon with C ) and name it in Capital letters as CONTAINER.The code below in bold letters is what exactly you want.I ve given a small example on how to use ALV:
    REPORT SAMPLE.
    DATA: alv type ref to cl_gui_alv_GRID,
    cont type ref to cl_gui_custom_container,
    itab_spfli type table of spfli.
    START-OF-SELECTION.
    select * from spfli into table itab_spfli.
    call screen 100.
    END-OF-SELECTION.
    *& Module STATUS_0100 OUTPUT
    text
    MODULE STATUS_0100 OUTPUT.
    seT PF-STATUS 'GUI'.
    SET TITLEBAR 'xxx'.
    if cont is initial.
    CREATE OBJECT cont
    EXPORTING
    CONTAINER_NAME = 'CONTAINER'.
    CREATE OBJECT ALV
    EXPORTING
    I_PARENT = CONT.
    CALL METHOD ALV->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
    I_STRUCTURE_NAME = 'SPFLI'
    CHANGING
    IT_OUTTAB = itab_spfli
    Now for your requirement,you can create two custom containers in the screen layout and two different alv grid instances.ie:
    DATA: alv1 type ref to cl_gui_alv_GRID,
    cont1 type ref to cl_gui_custom_container
    alv2 type ref to cl_gui_alv_GRID,
    cont2 type ref to cl_gui_custom_container.
    To select data from first grid,you can use events on double_click and fetch information and then display it in the second grid.
    <b>SOME MATERIAL REGARDING ALV:</b>
    www.abap4.it/download/ALV.pdf <b>(very useful)</b>
    http://www.sapdevelopment.co.uk/reporting/alvhome.htm
    <b>-->download the PDF from following link.</b>
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm
    <b>SAMPLE PROGRAMS IN ALV:</b>http://www.geocities.com/victorav15/sapr3/abap_ood.html#d_grid
    <b>DEMO PROGRAMS IN ALV:</b>BCALV*
    Regards,
    Beejal
    **Reward if this helps

  • Abap table /alv grid

    Hi Experts,
    I m looking for some abap sample programs to build a program with tabs.
    In any tab you have a table (ALV GRID ) with buttons to move up/down the selected row.

    1.Table maintanence generateor is used to maintain the table .
    If u want to allow others to create new entries u have to maintain the table.Which will have all the changes to the table.so that the users can get the newly activated table to go for further process..
    2.
    To edit the grid value u have to set the fieldcate.
    WA_FIELDCAT-EDIT = ''X'.
    3.
    Table control s used for the changes then and there and user friendly
    ALV is for Sort layoput changes and can download to wordformat etc...

  • Adding buttons in ABAP WD ALV toolbar

    Hi,
      Currently, on the ABAP WD ALV grid toolbar, there are the "Excel" and "Print Version" buttons by default. 
      I would like to know how can I add my own custom buttons to the toolbar (or remove the default ones)?  I've looked in the documentation, but I can't seem to find any examples.
    Thank you in advance for your help,
    Christian

    Hi Christian,
    use Interface IF_SALV_WD_STD_FUNCTIONS. There are a few methods included to control the buttons on the
    tool bar, e.g. SET_PDF_ALLOWED or SET_EDIT_DELETE_ROW_ALLOWED.
    Use the ALV configuration model to control this. There are a couple of tutorials available on SDN on how to implement it. Just do a search.
    regards, Ulli

  • ALV GRID-Abap Objects

    I am using ALV grid in ABAP objects. I have to sort ascending and descending. I saw the program BCALV_TEST_GRID. I copied the function code for ascending and descending from the program. But it is not working. what is the problem?

    You need to fill up the table
    it_sort             = gt_sort
    in the method
      call method gr_grid_d0100->set_table_for_first_display

  • List header for alv grid using abap objects

    Hai all,
          I have displayed alv grid in container control using abap objects i.e. using method set_table_for_first_display.
    now i need to display list header for this alv grid.
    please help me how to create with a sample coding.
    Thanks and regards,
    Prabu S.

    Create a splitter using CL_GUI_EASY_SPLITTER_CONTAINER with a top and bottom half.  Put the alv grid in the bottom half.  Use cl_dd_document (documented in help.sap.com )  to build the header in the top half.  Use events on CL_GUI_ALV_GRID to handle the top-of-list printing.
    Or, if available, use CL_SALV_TABLE, and read the documentation on that.  When I needed a header for my report, that's what I did.  There's plenty of good documentation about if you'll search for it.
    matt

  • Calling smartform and displaying ALV grid in ABAP WEBDYNPRO

    Hi all,
    I am new to ABAP web dynpro.I ahve few custom reports which are simple ALV list reports which I now need to convert to ABAP web dynpro application .
    For one particular report,based on the selection screen input,I need to display the ALV list and when I select the records from the ALV list,I need to call a smartform on clik of a push button.
    My questions:
    1. Im using 'REUSE_ALV_GRID_DISPLAY' FM  to display the o/p in my report.Is there any similar FM in webdynpro ABAP which will display my list in ALV GRID in my web dynpro application??/
    2. How to call a smartfrm in ALV grid in web dynpro??
    Edited by: abap_1000 on Jan 9, 2011 6:09 PM

    Hi,
    You can search SDN, there are several posts available. Just to get some idea, you can check --
    [Beginneru00B4s questions on WDA ALV;
    [Reg ALV Display;
    For clicking event on ALV --
    [Reg Row Data fetching on click in ALV;
    For ALV display on WDA --
    [http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/101df93f-4b5c-2910-14aa-9eb0338c2110?quicklink=index&overridelayout=true]
    Thanks.
    Kumar Saurav.

  • Exporting content of ALV grid in Web Dynpro for ABAP

    Hello Experts
    I have a following request which seems to be giving some headaches.
    I need to export results from one of the Web Dynpro reports (ABAP) I have developed to the Excel spreadsheet. Results are stored on ALV component. Request is to add header to export file with additional information like report title, selection criteria, date when report has been executed. By default export file contains only column names and data. I have set the header for ALV grid with all extra information I need to be passed to Excel file but it does not seem to be transferred at all.
    At the moment I see 2 possible solutions: 1) write my own Excel export 2) use PDF export where it is possible to set header/footer text. None of these solutions are ideal, I'd rather set header in standard Excel export. Is that even possible? Please help.
    Regards
    Michael
    Edited by: Soltuion Manager on Apr 20, 2009 10:08 AM
    Edited by: Soltuion Manager on Apr 20, 2009 10:26 AM

    Hello Michael,
    I haven't tried using the builtin functionality of ALV to achieve a similar fnctionality as yours but can suggest you a workaround for that. As how you might be already knowing you can try using the CL_WD_RUNTIME_SERVICES=>attach_file_to_response to download the contents into Excel/notepad/word. So just can modify the internal table to contain the extra information that you need. You can use the approach below for using the attach_file_to_response method:
    1) First read the table's data into an internal table.
    2) Convert the internal table data to STRING format.
    3) Now convert it into tab separated format as how desired.
    4) Convert this STRING format to XSTRING format
    5) Make use of the attach_file_to_response method.
    Regards,
    Uday
    METHOD onactionon_submit .
      DATA: lv_node TYPE REF TO if_wd_context_node,
            lt_mara TYPE if_main=>elements_mara,
            wa_mara TYPE if_main=>element_mara,
            lead_selection_index TYPE i,
            mara_string  TYPE string,
            mara_xstring TYPE xstring.
      lv_node = wd_context->get_child_node( name = 'MARA' ).
      CALL METHOD lv_node->get_static_attributes_table
        IMPORTING
          table = lt_mara.
      LOOP AT lt_mara INTO wa_mara.
        CONCATENATE mara_string
                    wa_mara-matnr
                    wa_mara-ersda
                    wa_mara-ernam
                    wa_mara-matkl
                    wa_mara-meins
                    cl_abap_char_utilities=>cr_lf INTO mara_string
                                            SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
      ENDLOOP.
    ** Now you need to add the column headers & the desired extra information through coding to
    ** mara_string
      CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          text   = mara_string
        IMPORTING
          buffer = mara_xstring.
      CL_WD_RUNTIME_SERVICES=>attach_file_to_response(  i_filename  = 'TEMP.XLS'
                                                        i_content   = mara_xstring
                                                        i_mime_type = 'EXCEL' ).
    ENDMETHOD.

  • Remove buttons in ALV grid display in ABAP Web Dynpro

    Hi,
    Sub: ALV grid-->Web Dynpro ABAP.
    Request guidance to prevent display of the buttons "Microsoft Excel" and "Print Version" (which provide options to export the ALV grid output into an Excel format document).
    Is there a way we could hide this from being displayed on the ALV grid in a Web dynpro ABAP component output?
    Thanks very much.
    Best Regards,
    Adi

    Hi Adithya,
    really simple solution is to call cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs=>set_all( abap_false ). This deactivates all ALV functionality.
    For individual setting cl_salv_wd_config_table if_salv_wd_standard_functions~set_<x>_allowed.
    - Michelle

  • ALV GRID Using oo abap example

    Hi Friends,
    I am new to oo abap, Can any one give me a basic example how i can create alv grid in oo abap.
    regards,
    DVNS

    HI,
    Programming for ALV grid display using the classes involves  creation of a screen and calling it for display.
    Since there has to be a linking between the program and the screen we have created , this comes in the form of a container. We use two important classes during the programming for displaying ALV grid, CL_GUI_ALV_GRID and CL_GUI_CUSTOM_CONTAINER.
    Steps To Use ALV Grid in a Program
    1. Declare reference variables for,
           Container (class CL_GUI_CUSTOM_CONTAINER) and
           Grid (class CL_GUI_ALV_GRID)
    Example
    DATA: grid  TYPE REF TO cl_gui_alv_grid,
                custom_container  TYPE REF TO cl_gui_custom_container
    2. Create Standard Screen and a container on that screen  and give a name to that container ( Use custom control button from tool bar) . This name will be used to link the container we have created on the screen with the object reference of class CL_GUI_CUSTOM_CONTAINER, which we have declared in the first step
    3. Call the screen which has been created
    4. Instantiate the container control and the ALV Grid Control in PBO of the screen.
    Example
    IF custom_container IS INITIAL.
      CREATE OBJECT custom_container
             EXPORTING
            CONTAINER_NAME = ‘MY_CONTAINER'.
    CREATE OBJECT grid
           EXPORTING
           I_PARENT = custom_container.
    ENDIF
    5. For displaying the data, call the method set_table_for_first_display of object reference of CL_GUI_ALV_GRID.
    Example
    CALL METHOD grid->set_table_for_first_display
    EXPORTING
    I_BUFFER_ACTIVE               =
    I_BYPASSING_BUFFER            =
    I_CONSISTENCY_CHECK           =
    I_STRUCTURE_NAME              =
    IS_VARIANT                    =
    I_SAVE                        =
    I_DEFAULT                     =
    IS_LAYOUT                     =
    IS_PRINT                      =
    IT_SPECIAL_GROUPS             =
    IT_TOOLBAR_EXCLUDING          =
    IT_HYPERLINK                  =
    IT_ALV_GRAPHICS               =
    IT_EXCEPT_QINFO               =
    CHANGING
    IT_OUTTAB                     =
    IT_FIELDCATALOG               =
    IT_SORT                       =
    IT_FILTER                     =
    EXCEPTION
    INVALID_PARAMETER_COMBINATION =
    PROGRAM_ERROR                 =
    TOO_MANY_LINES                =
    others                        =
    EXPLANATION OF SOME IMPORTANT PARAMETERS.
    I_BYPASSING_BUFFER & I_BUFFER_ACTIVE :
    When the program is run for the first time, the fields present in the output table and their positions are stored in a buffer.  So the buffer is taken as reference for the successive executions.  In order to bypass this buffer the above parameter values should be ‘X’ and  ‘ ‘(space)  respectively. If these values are not passed  to the function module, the changes made in the structure of the internal table will not be reflected in the output.
    I_STRUCTURE_NAME:
    If the structure of your output table corresponds to a structure stored in the Data Dictionary (DDIC), the ALV Grid Control can use this information to generate the field catalog automatically. Pass the table structure as parameter. In this case, all fields of this DDIC structure are displayed in the list.
    IS_VARIANT :
    It allows the user to save and reuse the layout. It is a structure of type DISVARIANT and contain the display variant name. It  facilitates pre-assignment for a layout, rather than displaying report and then choosing displaying variant.
    I_SAVE:
    This single character variable specifies whether the user specific display variants can be saved or not.
    The I_SAVE "Options for saving layouts" parameter can have the following values:
    U Only user specific layouts can be saved
    X Only global layouts can be saved
    A Both user specific and global layouts can be saved
    Space Layouts can not be saved
    IS_LAYOUT:
    This structure of type LVC_S_LAYO
    is used to control the layout of the ALV.  Two important fields are:
    GRID TITLE. : Title of grid
    ZEBRA : Alternate lines in list are displayed in different colors.
    IT_FIELDCATALOG:
    This internal table of type LVC_T_FCAT
    is used to specify the position of various fields in the report itab.
    There are three ways we can fill the field catalog table
    1. Automatically through data dictionary structure (DDIC). In this case we pass the table structure to I_STRUCTURE_NAME.
    2. Manually in ABAP program. Filling the internal table of type LVC_T_FCAT
    1.                  . With each row corresponding to each column of output table. Each row of this table will hold value like
    i). TABNAME & FIELDNAME specifies the reference fields for F1 help
    ii). CTABNAME & CFIELDNAME specifies the reference fields for currency formatting
    iii). QTABNAME & QFIELDNAME specifies the reference fields for quantity formatting
    iv). SELTEXT_L holds the long description of the field
    v).  SELTEXT_M holds the medium description of the field
    vi). SELTEXT_S holds the small description of the field
    vii). KEY specifies the Key field ( cannot be hidden )
    viii). OUTPUTLEN species the output length of the field
    ix). DO_SUM specifies that subtotal is required on this field
    x). NO_OUT specifies a hidden field
    3.  Semi-Automatically by combining the above 2 procedures.
    Call function Module REUSE_ALV_FIELDCATALOG_MERGE and pass DDIC
    structure or the output table to generate the field catalog.
    Add additional Rows or modify existing properties of the fields to be displayed.
    METHODS OF IMPLEMENTING SOME EXTRA FEATURES
    Set focus to the grid
    After CALL METHODgrid->set_table_for_first_display insert the following stament:
    CALL METHOD cl_gui_control=>set_focus EXPORTING control = grid
    Refresh grid display
    Use the grid method REFRESH_TABLE_DISPLAY
    Example:
    CALL METHOD grid->refresh_table_display.
    Set the title of the grid
    Fill the grid_title field of structure lvc_s_layo.
    DATA:
    gs_layout TYPE lvc_s_layo.
    gs_layout-grid_title = 'TITLE'.
    CALL METHOD go_grid->set_table_for_first_display
    EXPORTING i_structure_name = 'structure name'
    is_layout               = gs_layout
    CHANGING   it_outtab               = Output table.
    The structure lvc_s_layo contains fields for setting graphical properties, displaying exceptions, calculating totals and enabling specific interaction options
    Event Handling
    We can handle the events triggered by
    1. User defined Text Output
    2. Mouse-controlled Actions
    3. Self-defined and Standard Functions
    Steps for Event Handling
    1. Define a (local) class for event handling
    2. Define a method for each event you need to handle
    3. Implement your event handler methods.
    4. Create Object of the above class
    5. Link used events and event handler methods of the  receiver object and the grid
    object.
    Example program : Handling “Double Click” Event
    Step1.Define a class.
    class lcl_my_event_receiver definition.
    public section.
    methods:
    handle_double_click
    for event double_click of cl_gui_alv_grid.
    endclass.
    Step 2. Implement the class
    class lcl_my_event_receiver implementation.
    method handle_double_click.
    message i001(zz) with ' double click event - Triggerd '.
    endmethod.
    endclass.
    Step 3. Declare and create Object for the local class defined and implemented in steps 1 and 2 respectively
    o_receiver   TYPE REF TO lcl_my_event_receiver   (Declaration)
    create object o_receiver.                                            (Instantiation)
    Step 4. Link the method for handling the event with the grid object in the PBO of screen after instantiating the grid object
    set handler o_receiver->handle_double_click for grid.
    EXAMPLE PROGRAM TO CHANGE A CLASSICAL REPORT OUTPUT TO A ALV GRID
    This can be used as a template program to convert a classical report layout to a ALV grid.
    Report<Report name>
    Grid data Declarations----------------------------------------------*
      INCLUDE ZVINALVD.
    Internal table for ALV grid
    TYPES: BEGIN OF T_ALV,
             Field1 like table-field1,
             Field2 like table-field2,
           END OF T_ALV.
    DATA: I_ALV  TYPE TABLE OF T_ALV.
    DATA: WA_ALV TYPE T_ALV.
    -Class declarations----
      INCLUDE ZVINALVE.
    Add a checkbox in selection screen for ALV grid display. If it is unchecked
    output will be of classical type.
    SELECTION-SCREEN BEGIN OF BLOCK box01.
    SELECTION-SCREEN: BEGIN OF LINE.                           
    SELECTION-SCREEN: COMMENT 4(30) ‘To display repot output as a ALV grid’.                  
    PARAMETERS: p_alv AS CHECKBOX.                             
    SELECTION-SCREEN: END OF LINE.                             
    SELECTION-SCREEN END OF BLOCK box01.
    START-OF-SELECTION.
    Fill the ALV grid internal table
    END-OF-SELECTION.
    IF P_ALV = ‘X’.
      PERFORM ALV_DISPLAY.
    ELSE.
      PERFORM CLASSICAL_DISPLAY.
    ENDIF.
    Alv Display
    FORM ALV_DISPLAY.
      CALL SCREEN 100.
    ENDFORM.
    Module  STATUS_0100  OUTPUT
    PBO for ALV Grid
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'GRID_DISPLAY'.
      DATA:
    For parameter IS_VARIANT that is used to set up options for storing
    the grid layout as a variant in method set_table_for_first_display
      l_layout TYPE disvariant.
      GS_LAYOUT-SEL_MODE = 'B'.
    Optimize column width
      GS_LAYOUT-CWIDTH_OPT = 'X'.
    Read data and create objects
      IF go_custom_container IS INITIAL.
    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 to report
    To built fieldcatalog
        PERFORM alv_build_fieldcatalog.
    Grid setup for first display
        CALL METHOD go_grid->set_table_for_first_display
          EXPORTING
                    is_variant      = l_layout
                    i_save          = 'A'
                    is_layout       = gs_layout
          CHANGING  it_outtab       = I_ALV
                    it_fieldcatalog = fieldcat.
    Raise event toolbar to show the modified toolbar
        CALL METHOD go_grid->set_toolbar_interactive.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    Form ALV_BUILD_FIELDCATALOG.
    Store contents of selected line in a internal table
    FORM alv_build_fieldcatalog.
      CLEAR afield.
      afield-fieldname = 'FIELD1'.
      afield-tabname   = 'I_ALV'.
      afield-coltext   = ‘Field Name 1’.
      afield-lzero     = ' '.
      afield-key       = 'X'.
      afield-outputlen =  XX.
      APPEND afield TO fieldcat.
      CLEAR afield.
      afield-fieldname = 'FIELD2'.
      afield-tabname   = 'I_ALV'.
      afield-coltext   = ‘Field Name 2’.
      APPEND afield TO fieldcat.
    ENDFORM.                    " alv_build_fieldcatalog
    Module  USER_COMMAND_0100  INPUT
    PAI for ALV Grid
    MODULE USER_COMMAND_0100 INPUT.
      CASE OK_100.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    Form  SELECT_LINE
    Store contents of selected line in a internal table
    FORM SELECT_LINE.
      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.
      LOOP AT gi_index_rows INTO g_selected_row.
        IF sy-tabix = 1.
          READ TABLE I_ALV INDEX g_selected_row-index INTO
                         WA_ALV.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " SELECT_LINE
    Includes:
    1. ZVINALVD for data declarations
    INCLUDE ZVINALVD .
    Type pool for icons - used in the toolbar
    TYPE-POOLS: icon.
    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.
    GLOBAL DATA FOR ALV GRID
    DATA:
    OK code for alv grid screen
      OK_100(4)           TYPE C,
    ALV control: Layout structure
      gs_layout           TYPE   lvc_s_layo,
    Declare reference variables to the ALV grid and the container
      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 for storing information about selected rows in the grid
    Internal table
      gi_index_rows       TYPE lvc_t_row,
    Information about 1 row
      g_selected_row      LIKE lvc_s_row.
    fieldcatalog
    DATA: fieldcat        TYPE LVC_T_FCAT,
          afield          TYPE LVC_S_FCAT.
    2. ZVINALVE for Class/object declarations
    INCLUDE ZVINALVE.
    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 'DISPLAY'        TO ls_toolbar-function.
        MOVE  icon_DISPLAY    TO ls_toolbar-icon.
        MOVE 'Displaying customer' TO ls_toolbar-quickinfo.
        MOVE 'Display'        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 'DISPLAY'.
            PERFORM SELECT_LINE.
        ENDCASE.
    ENDMETHOD.
    Reward if useful

  • Urgent issue.......ALV grid...... Dyn pro.... ABAP

    Dear all
    This requirment is
    A logfile has to be created where the rows per interface will be added which had to be erased from the datapackage because of forbidden values.
    Logfile Data (skipped in the transfer routine) is stored in a transparent table.
    This logfile data can be stored to a local flatfile at the local Work Station.
    Implement this functionality at  Dynpro where
    1.Initially you select the interface you want to view.
    2. Then the content of the transparent table for this interface is displayed in an ALV grid.
    3. After that its possible to download the content into a local flatfile (Is there any standard functionality for this with ABAP?) .
    4. When stored locally the content of the transparent table will be erased.
    Any suggestions please......... how hanlde this issue.....
    Thanks in advance
    Cheers
    Sailekha

    Hi Sebastien,
    I am new to this concept. Can you please expalin me in detail the standard functionality for export in Local work station.  any example code available for this functionality.
    Thanks in advance
    Cheers
    Sailekha

  • What is the constant name for Change layout Button in ALV Grid ABAP Objects

    Dear All,
    I have one query please help me.
    what is the constant name for Change layout Button in ALV Grid ABAP Objects.
    With Rgds,
    Babu

    Halo Vinod,
    The consant name is cl_gui_alv_grid=>mc_fc_current_variant.
    Regards
    Arshad

  • First try with ALV Grid and Abap Objects

    Hi,
    this is my first try to write a simple report which just reads a textfile and display it in an ALV Grid. As a basis, I used some examples from SDN, but it did not work as expected
    I would like just to use a docking container. I do not need a separate area for the ALV Grid. The report gives no syntax errors, but it just display the report title, nothing else. SAP R/3 Release is 4.7. Below is the source code of the report. Any idea what is missing?
    *& Report  Z_PLAN_TEXT_UPLOAD                                          *
    REPORT z_plan_text_upload.
    INCLUDE <icon>.
    * Data Declaration
    DATA:
      gf_dynnr TYPE sy-dynnr,
      gf_repid TYPE sy-repid.
    DATA:
      go_docking_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat LIKE LINE OF gt_fieldcat.
    TYPES:
      BEGIN OF gy_text_input,
        firma(20)           TYPE c,
        kostenstelle(20)    TYPE c,
        datenart1(10)       TYPE c,
        planjahr(10)        TYPE c,
    *    planperiode         TYPE co_perio,
        planperiode(5)      TYPE c,
        datenart2(10)       TYPE c,
        planungposition(10) TYPE c,
    *    kostenart           TYPE koart,
        kostenart(10)       TYPE c,
    *    planbetrag          TYPE bapicurr_d,
        planbetrag(20)      TYPE c,
      END OF gy_text_input.
    DATA:
      gt_text_input TYPE TABLE OF gy_text_input,
      gs_text_input LIKE LINE OF gt_text_input.
    * Local Class Definition
    * Local Class Implementation
    * Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1
      WITH FRAME TITLE text-001.
    SKIP.
    PARAMETERS:
      gp_file TYPE localfile,
      gp_head TYPE checkbox DEFAULT 'X'.
    SKIP.
    PARAMETERS:
      gp_gjahr LIKE coep-gjahr,
      gp_versn LIKE coep-versn.
    SELECTION-SCREEN END OF BLOCK b1.
    * Initialization
    INITIALIZATION.
      DATA:
        lf_sapworkdir TYPE string.
      CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
        CHANGING
          sapworkdir            = lf_sapworkdir
        EXCEPTIONS
          get_sapworkdir_failed = 1
          cntl_error            = 2
          error_no_gui          = 3
          not_supported_by_gui  = 4
          OTHERS                = 5.
      IF sy-subrc <> 0 OR lf_sapworkdir = ''.
        CALL METHOD cl_gui_frontend_services=>directory_get_current
          CHANGING
            current_directory            = lf_sapworkdir
          EXCEPTIONS
            directory_get_current_failed = 1
            cntl_error                   = 2
            error_no_gui                 = 3
            not_supported_by_gui         = 4
            OTHERS                       = 5.
        CALL METHOD cl_gui_cfw=>flush.
      ENDIF."sy-subrc <> 0 OR sapworkdir = ''
      gp_file = lf_sapworkdir.
      gf_dynnr = sy-dynnr.
      gf_repid = sy-repid.
    * At Selection-Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
      DATA:
        lt_filetable TYPE filetable,
        ls_filetable LIKE LINE OF lt_filetable,
        lt_rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    *  EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        CHANGING
          file_table              = lt_filetable
          rc                      = lt_rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE lt_filetable INDEX 1
        INTO
          ls_filetable.
      gp_file = ls_filetable-filename.
      CALL METHOD cl_gui_cfw=>flush.
    * Start-Of-Selection
    START-OF-SELECTION.
      DATA:
        lf_filename LIKE filename-fileintern.
      lf_filename = gp_file.
      CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
        EXPORTING
          i_filename                 = lf_filename
          i_servertyp                = 'PRS '
          i_fileformat               = 'TXT'
    *     I_FIELD_SEPERATOR          =
          i_line_header              = gp_head
    *   IMPORTING
    *     E_BIN_FILELENGTH           =
       TABLES
         i_tab_receiver             = gt_text_input
       EXCEPTIONS
         file_not_found             = 1
         close_failed               = 2
         authorization_failed       = 3
         open_failed                = 4
         conversion_failed          = 5
         OTHERS                     = 6.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog ---------------------------------------*
      PERFORM build_fieldcatalog
        CHANGING gt_fieldcat.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
    *      PARENT                      =
            repid                       = gf_repid
            dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *      EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
    *      RATIO                       =
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_docking_container IS INITIAL
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid IS INITIAL.
        CREATE OBJECT go_alv_grid
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
            i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_alv_grid is initial
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_text_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *&      Form  build_fieldcatalog
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      ls_fcat-fieldname = 'FIRMA' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Firma' .
      ls_fcat-seltext = 'Firma' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENSTELLE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Kostenstelle' .
      ls_fcat-seltext = 'Kostenstelle' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART1' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart1' .
      ls_fcat-seltext = 'Datenart1' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANJAHR' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planjahr' .
      ls_fcat-seltext = 'Planjahr' .
      APPEND ls_fcat TO pt_fieldcat .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANPERIODE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '5' .
      ls_fcat-coltext = 'Planperiode' .
      ls_fcat-seltext = 'Planperiode' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART2' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart2' .
      ls_fcat-seltext = 'Datenart2' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANUNGSPOSITION' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planungsposition' .
      ls_fcat-seltext = 'Planungsposition' .
      APPEND ls_fcat TO pt_fieldcat .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENART' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Kostenart' .
      ls_fcat-seltext = 'Kostenart' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANBETRAG' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Planbetrag' .
      ls_fcat-seltext = 'Planbetrag' .
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    "build_fieldcatalog

    I have added some more functionality to my report. The good thing is, the report works as it should.
    BUT, I'm not really sure, whether this is a good (correct) design. The report works the following way:
    1. Read planning data form text file into internal table
    2. Display the internal table
    3. Convert the data and display the converted result
    4. Post the converted data to the system
    5. Display log with messages
    The main thing is, I would like to know, do i really need two dynros, to display the two different internal tables or is it possible just to use one ALV-Grid? I was not able to find another solution. Any comment or help to the report is appreciated.
    *& Report  Z_PLAN_TEXT_UPLOAD_TEST                                     *
    REPORT z_plan_text_upload_test.
    INCLUDE <icon>.
    * Data Declaration
    DATA:
      gf_okcode TYPE ui_func,
      gf_balloghndl TYPE balloghndl.
    DATA:
      go_docking_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid_0100 TYPE REF TO cl_gui_alv_grid,
      go_alv_grid_0200 TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat LIKE LINE OF gt_fieldcat.
    TYPES:
      BEGIN OF gy_text_input,
        firma(20)            TYPE c,
        kostenstelle(20)     TYPE c,
        datenart1(10)        TYPE c,
        planjahr(10)         TYPE c,
    *    planperiode         TYPE co_perio,
        planperiode(5)       TYPE c,
        datenart2(10)        TYPE c,
        planungsposition(10) TYPE c,
    *    kostenart           TYPE koart,
        kostenart(10)        TYPE c,
    *    planbetrag          TYPE bapicurr_d,
        planbetrag(20)       TYPE c,
      END OF gy_text_input.
    DATA:
      gt_text_input TYPE TABLE OF gy_text_input,
      gs_text_input LIKE LINE OF gt_text_input.
    * Bapi Strukturen
    DATA:
      gs_headerinfo TYPE bapiplnhdr,
      gt_indexstructure TYPE TABLE OF bapiacpstru,
      gs_indexstructure LIKE LINE OF gt_indexstructure,
      gt_coobject TYPE TABLE OF bapipcpobj,
      gs_coobject LIKE LINE OF gt_coobject,
      gt_pervalue TYPE TABLE OF bapipcpval,
      gs_pervalue LIKE LINE OF gt_pervalue,
      gt_return TYPE TABLE OF bapiret2,
      gs_return LIKE LINE OF gt_return,
      gt_control TYPE TABLE OF bapipcpctrl,
      gt_totvalue TYPE TABLE OF bapipcptot.
    TYPES:
      BEGIN OF gy_bapi_input,
        version      TYPE versn,
    *    perio       TYPE co_perio,
        fisc_year    TYPE gjahr,
        coobject(10) TYPE c,
        cost_elem    TYPE kstar,
        wkgbtr01     TYPE wkgxxx,
        wkgbtr02     TYPE wkgxxx,
        wkgbtr03     TYPE wkgxxx,
        wkgbtr04     TYPE wkgxxx,
        wkgbtr05     TYPE wkgxxx,
        wkgbtr06     TYPE wkgxxx,
        wkgbtr07     TYPE wkgxxx,
        wkgbtr08     TYPE wkgxxx,
        wkgbtr09     TYPE wkgxxx,
        wkgbtr10     TYPE wkgxxx,
        wkgbtr11     TYPE wkgxxx,
        wkgbtr12     TYPE wkgxxx,
      END OF gy_bapi_input.
    DATA:
      gt_bapi_input TYPE TABLE OF gy_bapi_input,
      gs_bapi_input LIKE LINE OF gt_bapi_input.
    * Anwendungs-Log
    DATA: gs_balsmsg TYPE bal_s_msg.
    * Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1
      WITH FRAME TITLE text-001.
    PARAMETERS:
      gp_file TYPE localfile,
      gp_head TYPE checkbox DEFAULT 'X'.
    SELECTION-SCREEN SKIP.
    PARAMETERS:
      gp_kokrs  LIKE coep-kokrs,
      gp_gjahr LIKE coep-gjahr,
      gp_versn LIKE coep-versn,
      gp_test AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK b1.
    * Local Class Definition
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_toolbar_0100 FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object
            e_interactive,
        handle_user_command_0100 FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING
            e_ucomm,
        handle_toolbar_0200 FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object
            e_interactive,
        handle_user_command_0200 FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING
            e_ucomm.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    * Local Class Implementation
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD handle_toolbar_0100.
        PERFORM handle_toolbar_0100
          USING
            e_object.
    *        e_interactive.
      ENDMETHOD.                    "handle_toolbar_0100
      METHOD handle_user_command_0100.
        PERFORM handle_user_command_0100
          USING
            e_ucomm.
      ENDMETHOD.                    "handle_user_command_0100
      METHOD handle_toolbar_0200.
        PERFORM handle_toolbar_0200
          USING
            e_object.
    *        e_interactive.
      ENDMETHOD.                    "handle_toolbar_0100
      METHOD handle_user_command_0200.
        PERFORM handle_user_command_0200
          USING
            e_ucomm.
      ENDMETHOD.                    "handle_user_command_0100
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    * Initialization
    INITIALIZATION.
      DATA:
        lf_sapworkdir TYPE string.
      CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
        CHANGING
          sapworkdir            = lf_sapworkdir
        EXCEPTIONS
          get_sapworkdir_failed = 1
          cntl_error            = 2
          error_no_gui          = 3
          not_supported_by_gui  = 4
          OTHERS                = 5.
      IF sy-subrc <> 0 OR lf_sapworkdir = ''.
        CALL METHOD cl_gui_frontend_services=>directory_get_current
          CHANGING
            current_directory            = lf_sapworkdir
          EXCEPTIONS
            directory_get_current_failed = 1
            cntl_error                   = 2
            error_no_gui                 = 3
            not_supported_by_gui         = 4
            OTHERS                       = 5.
        CALL METHOD cl_gui_cfw=>flush.
      ENDIF."sy-subrc <> 0 OR sapworkdir = ''
      gp_file = lf_sapworkdir.
    * At Selection-Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
      DATA:
        lt_filetable TYPE filetable,
        ls_filetable LIKE LINE OF lt_filetable,
        lt_rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    *  EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        CHANGING
          file_table              = lt_filetable
          rc                      = lt_rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      READ TABLE lt_filetable INDEX 1
        INTO
          ls_filetable.
      gp_file = ls_filetable-filename.
      CALL METHOD cl_gui_cfw=>flush.
    * Start-Of-Selection
    START-OF-SELECTION.
      DATA:
        lf_filename LIKE filename-fileintern.
      PERFORM create_log.
      gs_return-type = 'I'.
      IF gp_test = 'X'.
        gs_return-message = text-010.
      ELSE.
        gs_return-message = text-020.
      ENDIF.
      PERFORM add_log_message_free_text
        USING
           gs_return-type
           gs_return-message.
      lf_filename = gp_file.
      CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
        EXPORTING
          i_filename                 = lf_filename
          i_servertyp                = 'PRS '
          i_fileformat               = 'TXT'
    *     I_FIELD_SEPERATOR          =
          i_line_header              = gp_head
    *   IMPORTING
    *     E_BIN_FILELENGTH           =
       TABLES
         i_tab_receiver             = gt_text_input
       EXCEPTIONS
         file_not_found             = 1
         close_failed               = 2
         authorization_failed       = 3
         open_failed                = 4
         conversion_failed          = 5
         OTHERS                     = 6.
      IF sy-subrc <> 0.
        gs_balsmsg-msgty = sy-msgty.
        gs_balsmsg-msgid = sy-msgid.
        gs_balsmsg-msgno = sy-msgno.
        gs_balsmsg-msgv1 = sy-msgv1.
        gs_balsmsg-msgv2 = sy-msgv2.
        gs_balsmsg-msgv3 = sy-msgv3.
        gs_balsmsg-msgv4 = sy-msgv4.
        PERFORM add_log_message
          USING
            gs_balsmsg.
      ENDIF.
      CALL SCREEN '0100'.
    *&      Module  status_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
            parent                      = cl_gui_container=>screen0
    *        repid                       = gf_repid
    *        dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *       EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
            ratio                       = 95
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    *------ Expand  docking container to full screen    -------------------*
        CALL METHOD go_docking_container->set_extension
          EXPORTING
            extension  = 99999  "full-screen size !!!
          EXCEPTIONS
            cntl_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.
      ENDIF."go_docking_container IS INITIAL
    *------ Link docking container to screen ------------------------------*
      CALL METHOD go_docking_container->link
        EXPORTING
          repid                       = sy-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 3
          OTHERS                      = 4
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog ---------------------------------------*
      PERFORM build_fieldcatalog_input
        CHANGING gt_fieldcat.
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid_0100 IS INITIAL.
        CREATE OBJECT go_alv_grid_0100
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
            i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_alv_grid_0100 is initial
    *------ Create instance for event handler -----------------------------*
      DATA: go_event_handler_0100 TYPE REF TO lcl_event_handler.
      CREATE OBJECT go_event_handler_0100.
    *------ Register event handler ----------------------------------------*
      SET HANDLER go_event_handler_0100->handle_toolbar_0100
        FOR go_alv_grid_0100.
      SET HANDLER go_event_handler_0100->handle_user_command_0100
        FOR go_alv_grid_0100.
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid_0100->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_text_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *---- Call method 'set_toolbar_interactive' to raise event TOOLBAR.
      CALL METHOD go_alv_grid_0100->set_toolbar_interactive.
    ENDMODULE.                 " status_0100  OUTPUT
    *&      Module  status_0200  OUTPUT
    *       text
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
            parent                      = cl_gui_container=>screen0
    *        repid                       = gf_repid
    *        dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *       EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
            ratio                       = 95
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    *------ Expand  docking container to full screen    -------------------*
        CALL METHOD go_docking_container->set_extension
          EXPORTING
            extension  = 99999
          EXCEPTIONS
            cntl_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.
      ENDIF."go_docking_container IS INITIAL
    *------ Link docking container to screen ------------------------------*
      CALL METHOD go_docking_container->link
        EXPORTING
          repid                       = sy-repid
          dynnr                       = '0200'
    *      CONTAINER                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 3
          OTHERS                      = 4
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog---------------------------------------*
      PERFORM build_fieldcatalog_bapi_input
        CHANGING
          gt_fieldcat.
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid_0200 IS INITIAL.
        CREATE OBJECT go_alv_grid_0200
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
           i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_alv_grid_0200 is initial
    *------ Create instance for event handler -----------------------------*
      DATA: go_event_handler_0200 TYPE REF TO lcl_event_handler.
      CREATE OBJECT go_event_handler_0200.
    *------ Register event handler ----------------------------------------*
      SET HANDLER go_event_handler_0200->handle_toolbar_0200
        FOR go_alv_grid_0200.
      SET HANDLER go_event_handler_0200->handle_user_command_0200
        FOR go_alv_grid_0200.
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid_0200->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_bapi_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *---- Call method 'set_toolbar_interactive' to raise event TOOLBAR.
      CALL METHOD go_alv_grid_0200->set_toolbar_interactive.
      CALL METHOD go_alv_grid_0200->refresh_table_display
    *  EXPORTING
    *    IS_STABLE      =
    *    I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 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.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = go_alv_grid_0200.
    ENDMODULE.                 " status_0200  OUTPUT
    *&      Module  user_command_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gf_okcode.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
      ENDCASE.
      CLEAR gf_okcode.
    ENDMODULE.                 " user_command_0100  INPUT
    *&      Module  user_command_0200  INPUT
    *       text
    MODULE user_command_0200 INPUT.
      CASE gf_okcode.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
      ENDCASE.
      CLEAR gf_okcode.
    ENDMODULE.                 " user_command_0200  INPUT
    *&      Form  build_fieldcatalog
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog_input
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR pt_fieldcat.
      ls_fcat-fieldname = 'FIRMA' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Firma' .
      ls_fcat-seltext = 'Firma' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENSTELLE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'CO-Objekt' .
      ls_fcat-seltext = 'CO-Objekt' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART1' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart1' .
      ls_fcat-seltext = 'Datenart1' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANJAHR' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planjahr' .
      ls_fcat-seltext = 'Planjahr' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANPERIODE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '5' .
      ls_fcat-coltext = 'Planperiode' .
      ls_fcat-seltext = 'Planperiode' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART2' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart2' .
      ls_fcat-seltext = 'Datenart2' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANUNGSPOSITION' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planungsposition' .
      ls_fcat-seltext = 'Planungsposition' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENART' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Kostenart' .
      ls_fcat-seltext = 'Kostenart' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANBETRAG' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Planbetrag' .
      ls_fcat-seltext = 'Planbetrag' .
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    "build_fieldcatalog
    *&      Form  handle_toolbar_0100
    *       text
    *      -->P_E_OBJECT  text
    *      -->P_E_INTERACTIVE  text
    FORM handle_toolbar_0100
      USING
        po_object TYPE REF TO cl_alv_event_toolbar_set.
      DATA: ls_toolbar TYPE stb_button.
      CLEAR ls_toolbar.
      ls_toolbar-butn_type  = 0.
      ls_toolbar-function   = 'KONV'.
      ls_toolbar-quickinfo  = 'Konvertieren'.
      ls_toolbar-text       = 'Konvertieren'.
      ls_toolbar-disabled   = ' '.
      APPEND ls_toolbar TO po_object->mt_toolbar.
    ENDFORM.                    " handle_toolbar_0100
    *&      Form  handle_user_command_0100
    *       text
    *      -->P_E_UCOMM  text
    FORM handle_user_command_0100
      USING
        pf_ucomm TYPE syucomm.
      CASE pf_ucomm.
        WHEN 'KONV'.
          PERFORM convert_data.
      ENDCASE.
    ENDFORM.                    " handle_user_command_0100
    *&      Form  exit_program
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM exit_program.
      CALL METHOD go_alv_grid_0100->free.
      IF NOT go_alv_grid_0200 IS INITIAL.
        CALL METHOD go_alv_grid_0200->free.
      ENDIF.
      CALL METHOD go_docking_container->free.
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc NE 0.
    * add your handling, for example
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel = sy-repid
            txt2  = sy-subrc
            txt1  = 'Error in Flush'(500).
      ENDIF.
      LEAVE PROGRAM.
    ENDFORM.                    " exit_program
    *&      Form  handle_toolbar_0200
    *       text
    *      -->P_E_OBJECT  text
    *      -->P_E_INTERACTIVE  text
    FORM handle_toolbar_0200
      USING
        po_object TYPE REF TO cl_alv_event_toolbar_set.
      DATA: ls_toolbar TYPE stb_button.
      CLEAR ls_toolbar.
      ls_toolbar-butn_type  = 0.
      ls_toolbar-function   = 'POST'.
      ls_toolbar-quickinfo  = 'Buchen'.
      ls_toolbar-text       = 'Buchen'.
      ls_toolbar-disabled   = ' '.
      APPEND ls_toolbar TO po_object->mt_toolbar.
    ENDFORM.                    " handle_toolbar_0200
    *&      Form  handle_user_command_0200
    *       text
    *      -->P_E_UCOMM  text
    FORM handle_user_command_0200
      USING
        pf_ucomm TYPE syucomm.
      CASE pf_ucomm.
        WHEN 'POST'.
          PERFORM post.
      ENDCASE.
    ENDFORM.                    " handle_user_command_0200
    *&      Form  convert_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM convert_data.
      DATA: lf_perio(3) TYPE n.
      LOOP AT gt_text_input INTO gs_text_input.
        TRANSLATE gs_text_input-planbetrag USING '. '.
        TRANSLATE gs_text_input-planbetrag USING ',.'.
        CONDENSE gs_text_input-planbetrag.
        gs_bapi_input-version   = gp_versn.
        gs_bapi_input-fisc_year = gp_gjahr.
        gs_bapi_input-coobject  = gs_text_input-kostenstelle.
        gs_bapi_input-cost_elem = gs_text_input-kostenart.
        lf_perio = gs_text_input-planperiode.
        CASE lf_perio.
          WHEN '001'.
            gs_bapi_input-wkgbtr01 = gs_text_input-planbetrag.
          WHEN '002'.
            gs_bapi_input-wkgbtr02 = gs_text_input-planbetrag.
          WHEN '003'.
            gs_bapi_input-wkgbtr03 = gs_text_input-planbetrag.
          WHEN '004'.
            gs_bapi_input-wkgbtr04 = gs_text_input-planbetrag.
          WHEN '005'.
            gs_bapi_input-wkgbtr05 = gs_text_input-planbetrag.
          WHEN '006'.
            gs_bapi_input-wkgbtr06 = gs_text_input-planbetrag.
          WHEN '007'.
            gs_bapi_input-wkgbtr07 = gs_text_input-planbetrag.
          WHEN '008'.
            gs_bapi_input-wkgbtr08 = gs_text_input-planbetrag.
          WHEN '009'.
            gs_bapi_input-wkgbtr09 = gs_text_input-planbetrag.
          WHEN '010'.
            gs_bapi_input-wkgbtr10 = gs_text_input-planbetrag.
          WHEN '011'.
            gs_bapi_input-wkgbtr11 = gs_text_input-planbetrag.
          WHEN '012'.
            gs_bapi_input-wkgbtr12 = gs_text_input-planbetrag.
        ENDCASE.
        COLLECT gs_bapi_input INTO gt_bapi_input.
        CLEAR gs_bapi_input.
      ENDLOOP. "at gt_text_input
      CALL SCREEN 0200.
    ENDFORM.                    " convert_data
    *&      Form  build_fieldcatalog_bapi_input
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog_bapi_input
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'VERSION' .
      ls_fcat-ref_table = 'BAPIPLNHDR' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'FISC_YEAR' .
      ls_fcat-ref_table = 'BAPIPLNHDR' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'COOBJECT' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'CO-Objekt' .
      ls_fcat-seltext = 'CO-Objekt' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'COST_ELEM' .
      ls_fcat-ref_table = 'BAPIPCPVAL' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR01'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR02'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR03'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR04'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR05'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR06'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR07'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR08'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR09'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR10'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR11'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR12'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    " build_fieldcatalog_bapi_input
    *&      Form  post
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM post.
      DATA:
        lf_index(6) TYPE n,
        lf_kostl    LIKE csks-kostl,
        lf_aufnr    LIKE aufk-aufnr,
        lf_kstar    LIKE cska-kstar.
      DATA:
        lt_csks TYPE TABLE OF csks.
      break c5085345.
    * Header
      gs_headerinfo-co_area       = gp_kokrs.
      gs_headerinfo-fisc_year     = gp_gjahr.
      gs_headerinfo-period_from   = '001'.
      gs_headerinfo-period_to     = '012'.
      gs_headerinfo-version       = gp_versn.
      gs_headerinfo-plan_currtype = 'C'.
      LOOP AT gt_bapi_input INTO gs_bapi_input.
    *   Fill index structure
        CLEAR gs_indexstructure.
        lf_index = sy-tabix.
        gs_indexstructure-object_index = lf_index.
        gs_indexstructure-value_index  = lf_index.
        gs_indexstructure-attrib_index = '000000'.
        INSERT gs_indexstructure INTO TABLE gt_indexstructure.
    *   Fill coobject
        CLEAR gs_coobject.
        gs_coobject-object_index = lf_index.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_bapi_input-coobject
          IMPORTING
            output = lf_kostl.
        SELECT * FROM csks INTO TABLE lt_csks
          WHERE
            kokrs = gp_kokrs AND
            kostl = lf_kostl.
        IF sy-subrc = 0.
          gs_coobject-costcenter = lf_kostl.
        ELSE.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = gs_bapi_input-coobject
            IMPORTING
              output = lf_aufnr.
          CALL FUNCTION 'K_ORDER_READ'
            EXPORTING
              aufnr     = lf_aufnr
            EXCEPTIONS
              not_found = 1.
          IF NOT sy-subrc = 0.
            gs_return-type = 'E'.
            gs_return-message+0(10)  = 'CO-Objekt '.
            gs_return-message+10(10) = gs_bapi_input-coobject.
            gs_return-message+20(20)  = ' existiert nicht.'.
            CONDENSE gs_return-message.
            PERFORM add_log_message_free_text
              USING
                gs_return-type
                gs_return-message.
            EXIT.
          ENDIF. "IF NOT sy-subrc = 0
          gs_coobject-orderid = lf_aufnr.
        ENDIF. "sy-subrc = 0
        INSERT gs_coobject INTO TABLE gt_coobject.
    *   Period value
        gs_pervalue-value_index = lf_index.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_bapi_input-cost_elem
          IMPORTING
            output = lf_kstar.
        gs_pervalue-cost_elem = lf_kstar.
        gs_pervalue-fix_val_per01 = gs_bapi_input-wkgbtr01.
        gs_pervalue-fix_val_per02 = gs_bapi_input-wkgbtr02.
        gs_pervalue-fix_val_per03 = gs_bapi_input-wkgbtr03.
        gs_pervalue-fix_val_per04 = gs_bapi_input-wkgbtr04.
        gs_pervalue-fix_val_per05 = gs_bapi_input-wkgbtr05.
        gs_pervalue-fix_val_per06 = gs_bapi_input-wkgbtr06.
        gs_pervalue-fix_val_per07 = gs_bapi_input-wkgbtr07.
        gs_pervalue-fix_val_per08 = gs_bapi_input-wkgbtr08.
        gs_pervalue-fix_val_per09 = gs_bapi_input-wkgbtr09.
        gs_pervalue-fix_val_per10 = gs_bapi_input-wkgbtr10.
        gs_pervalue-fix_val_per11 = gs_bapi_input-wkgbtr11.
        gs_pervalue-fix_val_per12 = gs_bapi_input-wkgbtr12.
        INSERT gs_pervalue INTO TABLE gt_pervalue.
      ENDLOOP. "at gt_bapi_input
    * Buchungsbaustein
      CALL FUNCTION 'BAPI_PRIM_COST_CHECK_AND_POST'
        EXPORTING
          header_info         = gs_headerinfo
          testrun             = gp_test
    *   DELTA               = ' '
        TABLES
          idx_structure       = gt_indexstructure
          object              = gt_coobject
          per_value           = gt_pervalue
          tot_value           = gt_totvalue
          contrl              = gt_control
          return              = gt_return.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    *   EXPORTING
    *     WAIT          =
    *   IMPORTING
    *     RETURN        =
      LOOP AT gt_return INTO gs_return.
        gs_balsmsg-msgty = gs_return-type.
        gs_balsmsg-msgid = gs_return-id.
        gs_balsmsg-msgno = gs_return-number.
        gs_balsmsg-msgv1 = gs_return-message_v1.
        gs_balsmsg-msgv2 = gs_return-message_v2.
        gs_balsmsg-msgv3 = gs_return-message_v3.
        gs_balsmsg-msgv4 = gs_return-message_v4.
        PERFORM add_log_message
          USING
            gs_balsmsg.
      ENDLOOP. "AT gt_return
      PERFORM show_log.
    ENDFORM.                    " post
    *&      Form  create_log
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_log .
      DATA: ls_balslog TYPE bal_s_log.
    * Einige Verwaltungsdaten
      ls_balslog-extnumber = 'ZPLAN010'.
      ls_balslog-aluser    = sy-uname.
      ls_balslog-alprog    = sy-repid.
    * Create
      CALL FUNCTION 'BAL_LOG_CREATE'
        EXPORTING
          i_s_log                 = ls_balslog
    *    IMPORTING
    *      e_log_handle            = gf_balloghndl
        EXCEPTIONS
          log_header_inconsistent = 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.                    " create_log
    *&      Form  add_log_message
    *       text
    *      -->P_GS_BALSMSG  text
    FORM add_log_message
      USING
        ps_balsmsg TYPE bal_s_msg.
      break c5085345.
      CALL FUNCTION 'BAL_LOG_MSG_ADD'
        EXPORTING
    *       I_LOG_HANDLE              =
          i_s_msg                   = ps_balsmsg
    *     IMPORTING
    *       E_S_MSG_HANDLE            =
    *       E_MSG_WAS_LOGGED          =
    *       E_MSG_WAS_DISPLAYED       =
       EXCEPTIONS
         log_not_found             = 1
         msg_inconsistent          = 2
         log_is_full               = 3
         OTHERS                    = 4.
      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.                    " add_log_messa
    *&      Form  add_log_message_free_text
    *       text
    *      -->P_GS_RETURN_TYPE  text
    *      -->P_GS_RETURN_MESSAGE  text
    FORM add_log_message_free_text
      USING
        ps_type
        ps_message.
      CALL FUNCTION 'BAL_LOG_MSG_ADD_FREE_TEXT'
        EXPORTING
    *       I_LOG_HANDLE              =
          i_msgty                   = ps_type
    *       I_PROBCLASS               = '4'
          i_text                    = ps_message
    *       I_S_CONTEXT               =
    *       I_S_PARAMS                =
    *     IMPORTING
    *       E_S_MSG_HANDLE            =
    *       E_MSG_WAS_LOGGED          =
    *       E_MSG_WAS_DISPLAYED       =
       EXCEPTIONS
         log_not_found             = 1
         msg_inconsistent          = 2
         log_is_full               = 3
         OTHERS                    = 4.
      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.                    " add_log_message_free_text
    *&      Form  show_log
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM show_log .
      DATA:
        l_s_display_profile TYPE bal_s_prof.
    * get display profile
      CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
        IMPORTING
          e_s_display_profile = l_s_display_profile
        EXCEPTIONS
          OTHERS              = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    * use grid for display if wanted
      l_s_display_profile-use_grid = 'X'.
    * set report to allow saving of variants
      l_s_display_profile-disvariant-report = sy-repid.
    * when you use also other ALV lists in your report,
    * please specify a handle to distinguish between the display
    * variants of these different lists, e.g:
      l_s_display_profile-disvariant-handle = 'LOG'.
    * call display function module
    * We do not specify any filter (like I_S_LOG_FILTER, ...,
    * I_T_MSG_HANDLE) since we want to display all logs available
      CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
        EXPORTING
          i_s_display_profile = l_s_display_profile
        EXCEPTIONS
          OTHERS              = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  • F4 help for field in ALV grid control (using ABAP objects)

    Hi All,
        I have created a z table ZTAB which is a master table( with single column X). field X should be a input field in ALV Grid through F4 key. I have created searchelp and assigned it to data element of X feild, and in domain level I have assigned ZTAB as value table.
        And in ALV field catalog wrote ls_fcat-ref_tab = 'ZTAB'. But still I'm not getting list of values when I press F4.
    Can anyone help me to understand what is missing here? How to call standardard F4 help?
    This is very urgent..
    Regards
    Jaker.

    u can refer to this standard program :BCALV_EDIT_08
    also u wont get the list of values automatically..
    declare a class :
    CLASS LCL_EVENT_HANDLER DEFINITION.
      PUBLIC SECTION.
        METHODS :
        handle_on_f4 for event onf4 of cl_gui_alv_grid
        importing e_fieldname es_row_no er_event_data,
    ENDCLASS.               "LCL_EVENT_HANDLER
    implementation of class
    here u pass ur internal table what u want to display as pop up for f4 help.
    *&       Class (Implementation)  LCL_EVENT_HANDLER
           Text
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Method to handle F4 click.
      Method handle_on_f4.
    Function to create a popup and passing the values of internal table in it.
          CALL FUNCTION 'POPUP_WITH_TABLE'
            EXPORTING
              ENDPOS_COL   = 60
              ENDPOS_ROW   = 60
              STARTPOS_COL = 5
              STARTPOS_ROW = 5
              TITLETEXT    = 'pop up'
            IMPORTING
              CHOICE       = wa_grid-zfield
            TABLES
              VALUETAB     = ITAB
            EXCEPTIONS
              BREAK_OFF    = 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.
            RETURN.
          ENDIF.
      endmethod.                    "handle_on_f4
    ENDCLASS.               "LCL_EVENT_HANDLER
    hope this gives u some idea.

Maybe you are looking for

  • Printer Queue - How can I hide print job title and username?

    Hi, Does anyone know if it is possible to hide print job title and username in the printerqueue? Because of our privacy agreement we would like to hide this information,  Workstation OS: Windows 7 x64  Printserver : MS 2008 R2 Thanks in advance Mark

  • Trouble Installing Windows 2012 R2 (Windows can't be installed on this drive)

    <p>I "binged" this error message and it seems to be beaten to death but my problem is not resolved. Basically, Im trying to install 2012 R2 on a server which currently also has CentOS6.3. Im not doing a dual boot and I want only Windows 2012.</p><p>D

  • Grub2 problem with BIOS-GPT

    I have just installed arch linux following this part of wiki https://wiki.archlinux.org/index.php/Dm - VM_on_LUKS (also for partitioning made with cgdisk). I havn't find any problem untill i have rebooted the machine. My pc can't find the bootloader

  • Flickr sets not synchronizing with Aperture

    I have been using Aperture successfully to upload to my Flickr account for some time, but today I have been unable to upload images to a set. Curiously however, I can upload to my Photostream directly. I can use Flickr to move those items into a set,

  • App Store Log In Error

    Can anyone assist me in overcoming the following error when I attempt to sign in: Your device or computer could not be verified. Contact support for assistance.