ALV Grid data changed

Hello;
i am using fm REUSE_ALV_GRID (not OO) to display an internal table. The user wants to change the data in a certain cell. I have marked this cell as editable and it works fine. I want to learn what to check in the event of data_changed. I have added this event in table ALV_EVENTS and directed to a subroutine. What parameters should i pass to the subroutine and what should i check to read the relevant line? Is it possible to control changes in more than one line?
Thx
Ali

<i>Is it possible to control changes in more than one line?</i>
yes.
for usage of the method, and editable grid please refer the sample code.
REPORT  ZTESTDFALV1                             .
*Data Declaration
DATA: BEGIN OF T_EKKO,
  EBELN TYPE EKPO-EBELN,
  EBELP TYPE EKPO-EBELP,
END OF T_EKKO.
DATA: BEGIN OF IT_EKKO OCCURS 0.
        INCLUDE STRUCTURE T_EKKO.
DATA: END OF IT_EKKO.
DATA: BEGIN OF IT_BACKUP OCCURS 0.
        INCLUDE STRUCTURE T_EKKO.
DATA: END OF IT_BACKUP.
*ALV data declarations
TYPE-POOLS: SLIS.                                 "ALV Declarations
DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
      GD_LAYOUT    TYPE SLIS_LAYOUT_ALV,
      GD_REPID     LIKE SY-REPID.
*Start-of-selection.
START-OF-SELECTION.
  PERFORM DATA_RETRIEVAL.
  PERFORM BUILD_FIELDCATALOG.
  PERFORM BUILD_LAYOUT.
  IT_BACKUP[] = IT_EKKO[].
  PERFORM DISPLAY_ALV_REPORT.
*&      Form  build_fieldcatalog
*       text
FORM BUILD_FIELDCATALOG.
  REFRESH FIELDCATALOG.
  CLEAR FIELDCATALOG.
  FIELDCATALOG-FIELDNAME   = 'EBELN'.
  FIELDCATALOG-SELTEXT_M   = 'Purchase Order'.
  FIELDCATALOG-INPUT     = 'X'.
  FIELDCATALOG-EDIT     = 'X'.
  FIELDCATALOG-COL_POS     = 2.
  APPEND FIELDCATALOG.
  CLEAR  FIELDCATALOG.
  FIELDCATALOG-FIELDNAME   = 'EBELP'.
  FIELDCATALOG-SELTEXT_M   = 'PO Item'.
  FIELDCATALOG-COL_POS     = 3.
  APPEND FIELDCATALOG.
  CLEAR  FIELDCATALOG.
ENDFORM.                    " BUILD_FIELDCATALOG
*&      Form  BUILD_LAYOUT
*       Build layout for ALV grid report
FORM BUILD_LAYOUT.
  "Permet d'ajuster les colonnes au text
*  gd_layout-colwidth_optimize = 'X'.
  GD_LAYOUT-TOTALS_TEXT       = 'Totals'(201).
*  gd_layout-box_fieldname = 'SELECT'.
*  gd_layout-box_tabname   = 'IT_EKKO'.
ENDFORM.                    " BUILD_LAYOUT
*&      Form  DISPLAY_ALV_REPORT
*       Display report using ALV grid
FORM DISPLAY_ALV_REPORT.
  GD_REPID = SY-REPID.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            I_CALLBACK_PROGRAM        = GD_REPID
*            i_callback_top_of_page   = 'TOP-OF-PAGE'
            I_CALLBACK_PF_STATUS_SET  = 'SET_PF_STATUS'
            I_CALLBACK_USER_COMMAND   = 'USER_COMMAND'
*            i_grid_title             = 'My Title'
            IS_LAYOUT                 = GD_LAYOUT
            IT_FIELDCAT               = FIELDCATALOG[]
       TABLES
            T_OUTTAB                  = IT_EKKO
       EXCEPTIONS
            PROGRAM_ERROR             = 1
            OTHERS                    = 2.
  IF SY-SUBRC <> 0.
    WRITE:/ SY-SUBRC.
  ENDIF.
ENDFORM.                    " DISPLAY_ALV_REPORT
*&      Form  DATA_RETRIEVAL
*       Retrieve data form EKPO table and populate itab it_ekko
FORM DATA_RETRIEVAL.
  SELECT EBELN EBELP
   UP TO 10 ROWS
    FROM EKPO
    INTO CORRESPONDING FIELDS OF TABLE  IT_EKKO.
ENDFORM.                    " DATA_RETRIEVAL
*                      FORM SET_PF_STATUS                              *
FORM SET_PF_STATUS USING RT_EXTAB   TYPE  SLIS_T_EXTAB.
  SET PF-STATUS 'STANDARD_FULLSCREEN1' EXCLUDING RT_EXTAB.
ENDFORM.                    "set_pf_status
*&      Form  user_command
*       text
*      -->R_UCOMM    text
*      -->RS_SELFIELDtext
FORM USER_COMMAND  USING R_UCOMM LIKE SY-UCOMM
                         RS_SELFIELD TYPE SLIS_SELFIELD.
  <b>DATA: GD_REPID LIKE SY-REPID, "Exists
  REF_GRID TYPE REF TO CL_GUI_ALV_GRID. "new
*then insert the following code in your USER_COMMAND routine...
  IF REF_GRID IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        E_GRID = REF_GRID.
  ENDIF.
  IF NOT REF_GRID IS INITIAL.
    CALL METHOD REF_GRID->CHECK_CHANGED_DATA
  ENDIF.</b>
  CASE R_UCOMM.
    WHEN '&IC1'.
      CHECK RS_SELFIELD-TABINDEX > 0.
      IF RS_SELFIELD-VALUE EQ '6000000001'.
        CALL TRANSACTION 'ZDF2'.
      ENDIF.
    WHEN 'ENTER'.
      READ TABLE IT_EKKO INDEX  RS_SELFIELD-TABINDEX.
      IF SY-SUBRC = 0.
        READ TABLE IT_BACKUP INDEX RS_SELFIELD-TABINDEX.
        IF SY-SUBRC = 0.
          IF IT_EKKO <> IT_BACKUP.
*  then do your check
          ENDIF.
        ENDIF.
      ENDIF.
      PERFORM DATA_RETRIEVAL.
      RS_SELFIELD-REFRESH = 'X'.
  ENDCASE.
ENDFORM.                    "user_command
Regards
Vijay

