Editable ALV-No change in internal table

Hello Experts,
   I have an ALV output, in which I have a column as editable. I have generated the output using 'REUSE_ALV_GRID_DISPLAY'. I got to know that after changing the editable cell's value, if we double click the cell or if operate with any PF-status  components, the value will automatically get changed in internal table also. For double click I am getting the expected result. But If I click a button the value doesn't get changed in internal table. Is there any other change I have to do for this. If I have checkbox in ALV will it be rectified. But my requirement is when I click the button only It has to be modified in the database table.
Thanks and regards,
Venkat.

Hi Venkat,
In your form for User Command
write following
DATA ref1 TYPE REF TO cl_gui_alv_grid.
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = ref1.
      CALL METHOD ref1->check_changed_data.
Case 'User-Command'.
Endcase.
or
data : i_grid_settings type lvc_s_glay.
"Calling ALV grid for display
call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      i_callback_program             = sy-repid
      i_callback_user_command   = i_callback_user_command
      i_grid_settings                    = i_grid_settings
      is_layout                            = is_layout
      it_fieldcat                           = it_fieldcat
    tables
      t_outtab                             = it_final
"for call back values from editable grid cells
  i_grid_settings-edt_cll_cb = 'X'.
Hope it helps you,
Pratik

Similar Messages

  • How to Transfer Data from editable ALV grid control to internal table?

    Hi,
    Can anyone give me a simple example by which I can transfer data from editable alv grid control back to the internal table. The ALV has been created by OO approach.
    I would appreciate if the solution is provided without handling any events.
    Regards,
    Auro

    Hello Auro
    You simply need to call method <b>go_grid->check_changed_data</b> at PAI of the dynpro displaying the ALV grid. If data have been changed on the editable ALV grid then this method will raise event DATA_CHANGED. If you do not want or need to handle this event (e.g. for validating the edited values) then you do not define any event handler method.
    Regards
      Uwe

  • Display ALV GRID Using Dynamic Internal Table

    Hi all,
    I try to display ALV Grid using Dynamic Internal Table, but when i activate my program, i get an error message "DYN_TABLE" is not type-compatible with formal parameter "IT_OUTTAB". ( DYN_TABLE is my Dynamic Itab).
    Anybody can help me how to passing Dynamic Itab into ALV Grid ?? Of ALV Grid only accept static Itab ??
    Thanks,

    Hi Vijay,
    It's doesn't work, and make new error "Formal parameter "IT_OUTTAB[]" does not exist. However, the parameter "IT_OUTTAB" has a similar name."
    Because the method is:
    CALL METHOD <ref. var. to CL_GUI_ALV_GRID>->set_table_for_first_display
    EXPORTING
    I_BUFFER_ACTIVE = <any type (ANY)>
    I_STRUCTURE_NAME = <string of type DD02L-TABNAME>
    IS_VARIANT = <structure of type DISVARIANT>
    I_SAVE = <var. of type CHAR01>
    I_DEFAULT = <var. of type CHAR01>
    IS_LAYOUT = <structure of type LVC_S_LAYO>
    IS_PRINT = <structure of type LVC_S_PRNT>
    IT_SPECIAL_GROUPS = <internal table of type LVC_T_SGRP>
    IT_TOOLBAR_EXCLUDING = <internal table of type UI_FUNCTIONS>
    IT_HYPERLINK = <internal table of type LVC_T_HYPE>
    IT_ALV_GRAPHICS = <internal table of type DTC_T_TC>
    CHANGING
    IT_OUTTAB = <internal table>
    IT_FIELDCATALOG = <internal table of type LVC_T_FCAT>
    IT_SORT = <internal table of type LVC_T_SORT>
    IT_FILTER = <internal table of type LVC_T_FILT>
    Thanks,

  • Problem in changing the internal table contents of a standard program

    Dear All,
    I am making changes to internal table LT_PPDIT of standard program SAPLHRPT in the user exit EXIT_SAPLACC4_001 while payroll posting to accounting with tcode PC00_M99_CIPE. But though the changed value of LT_PPDIT is visible within the exit still the value of LT_PPDIT when we come outside exit is the same as what was before entering exit.
    Please suggest is there any way of modifying internal table of a standard program in the user exit.
    Regards,
    Kanupriya

    Hi,
    I think the internal table is getting refreshed or something like that after the user exit.
    Try debugging after the user exit and put breakpoints at clear and modify statements.
    Then you ll find out where its regaining the oringinal value after getting changes.
    After locating that point try finding some enhancmenent point there and including your code so that your value of internal able gets modified.
    Regards,
    Subhashini

  • ALV - Reflect layout change into internal table

    I have an ALV :
    CALL METHOD grid1->set_table_for_first_display
                EXPORTING I_STRUCTURE_NAME = 'Z_ALV_STRUCTURE_01'
                          IS_VARIANT = GS_VARIANT
                          I_SAVE = X_SAVE
                CHANGING IT_OUTTAB = itab
                         IT_FIELDCATALOG = gt_fieldcat_lvc1[].
    This internal table itab has for example the fields: matnr, plant, stock, vendor
    If for example the user changes the sequence of the columns in the ALV grid display into: stock, plant, vendor, matnr
    Is there an easy way to get the layout change reflected in my internal table or is the only possibility to built dynamically a new internal table based on the front end field catalog?
    Kind regards
    Frank

    Hi
    Can't u use the std icone to create an excel file?
    Anyway in this case you should use the method get_frontend_fieldcatalog in order to get the status of the catalog and so fill the table for the excel in the right way.
    I believe the problem should be on how to create the table for the excel, i.e. you need to consider the sequence of the fields in ordert to create the table for the excel.
    Max

  • Rows missing in ALV output compared to internal table (was "ALV issue")

    Hi guys,
    I am getting an ALV for 70 rows whereas the internal table I am passing has 120 rows.
    Any idea why I could be facing this issue.Has anyone ever faced something similar?
    Thanks,
    Chirantan
    Moderator message: please use more descriptive subject lines for your posts.
    Edited by: Thomas Zloch on May 9, 2011 9:51 AM

    BY default, maximum number of coulmns displayed in ALV is 90.
    You can increase it by setting the parameter NO_OUT as initial for the remaining fields in their field catalog.
    Please check below sample code:
    "Build Field catalog using structure of QALS
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = sy-repid
          i_structure_name       = 'QALS'
        CHANGING
          ct_fieldcat            = g_t_fcat   " Internal table contains more than 90 fields
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
    "Only first 90 fields will be displayed in output. So, set NO_OUT as initial for remaining fields.
    LOOP AT g_t_fcat INTO g_r_fcat WHERE no_out = 'X'.
      g_r_fcat-no_out = ''.   " Set NO_OUT as initial
      MODIFY g_t_fcat FROM g_r_fcat INDEX sy-tabix TRANSPORTING no_out.
    ENDLOOP.

  • Really urgent: reagrding alv format for like (internal tables)

    Hi,
    I making a report in which i am using the concept of 2 internal tables and i am usnig the concept of likes in a internal table .
    for instance,
    DATA : BEGIN OF ITAB OCCURS 0,
              ITEMID LIKE CHVW-MATNR,      
              WERKS LIKE CHVW-WERKS,   
              CHARG LIKE CHVW-CHARG,       
              SHKZG LIKE CHVW-SHKZG,       
              MENGE LIKE CHVW-MENGE,     
              MEINS LIKE CHVW-MEINS, 
    END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 0,
               MATNR TYPE BSEG-MATNR,  
               LIFNR TYPE BSEG-LIFNR,       
               AUGDT TYPE BSEG-AUGDT,     
               WRBTR TYPE BSEG-WRBTR,      
             END OF IT_BSEG.
    and i am able to create ALV for 1 itab only as i had declared all fields in a 1 itab ,but now i have to declare 1 more itab and i  dont know how to perform ALV with 2 itabs..
    Plzz help me out as it is really urgent to me.
    Edited by: ric .s on Apr 22, 2008 11:45 AM
    Edited by: ric .s on Apr 23, 2008 7:21 AM
    Edited by: ric .s on Apr 23, 2008 7:55 AM

    Hi Ric,
    Yes, You can .
    Check the sample ALV  program which helps u in displaying output using ALV . Comments have been made everywhere .
    report  zvenkat_alv_2_grid_description.
    types:
          begin of t_mard,
           werks type mard-werks,
           lgort type mard-lgort,
           matnr type mard-matnr,
           insme type mard-insme,
           einme type mard-einme,
           speme type mard-speme,
          end of t_mard.
    data:
          w_mard type t_mard.
    data:
          i_mard type standard table of t_mard.
    " ALV Declarations
    "     ALV internal tables and Structures
    "     To refer ALV tables(slis tables) and structures.SLIS must be
    "     declared under TYPE-POOLS(see below).SLIS is a Type group which is
    "     defined in Dictionary.Internal tables and structures and constants
    "     are defined under type group.(Double click on SLIS).
    * Types Pools
    type-pools:
       slis.
    * Types
    types:
       t_fieldcat         type slis_fieldcat_alv,
       t_events           type slis_alv_event,
       t_layout           type slis_layout_alv.
    * Workareas
    data:
       w_fieldcat         type t_fieldcat,
       w_events           type t_events,
       w_layout           type t_layout.
    * Internal Tables
    data:
       i_fieldcat         type standard table of t_fieldcat,
       i_fieldcat1        type standard table of t_fieldcat,
       i_events           type standard table of t_events.
    *&      START-OF-SELECTION
    start-of-selection.
      perform get_data_from_database .
      "      END-OF-SELECTION
      "     Steps to create simple ALV program
      "      1. Pass an internal table with the set of output information
      "      2. Pass a field catalog as an internal table
      "      3. Pass a structure with general list layout details
    end-of-selection.
      perform build_fieldcatalog.
      perform build_events.
      perform build_layout.
      perform display_data.
      "      Form  build_fieldcatalog
      "     Fieldcatalog Internal table
      "    1. It contains descriptions of the list output fields
      "       (usually a subset of the internal output table fields).
      "    2. A field catalog is required for every ALV list output.
    form build_fieldcatalog .
      clear :
        w_fieldcat,
       i_fieldcat[].
      perform build_fcat using:
            "Field   Int.Table Column headings
            'WERKS' 'I_MARD' 'WERKS',
            'LGORT' 'I_MARD' 'LGORT',
            'MATNR' 'I_MARD' 'MATNR',
            'INSME' 'I_MARD' 'INSME',
            'EINME' 'I_MARD' 'EINME',
            'SPEME' 'I_MARD' 'SPEME'.
    endform.                    " build_fieldcatalog
    *&      Form  display_data
    form display_data .
      data :program like sy-repid value sy-repid.
      call function 'REUSE_ALV_LIST_DISPLAY'
        exporting
          i_callback_program = program
          is_layout          = w_layout
          it_fieldcat        = i_fieldcat
          it_events          = i_events
        tables
          t_outtab           = i_mard.
      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_data
    *&      Form  get_data_from_database
    *       text
    form get_data_from_database .
      clear :i_mard,
             i_mard[].
      select werks lgort matnr insme einme speme
      from mard
      into corresponding fields of table i_mard
        up to 100 rows.
    endform.                    " get_data_from_database
    *&      Form  top_of_page
    *       text
    form top_of_page.
      data :
      i_header type slis_t_listheader,
      w_header like line of i_header.
      data:l_date1 type datum,
           l_date2 type datum.
      w_header-typ = 'S'.
      w_header-info = sy-title.
      append w_header to i_header.
      clear w_header.
      w_header-typ = 'H'.
      w_header-info = sy-repid.
      append w_header to i_header.
      clear w_header.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary = i_header
          i_logo             = 'ENJOYSAP_LOGO'.
    endform.                    "top_of_page
    *&      Form  BUILD_FCAT
    form build_fcat  using  l_field l_tab l_text.
      w_fieldcat-fieldname = l_field.
      w_fieldcat-tabname   = l_tab.
      w_fieldcat-seltext_m = l_text.
      append w_fieldcat to i_fieldcat.
      clear w_fieldcat.
    endform.                    " BUILD_FCAT
    "      Form  build_events
    "     Events
    "    1. When we use ALV,certain events TOP-OF-PAGE ,END-OF-PAGE,
    "       AT LINE-SELECTION,AT USER-COMMANDs are not triggered.
    "    2. To perform those Functions ,we have to build Events table and
    "       pass this table through REUSE_ALV_LIST_DISPALY Function.
    form build_events .
      clear :
             w_events,i_events[].
      w_events-name = 'TOP_OF_PAGE'.
      w_events-form = 'TOP_OF_PAGE'.
      append w_events to i_events.
      clear w_events.
    endform.                    " build_events
    "&      Form  build_layout
    "     Layouts
    "  Use :We change the display of our list using layouts.
    "  ===
    "  Features
    "  ========
    "    The layouts that you can use vary according to the type of list:
    "   1-->In all lists, you can do the following:
    "       (a).Choose one of the std layouts supplied with the std system.
    "       (b).Change the current layout of the list .
    "   2-->In lists that use only the standard layouts in the std system
    "       you cannot save your changes to the current layout.When you
    "       choose the layouts, only the standard layouts will be proposed.
    "   3-->In some lists, you can also save the layouts that you have
    "       defined as our own layouts.
    "      User-defined layouts are generally saved for all users. They can
    "       then be used by all users. All users will be able to choose from
    "       the user-defined layouts as well as the standard layouts.
    "   4-->In some lists, you can also save user-specific layouts that you
    "       have defined . When you choose the current layout,only these
    "       layouts are available to you.
    "   5-->You can delete or transport layouts, or define them as initial
    "       layouts
    "   6-->STRUCTURE :SLIS_LAYOUT_ALV.
    form build_layout .
      clear:
            w_layout.
      w_layout-colwidth_optimize = 'X'.
    endform.                    " build_layout
    Regards,
    Venkat.O

  • Editable ALV -- OO -- Changed data capture

    Hi,
    I'm using an editable ALV to display the output. Output has a field for the user to enter comments. When the user enters the comments and presses "ENTER" key or clicks somewhere else on the ALV itself, the event DATA_CHANGED or DATA_CHANGED_FINISHED gets triggered and I'm able to capture the changed data and update the DB table.(I have a "SAVE" button on the menu bar which when pressed will update the ALV values into DB table.)
    However, I need to capture this changed data even if the user does not press the "ENTER" key or clicks somewhere else on the ALV, but just presses the "SAVE" button.  Please let me know if there is any way to do this.
    Thanks,
    Raj.

    Hi,
    in your program check the user-command if 'SAVE' then write the following code in it
    "Call the method check_changed_data to update the  internal table with changed data.
    DATA: lv_valid TYPE xfeld,
                lv_refresh TYPE xfeld.
          CALL METHOD gv_alv_grid->check_changed_data
            IMPORTING
              e_valid   = lv_valid
            CHANGING
              c_refresh = lv_refresh.
    " to refresh alv
    CALL METHOD gv_alv_grid->refresh_table_display
            EXCEPTIONS
              finished = 1
              OTHERS   = 2.
    by this way it the internal table will get the changed data and then you can update it in the DB and also after updating show the ALV since it is refreshed it will now show the changed data.
    Hope it helps you,
    Regards,
    Abhijit G. Borkar

  • Error while uploading an edited excel file into an internal table

    Hi Experts,
    I am getting error while uploading an excel file that has been edited.
    I am using GUI_UPLOAD for uploading the file into internal table.
    In my program I first have to download a file, if I use the same file without editing I am able to read the file.
    When I try to edit it and then use it to upload it fails, but this is part of the my requirement.
    PLease suggest.
    Regards
    Kishore

    TYPE-POOLS: truxs.
    parameter :    lv_full_path     TYPE rlgrap-filename,
    data : lt_conv_data   TYPE truxs_t_text_data,
              lt_roles_excel   type table of ( your structure).
    start-of-selection.
            CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
              EXPORTING
                i_line_header        = 'X'
                i_filename           = lv_full_path
              TABLES
                i_tab_sap_data       = lt_roles_excel
              CHANGING
                i_tab_converted_data = lt_conv_data
              EXCEPTIONS
                conversion_failed    = 1
                OTHERS               = 2.
    In the FM Line_header = 'X' means it will negelect the first line. So u can give the heading in the excel file.
    Hope this might help u .
    With Regards,
    Sumodh.P

  • SAP query change the internal table extracted after a join instruction

    Hi Gurus
    I would like to know if it is possible to change the data in internal table after that the
    join instruction has been executed .
    I should have to delete some lines extracted if some conditions are satisfied.
    Do you think that it is not possible and it is better to crete a program?
    Thanks in advance

    HI,
    use select and end select.
    select single msegbukrs msegwerks msegmatnr msegmenge msegaufnr msegsmbln msegbwart msegshkzg mseg~meins
             afkorsnum afpoverid
             maststlnr maststlal stpoidnrk stpomenge stpomeins stkobmeng
         into (itab-mblnr,
               itab-budat,
               itab-bktxt,
               itab-bukrs,
               itab-werks,
               itab-matnr,
               itab-menge,
               itab-aufnr,
               itab-smbln,
               itab-bwart,
               itab-shkzg,
               itab-meins,
               itab-rsnum,
               itab-verid,
               itab-stlnr,
               itab-stlal,
               itab-matnr_r,
               itab-bdmng,
               itab-meins_r,
               itab-bmeng)
         from mkpf
         inner join mseg on msegmblnr eq mkpfmblnr and mkpfmjahr eq msegmjahr
         inner join mara on maramatnr eq msegmatnr
         inner join afpo on afpoaufnr eq msegaufnr
         inner join mast on mastmatnr eq msegmatnr and mastwerks eq msegwerks
         inner join afko on afkoaufnr eq msegaufnr and afkostlal eq maststlal
         inner join stko on stkostlnr eq maststlnr and stkostlal eq maststlal
         inner join stpo on stpostlnr eq stkostlnr
         inner join stas on stasstlnr eq maststlnr and stasstlal eq maststlal and stasstlkn eq stpostlkn
         where mseg~werks in s_werks
         and mseg~matnr in s_matnr
         and mkpf~budat in s_budat
         and mseg~aufnr in s_aufnr
         and mseg~bwart eq '101'
         and mast~stlan eq '1'
         and stko~stlty eq 'M'
         and stpo~stlty eq 'M'.
    if condtion .
        append: itab.
    endif.
        clear: itab.
      endselect.
    Edited by: ZAHID HAMEED on Oct 12, 2011 3:56 PM

  • Coloring an ALV Cell with DYNAMIC INTERNAL TABLES

    Hello Gurus,
    I need your help regarding coloring of a cell in my ALV Grid report with DYNAMIC tables.
    I have used the call method in calling my ALV. (CALL METHOD gr_alvgrid->set_table_for_first_display).
    Now my problem is, I can not bring out the cellcolor succesfully, I always ended up to dump (GETWA_NOT_ASSIGNED = You attempted to access an unassigned field symbol     
    (data segment 32807).                                  
    What I have done:
    I've created 2 internal tables:
    *1st table
    *After appended all of my columns to  gt_fieldcat
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = gt_fieldcat
        IMPORTING
          ep_table        = gp_both.
      ASSIGN gp_both->* TO <i_xtab1>.
    *2nd table
    Appended these column for CellColor
      CLEAR wa_gtfldcat.
      wa_gtfldcat-fieldname = 'CELLCOLOR'.
      wa_gtfldcat-ref_table = 'CALENDAR_TYPE'.
      wa_gtfldcat-ref_field = 'COLTAB'.
      APPEND wa_gtfldcat TO gt_fieldcat.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = gt_fieldcat
        IMPORTING
          ep_table        = gp_alvgrid.
      ASSIGN gp_alvgrid->* TO <i_xtab2>.
    *Work Areas for tab1 and tab2
    CREATE DATA dref1 LIKE LINE OF <i_xtab1>.
      ASSIGN dref1->* TO <wa_xtab1>.
      CREATE DATA dref2 LIKE LINE OF <i_xtab2>.
      ASSIGN dref2->* TO <wa_xtab2>.
    *Move contents of table1 to table2 and modify cellcolor column
    LOOP AT <i_xtab1> ASSIGNING <wa_xtab1>.
    *-----Cell color assignment
        DESCRIBE TABLE gt_fieldcat.
        DO sy-tfill TIMES.
          READ TABLE gt_fieldcat INTO wa_gtfldcat INDEX sy-index.
          ASSIGN COMPONENT wa_gtfldcat-fieldname
            OF STRUCTURE <wa_xtab1> TO <fs4>.
          IF sy-subrc NE 0. EXIT .ENDIF.
          ASSIGN COMPONENT wa_gtfldcat-fieldname
            OF STRUCTURE <wa_xtab2> TO <fs3>.
          IF sy-subrc NE 0. EXIT .ENDIF.
            <fs3> = <fs4>.
        ENDDO.
        ASSIGN COMPONENT 'CELLCOLOR' OF STRUCTURE <wa_xtab2> TO <fs3>.
        IF sy-subrc = 0.
          PERFORM modify_cell_color USING 'ZZMATNR' <fs3>.
        ENDIF.
        APPEND <wa_xtab1> TO <i_xtab2>.
    ENDLOOP.
    *Call ALV
    gs_layout-ctab_fname = 'COLORCELL'
        CALL METHOD gr_alvgrid->set_table_for_first_display
          EXPORTING
            is_layout                     = gs_layout
          CHANGING
            it_outtab                     = <i_xtab2d>[]
            it_fieldcatalog               = gt_fieldcat
            it_sort                       = lt_sort
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.
        IF sy-subrc <> 0.
    *--->Exception handling
        ENDIF.
    FORM modify_cell_color  USING p_fieldname   TYPE lvc_fname
                                  pt_cellcolor  TYPE table.
      DATA l_cellcolor TYPE lvc_s_scol.
      CLEAR l_cellcolor.
      l_cellcolor-fname = p_fieldname.
      l_cellcolor-color-col = 6.       " Red.
      l_cellcolor-color-int = 0.
      l_cellcolor-color-inv = 0.
      INSERT l_cellcolor INTO TABLE pt_cellcolor.
    ENDFORM.                    " MODIFY_CELL_COLOR

    Hi,
    The internal tabl which you are using to display the output should have one column in the end.
    The cell in this column will contain an internal table of type 'lvc_s_scol'.
    The contents of this internal table will be the field names of all other columns of your main internal table in the field FNAME and the required color in the field COLOR.
    Please note that the field COLOR will have a hex value for different colors.
    In the stucture is_layout  whihc you pass to the method 'set_table_for_first_display'
    the name of this last column should be given to the field 'ctab_fname'.
    This will help you to give the colors to each cell.
    for example
    I have my data table as follows:-
    ITAB1
    MATNR  MAKTX        COLOR_TAB
    1           ABC            FNAME  COLOR  NOKEYCOL
                                    MATNR 8000
                                    MAKTX 8000
    2          XYZ             MATNR 10000
                                  MAKTX  10000
    So my internal table ITAB1 had 3 columns MATNR MAKTX and COLOR_TAB.
    And COLOR_TAB will contain an internal table with 3 columns FNAME COLOR and NOKEYCOL.
    The value to importing parameter IS_LAYOUT-CTAB_FNAME will be COLOR_TAB.
    This will help you to assign various colors to the cell of the internal table ITAB.
    When you have to change any color, then you will have to just change the entries in cell COLOR_TAB for the particular row and cell.
    Regards,
    Ankur Parab

  • ALV reprot With four internal tables

    Hi all,
    Could any one please tell what is function module we have to use for displaying four internal tables in a single ALV REPORT.
    Thanks & regards
    Vardhan

    This is the code for displaying ALV using containers.. u need to create 4 containers in one screen and need to display data...
    I would suggest you to get all the data into one internal table and display.. for more clarity u can give diff colors for diff table data using field catalog..
                                        *& Report  ZTRPSD110                                                   *
                                        * TITLE: Statement of Export Report for Tata Tetley                    *
                                        * PURPOSE:Statement of Export Report for Tata Tetley                   *
                                        * A. Start-of-selection:                                               *
                                        * 1. In get_billing_data using the selection screen parameters get the *
                                        *     billing data from billing header(VBAK) and Item (VBAP)           *
                                        * 2.  Get the SHIP-TO partner data from VBPA using Customer number as  *
                                        *     one condition and store in it_vbpa_sh
                                        * 9.  Popultae the ALV display table
                                        * B. End-of-selection:
                                        *    Call screen 9000 and display data in ALV
                                        REPORT  ztrps110  MESSAGE-ID zttl  LINE-SIZE 130.
                                                                                    TABLES: vbrk.
                                                                                    * CONSTANTS
                                        CONSTANTS :
                                        c_x(1)        TYPE c VALUE 'X',
                                        c_zxto        TYPE vbak-auart VALUE 'ZXTO',
                                        c_e           TYPE spras VALUE 'E',
                                        c_000000      TYPE posnr VALUE '000000',
                                        c_ship_to     TYPE parvw VALUE 'WE'.      "Ship To Party
                                                                                    * Table Types
                                        TYPES: BEGIN OF ty_vbrk_vbrp,
                                        vbeln TYPE vbrk-vbeln,    "Billing doc
                                        posnr TYPE vbrp-posnr,    "Billing item
                                        aubel TYPE vbrp-aubel,    "Sales order
                                        waerk TYPE vbrk-waerk,    "Doc currency
                                        mvgr1 TYPE vbrp-mvgr1,    "Material group 1
                                        mvgr3 TYPE vbrp-mvgr3,    "Material group 3
                                        mvgr4 TYPE vbrp-mvgr4,    "Material group 4
                                        matnr TYPE vbrp-matnr,    "Material no
                                        ntgew TYPE vbrp-ntgew,    "Net wt
                                        gewei TYPE vbrp-gewei,    "Wt unit
                                        kzwi1 TYPE vbrp-kzwi1,                             "Subtotal 1
                                        kursk TYPE vbrp-kursk,    "Exchange rate
                                        END   OF ty_vbrk_vbrp.
                                                                                    TYPES: BEGIN OF ty_data,
                                        land1 TYPE vbpa-land1,
                                        landx TYPE t005t-landx,
                                        mvgr3 TYPE vbrp-mvgr3,
                                        mvgr4 TYPE vbrp-mvgr4,
                                        bezei3 TYPE tvm3t-bezei,
                                        bezei4 TYPE tvm4t-bezei,
                                        ntgew_tea_bag TYPE vbrp-ntgew,
                                        ntgew_pkt_tea TYPE vbrp-ntgew,
                                        ntgew_bulk_tea TYPE vbrp-ntgew,
                                        kzwi1_tea_bag TYPE vbrp-kzwi1,    "Subtotal 1 Tea Bag
                                        kzwi1_pkt_tea TYPE vbrp-kzwi1,    "Subtotal 1 Pkt Tea
                                        kzwi1_bulk_tea TYPE vbrp-kzwi1,   "Subtotal 1 Bulk Tea
                                        ntgew_tot TYPE vbrp-ntgew,
                                        kzwi1_tot TYPE vbrp-kzwi1,
                                        line_color(4) TYPE c,  "For line color
                                        END OF ty_data.
                                        TYPES: BEGIN OF ty_vbpa,
                                        vbeln TYPE vbpa-vbeln,
                                        land1 TYPE vbpa-land1,
                                        END OF ty_vbpa.
                                        TYPES: BEGIN OF ty_t005t,
                                        land1 TYPE t005t-land1,
                                        landx TYPE t005t-landx,
                                        END OF ty_t005t.
                                        TYPES: BEGIN OF ty_tvm3t,
                                        mvgr3 TYPE tvm3-mvgr3,
                                        bezei TYPE tvm3t-bezei,
                                        END OF ty_tvm3t.
                                        TYPES: BEGIN OF ty_tvm4t,
                                        mvgr4 TYPE tvm4-mvgr4,
                                        bezei TYPE tvm4t-bezei,
                                        END OF ty_tvm4t.
                                                                                    DATA: it_vbrk_vbrp TYPE STANDARD TABLE OF ty_vbrk_vbrp,
                                        wa_vbrk_vbrp TYPE ty_vbrk_vbrp,
                                        it_vbpa TYPE STANDARD TABLE OF ty_vbpa,
                                        wa_vbpa TYPE ty_vbpa,
                                        it_data TYPE STANDARD TABLE OF ty_data,
                                        wa_data TYPE ty_data,
                                        it_t005t TYPE STANDARD TABLE OF ty_t005t,
                                        wa_t005t TYPE ty_t005t,
                                        it_tvm3t TYPE STANDARD TABLE OF ty_tvm3t,
                                        wa_tvm3t TYPE ty_tvm3t,
                                        it_tvm4t TYPE STANDARD TABLE OF ty_tvm4t,
                                        wa_tvm4t TYPE ty_tvm4t.
                                                                                    * Global data for grand total
                                        DATA:
                                        w_tot_ntgew_tea_bag TYPE vbrp-ntgew,
                                        w_tot_ntgew_pkt_tea TYPE vbrp-ntgew,
                                        w_tot_ntgew_bulk_tea TYPE vbrp-ntgew,
                                        w_tot_ntgew_tot TYPE vbrp-ntgew,
                                        w_tot_kzwi1_tea_bag TYPE vbrp-kzwi1,
                                        w_tot_kzwi1_pkt_tea TYPE vbrp-kzwi1,
                                        w_tot_kzwi1_bulk_tea TYPE vbrp-kzwi1,
                                        w_tot_kzwi1_tot TYPE vbrp-kzwi1.
                                                                                    * Global data definitions for ALV
                                        DATA :
                                        * ALV Grid container
                                        w_alv_container TYPE REF TO cl_gui_custom_container,
                                        * ALV Grid
                                        w_alv_grid      TYPE REF TO cl_gui_alv_grid,
                                        w_layo          TYPE        lvc_s_layo,     "For layout
                                        wt_fieldcat     TYPE        lvc_t_fcat,     "For field catalog
                                        okcode          TYPE         okcode,        "OK Code
                                        w_to(2)         TYPE         c,
                                        w_title         TYPE        string.
                                        *-------------- START OF SELECTION SCREEN ----------------------------*
                                        SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
                                        * Billing Date
                                        SELECT-OPTIONS: s_fkdat FOR vbrk-fkdat MEMORY ID vf OBLIGATORY NO-EXTENSION.
                                        SELECTION-SCREEN:SKIP 1.
                                        SELECTION-SCREEN: END OF BLOCK b1.
                                        *-------------- END OF SELECTION SCREEN ------------------------------*
                                                                                    *-------------   EVENT START-OF-SELECTION  -------------------------------*
                                        START-OF-SELECTION.
                                                                                    * Get billing data from Delivery header(VBRK) and item (VBRP)
                                        PERFORM get_billing_data.
                                        * Get ship-to country
                                        PERFORM get_ship_to_data.
                                        * Get material group description 3
                                        PERFORM get_material_group_3.
                                        * Get material group description 4
                                        PERFORM get_material_group_4.
                                        * Form the ALV Grid title
                                        PERFORM form_title.
                                        * Process data
                                        PERFORM process_data.
                                        * Populate text descriptions
                                        PERFORM populate_description.
                                                                                    *-------------   EVENT END-OF-SELECTION  -------------------------------*
                                        END-OF-SELECTION.
                                        * Set the text to when date high is there
                                        IF NOT s_fkdat-high IS INITIAL.
                                        w_to = 'to'(c16).
                                        ENDIF.
                                        * Call the scren 9000 for ALV Display
                                        CALL SCREEN 9000.
                                        *&      Form  get_billing_data
                                        * Get billing data from Delivery header(VBRK) and item (VBRP)
                                        * & store in internal table it_vbrk_vbrp
                                        FORM get_billing_data .
                                        REFRESH: it_vbrk_vbrp.
                                                                                    * Select Billing data by joining VBRK & VBRP and store in it_vbrk_vbrp
                                        SELECT a~vbeln
                                        b~posnr
                                        b~aubel
                                        a~waerk
                                        b~mvgr1
                                        b~mvgr3
                                        b~mvgr4
                                        b~matnr
                                        b~ntgew
                                        b~gewei
                                        b~kzwi1
                                        b~kursk
                                        FROM vbrk AS a INNER JOIN vbrp AS b
                                        ON a~vbeln = b~vbeln
                                        INTO TABLE it_vbrk_vbrp
                                        WHERE a~fkdat IN s_fkdat
                                        * Consider only non-deleted document
                                        AND fksto = space
                                        * Billing doc type should be ZXTB
                                        AND fkart = 'ZXTB'
                                        AND pstyv = c_zxto.
                                        IF sy-subrc <> 0.
                                        MESSAGE i999(zttl) WITH 'No data is there'(m06).
                                        LEAVE LIST-PROCESSING.
                                        ENDIF.
                                        ENDFORM.                    " get_billing_data
                                        *&      Form  get_ship_to_data
                                        * Get Ship-To party data
                                        FORM get_ship_to_data .
                                        DATA: l_it_vbpa TYPE STANDARD TABLE OF ty_vbpa.
                                        REFRESH: it_vbpa, it_t005t.
                                        IF NOT it_vbrk_vbrp[] IS INITIAL.
                                        SELECT vbeln
                                        land1
                                        FROM vbpa
                                        INTO TABLE it_vbpa
                                        FOR ALL ENTRIES IN it_vbrk_vbrp
                                        WHERE vbeln = it_vbrk_vbrp-aubel
                                        AND posnr = c_000000
                                        AND parvw = c_ship_to.
                                        IF sy-subrc <> 0.
                                        MESSAGE i999(zttl) WITH 'Exporter country not maintained'(m02).
                                        LEAVE LIST-PROCESSING.
                                        ELSE.
                                        SORT it_vbpa BY vbeln.
                                        * Create an unique and sorted driver table
                                        l_it_vbpa[] = it_vbpa[].
                                        SORT l_it_vbpa BY land1.
                                        DELETE ADJACENT DUPLICATES FROM l_it_vbpa COMPARING land1.
                                        IF NOT l_it_vbpa[] IS INITIAL.
                                        * Get the country description from T005t table
                                        SELECT land1
                                        landx
                                        FROM t005t
                                        INTO TABLE it_t005t
                                        FOR ALL ENTRIES IN l_it_vbpa
                                        WHERE spras = c_e
                                        AND  land1 = l_it_vbpa-land1.
                                        IF sy-subrc = 0.
                                        SORT it_t005t BY land1.
                                        ENDIF.
                                        ENDIF.
                                        ENDIF.
                                        ENDIF.
                                        ENDFORM.                    " get_ship_to_data
                                        *&      Form  get_material_group_3
                                        * Get material group 3
                                        FORM get_material_group_3 .
                                        DATA: l_it_vbrk_vbrp TYPE STANDARD TABLE OF ty_vbrk_vbrp.
                                        REFRESH: it_tvm3t.
                                        * Create an unique and sorted driver table
                                        l_it_vbrk_vbrp[] = it_vbrk_vbrp[].
                                        SORT l_it_vbrk_vbrp BY mvgr3.
                                        DELETE ADJACENT DUPLICATES FROM l_it_vbrk_vbrp COMPARING mvgr3.
                                        IF NOT l_it_vbrk_vbrp[] IS INITIAL.
                                        SELECT mvgr3
                                        bezei
                                        FROM tvm3t
                                        INTO TABLE it_tvm3t
                                        FOR ALL ENTRIES IN l_it_vbrk_vbrp
                                        WHERE mvgr3 = l_it_vbrk_vbrp-mvgr3.
                                        IF sy-subrc = 0.
                                        SORT it_tvm3t BY mvgr3.
                                        ENDIF.
                                        ENDIF.
                                        ENDFORM.                    " get_material_group_3
                                        *&      Form  get_material_group_4
                                        * Get material group 4
                                        FORM get_material_group_4 .
                                        DATA: l_it_vbrk_vbrp TYPE STANDARD TABLE OF ty_vbrk_vbrp.
                                        REFRESH: it_tvm4t.
                                        * Create an unique and sorted driver table
                                        l_it_vbrk_vbrp[] = it_vbrk_vbrp[].
                                        SORT l_it_vbrk_vbrp BY mvgr4.
                                        DELETE ADJACENT DUPLICATES FROM l_it_vbrk_vbrp COMPARING mvgr4.
                                        IF NOT l_it_vbrk_vbrp[] IS INITIAL.
                                        SELECT mvgr4
                                        bezei
                                        FROM tvm4t
                                        INTO TABLE it_tvm4t
                                             FOR ALL ENTRIES IN l_it_vbrk_vbrp
                                             WHERE mvgr4 = l_it_vbrk_vbrp-mvgr4.
                                             IF sy-subrc = 0.
                                               SORT it_tvm4t BY mvgr4.
                                             ENDIF.
                                           ENDIF.
                                        ENDFORM.                    " get_material_group_4
                                        *&      Form  process_data
                                        * Process the data and do summation and populate final display table
                                        FORM process_data .
                                                                                    LOOP AT it_vbrk_vbrp INTO wa_vbrk_vbrp.
                                             CLEAR: wa_data, wa_vbpa.
                                             READ TABLE it_vbpa INTO wa_vbpa WITH KEY
                                                                          vbeln = wa_vbrk_vbrp-aubel
                                                                          BINARY SEARCH.
                                             IF sy-subrc = 0.
                                               wa_data-land1 = wa_vbpa-land1.
                                             ENDIF.
                                                                                    wa_data-mvgr3 = wa_vbrk_vbrp-mvgr3.
                                             wa_data-mvgr4 = wa_vbrk_vbrp-mvgr4.
                                                                                    * Do an unit conversion of the quamtity
                                             CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
                                               EXPORTING
                                                 input                      = wa_vbrk_vbrp-ntgew
                                        *      NO_TYPE_CHECK              = 'X'
                                        *      ROUND_SIGN                 = ' '
                                                unit_in                    = wa_vbrk_vbrp-gewei
                                                unit_out                   = 'TO' "Metric tonn
                                              IMPORTING
                                                output                     = wa_vbrk_vbrp-ntgew
                                              EXCEPTIONS
                                                conversion_not_found       = 1
                                                division_by_zero           = 2
                                                input_invalid              = 3
                                                output_invalid             = 4
                                                overflow                   = 5
                                                type_invalid               = 6
                                                units_missing              = 7
                                                unit_in_not_found          = 8
                                                unit_out_not_found         = 9
                                                OTHERS                     = 10.
                                             IF sy-subrc <> 0.
                                               wa_vbrk_vbrp-ntgew = wa_vbrk_vbrp-ntgew.
                                             ENDIF.
                                        * Convert the currency from Customer currency to local
                                        * currency by multiplying with kursk
                                             wa_vbrk_vbrp-kzwi1 =  wa_vbrk_vbrp-kzwi1 * wa_vbrk_vbrp-kursk.
                                        * Convert the amount to Lacks by dividing with 100000
                                            wa_vbrk_vbrp-kzwi1 = wa_vbrk_vbrp-kzwi1 / 100000.       "DV1K905028
                                        * When MVGR1 is between A to F use the amount as TEA_BAG
                                             IF wa_vbrk_vbrp-mvgr1 BETWEEN 'A' AND 'F'.
                                               wa_data-ntgew_tea_bag = wa_vbrk_vbrp-ntgew.
                                               wa_data-kzwi1_tea_bag = wa_vbrk_vbrp-kzwi1.
                                             ENDIF.
                                        * When MVGR1 is between G to L use the amount as TEA_BAG
                                             IF wa_vbrk_vbrp-mvgr1 BETWEEN 'G' AND 'L'.
                                               wa_data-ntgew_pkt_tea = wa_vbrk_vbrp-ntgew.
                                               wa_data-kzwi1_pkt_tea = wa_vbrk_vbrp-kzwi1.
                                             ENDIF.
                                        * When MVGR1 is between G to L use the amount as TEA_BAG
                                             IF wa_vbrk_vbrp-mvgr1 = 'M'.
                                               wa_data-ntgew_bulk_tea = wa_vbrk_vbrp-ntgew.
                                               wa_data-kzwi1_bulk_tea = wa_vbrk_vbrp-kzwi1.
                                             ENDIF.
                                                                                    COLLECT wa_data INTO it_data.
                                           ENDLOOP.
                                        ENDFORM.                    " process_data
                                        *&      Form  populate_description
                                        * Populate the description fields
                                        FORM populate_description .
                                           LOOP AT it_data INTO wa_data.
                                             CLEAR: wa_t005t.
                                             READ TABLE it_t005t INTO wa_t005t WITH KEY land1 = wa_data-land1
                                                                                    BINARY SEARCH.
                                             IF sy-subrc = 0.
                                               wa_data-landx = wa_t005t-landx.
                                             ENDIF.
                                        * Read description of Material group 3
                                             CLEAR wa_tvm3t.
                                             READ TABLE it_tvm3t INTO wa_tvm3t WITH KEY
                                                                      mvgr3 = wa_data-mvgr3
                                                                      BINARY SEARCH.
                                             IF sy-subrc = 0.
                                               wa_data-bezei3 = wa_tvm3t-bezei.
                                             ENDIF.
                                        * Read description of Material group 4
                                             CLEAR wa_tvm4t.
                                             READ TABLE it_tvm4t INTO wa_tvm4t WITH KEY
                                                                      mvgr4 = wa_data-mvgr4
                                                                      BINARY SEARCH.
                                             IF sy-subrc = 0.
                                               wa_data-bezei4 = wa_tvm4t-bezei.
                                             ENDIF.
                                        * Get the grand totals
                                             wa_data-ntgew_tot = wa_data-ntgew_tea_bag
                                                      + wa_data-ntgew_pkt_tea
                                                      + wa_data-ntgew_bulk_tea.
                                                                                    wa_data-kzwi1_tot = wa_data-kzwi1_tea_bag
                                                      + wa_data-kzwi1_pkt_tea
                                                      + wa_data-kzwi1_bulk_tea.
                                                                                    MODIFY it_data FROM wa_data TRANSPORTING landx
                                                                                    bezei3
                                                                                    bezei4
                                                                                    ntgew_tot
                                                                                    kzwi1_tot.
                                        * Summattion of grand totals
                                             w_tot_ntgew_tea_bag  = w_tot_ntgew_tea_bag  + wa_data-ntgew_tea_bag.
                                             w_tot_ntgew_pkt_tea  = w_tot_ntgew_pkt_tea  + wa_data-ntgew_pkt_tea.
                                             w_tot_ntgew_bulk_tea  = w_tot_ntgew_bulk_tea  + wa_data-ntgew_bulk_tea.
                                             w_tot_ntgew_tot  = w_tot_ntgew_tot  + wa_data-ntgew_tot.
                                                                                    w_tot_kzwi1_tea_bag  = w_tot_kzwi1_tea_bag  + wa_data-kzwi1_tea_bag.
                                             w_tot_kzwi1_pkt_tea  = w_tot_kzwi1_pkt_tea  + wa_data-kzwi1_pkt_tea.
                                             w_tot_kzwi1_bulk_tea  = w_tot_kzwi1_bulk_tea  + wa_data-kzwi1_bulk_tea.
                                             w_tot_kzwi1_tot  = w_tot_kzwi1_tot  + wa_data-kzwi1_tot.
                                                                                    ENDLOOP.
                                        * Append a grand Total row at the end
                                           CLEAR wa_data.
                                           wa_data-landx = 'Grand Total:'.
                                           wa_data-ntgew_tea_bag = w_tot_ntgew_tea_bag.
                                           wa_data-ntgew_pkt_tea = w_tot_ntgew_pkt_tea.
                                           wa_data-ntgew_bulk_tea = w_tot_ntgew_bulk_tea.
                                           wa_data-ntgew_tot = w_tot_ntgew_tot.
                                           wa_data-kzwi1_tea_bag = w_tot_kzwi1_tea_bag.
                                           wa_data-kzwi1_pkt_tea = w_tot_kzwi1_pkt_tea.
                                           wa_data-kzwi1_bulk_tea = w_tot_kzwi1_bulk_tea.
                                           wa_data-kzwi1_tot = w_tot_kzwi1_tot.
                                           wa_data-line_color    = 'C310'.
                                           APPEND wa_data TO it_data.
                                        ENDFORM.                    " populate_description
                                        *&      Module  STATUS_9000  OUTPUT
                                        * Initialise PF-STATUS and title
                                        MODULE status_9000 OUTPUT.
                                           SET PF-STATUS 'MAIN9000'.
                                           SET TITLEBAR 'TITLE_9000'.
                                        ENDMODULE.                 " STATUS_9000  OUTPUT
                                        *&      Module  initialize_9000  OUTPUT
                                        *       text
                                        MODULE initialize_9000 OUTPUT.
                                        * Call the ALV grid to display data
                                           PERFORM display_alv_grid.
                                        ENDMODULE.                 " initialize_9000  OUTPUT
                                        *&      Module  USER_COMMAND_9000  INPUT
                                        * Module to handle User Command
                                        MODULE user_command_9000 INPUT.
                                           CASE okcode.
                                             WHEN 'BACK'.
                                               SET SCREEN 0.
                                               CLEAR okcode.
                                               LEAVE SCREEN.
                                             WHEN 'CANCEL'.
                                               SET SCREEN 0.
                                               CLEAR okcode.
                                               LEAVE SCREEN.
                                             WHEN 'EXIT'.
                                               CLEAR okcode.
                                               LEAVE PROGRAM.
                                             WHEN OTHERS.
                                           ENDCASE.
                                        ENDMODULE.                 " USER_COMMAND_9000  INPUT
                                        *&      Form  display_alv_grid
                                        * Display the data in ALV Grid
                                        FORM display_alv_grid .
                                           IF w_alv_container IS INITIAL.
                                        * Create the alv container object
                                             CREATE OBJECT w_alv_container
                                               EXPORTING
                                                 container_name = 'ALV_GRID'
                                               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 e999(zttl) WITH 'Problem in ALV display'(t04).
                                             ENDIF.
                                        * Create the ALV grid object. The parent is the ALV container
                                             CREATE OBJECT w_alv_grid
                                               EXPORTING
                                                 i_parent = w_alv_container
                                               EXCEPTIONS
                                                 error_cntl_create = 1
                                                 error_cntl_init   = 2
                                                 error_cntl_link   = 3
                                                 error_dp_create   = 4
                                                 OTHERS            = 5.
                                                                                    IF sy-subrc <> 0.
                                               MESSAGE e999(zttl) WITH 'Problem in ALV display'(t04).
                                             ENDIF.
                                        * This subrotine creates the field catalog and
                                        * store in internal table lt_fieldcat
                                             PERFORM prepare_fieldcat CHANGING wt_fieldcat.
                                                                                    * Layout design
                                             w_layo-no_toolbar = ''.
                                        * Not to allow totaling feature
                                             w_layo-no_totline = c_x.
                                        * Report title
                                        *    w_layo-grid_title = text-004.
                                             w_layo-grid_title = w_title.
                                                                                    w_layo-zebra      = c_x.    "Alternating line color (striped)
                                             w_layo-cwidth_opt = c_x.    "Optimize column width
                                             w_layo-sel_mode   = 'A'.    "Selection Mode
                                        * Name of the color field
                                             w_layo-info_fname = 'LINE_COLOR'."For row color
                                        * Call the method to display the data in ALV grid
                                             CALL METHOD w_alv_grid->set_table_for_first_display
                                               EXPORTING
                                                 i_save                        = 'A'
                                                 is_layout                     = w_layo
                                               CHANGING
                                                 it_outtab                     = it_data[]
                                                 it_fieldcatalog               = wt_fieldcat
                                               EXCEPTIONS
                                                 invalid_parameter_combination = 1
                                                 program_error                 = 2
                                                 too_many_lines                = 3
                                                 OTHERS                        = 4.
                                                                                    IF sy-subrc <> 0.
                                               MESSAGE e999(zttl) WITH text-t04.
                                             ENDIF.
                                           ELSE.
                                        * If the container & grid object is alreadt there reuse them
                                             CALL METHOD w_alv_grid->refresh_table_display
                                               EXCEPTIONS
                                                 finished = 1
                                                 OTHERS   = 2.
                                             IF sy-subrc <> 0.
                                               MESSAGE e999(zttl) WITH text-t04.
                                             ENDIF.
                                           ENDIF.
                                           IF okcode = 'CANCEL'.
                                             EXIT.
                                           ENDIF.
                                        ENDFORM.                    " display_alv_grid
                                        *&      Form  prepare_fieldcat
                 

  • Unable to Capture ALV output in an Internal Table, after CALL TRANSACTION

    Dear all,
    My requirement is to run multiple materials in T-code CK86_99 but as we know CK86_99 is only adequate to one material at a time.
    So, I want to capture the Output of the T-code in my Internal table with respect to all the Material Numbers I use in the Select-Options of my Z Program.
    Below is the Code I developed so far, but the Class
    cl_salv_bs_runtime_info=>get_data_ref(
            IMPORTING r_data = lf_ref ).
    is not capturing the Ouput...
    Please have a look and enlighten me how it could be solved.
    TABLES : mara.
    DATA : BEGIN OF wa_mara,
      matnr TYPE mara-matnr,
      END OF wa_mara.
    DATA: it_bdcdata TYPE TABLE OF bdcdata,
          wa_it_bdcdata LIKE LINE OF it_bdcdata,
          it_mara LIKE TABLE OF wa_mara.
    *      BELNR(10).
    FIELD-SYMBOLS:<fs_tab> TYPE ANY TABLE,
    <fs_line> TYPE any.
    DATA:lf_ref TYPE REF TO data,
         lf_ref1 TYPE REF TO data.
    SELECT-OPTIONS so_matnr FOR mara-matnr.
    PARAMETERS p_werks LIKE t001w-werks.
    *BELNR = 'Z92'. " Give Document Number here
    SELECT matnr FROM mara INTO TABLE it_mara WHERE matnr IN so_matnr.
    DATA opt TYPE ctu_params.
    LOOP AT it_mara INTO wa_mara.
      CLEAR wa_it_bdcdata.
    wa_it_bdcdata-program  = 'SAPMKKB0'.
    wa_it_bdcdata-dynpro   = '0300'.
    wa_it_bdcdata-dynbegin = 'X'.
      APPEND wa_it_bdcdata TO it_bdcdata.
      CLEAR wa_it_bdcdata.
    wa_it_bdcdata-fnam = 'BDC_CURSOR'.
    wa_it_bdcdata-fval = 'KKB0-MATNR'.
      APPEND wa_it_bdcdata TO it_bdcdata.
      CLEAR wa_it_bdcdata.
    wa_it_bdcdata-fnam = 'KKB0-MATNR'.
      wa_it_bdcdata-fval = wa_mara-matnr.
      APPEND wa_it_bdcdata TO it_bdcdata.
      CLEAR wa_it_bdcdata.
    wa_it_bdcdata-fnam = 'BDC_CURSOR'.
    wa_it_bdcdata-fval = 'KKB0-WERKS'.
      APPEND wa_it_bdcdata TO it_bdcdata.
      CLEAR wa_it_bdcdata.
      wa_it_bdcdata-fnam = 'KKB0-WERKS'.
    wa_it_bdcdata-fval = p_werks.
      APPEND wa_it_bdcdata TO it_bdcdata.
      CLEAR wa_it_bdcdata.
    wa_it_bdcdata-fnam = 'BDC_OKCODE'.
    wa_it_bdcdata-fval = 'OSNY'."'ONLI'."=CRET'.
      APPEND wa_it_bdcdata TO it_bdcdata.
    *  CLEAR wa_it_bdcdata.
    * wa_it_bdcdata-program  = 'SAPLKKRSOO'.
    * wa_it_bdcdata-dynpro   = '0100'.
    * wa_it_bdcdata-dynbegin = 'X'.
    *  APPEND wa_it_bdcdata TO it_bdcdata.
    *  CLEAR wa_it_bdcdata.
    * wa_it_bdcdata-fnam = 'BDC_OKCODE'.
    *  wa_it_bdcdata-fval = 'BACK'."=CRET'.
    *  APPEND wa_it_bdcdata TO it_bdcdata.
    *  CLEAR wa_it_bdcdata.
    * wa_it_bdcdata-program  = 'SAPMKKB0'.
    * wa_it_bdcdata-dynpro   = '0300'.
    * wa_it_bdcdata-dynbegin = 'X'.
    *  APPEND wa_it_bdcdata TO it_bdcdata.
    *  CLEAR wa_it_bdcdata.
    * wa_it_bdcdata-fnam = 'BDC_OKCODE'.
    * wa_it_bdcdata-fval = 'EXIT'."=CRET'.
    *  APPEND wa_it_bdcdata TO it_bdcdata.
      opt-dismode = 'N'.
    cl_salv_bs_runtime_info=>set(
        EXPORTING display  = abap_false
                  metadata = abap_true
    data     = abap_true ).
      CALL TRANSACTION 'CK86_99' USING it_bdcdata OPTIONS FROM opt.
      TRY.
    cl_salv_bs_runtime_info=>get_data_ref(
            IMPORTING r_data = lf_ref ).
          ASSIGN lf_ref->* TO <fs_tab>.
        CATCH cx_salv_bs_sc_runtime_info.
          MESSAGE 'Unable to retrieve ALV data' TYPE 'E'.
      ENDTRY.
    cl_salv_bs_runtime_info=>clear_all( ).
      IF <fs_tab> IS ASSIGNED.
        CREATE DATA lf_ref1 LIKE LINE OF <fs_tab>.
        ASSIGN lf_ref1->* TO <fs_line>.
      ENDIF.
    *LOOP AT <FS_TAB> ASSIGNING <FS_LINE>.
    *ENDLOOP.

    Hi Abhay,
          If you go to Transaction code SE93, enter the tcode "CK86_99" and click display, you may see the default value for transaction is "KKBB" and the screen field for P_SCREEN = 0300, P_TCODE = ck86_99.
          You may need to copy the transaction code "KKBB" and go to SE93 again, enter the tcode for "KKBB" then click display, now you may see the program name is "RKKB1000".
          Hope this answer your question.
    Thanks
    Hock Lin

  • How to get total in ALV report in same Internal table?

    Data : Begin of it_data,
            kunnr type kunnr,
            name1 type name1,
            amt1  type btrt01, " CURR 15,2
           end of it_data.
    loop at it_data into wa_data
    endloop.      
    Hello friends,
    I am developing one ALV report with 20 rows.
    I have filled one internal table with some fileds like amount.
    I want to get total of all amount1 in AMT1 field.
    So, How to get total of amount in same internal table in ALV report ?
    It is ok if i get duplicate rows in internal table.
    Points 'll be awarded soon.
    Regards,
    NVM

    Hi Ronny,
    the alv output will display the sum at the last row.
    for this functionality u have do this logic.
    data: lw_fcat type slis_fieldcat_alv.
    data: lt_fcat type slis_t_fieldcat_alv/
    wa_fcat-fieldname = 'AMT1'.
    wa_fcat-tabname = 'ITAB'.
    wa_fcat-do_sum = 'X'.
    append wa_fcat to lt_fcat.
    and then pass it to reuse_alv_grid_display function,
    regards,
    Santosh Thorat

  • ALV TREE FOR 3 internal table

    Hi ,
    I want to display report output in the form of ALV tree.
    Since I have data in 3 internal table for each hierarchial level, I can't use ALV hierarchial sequential list .
    Please guide me how to implement the same.
    Please share sample code other than SAP code if any.

    Hi Navdeep,
    You have to use class CL_GUI_CUSTOM_CONTAINER to create three different containers.
    A reference code on below link :-
    [http://wiki.sdn.sap.com/wiki/display/ABAP/TREE+ALV]
    Regards
    Abhii

Maybe you are looking for

  • Is there a Numbers equivalent to Excel's "Text to Columns"?

    I am new to Numbers 09. In Excel I often need to take large amounts of ASCII text data, with hundreds or even thousands of line, paste the data into Column A, then use the "Text to Columns" utility to parse the data into separate columns for further

  • Getting the below Exception after starting the components in JavaES5

    Hi All, I have Installed the JES5 "java_es-5_appsuite-windows-x86" on windows and after successfull intsallation and checking the option to start all the components getting the below error in the appserver-->domains-->domain1-->logs-->server.log file

  • Can't update my iPhoto 9.4.2 to 9.4.3

    When I search for new updates in iPhoto its comes with the message " new update availible" and then I open software update in the app store. Software update doesn't see any new updates. I downloaded the 9.4.3 manualy and then I get a warning that I n

  • Dynamic Tooltip Text over Business Graphics

    Hello, I would like to know if there is a possibility to display dynamically point coordinates (or other tooltip text) in a Business Graphics when the mouse is going over the gragh or when clicking ? Thanks a lot Marc

  • Assigning suppl. plant to vendor in vendor master (STO)

    Hi All I am working on STO with delivery , please tell me where to Assign Vendor No. to the Supplying Plant in vendor master. i have checked all the views but have not found supplying plant in vendor master. Tks Anjan