Similar Messages

  • Hi iam getting the alv grid data in excel format but iam facing one problem

    hi iam getting the alv grid data in excel format but iam facing one problem ,
    i.e., i want it read only  but iam getting it in edit mode i use layout default in excel iam getting in xl directly but in edit mode but i need it in read only mode
    what i have to do for that  and bdy knows reply me i need it urgently.

    there's always edit-mode if you choose excel-inplace - but noone can modify/rewrite the data
    A.

  • ALV Grid - Display/change Problem

    Hi Guys,
    I have a peculiar problem. I have developed a Module pool application containing two screens. In the first screen I have a input field and 2 buttons for display and change. When I enter the value and press Displaythe second screen is called which shows an ALV grid in the respective display mode. But If I come back and press change I could not get the change mode for the ALV grid still it remains in the Display mode. Again if rerun the transaction and press change it shows the ALV grid in change mode but if we press back and choose display then it is not getting changed still remains as such. In all at the first run what ever the mode is chosen it remains stationery. I am using OOALV and i have tried flushing the container, grid and also refreshing the ALV. But could not trace the problem. If you guys have worked or can put some inputs please reply back.
    Jagath.

    Please find the attached code...
    from the first screen 100 i am assigning the flag w_display or w_change based on the okcode. in the second screen 200 PBO i have the following code:
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'STAT200'.
      SET TITLEBAR 'TIT200'.
      if w_display eq 'X'.
      perform grid_display.
      else.
      perform grid_change.
      endif.
    ENDMODULE.                 " STATUS_0200  OUTPUT
    Now in perform display I have the following code:
    form grid_display .
    Set the Fieldcatalog.
      REFRESH t_fieldcat.
      PERFORM get_field_catalog.
    set the Layout.
      CLEAR wa_layout.
      wa_layout-cwidth_opt = 'X'.
    wa_layout-stylefname = 'CELLTAB'.
    set the Variant
      w_variant-report = sy-repid.
    Create the Instance for container
      IF lcl_custom_disp IS INITIAL.
        CREATE OBJECT lcl_custom_disp
          EXPORTING
           PARENT                      =
            container_name              = 'CONTAINER1'
          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.
    create the object for ALV grid
        CREATE OBJECT lcl_grid_disp
          EXPORTING
            i_parent          = lcl_custom_disp
          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.
    Create the object for events
        CREATE OBJECT lcl_events.
        SET HANDLER lcl_events->handle_top_of_list FOR lcl_grid_disp.
    Display the  ALV.
        CALL METHOD lcl_grid_disp->set_table_for_first_display
          EXPORTING
            is_variant                    = w_variant
            i_save                        = ' '
            is_layout                     = wa_layout
          CHANGING
            it_outtab                     = t_final[]
            it_fieldcatalog               = t_fieldcat
          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.
      ELSE.
    Refresh the ALV grid
        CALL METHOD lcl_grid_disp->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.
      ENDIF.
    endform.                    " grid_display
    In the perform change the same code is followed for different object with the fieldcatalog  is changed to edit based on flag.
    Set the Fieldcatalog.
      REFRESH t_fieldcat.
      PERFORM get_field_catalog.
    set the Layout.
      CLEAR wa_layout.
      wa_layout-cwidth_opt = 'X'.
    wa_layout-stylefname = 'CELLTAB'.
    set the Variant
      w_variant-report = sy-repid.
    Create the Instance for container
      IF lcl_custom_chng IS INITIAL.
        CREATE OBJECT lcl_custom_chng
          EXPORTING
           PARENT                      =
            container_name              = 'CONTAINER1'
          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.
    create the object for ALV grid
        CREATE OBJECT lcl_grid_chng
          EXPORTING
            i_parent          = lcl_custom_chng
          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.
    Create the object for events
        CREATE OBJECT lcl_events.
        SET HANDLER lcl_events->handle_top_of_list FOR lcl_grid_chng.
        SET HANDLER lcl_events->handle_data_changed FOR lcl_grid_chng.
        SET HANDLER lcl_events->handle_data_changed_finished FOR lcl_grid_chng.
    Display the  ALV.
        CALL METHOD lcl_grid_chng->set_table_for_first_display
          EXPORTING
            is_variant                    = w_variant
            i_save                        = ' '
            is_layout                     = wa_layout
          CHANGING
            it_outtab                     = t_final[]
            it_fieldcatalog               = t_fieldcat
          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.
      ELSE.
    Refresh the ALV grid
        CALL METHOD lcl_grid_chng->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.
      ENDIF.
    Please let me know if you require some more inputs?
    Jagath

  • Reg: Download alv grid data with top of page into excel sheet

    Hi All,
    I have a selection screen with radio button for download .
    If that radio button was selected then the data will download into excel sheet (like if we execute normal ALV grid display from there we can download top-of-page and body as it is).
    AOO : 2009P               
    Fiscal year : 2009               
    Posting period : 00               
    Local Currency : USD               
    CO Area Currency :               
    Accounting standard:               
    Sector : 23               
    BB code     Period Value LC     Periodic Quantity
    AHDKGKAJ   200                         0

    Did not get your question

  • Alv grid data

    Hi All,
       I developed alv grid.I passed data from it_final table into grid.In our it_final table, there is 10 rows and when I execute report then it comes 10 line item.It is perfect. Now I do subtotal in any field.Then In the
    grid total 15 line item comming.Now I want that 15 line item should come in a table.eithe it_final or
    either any defined table.is it possible?please help me.I want just output alv grid after subtotal(15 lines item) should come in table after pressing in any button.
    Thanks,
    Rakesh

    You will have to manually loop at it_final and calculate the subtotal for the fields and append this into the it_final while displaying.
    If you r calculating subtotal in sort table by subtos = 'X'. this entry cannot be put into final internal table.
    Regards,
    Mansi.

  • Re: ALV grid date format MM/DD/YYYY

    Hi All,
    i am craeting report in ALV grid, in that report i want to dispaly date like 'MM/DD/YYYY'. present its display like YYYYMMDD.
    can you give me some idea...
    Thanks
    zeni

    If you want to use the date type (this is the easiest way and it will be formatted according to the logon default of the master data of the current user):
    1. Be sure you are using a proper date type in the output table.
    2. Make sure that the following fields of the field catalog contain the following:
        LVC_S_FCAT-DATATYPE = 'DATS'.
        LVC_S_FCAT-INTTYPE = 'D'.
        LVC_S_FCAT-INTLEN = '000008'.
        LVC_S_FCAT-DD_OUTLEN = '000010'.
    However if you want to have a more generic approach that is independent on the user master data:
    Assuming output_tab-external_date is of type C and has 10 digits.
    data: date_int  type d value '20080808'.
    case date_format.
      when 'MM/DD/YYYY'.
        write date_int to output_tab-external_date MM/DD/YYYY.
       when 'MM/DD/YY'.
         write date_int to output_tab-external_date MM/DD/YY.
       when 'DD/MM/YYYY'.
         write date_int to output_tab-external_date DD/MM/YYYY.
       when 'DD/MM/YY'.
         write date_int to output_tab-external_date DD/MM/YY.
    endcase.
    append output_tab.
    Then make sure that the following fields of the field catalog contain the following:
        LVC_S_FCAT-DATATYPE = 'CHAR'.
        LVC_S_FCAT-INTTYPE = 'C'.
        LVC_S_FCAT-INTLEN = '000010'.
        LVC_S_FCAT-DD_OUTLEN = '000010'.

  • Transferring alv grid data to other program

    Hi All,
    We have two reports, report A is for displaying data using ALV GRID, we want to let user select some lines in A and then click a button to transfer selected records to report B and make relevant select-options value default to the selected records. I tried the statement "IMPORT XXX FROM MEMORY ID XXX" in report B but seems ALV will empty them while switching to new report so I cannot get any result. Because the selection conditions in report A are a bit complex, so I can neither use "SUBMIT A EXPORTING LIST TO MEMORY WITH SEL = 'X' AND RETURN." in report B. Is there any solution?
    Thank you!
    Best Regards,
    Jeff

    See the example below
    REPORT  ZTEST.
    TYPE-POOLS: SLIS.
    DATA : IT_FIELDCAT  TYPE  SLIS_T_FIELDCAT_ALV.
    DATA: WA_FIELDCAT TYPE  SLIS_FIELDCAT_ALV.
    DATA: BEGIN OF TA_MARC OCCURS 0 ,
            CHBOX(1)." TYPE C.
            INCLUDE STRUCTURE MARC.
    DATA:        END OF TA_MARC.
    SELECT *
           FROM MARC
           INTO CORRESPONDING FIELDS OF TABLE TA_MARC
           UP TO 10 ROWS.
    DATA: IS_LAYOUT TYPE  SLIS_LAYOUT_ALV.
    DATA: I_GRID_SETTINGS TYPE  LVC_S_GLAY.
    I_GRID_SETTINGS-EDT_CLL_CB = 'X'.
    *IS_LAYOUT-box_fieldname = 'CHBOX'.
    *IS_LAYOUT-box_tabname = 'TA_MARC'.
    *IS_LAYOUT-edit = 'X'.
    WA_FIELDCAT-SELTEXT_L  = 'Check'.
    WA_FIELDCAT-FIELDNAME = 'CHBOX'.
    WA_FIELDCAT-CHECKBOX = 'X'.
    WA_FIELDCAT-EDIT = 'X'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-SELTEXT_L  = 'Material'.
    WA_FIELDCAT-FIELDNAME = 'MATNR'.
    *WA_FIELDCAT-edit = 'X'.   If U want to Make Material as Editable Field
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    WA_FIELDCAT-SELTEXT_L  = 'Plant'.
    WA_FIELDCAT-FIELDNAME = 'WERKS'.
    WA_FIELDCAT-EDIT = ''.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM      = SY-CPROG
        I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
        IT_FIELDCAT             = IT_FIELDCAT
        IS_LAYOUT               = IS_LAYOUT
        I_GRID_SETTINGS         = I_GRID_SETTINGS
      TABLES
        T_OUTTAB                = TA_MARC.
    *&      Form  USER_COMMAND
    *       text
    *      -->R_UCOMM    text
    *      -->R_SELFIELD text
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                      R_SELFIELD TYPE SLIS_SELFIELD.
      RANGES : MATNR FOR MARA-MATNR.
      LOOP AT TA_MARC  WHERE CHBOX = 'X'.
        MATNR-SIGN  =   'I'.
        MATNR-OPTION = 'EQ'.
        MATNR-LOW    = TA_MARC-MATNR.
        MATNR-HIGH  = ''.
        APPEND MATNR.
      ENDLOOP.
      SUBMIT ZTEST1 VIA SELECTION-SCREEN WITH MATNR IN MATNR and RETURN.
    ENDFORM.                    "USER_COMMAND
    When u will select rows in ZTEST ALV and press submit button data will pass to ZTEST1 on selection screen.
    REPORT  ztest1.
    tables: mara.
    select-OPTIONS: matnr for mara-matnr.
    BREAK-POINT.
    Hope u are looking for same.
    Thanks,
    Suyog.

  • ALV Grid data transfer to Exel

    Hallo,
    When I transfer data from ALV-Grid to Exel then the summation row is not considerd or it is not there.What can I do that
    summation row also in EXEL appears.
    regards
    rana

    Check Mr. Naimesh Patel's blog for it [here >>>|http://help-abap.blogspot.com/2008/09/preserve-downloaded-data-formatting-in.html]

  • Resizing ALV Grid When Changing Screen Resolution

    I have an ALV Grid imbedded in a custom container.  I would like for the Grid to resize if the user switches from 1024x768 to 800x600 resolution.  I obviously could size it for the lower res screen (and it would be ok on the higher res screen), but I ultimately would like it to resize.  Does anyone know how to make this happen?

    Is your Grid running within a custom container that was placed in the screen painter?  If so this is very easy.  Just make you screen very large (much larger then even 1024x768).  When you lay down the custom container, make it large enough to fill the entire empty area.  Your custom container should have a Resizing section in the attributes window.  Just check on Vertical and Horizontal resizing and choose you minimum size.

  • ALV GRID DATA IDENTIFICATION

    Hi all,
    I am using FM : REUSE_ALV_GRID_DISPLAY to set up an ALV list.
    I have added a button to export the data to a particular format of text as a *.txt document.
    I cannot find out how to identify the data that is actually on the screen.
    I explain, if I have 5 colums and that I hide 3 of them, when I export to excel, I only get the two remaining colums.
    I would like to acheive the same data extraction to send to my txt file.
    Has anyone got an idea ?
    Nicolas

    Nicolas,
    The function REUSE_ALV_GRID_LAYOUT_INFO_GET will give you back the modified field catalog with the changes you have done. So the NO_OUT parameter will be set for the fields you have hidden.
    Identify those fields and transfer only those fields data into another internal table and export the data.
    Regards,
    Ravi
    Note : please mark the helpful answers

  • ALV GRID DATAS to TXT

    i wanted to write all data on grid to a txt file at the end of to program. this is my code. not all program but considered parts.
    Regrads.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
         EXPORTING
           i_background_id    = 'ALV_BACKGROUND'
           i_buffer_active    = 'X'
           i_callback_program = g_repid
           it_fieldcat        = it_fieldcat
           is_layout          = gs_layout
           i_save             = g_save
           is_variant         = gs_variant
           it_events          = gt_events[]
         TABLES
           t_outtab           = it_vbak
         EXCEPTIONS
           program_error      = 1
           OTHERS             = 2.
       PERFORM save_file.
    FORM save_file.
       DATA: iv_filename TYPE string,
             iv_vbak1 TYPE TABLE OF vbak.
       iv_filename = 'C:\test\data1.txt'.
       CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
           filename              = iv_filename
           filetype              = 'ASC'
           write_field_separator = 'X'
         TABLES
           data_tab              = it_fieldcat.
    ENDFORM.                    " save_file

    Hi,
    Pls look into below code
    TYPE-POOLS: slis,vrm.
    TABLES:vbak,vbrk,vbrp.
    TYPES:BEGIN OF gty_vbakvbap,
       vbeln TYPE vbak-vbeln,
       vkorg TYPE vbak-vkorg,
       audat TYPE vbak-audat,
       auart TYPE vbak-auart,
       kunnr TYPE vbak-kunnr,
       posnr TYPE vbap-posnr,
       matnr TYPE vbap-matnr,
       matkl TYPE vbap-matkl,
       kwmeng TYPE vbap-kwmeng,
    END OF gty_vbakvbap,
    gty_t_vbakvbap TYPE TABLE OF gty_vbakvbap.
    TYPES:BEGIN OF gty_kna1,
       kunnr TYPE kna1-kunnr,
       land1 TYPE kna1-land1,
       name1 TYPE kna1-name1,
       ort01 TYPE kna1-ort01,
    END OF gty_kna1,
    gty_t_kna1 TYPE TABLE OF gty_kna1.
    TYPES : BEGIN OF gty_vbrkvbrp,
             vbeln TYPE vbrk-vbeln,
             bukrs TYPE vbrk-bukrs,
             vkorg TYPE vbrk-vkorg,
             vtweg TYPE vbrk-vtweg,
             fkdat TYPE vbrk-fkdat,
             posnr TYPE vbrp-posnr,
             werks TYPE vbrp-werks,
       END OF gty_vbrkvbrp,
    gty_t_vbrkvbrp TYPE TABLE OF gty_vbrkvbrp.
    TYPES:BEGIN OF gty_final,
       vbeln TYPE vbak-vbeln,
       vkorg TYPE vbak-vkorg,
       audat TYPE vbak-audat,
       auart TYPE vbak-auart,
       kunnr TYPE vbak-kunnr,
       posnr TYPE vbap-posnr,
       matnr TYPE vbap-matnr,
       matkl TYPE vbap-matkl,
       kwmeng TYPE vbap-kwmeng,
       land1 TYPE kna1-land1,
       name1 TYPE kna1-name1,
       ort01 TYPE kna1-ort01,
       bukrs TYPE vbrk-bukrs,
       fkdat TYPE vbrk-fkdat,
       vtweg TYPE vbrk-vtweg,
       werks TYPE vbrp-werks,
    END OF gty_final,
    gty_t_final TYPE TABLE OF gty_final.
    TYPES:BEGIN OF gty_header,
       vbeln(15) TYPE c,
       vkorg(10) TYPE c,
       audat(15) TYPE c,
       auart(15) TYPE c,
       kunnr(15) TYPE c,
       posnr(10) TYPE c,
       matnr(15) TYPE c,
       matkl(10) TYPE c,
       kwmeng(10) TYPE c,
       land1(10) TYPE c,
       name1(10) TYPE c,
       ort01(10) TYPE c,
    END OF gty_header,
    gty_t_header TYPE TABLE OF gty_header.
    TYPES : t_document_data TYPE sodocchgi1,
             t_packing_list TYPE sopcklsti1,
             t_attachment TYPE solisti1,
             t_body_msg TYPE solisti1,
             t_receivers TYPE somlreci1.
    DATA: w_document_data TYPE t_document_data,
           w_packing_list TYPE t_packing_list,
           w_attachment TYPE   t_attachment,
           w_body_msg TYPE t_body_msg,
           w_receivers TYPE  t_receivers,
           e(10) TYPE c.
    DATA: i_document_data TYPE TABLE OF t_document_data,
           i_packing_list TYPE TABLE OF t_packing_list,
           i_attachment TYPE  TABLE OF t_attachment,
           i_body_msg TYPE TABLE OF t_body_msg,
           i_receivers TYPE TABLE OF t_receivers.
    DATA: e_mail TYPE somlreci1-receiver,
           date(10) TYPE c,
           time(8) TYPE c,
           dd(2) TYPE c,
           mm(2) TYPE c,
           yy(4) TYPE c,
           h(2) TYPE c,
           m(2) TYPE c,
           s(2) TYPE c,
           orders(10) TYPE c VALUE 'C:\Orders',
           gt_list TYPE vrm_values,
           gw_list TYPE vrm_value,
           gt_values TYPE TABLE OF dynpread,
           gw_values TYPE dynpread,
           gv_selected_value(10) TYPE c,
           g_tab_lines TYPE i,
           r_ucomm TYPE sy-ucomm,
    * Sub total based on the header details Sales order no. vbeln = 5006.
           gt_sort TYPE slis_t_sortinfo_alv,
           gw_sort TYPE slis_sortinfo_alv.
       DATA : gv_qty TYPE string.
    DATA : gt_vbakvbap  TYPE gty_t_vbakvbap,
            gw_vbakvbap  TYPE gty_vbakvbap,
            gt_kna1      TYPE gty_t_kna1,
            gw_kna1      TYPE gty_kna1,
            gt_vbrkvbrp  TYPE gty_t_vbrkvbrp,
            gw_vbrkvbrp  TYPE gty_vbrkvbrp,
            gt_final     TYPE gty_t_final,
            gw_final     TYPE gty_final,
            gt_fcat      TYPE slis_t_fieldcat_alv,
            gw_fcat      TYPE slis_fieldcat_alv,
            tab          TYPE TABLE OF gty_final.
    data  zbomrnd.
    SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-010.
    SELECT-OPTIONS: s_fkdat FOR vbrk-fkdat,
                     s_bukrs FOR vbrk-bukrs,
                     s_vkorg FOR vbak-vkorg,
                     s_vtweg FOR vbak-vtweg,
                     s_werks FOR vbrp-werks,
                     s_vbeln FOR vbak-vbeln.
    SELECTION-SCREEN END OF BLOCK blk.
    SELECTION-SCREEN BEGIN OF BLOCK selscr WITH FRAME TITLE text-001.
    PARAMETERS: p_rad1 RADIOBUTTON GROUP rad1 USER-COMMAND a ,
                 p_rad2 RADIOBUTTON GROUP rad1 .
    *-- Selection Screen for radio button 2
    SELECTION-SCREEN BEGIN OF BLOCK rad2 WITH FRAME TITLE text-001.
    PARAMETERS:p_file TYPE ibipparms-path MODIF ID one ,
    p_type(4) TYPE c AS LISTBOX VISIBLE LENGTH 20 MODIF ID one.
    SELECTION-SCREEN END OF BLOCK rad2.
    PARAMETERS: p_rad3   RADIOBUTTON GROUP rad1.
    *-- Selection Screen for radio button 3
    SELECTION-SCREEN BEGIN OF BLOCK rad3 WITH FRAME TITLE text-030.
    SELECT-OPTIONS : mail_id FOR e_mail NO INTERVALS MODIF ID two .
    SELECTION-SCREEN END OF BLOCK rad3.
    PARAMETERS:p_rad4   RADIOBUTTON GROUP rad1.
    *-- Selection Screen for radio button 4
    SELECTION-SCREEN BEGIN OF BLOCK rad4 WITH FRAME TITLE text-004.
    PARAMETERS: p_path TYPE rlgrap-filename MODIF ID tri.
    SELECTION-SCREEN END OF BLOCK rad4.
    SELECTION-SCREEN END OF BLOCK selscr.
    INITIALIZATION.
       LOOP AT SCREEN.
         IF  screen-group1 = 'TWO' OR
             screen-group1 = 'TRI'.
           screen-input = 0.
           screen-invisible = 1.
           MODIFY SCREEN.
         ENDIF.
       ENDLOOP.
       date = sy-datum.
       time = sy-uzeit.
       yy = date+0(4).
       mm = date+4(2).
       dd = date+6(2).
       h = time+0(2).
       m = time+2(2).
       s = time+4(2).
       date+0(2) = dd.
       date+2(1) = '-'.
       date+3(2) = mm.
       date+5(1) = '-'.
       date+6(4) = yy.
       time+0(2) = h.
       time+2(1) = '.'.
       time+3(2) = m.
       time+5(1) = '.'.
       time+6(2) = s.
       CONCATENATE  orders date time INTO p_file SEPARATED BY '_'.
       LOOP AT SCREEN.
         IF screen-group1 = 'ONE' OR
         screen-group1 = 'TWO' OR
         screen-group1 = 'TRI'.
           screen-input = 0.
           screen-invisible = 1.
           MODIFY SCREEN.
         ENDIF.
       ENDLOOP.
       gw_list-key = '.TXT'.
       gw_list-text = 'TXT'.
       APPEND gw_list TO gt_list.
       gw_list-key = '.CSV'.
       gw_list-text = 'CSV'.
       APPEND gw_list TO gt_list.
       gw_list-key = '.XLS'.
       gw_list-text = 'XLS'.
       APPEND gw_list TO gt_list.
       CALL FUNCTION 'VRM_SET_VALUES'
         EXPORTING
           id     = 'P_TYPE'
           values = gt_list.
       EXPORT tab TO MEMORY ID 'MESSAGE'.
    AT SELECTION-SCREEN OUTPUT.
       CASE 'X'.
         WHEN p_rad1 .
           LOOP AT SCREEN.
             IF screen-group1 = 'ONE' OR
             screen-group1 = 'TWO' OR
             screen-group1 = 'TRI'.
               screen-input = 0.
               screen-invisible = 1.
               MODIFY SCREEN.
             ENDIF.
           ENDLOOP.
         WHEN p_rad2.
           LOOP AT SCREEN.
             IF  screen-group1 = 'TWO' OR
             screen-group1 = 'TRI'.
               screen-input = 0.
               screen-invisible = 1.
               MODIFY SCREEN.
             ENDIF.
           ENDLOOP.
         WHEN p_rad3.
           LOOP AT SCREEN.
             IF screen-group1 = 'ONE' OR
             screen-group1 = 'TRI'.
               screen-input = 0.
               screen-invisible = 1.
               MODIFY SCREEN.
             ENDIF.
           ENDLOOP.
         WHEN p_rad4.
           LOOP AT SCREEN.
             IF screen-group1 = 'ONE' OR
             screen-group1 = 'TWO'.
               screen-input = 0.
               screen-invisible = 1.
               MODIFY SCREEN.
             ENDIF.
           ENDLOOP.
       ENDCASE.
    AT SELECTION-SCREEN ON p_type.
       CLEAR : gw_values,gt_values.
       REFRESH gt_values.
       gw_values-fieldname = 'P_TYPE'.
       APPEND gw_values TO gt_values.
       CALL FUNCTION 'DYNP_VALUES_READ'
         EXPORTING
           dyname             = sy-cprog
           dynumb             = sy-dynnr
           translate_to_upper = 'X '
         TABLES
           dynpfields         = gt_values.
       READ TABLE gt_values INDEX 1 INTO gw_values.
       IF sy-subrc = 0 AND gw_values-fieldvalue IS NOT INITIAL.
         READ TABLE gt_list INTO gw_list WITH KEY key = gw_values-fieldvalue.
         IF sy-subrc = 0.
           gv_selected_value = gw_list-text.
         ENDIF.
       ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
       CALL FUNCTION 'F4_FILENAME'
         EXPORTING
           program_name  = syst-cprog
           dynpro_number = syst-dynnr
           field_name    = 'P_FILE '
         IMPORTING
           file_name     = p_file.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
       CALL FUNCTION 'F4_FILENAME'
         EXPORTING
           program_name  = syst-cprog
           dynpro_number = syst-dynnr
           field_name    = 'P_PATH'
         IMPORTING
           file_name     = p_path.
    START-OF-SELECTION.
       CONCATENATE p_file p_type INTO p_file .
       PERFORM f_fetch_vbakvbap.
       PERFORM f_fetch_kna1.
       PERFORM f_fetch_vbrk.
       SORT BY gt_kna1.
       PERFORM f_fill_final.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
            EXPORTING
                 PERCENTAGE = sy-tabix
                 TEXT       = 'Extracting Data From Tables'.
    END-OF-SELECTION.
       CASE 'X'.
         WHEN p_rad1.
           IF gt_final IS NOT INITIAL.
             PERFORM f_fill_fcat.
             PERFORM f_display_alv.
           ELSE.
             MESSAGE 'No records exists for the selection' TYPE 'I'.
           ENDIF.
         WHEN p_rad2.
           IF p_type = ''.
             MESSAGE 'Enter the File Type' TYPE 'I'.
             EXPORT tab TO MEMORY ID 'MESSAGE'.
           ELSE.
             PERFORM f_gui_download.
           ENDIF.
         WHEN p_rad3.
           IF mail_id = ''.
             MESSAGE ' Enter the Email ID' TYPE 'I'.
           ELSE.
             PERFORM f_email.
           ENDIF.
         WHEN OTHERS.
           IF p_path = ''.
             MESSAGE 'Enter the Path' TYPE 'I'.
           ENDIF.
       ENDCASE.
    *&      Form  f_fetch_vbakvbap
    *       text
    FORM f_fetch_vbakvbap .
       SELECT vbak~vbeln vbak~vkorg vbak~audat vbak~auart vbak~kunnr
       vbap~posnr vbap~matnr vbap~matkl vbap~kwmeng
       INTO TABLE gt_vbakvbap
       FROM vbak
       INNER JOIN vbap
       ON vbak~vbeln = vbap~vbeln
       WHERE vbak~vtweg IN s_vtweg
       AND vbak~vkorg IN s_vkorg
       AND vbak~vbeln IN s_vbeln.
    ENDFORM.                    "f_fetch_vbakvbap
    *&      Form  f_fetch_kna1
    *       text
    FORM f_fetch_kna1 .
       IF NOT gt_vbakvbap[] IS INITIAL.
         SELECT kunnr land1 name1 ort01
         INTO TABLE gt_kna1
         FROM kna1
         FOR ALL ENTRIES IN gt_vbakvbap
         WHERE kunnr = gt_vbakvbap-kunnr.
       ENDIF.
    ENDFORM.                    "f_fetch_kna1
    *&      Form  f_fetch_vbrk
    *       text
    FORM f_fetch_vbrk .
       IF gt_vbakvbap[] IS NOT INITIAL.
         SELECT vbrk~vbeln vbrk~bukrs vbrk~vkorg vbrk~vtweg vbrk~fkdat vbrp~posnr vbrp~werks
           INTO TABLE gt_vbrkvbrp
         FROM vbrk
         INNER JOIN vbrp
       ON vbrk~vbeln = vbrp~vbeln
         WHERE fkdat IN s_fkdat
         AND   bukrs IN s_bukrs
         AND   werks IN s_werks
         AND   vtweg IN s_vtweg.
       ENDIF.
    ENDFORM. " f_fetch_vbrk
    *&      Form  f_fetch_vbrp
    *       text
    *  -->  p1        text
    *  <--  p2        text
    *&      Form  f_fill_final
    *       text
    FORM f_fill_final .
       CLEAR :gv_qty.
       LOOP AT gt_vbakvbap INTO gw_vbakvbap.
         MOVE : gw_vbakvbap-vbeln TO gw_final-vbeln,
         gw_vbakvbap-vkorg TO gw_final-vkorg,
         gw_vbakvbap-audat TO gw_final-audat,
         gw_vbakvbap-auart TO gw_final-auart,
         gw_vbakvbap-kunnr TO gw_final-kunnr,
         gw_vbakvbap-posnr TO gw_final-posnr,
         gw_vbakvbap-matnr TO gw_final-matnr,
         gw_vbakvbap-matkl TO gw_final-matkl,
         gw_vbakvbap-kwmeng TO gw_final-kwmeng.
         gv_qty = gv_qty + gw_final-kwmeng.
         READ TABLE gt_kna1 INTO gw_kna1 WITH KEY kunnr = gw_vbakvbap-kunnr BINARY SEARCH.
         IF sy-subrc = 0.
           MOVE: gw_kna1-name1 TO gw_final-name1,
                 gw_kna1-land1 TO gw_final-land1,
                 gw_kna1-ort01 TO gw_final-ort01.
         ENDIF.
         READ TABLE gt_vbrkvbrp INTO gw_vbrkvbrp WITH KEY vkorg = gw_vbakvbap-vkorg.
         IF sy-subrc = 0.
           MOVE: gw_vbrkvbrp-fkdat TO gw_final-fkdat,
                 gw_vbrkvbrp-bukrs TO gw_final-bukrs,
                 gw_vbrkvbrp-vtweg TO gw_final-vtweg,
                 gw_vbrkvbrp-werks TO gw_final-werks.
         ENDIF.
         APPEND gw_final TO gt_final.
         CLEAR gw_final.
       ENDLOOP.
    ENDFORM.                    "f_fill_final
    *&      Form  f_fill_fcat
    *       text
    FORM f_fill_fcat .
       gw_fcat-fieldname = 'VBELN'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Sales Order'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'VKORG'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Sales Org.'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'VTWEG'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Distribution Channel'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'AUDAT'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Document Date'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'AUART'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Document Type'.
       APPEND gw_fcat TO gt_fcat.

  • ALV Grid - mark fields as changed

    I have an editable ALV grid, and when the user changes field values then the data_changed event is called correctly so I can validate the changes.
    I am now implementing an upload method which replaces the values in the data table.  The problem is that the control does not recognise the lines as new or changed, so does not do any checking on them or pass to the data_changed event. 
    I can use method if_cached_prop~set_prop ( propname  = 'GridModified'           propvalue = '1' )
    to set the grid modified flag, but  get_modified_cells returns an empty table so there are no fields passed to my data_changed implementation.
    I think I could use method CHANGE_DATA_FROM_INSIDE to set the new values.  However, it is marked as internal only, and it will be very tedious to fill the tables...
    Is there any way to flag fields as changed?
    Alternatively, if I do my checks in my upload method, is there a way to add messages to the output log? 
    Thanks
    Michael

    I have worked out a solution.
    I can use method CHANGE_DATA_FROM_INSIDE, and as long as layout-val_data = 'X' then the data_changed method is called to do validations.  However, the data in fields with errors is deleted...
    My alternative solution is to store the uploaded values and when checking the data, put the uploaded values manually into er_data_changed->mt_good_cells.  The trick is to manually set the grid status to modified, so that the data_changed handler implementation is called - this is done with METHOD gr_grid_0200->if_cached_prop~set_prop.
    The ALV grid data is in <outtab> which has all fields of <outtab> plus a few extras
    I upload from file into <data_table>.
        data:
          ls_mod_cell     type LVC_S_MODI.
    *     Add correct tabix and celltab fields.
          refresh <outtab>.
          clear <gs_outtab>.
    *     Move to outtab structure and put into grid table
          loop at <data_table> assigning <data>.
            move-corresponding <data> to <gs_outtab>.
            insert <gs_outtab> into table <outtab>.
    *       Store the field data for validations
            ls_mod_cell-row_id = sy-tabix.
            ls_mod_cell-tabix = sy-tabix.
            ls_mod_cell-SUB_ROW_ID = fl_uploaded.
            LOOP AT gt_fieldcat_0200 ASSIGNING <fcat>
                    where tech = '' and no_out = ' '.
              ls_mod_cell-fieldname = <fcat>-fieldname.
              assign component <fcat>-fieldname of structure <data> to <value>.
              if sy-subrc = 0.
                ls_mod_cell-value = <value>.
                insert ls_mod_cell into table t_mod_cells.
              endif.
            Endloop.
          endloop.
    *     Update the table display.  This resets the internal version of the data table.
          CALL METHOD gr_grid_0200->refresh_table_display.
    *     Force the GridModified flag to on
          CALL METHOD gr_grid_0200->if_cached_prop~set_prop
            EXPORTING
              propname           = 'GridModified'
              propvalue          = '1'
            EXCEPTIONS
              others             = 0              .
    In the local method for handle_data_changed, I can then use the stored data
    *   When importing data from file, the fields are not checked
    *   Add uploaded values to the data_changed tables
    *   (First remove any fields which have been subsequently changed by the user)
        if t_mod_cells is not initial.
          loop at er_data_changed->mt_mod_cells into ls_mod_cell.
            delete t_mod_cells
                   where row_id    = ls_mod_cell-row_id
                   and   fieldname = ls_mod_cell-fieldname.
          endloop.
          insert lines of t_mod_cells into table er_data_changed->mt_good_cells.
          insert lines of t_mod_cells into table er_data_changed->mt_mod_cells.
        endif.
       ....  Validation code ...
    *   Remove uploaded fields.  Otherwise any without error will blank out the value in the grid...
        delete er_data_changed->mt_good_cells where SUB_ROW_ID = fl_uploaded.
        delete er_data_changed->mt_mod_cells where SUB_ROW_ID = fl_uploaded.
    *   If no errors, remove uploaded data
        if error_in_data EQ space.
          clear t_mod_cells.
        endif.

  • Alv grid with data

    hey,
    alv grid method for export data from alv grid  to itab.
    regards,
    purna

    Hey,
    Any methods for exporting  alv grid data into itab.

  • Reg : ALV Grid Refresh - Output not appearing

    Hi All ,
    Am calling a screen 100 at 3 different places.
    Though i use refresh_table_display , The value in the output table, say i_final changes, but while displaying the output , the whole screen is blank , even the container is not appearing in the output .
    Can you please help me with your inputs .
    Regards,
    Chitra

    yes it is good ...see the example...for your requirement..
    REPORT yztest .
    TYPE-POOLS: slis.
    Tables
    TABLES: mara.
    TYPES: BEGIN OF ty_name,
           name  TYPE char10,
           age   TYPE i,
           END OF ty_name.
    TYPES: BEGIN OF ty_marks,
           sub1   TYPE i,
           sub2   TYPE i,
           total  TYPE  i,
           END OF ty_marks.
    TYPES: BEGIN OF ty_phone,
           phnum TYPE char10,
           END  OF ty_phone.
    TYPES: BEGIN OF ty_addr,
           address TYPE char20,
           END  OF ty_addr .
    Output internal table
    DATA: itab TYPE TABLE OF ty_name,
          wa   TYPE ty_name,
          itab1 TYPE TABLE OF ty_marks,
          wa1  TYPE ty_marks,
          itab2 TYPE TABLE OF ty_phone,
          wa2  TYPE ty_phone,
          itab3 TYPE TABLE OF ty_addr,
          wa3  TYPE ty_addr.
    ALV Grid
    DATA: r_grid  TYPE REF TO cl_gui_alv_grid,
          r_grid1 TYPE REF TO cl_gui_alv_grid,
          r_grid2  TYPE REF TO cl_gui_alv_grid,
          r_grid3  TYPE REF TO cl_gui_alv_grid,
          g_dock TYPE REF TO cl_gui_docking_container,
          g_dock1 TYPE REF TO cl_gui_docking_container,
          g_dock2 TYPE REF TO cl_gui_docking_container,
          g_dock3 TYPE REF TO cl_gui_docking_container,
          g_dock4 TYPE REF TO cl_gui_docking_container,
          it_fieldcat  TYPE lvc_t_fcat,
          it_fieldcat1 TYPE lvc_t_fcat,
          it_fieldcat2 TYPE lvc_t_fcat,
          it_fieldcat3 TYPE lvc_t_fcat,
          wa_fieldcat TYPE lvc_s_fcat.
    DATA picture TYPE REF TO cl_gui_picture.
    DATA url(255).
    CLEAR url.
    DATA  init.
    START-OF-SELECTION.
      wa-name = 'test01'.
      wa-age = '1'.
      APPEND wa TO itab.
      wa-name = 'test02'.
      wa-age = '2'.
      APPEND wa TO itab.
      wa-name = 'test03'.
      wa-age = '3'.
      APPEND wa TO itab.
      wa1-sub1 = '11'.
      wa1-sub2 = '22'.
      wa1-total = wa1-sub1 + wa1-sub2.
      APPEND wa1 TO itab1.
      wa1-sub1 = '22'.
      wa1-sub2 = '33'.
      wa1-total = wa1-sub1 + wa1-sub2.
      APPEND wa1 TO itab1.
      wa2-phnum = '99999999999'.
      APPEND wa2 TO itab2.
      wa2-phnum = '888888888888'.
      APPEND wa2 TO itab2.
      wa2-phnum = '777777777777'.
      APPEND wa2 TO itab2.
      wa3-address = 'HItech City'.
      APPEND wa3 TO itab3.
      wa3-address = 'Secunderabad'.
      APPEND wa3 TO itab3.
      wa3-address = 'Hyderabad'.
      APPEND wa3 TO itab3.
      PERFORM display_image.
      CALL SCREEN 100.
    *& Module STATUS_0100 OUTPUT
    text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'LISTOUT1'.
      SET TITLEBAR 'LIST1'.
      wa_fieldcat-fieldname = 'NAME'.
      wa_fieldcat-seltext   = 'NAME OF THE STUDENT'.
      wa_fieldcat-coltext =   'NAME OF THE STUDENT'.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname = 'AGE'.
      wa_fieldcat-seltext   = 'AGE OF THE STUDENT'.
      wa_fieldcat-coltext =    'AGE OF THE STUDENT'.
      APPEND wa_fieldcat TO it_fieldcat.
      wa_fieldcat-fieldname = 'SUB1'.
      wa_fieldcat-seltext   = 'SUBJECT1'.
      wa_fieldcat-coltext =    'SUBJECT1'.
      APPEND wa_fieldcat TO it_fieldcat1.
      wa_fieldcat-fieldname = 'SUB2'.
      wa_fieldcat-seltext   = 'SUBJECT2'.
      wa_fieldcat-coltext =    'SUBJECT2'.
      APPEND wa_fieldcat TO it_fieldcat1.
      wa_fieldcat-fieldname = 'TOTAL'.
      wa_fieldcat-seltext   = 'TOTAL'.
      wa_fieldcat-coltext =    'TOTAL'.
      APPEND wa_fieldcat TO it_fieldcat1.
      wa_fieldcat-fieldname = 'PHNUM'.
      wa_fieldcat-seltext   = 'PHONE NO'.
      wa_fieldcat-coltext =    'PHONE NO'.
      APPEND wa_fieldcat TO it_fieldcat2.
      wa_fieldcat-fieldname = 'ADDRESS'.
      wa_fieldcat-seltext   = 'ADDRESS'.
      wa_fieldcat-coltext =    'ADDRESS'.
      APPEND wa_fieldcat TO it_fieldcat3.
      IF g_dock IS INITIAL.
        CREATE OBJECT g_dock
                      EXPORTING
                      repid     = sy-repid
                      dynnr     = sy-dynnr
                      side      = g_dock->dock_at_left
                      extension = 300.
        CREATE OBJECT r_grid
                  EXPORTING
                  i_parent = g_dock.
      ENDIF.
      IF g_dock1 IS INITIAL.
        CREATE OBJECT g_dock1
                      EXPORTING
                      repid     = sy-repid
                      dynnr     = sy-dynnr
                      side      = g_dock1->dock_at_right
                      extension = 300.
        CREATE OBJECT r_grid1
                  EXPORTING
                  i_parent = g_dock1.
      ENDIF.
      IF g_dock2 IS INITIAL.
        CREATE OBJECT g_dock2
                      EXPORTING
                      repid     = sy-repid
                      dynnr     = sy-dynnr
                      side      = g_dock2->dock_at_top
                      extension = 100.
        CREATE OBJECT r_grid2
                  EXPORTING
                  i_parent = g_dock2.
        IF g_dock3 IS INITIAL.
          CREATE OBJECT g_dock3
                        EXPORTING
                        repid     = sy-repid
                        dynnr     = sy-dynnr
                        side      = g_dock3->dock_at_top
                        extension = 100.
          CREATE OBJECT r_grid3
                    EXPORTING
                    i_parent = g_dock3.
        ENDIF.
        IF NOT itab[] IS INITIAL.
          CALL METHOD r_grid->set_table_for_first_display
            CHANGING
              it_outtab       = itab
              it_fieldcatalog = it_fieldcat.
        ENDIF.
        IF NOT itab1[] IS INITIAL.
          CALL METHOD r_grid1->set_table_for_first_display
            CHANGING
              it_outtab       = itab1
              it_fieldcatalog = it_fieldcat1.
        ENDIF.
        IF NOT itab2[] IS INITIAL.
          CALL METHOD r_grid2->set_table_for_first_display
            CHANGING
              it_outtab       = itab2
              it_fieldcatalog = it_fieldcat2.
        ENDIF.
        IF NOT itab3[] IS INITIAL.
          CALL METHOD r_grid3->set_table_for_first_display
            CHANGING
              it_outtab       = itab3
              it_fieldcatalog = it_fieldcat3.
        ENDIF.
    if   g_dock4 is initial.
        CREATE OBJECT g_dock4
                      EXPORTING
                      repid     = sy-repid
                      dynnr     = sy-dynnr
                      side      = g_dock4->dock_at_bottom
                      extension = 100.
        CREATE OBJECT picture
                          EXPORTING parent = g_dock4.
        CALL METHOD picture->load_picture_from_url
          EXPORTING
            url = url.
        init = 'X'.
    endif.
      ENDIF.
    ENDMODULE. " STATUS_0100 OUTPUT
    *& Module USER_COMMAND_0100 INPUT
    text
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    *&      Form  display_image
    FORM display_image .
      DATA query_table LIKE w3query OCCURS 1 WITH HEADER LINE.
      DATA html_table LIKE w3html OCCURS 1.
      DATA return_code LIKE  w3param-ret_code.
      DATA content_type LIKE  w3param-cont_type.
      DATA content_length LIKE  w3param-cont_len.
      DATA pic_data LIKE w3mime OCCURS 0.
      DATA pic_size TYPE i.
      REFRESH query_table.
      query_table-name = '_OBJECT_ID'.
      query_table-value = 'ENJOYSAP_LOGO'.
      APPEND query_table.
      CALL FUNCTION 'WWW_GET_MIME_OBJECT'
        TABLES
          query_string        = query_table
          html                = html_table
          mime                = pic_data
        CHANGING
          return_code         = return_code
          content_type        = content_type
          content_length      = content_length
        EXCEPTIONS
          object_not_found    = 1
          parameter_not_found = 2
          OTHERS              = 3.
      IF sy-subrc = 0.
        pic_size = content_length.
      ENDIF.
      CALL FUNCTION 'DP_CREATE_URL'
        EXPORTING
          type     = 'image'
          subtype  = cndp_sap_tab_unknown
          size     = pic_size
          lifetime = cndp_lifetime_transaction
        TABLES
          data     = pic_data
        CHANGING
          url      = url
        EXCEPTIONS
          OTHERS   = 1.
    ENDFORM.                    " display_image
    *&      Module  EXIT  INPUT
          text
    MODULE exit INPUT.
      CALL METHOD g_dock->free.
      CALL METHOD g_dock1->free.
      CALL METHOD g_dock2->free.
      CALL METHOD g_dock3->free.
    ENDMODULE.                 " EXIT  INPUT

  • ALV OO and refreshing the ALV grid

    Hi,
    i have some problems with my ALV 00 program.
    On screen 1 i have to fill in a material number.
    For that material i'm getting some data and show in screen 2 in a ALV grid.
    Via BACK-button i'm getting back to screen 1 and can fill in another material number.
    But the 2nd (and 3rd, etc) time i fill a material, the ALV grid data from material 1 is shown. Even if the internal table I_ALV where the data is, is changed.
    What should i do ?
    I have initialized the customer container and the grid, but that didn't solved the problem.
    regards,
    Hans

    Hi,
    Try clearing and refreshing the alv grid data table in screen 2.
    Check with this code. this code is working fine. If we go back and change the input, it is showing the output corresponding to the second input only.
    Have you use this method?
    <b> GR_ALVGRID->REFRESH_TABLE_DISPLAY</b>
    TYPE-POOLS : SLIS.
    * Tables                                                              *
    TABLES:
      VBRK,
      VBRP.
    * Parameters and select options OR SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS:
                S_VBELN FOR VBRK-VBELN.
    SELECTION-SCREEN END OF BLOCK B1.
    * Internal Tables                                                     *
    * work areas
    DATA: BEGIN OF IT_VBRP OCCURS 0,
           VBELN LIKE VBRK-VBELN,
           POSNR LIKE VBRP-POSNR,
           UEPOS LIKE VBRP-UEPOS,
           FKIMG LIKE VBRP-FKIMG,
           NETWR LIKE VBRP-NETWR,
           MEINS LIKE VBRP-MEINS.
    DATA : END OF IT_VBRP.
    * Variables                                                           *
    DATA : GR_ALVGRID TYPE REF TO CL_GUI_ALV_GRID,
           GC_CUSTOM_CONTROL_NAME TYPE SCRFNAME VALUE 'CC_ALV',
           GR_CCONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
           GT_FIELDCAT TYPE LVC_T_FCAT,
           GS_LAYOUT TYPE LVC_S_LAYO,
           V_FLAG VALUE 'X'.
    * Start of Program                                                    *
    *       INITIALIZATION.                                               *
    INITIALIZATION.
      S_VBELN-LOW = 1.
      S_VBELN-HIGH = 1000000000.
      S_VBELN-OPTION = 'EQ'.
      S_VBELN-SIGN = 'I'.
      APPEND S_VBELN.
    *       SELECTION-SCREEN                                              *
    AT SELECTION-SCREEN.
      PERFORM VALIDATION.
    *       START-OF-SELECTION                                            *
    START-OF-SELECTION.
      PERFORM GET_DATA.
      CALL SCREEN 0100.
    *       END-OF-SELECTION                                              *
    END-OF-SELECTION.
    *       TOP-OF-PAGE                                                   *
    TOP-OF-PAGE.
    *       END-OF-PAGE                                                   *
    END-OF-PAGE.
    *       AT USER-COMMAND                                               *
    *&      Form  VALIDATION
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM VALIDATION .
      SELECT SINGLE VBELN
      FROM VBRK
      INTO VBRK-VBELN
      WHERE VBELN IN S_VBELN.
      IF SY-SUBRC <> 0.
        MESSAGE E000 WITH 'no billing documents found'.
      ENDIF.
    ENDFORM.                    " VALIDATION
    *&      Form  GET_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM GET_DATA .
      SELECT VBELN
             POSNR
             UEPOS
             FKIMG
             NETWR
             MEINS
      FROM VBRP
      INTO TABLE IT_VBRP
      WHERE VBELN IN S_VBELN.
    ENDFORM.                    " GET_DATA
    *&      Module  DISPLAY_ALV  OUTPUT
    *       text
    MODULE DISPLAY_ALV OUTPUT.
      IF V_FLAG = 'X'.
        PERFORM DISPLAY_ALV.
        PERFORM PREPARE_FIELD_CATALOG CHANGING GT_FIELDCAT.
        PERFORM PREPARE_LAYOUT CHANGING GS_LAYOUT.
       CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
            EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              = 'VBRP'
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
              IS_LAYOUT                     = GS_LAYOUT
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
            CHANGING
              IT_OUTTAB                     = IT_VBRP[]
              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.
          CALL METHOD GR_ALVGRID->SET_READY_FOR_INPUT
            EXPORTING
              I_READY_FOR_INPUT = 1.
        ELSE.
          <b>CALL METHOD GR_ALVGRID->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.</b>
        ENDIF.
        CLEAR V_FLAG.
      ENDIF.
    ENDMODULE.                 " DISPLAY_ALV  OUTPUT
    *&      Form  DISPLAY_ALV
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DISPLAY_ALV .
      IF GR_ALVGRID IS INITIAL.
        CREATE OBJECT GR_ALVGRID
          EXPORTING
    *    I_SHELLSTYLE      = 0
    *    I_LIFETIME        =
            I_PARENT          = GR_CCONTAINER
    *    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.
    ENDFORM.                    " DISPLAY_ALV
    *&      Form  PREPARE_FIELD_CATALOG
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM PREPARE_FIELD_CATALOG  CHANGING P_GT_FIELDCAT TYPE LVC_T_FCAT.
      DATA : LS_FCAT TYPE LVC_S_FCAT,
             L_POS TYPE I.
      L_POS = L_POS + 1.
      LS_FCAT-FIELDNAME = 'VBELN'.
      LS_FCAT-TABNAME = 'IT_VBRP'.
      LS_FCAT-COL_POS = L_POS.
      LS_FCAT-SCRTEXT_M = 'Billing Document'.
      LS_FCAT-OUTPUTLEN = '10'.
      APPEND LS_FCAT TO P_GT_FIELDCAT.
      CLEAR LS_FCAT.
      L_POS = L_POS + 1.
      LS_FCAT-FIELDNAME = 'POSNR'.
      LS_FCAT-TABNAME = 'IT_VBRP'.
      LS_FCAT-COL_POS = L_POS.
      LS_FCAT-SCRTEXT_M = 'Billing Item'.
      LS_FCAT-OUTPUTLEN = '6'.
      APPEND LS_FCAT TO P_GT_FIELDCAT.
      CLEAR LS_FCAT.
      L_POS = L_POS + 1.
      LS_FCAT-FIELDNAME = 'UEPOS'.
      LS_FCAT-TABNAME = 'IT_VBRP'.
      LS_FCAT-COL_POS = L_POS.
      LS_FCAT-SCRTEXT_M = 'Higher Level Item'.
      LS_FCAT-OUTPUTLEN = '6'.
      APPEND LS_FCAT TO P_GT_FIELDCAT.
      CLEAR LS_FCAT.
      L_POS = L_POS + 1.
      LS_FCAT-FIELDNAME = 'FKIMG'.
      LS_FCAT-TABNAME = 'IT_VBRP'.
      LS_FCAT-COL_POS = L_POS.
      LS_FCAT-SCRTEXT_M = 'Invoice Quantity'.
      LS_FCAT-OUTPUTLEN = '13'.
      APPEND LS_FCAT TO P_GT_FIELDCAT.
      CLEAR LS_FCAT.
      L_POS = L_POS + 1.
      LS_FCAT-FIELDNAME = 'NETWR'.
      LS_FCAT-TABNAME = 'IT_VBRP'.
      LS_FCAT-COL_POS = L_POS.
      LS_FCAT-SCRTEXT_M = 'Net Value'.
      LS_FCAT-OUTPUTLEN = '15'.
      APPEND LS_FCAT TO P_GT_FIELDCAT.
      CLEAR LS_FCAT.
      L_POS = L_POS + 1.
      LS_FCAT-FIELDNAME = 'MEINS'.
      LS_FCAT-TABNAME = 'IT_VBRP'.
      LS_FCAT-COL_POS = L_POS.
      LS_FCAT-SCRTEXT_M = 'Unit of Measure'.
      LS_FCAT-OUTPUTLEN = '3'.
      APPEND LS_FCAT TO P_GT_FIELDCAT.
      CLEAR LS_FCAT.
      L_POS = L_POS + 1.
    ENDFORM.                    " PREPARE_FIELD_CATALOG
    *&      Form  PREPARE_LAYOUT
    *       text
    *      <--P_GS_LAYOUT  text
    FORM PREPARE_LAYOUT  CHANGING P_GS_LAYOUT TYPE LVC_S_LAYO.
      P_GS_LAYOUT-ZEBRA = 'X'.
      P_GS_LAYOUT-GRID_TITLE = 'INVOICE DETAILS'.
      P_GS_LAYOUT-SMALLTITLE = 'X'.
      P_GS_LAYOUT-EDIT = 'X'.
    ENDFORM.                    " PREPARE_LAYOUT
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'CANCEL'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'CANCEL'.
          LEAVE TO SCREEN 0.
        WHEN 'EXIT'.
          CALL TRANSACTION 'SE38'.
        WHEN 'CHANGE'.
          IF GR_ALVGRID->IS_READY_FOR_INPUT( ) = 0.
            CALL METHOD GR_ALVGRID->SET_READY_FOR_INPUT
              EXPORTING
                I_READY_FOR_INPUT = 1.
          ELSE.
            CALL METHOD GR_ALVGRID->SET_READY_FOR_INPUT
              EXPORTING
                I_READY_FOR_INPUT = 0.
          ENDIF.
      ENDCASE.
    Regards,
    Aswin

Maybe you are looking for

  • How to get data from the called program using SUBMIT in a background job?

    Hi Experts, I've a program which creates a background job using JOB_OPEN and JOB_CLOSE function modules. Between the above function modules I need to call a program using SUBMIT VIA JOB statement. My problem is, How do I fetch some data in an interna

  • Problem searching on a table

    I'm having problem searching data from a table. I'm able to search every single row but when it gets to the last one, it keeps going to the last result. I want it to search everytime I press the button and once it gets to the last result I want a mes

  • Creation of dynamic interal table and fieldcatalog for monat field

    Dear Experts, I am finding the average days of payments giving to our  vendors. for this i am passing company code, fiscal year , period and vendor in selection screen. Based on the period(monat)  i need to display the average days and finally i need

  • Jdbc & national chars

    When I'm trying to fetch some data from oracle that doesn't stored in tables (e.g. select to_char(sysdate,'month') from dual; or error text) I get question marks ('?') instead of correct national characters. If I select national symbols from tables I

  • Can I open Word doc in Pages 06

    I get a string error code everytime I try to open a Word doc in Pages 06. There is an option to repone but nothing ever happens.