Refresh ALV ( Internal Table Will Be Change)

Hi friends
I am using 2 internal table. And they have their own field catalog. I can refresh alv grid.
If my refresh data have stuation 1 I am using Inta another stuation I am using Intb.
How can I refresh my ALV grid with different catalog and internal table?

Hi,
yes you can do that,
Check this sample code, in your case you have to use two performs for display. with the help of SELFIELD-EXIT = 'X'. you can get what you want.
REPORT  ZTEST_ALV.
type-pools:slis.
DATA: GT_SFLIGHT TYPE TABLE OF SFLIGHT.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
      FIELDCAT type SLIS_FIELDCAT_ALV.
data: l_layout type SLIS_LAYOUT_ALV.
SELECT * FROM SFLIGHT INTO TABLE GT_SFLIGHT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
  EXPORTING
    I_PROGRAM_NAME         = sy-repid
    I_STRUCTURE_NAME       = 'SFLIGHT'
    I_INCLNAME             = sy-repid
  CHANGING
    CT_FIELDCAT            = gt_fieldcat
  EXCEPTIONS
    INCONSISTENT_INTERFACE = 1
    PROGRAM_ERROR          = 2
    OTHERS                 = 3.
IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
perform alv_display.
*&      Form  status
*       text
form status USING P_EXTAB TYPE SLIS_T_EXTAB  .
  set pf-status 'AAA' excluding p_extab.
endform.                    "status
*&      Form  USER_COMMAND
*       text
*      -->P_UCOMM    text
*      -->P_SELFIELD text
FORM USER_COMMAND USING    P_UCOMM    LIKE SY-UCOMM
      P_SELFIELD TYPE SLIS_SELFIELD.
  case p_ucomm.
    when 'TEST'.
        fieldcat-no_out = 'X'.
        modify gt_fieldcat from fieldcat
               transporting no_out where fieldname = 'PRICE'.
p_selfield-exit = 'X'.
perform alv_display.
endcase.
ENDFORM.                    "USER_COMMAND
*&      Form  alv_display
*       text
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    IS_LAYOUT                = l_layout
    I_CALLBACK_PROGRAM       = sy-repid
    I_STRUCTURE_NAME         = 'SFLIGHT'
    I_CALLBACK_PF_STATUS_SET = 'STATUS'
    I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
    IT_FIELDCAT              = GT_FIELDCAT[]
  TABLES
    T_OUTTAB                 = GT_SFLIGHT.
ENDFORM.                    " alv_display
Regards
vijay

Similar Messages

  • Can i send back an internal table by using Changing clause?

    i'm using a  Perform statement in SAP Script and i have written corresponding subroutine in an Zprogram.
    In that subroutine i want to create one internal table and send back it to script.
    can i send back an internal table by using Changing clause?
    if it is possible, pls give me the idea................

    Hi,
    While calling the formroutine,just u can pass the individual values using the ITCSY.In form,you are decalring the internal table with structure itcsy-input.
    Then,you need to place the loop on the table and print in script.
    But, passing the internal table in script,is not recomnded..
    Regards,
    Shiva Kumar

  • Dynamic ALV Internal table Problem

    Hi all,I have successfully built an IT using method 'create_dynamic_table'.But my problems are :
    1)When Iam trying to select the data with multiple tables then it is short dumping.
    2)I tried to oselect the data using one table,after selecting the data if I use FM REUSE_ALV_Grid_Display then it is showing short dump with error 'type conflict when calling FM'.
    I never used field symbols before.PLZ complete my program or give me suffecient feedback.Here is my program :
    DATA : g_tdref TYPE REF TO data,
           g_wdref TYPE REF TO data.
    DATA : dats LIKE vbbe-mbdat,
           t_fieldcat TYPE lvc_t_fcat,
           wa_fieldcat TYPE lvc_s_fcat.
    FIELD-SYMBOLS : <it_dyn> TYPE STANDARD TABLE,
                    <wa_dyn>,
                    <dyn_field>.
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_mbdat FOR dats.
    SELECTION-SCREEN END OF BLOCK blk1.
    wa_fieldcat-tabname = 'MSKA'.
    wa_fieldcat-fieldname = 'WERKS'.
    wa_fieldcat-datatype = 'CHAR'.
    wa_fieldcat-intlen = '10'.
    APPEND wa_fieldcat TO t_fieldcat.
    CLEAR : wa_fieldcat.
    wa_fieldcat-tabname = 'MSKA'.
    wa_fieldcat-fieldname = 'MATNR'.
    wa_fieldcat-datatype = 'CHAR'.
    wa_fieldcat-seltext = 'Material Number'.
    wa_fieldcat-intlen = '18'.
    APPEND wa_fieldcat TO t_fieldcat.
    CLEAR : wa_fieldcat.
    wa_fieldcat-tabname = 'MAKT'.
    wa_fieldcat-fieldname = 'MAKTX'.
    wa_fieldcat-datatype = 'CHAR'.
    wa_fieldcat-intlen = '10'.
    APPEND wa_fieldcat TO t_fieldcat.
    CLEAR : wa_fieldcat.
    wa_fieldcat-tabname = 'VBBE'.
    wa_fieldcat-fieldname = 'MBDAT'.
    wa_fieldcat-datatype = 'CHAR'.
    wa_fieldcat-intlen = '10'.
    APPEND wa_fieldcat TO t_fieldcat.
    CLEAR : wa_fieldcat.
    wa_fieldcat-tabname = 'VBBE'.
    wa_fieldcat-fieldname = 'OMENG'.
    wa_fieldcat-datatype = 'QUAN'.
    wa_fieldcat-intlen = '10'.
    APPEND wa_fieldcat TO t_fieldcat.
    CLEAR : wa_fieldcat.
    DATA : d TYPE i,
           v(02) TYPE n VALUE '0',
           day(8) TYPE c.
    d = s_mbdat-high - s_mbdat-low + 1.
    DO d TIMES.
      v = v + 1.
      CONCATENATE 'Day' v INTO day.
      wa_fieldcat-tabname = 'VBBE'.
      wa_fieldcat-fieldname = day.
      wa_fieldcat-datatype = 'DATS'.
      wa_fieldcat-seltext = day.
      wa_fieldcat-intlen = '8'.
      APPEND wa_fieldcat TO t_fieldcat.
      CLEAR : wa_fieldcat.
    ENDDO.
    *-----Building Dynamic internal table.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
        it_fieldcatalog = t_fieldcat
      IMPORTING
        ep_table        = g_tdref.
    ASSIGN g_tdref->* TO <it_dyn>.
    CREATE DATA g_wdref LIKE LINE OF <it_dyn>.
    ASSIGN g_wdref->* TO <wa_dyn>.
    SELECT m~werks m~matnr v~omeng v~mbdat INTO CORRESPONDING FIELDS
    OF TABLE <it_dyn> FROM mska AS m INNER JOIN vbbe AS v
    ON m~posnr = v~posnr WHERE v~mbdat IN s_mbdat.

    *DATA : d TYPE i,
          v(02) TYPE n VALUE '0',
          day(8) TYPE c.
    *d = s_mbdat-high - s_mbdat-low + 1.
    *DO d TIMES.
    v = v + 1.
    CONCATENATE 'Day' v INTO day.
    wa_fieldcat-tabname = 'VBBE'.
    wa_fieldcat-fieldname = day.
    wa_fieldcat-datatype = 'DATS'.
    wa_fieldcat-seltext = day.
    wa_fieldcat-intlen = '8'.
    APPEND wa_fieldcat TO t_fieldcat.
    CLEAR : wa_fieldcat.
    *ENDDO.
    *-----Building Dynamic internal table.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
        it_fieldcatalog = t_fieldcat
      IMPORTING
        ep_table        = g_tdref.
    ASSIGN g_tdref->* TO <it_dyn>.
    CREATE DATA g_wdref LIKE LINE OF <it_dyn>.
    ASSIGN g_wdref->* TO <wa_dyn>.
    SELECT OMENG FROM VBBE INTO CORRESPONDING FIELDS OF TABLE <IT_DYN> WHERE MBDAT IN S_MBDAT.
    BREAK-POINT.
    YOU WILL GET VALUES IN INTERNAL TABLE.
    TO SOLVE YOUR ISSUE YOU SHOULD USE NUM INSTEAD OF DATS.

  • How to save Internal table inside Personnel Change Request after JSPcode ??

    HI ,
         I have built up Som Org management Data while running PCR . But when it goes to JSP for form display
    and comes back to SAP. The internal table that I have saved in SAP MEMORY / ABAP MEMORY is getting washed off..
    I m building the table in the INIT method of the BADI ( qisr1) .
    Can any body suggest a way for saving the DATA when control is back from JSP.
    is it posible thr saving in som class private data ??

    SAP and ABAP Memory belong to a user session, in a new session you wont have access to the ABAP/SAP Memory of another session. Seems like you are using a stateless JSP.
    Instead you could use the Shared Memory, check this link: http://help.sap.com/saphelp_nw04s/helpdata/en/14/dafc3e9d3b6927e10000000a114084/frameset.htm or you use a Server-Side cookie, http://help.sap.com/saphelp_nw70/helpdata/EN/bd/4cd23a09313b37e10000000a11405a/frameset.htm
    regards,
    Markus

  • Dynamic Internal Table - data type changed automatically

    Dear All,
    I have a requirement of craetion of dynamic inetrnal table which I have created referring to a custom table .
    In that custom table there is field ZDC002 of type DEC(16,7) which is converted to data type P(9,7) .
    Now it works fine if 2 digit and 7 decimals  value passed like 12.1234567 but it gives overflow error when passing more than 2 digit value .
    Please help me as I have no control to SAP standard functinality while creation of data-type . My piece of code :
    ref_table_des ?=
          cl_abap_typedescr=>describe_by_name( 'ZBW_EE_DCONTR' ).
          idetails[] = ref_table_des->components[].
    In this idetails[] table filedname data type changed from DEC16,7 to data type P(9,7). => Total Length of Packed Data Type is 9 which allows to contain only 2 numericdigits and 7 decimals => puts overflow error if more than 2 numeric data passed.
    Any suggestions will be appreciated.
    Thanks,
    Sachin

    Did you try to view the code on the Data Source view and cube that it is reflecting the correct data type on both places? if not you can change there and save it.
    prajwal kumar potula

  • How to update/modify the ALV internal table once it is displayed

    Hi All,
    I have a alv grid report using fm reuse_alv_grid_dispaly. My requirement is to create sales order using bapi (up to here it is working fine) and once the SO is created update the function module tables field with the created sales order.
    Example:
    My alv grid display before creating SO:
    Customer Material    SalesOrder
    1000001  material1 
    My alv grid display after creating SO:
    Customer Material    SalesOrder
    1000001  material1  3025642
    How can I achieve this functionality. Because the field catalog is already displayed, how can I modify/update it by adding the sales order number to it. Experts, suggest me.
    Thanks.

    FORM callback_ucomm USING ucomm LIKE sy-ucomm
                                   selfield TYPE slis_selfield.
    CASE ucomm.
        WHEN 'CRE'.
    * Logic to create sales order here...
    * Show the Sales order column
        CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
          IMPORTING
            et_fieldcat   = gt_fieldcat
          EXCEPTIONS
            no_infos      = 1
            program_error = 2
            OTHERS        = 3.
        if sy-subrc eq 0.
          read table gt_fieldcat into gs_fieldcat with key fieldname = 'VBELN'.
          if sy-subrc eq 0.
            gs_fieldcat-no_out = space.
            gs_fieldcat-tech   = space.
            modify gt_fieldcat from gs_fieldcat index sy-tabix transporting no_out tech.
          endif.
          CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_SET'
            EXPORTING
              it_fieldcat          = gt_fieldcat[].
        endif.
    ENDFORM.

  • Dynamic ALV and internal table.

    Hi all,
    I have a requirement of creating a dynamic field catelog based on input values in selection screen.
    Example:
    1) When I enter date range, say  20/03/2008 to 25/03/2008 I should have 6 columns in the output for each date with column heading as date itself.
    2) For entering values for these date columns, i need to create an dynamic internal table.(values in the column will be some numbers like 10 on 20/03/2008, 15 on 21/03/2008  etc)
    A rough output format would look like this:
    Component |  20/03/2008  |  21/03/2008 | .....      |25/03/2008
    comp1        |    10            |      15         |             |      5
    comp2        |    20            |      10         |             |     10
    Please let me know how can i achieve this...
    Need it very urgently..
    Regards,
    Dhareppa

    Hi Dhareppa,
    Refer the code below. Its almost on the same line as your requirments.
    REPORT  zglo2fr_master_planing_sedul NO STANDARD PAGE HEADING.
              P  R  O  G  R  A  M    H  E  A  D  E  R                   *
                        ArthroCare Corporation                          *
    Program            : ZGLO2FR_MASTER_PLANING_SEDUL                   *
    Author             : Munvar Basha                                   *
    Creation Date      : 11Mar08                                        *
    Release            : SAP ECC 6.0                                    *
    Request            : D01K904032                                     *
    Description        : Master Schedule Planning                       *
    Change log (Revisions)                                              *
    Author     Date     Request    Description                          *
                             P  R  O  G  R  A  M                        *
                           DATA DECLARATION                             *
    **--Structure to hold matrial & plant combination records.
    TYPES : BEGIN OF ty_marc,
              matnr  TYPE matnr,
              werks  TYPE werks_d,
              dispo  TYPE dispo,
              beskz  TYPE beskz,
              mtart  TYPE mtart,
            END OF ty_marc.
    **--structure to hold MRP LIST Data.
    TYPES : BEGIN OF ty_mrp_list,
              matnr TYPE matnr,
              werks TYPE werks_d,
              maktx TYPE maktx,
              meins TYPE meins,
              mtart TYPE mtart,
              week  TYPE kweek,
              mng01 TYPE mng01,
              delkz TYPE delkz,
            END OF ty_mrp_list.
    **--structure to hold no of weeks.
    TYPES: BEGIN OF ty_week,
             week TYPE kweek,
           END OF ty_week.
    **--structure to hold output data.
    TYPES : BEGIN OF ty_final,
              matnr TYPE matnr,
              werks TYPE werks_d,
              maktx TYPE maktx,
              meins TYPE meins,
              mtart TYPE mtart,
              week  TYPE kweek,
              mng01 TYPE mng01,
            END OF ty_final.
    TYPES : BEGIN OF ty_range,
              sign   TYPE sign,
              option TYPE option,
              low    TYPE sy-datum,
              high   TYPE sy-datum,
            END OF ty_range.
              Definitions of Table types.                               *
    TYPES : ty_marctab TYPE STANDARD TABLE OF ty_marc.
               Definitions of Ranges                                    *
    *RANGES ran_delkz FOR mdez-delkz.
    DATA : i_ran_delkz TYPE RANGE OF  mdez-delkz,
           wa_ran_delkz LIKE LINE OF i_ran_delkz,
           wa_date type ty_range.
               Definitions of internal tables.                          *
    data : i_marc      type standard table of ty_marc,
           i_mrp_list  type standard table of ty_mrp_list,
           i_week      type standard table of ty_week,
           i_final     type standard table of ty_final,
           i_mdps      type standard table of mdps,
           i_mdez      type standard table of mdez,
           i_mdsu      type standard table of mdsu.
               Definitions of work areas for internal tables            *
    DATA : wa_marc     TYPE ty_marc,
           wa_mrp_list TYPE ty_mrp_list,
           wa_week     TYPE ty_week,
           wa_final    TYPE ty_final,
           wa_mt61d    TYPE mt61d,
           wa_mdez     TYPE mdez.
               Definitiions of General variables                        *
    DATA : v_matnr TYPE mara-matnr, " Material Number
           v_mtart TYPE mara-mtart, " Material Type
           v_beskz TYPE marc-beskz, " Procurement Type
           v_werks TYPE marc-werks, " Plant
           v_dispo TYPE marc-dispo. " MRP Controller (Materials Planner)
    DATA : v_mng01 TYPE mng01. "Requirement Quantity
    DATA : v_year  TYPE char4,
           v_week  TYPE char2,
           v_ok_code TYPE sy-ucomm.
               Definitiions of Constants                                *
    CONSTANTS : k_slash TYPE c     VALUE '/',
                k_6     TYPE char8 VALUE '6',
                k_x     TYPE c     VALUE 'X'.
               Definitiions of Field Catlog                             *
    DATA : wa_fieldcat        TYPE lvc_s_fcat,
           i_fieldcat         TYPE lvc_t_fcat,
           v_container        TYPE scrfname VALUE 'CONTAINER_OUTPUT',
           v_custom_container TYPE REF TO cl_gui_custom_container,
           v_grid             TYPE REF TO cl_gui_alv_grid,
           i_gp_table           TYPE REF TO data,
           wa_gp_line            TYPE REF TO data.
    FIELD-SYMBOLS: <gt_table>  TYPE STANDARD TABLE,
                   <gwa_table> TYPE ANY,
                   <l_field>   TYPE ANY,
                   <l_matnr>   TYPE ANY,
                   <l_werks>   TYPE ANY,
                   <l_maktx>   TYPE ANY,
                   <l_meins>   TYPE ANY,
                   <l_mtart>   TYPE ANY.
                 DECLERATIONS FOR SELECTION SCREEN                      *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_matnr FOR v_matnr,
                     s_mtart FOR v_mtart NO INTERVALS,
                     s_beskz FOR v_beskz NO INTERVALS NO-EXTENSION,
                     s_werks FOR v_werks NO INTERVALS NO-EXTENSION
                     OBLIGATORY,
                     s_dispo FOR v_dispo,
                     s_date  FOR sy-datum OBLIGATORY.
    PARAMETERS :     p_dattp   TYPE dattp OBLIGATORY DEFAULT '1'.
    SELECTION-SCREEN END OF BLOCK b1.
               INITIALIZATION EVENT                                     *
    INITIALIZATION.
      CALL FUNCTION '/BEV4/PLPS__ADD_MONTH_TO_DATE'
        EXPORTING
          months  = k_6
          olddate = sy-datum
        IMPORTING
          newdate = wa_date-high.
      wa_date-low = sy-datum.
      wa_date-option = 'EQ'.
      wa_date-sign = 'I'.
      APPEND wa_date to s_date.
               SELECTION SCREEN EVENT                                   *
    **--Validation for Material
    AT SELECTION-SCREEN ON s_matnr.
      PERFORM validate_material.
    **--Validation for Plant
    AT SELECTION-SCREEN ON s_werks.
      PERFORM validate_plant.
                AT SELECTION-SCREEN ENENT                               *
    AT SELECTION-SCREEN.
      IF s_matnr IS INITIAL AND s_dispo IS INITIAL.
        MESSAGE text-002 TYPE 'E'.
      ENDIF.
      IF s_date-low LT sy-datum.
        MESSAGE text-003 TYPE 'E'.
      ENDIF.
                           START-OF-SELECTION EVENT                     *
    START-OF-SELECTION.
    **--refreshing the internal tables
      REFRESH : i_marc,
                i_mrp_list,
                i_week,
                i_final,
                i_mdps,
                i_mdez,
                i_mdsu.
    **--clearing the work areas of internal tables.
      CLEAR : wa_marc,
              wa_mrp_list,
              wa_week,
              wa_final,
              wa_mt61d,
              wa_mdez.
    To get all the matrial(s) and plant combination records
      SELECT a~matnr
             a~werks
             a~dispo
             a~beskz
             b~mtart
             INTO TABLE i_marc
             FROM marc AS a INNER JOIN
                  mara AS b
                  ON a~matnr = b~matnr
             WHERE a~werks IN s_werks AND
                   a~matnr IN s_matnr AND
                   a~dispo IN s_dispo AND
                   a~beskz IN s_beskz AND
                   b~mtart IN s_mtart.
      IF sy-subrc <> 0.
        MESSAGE text-005 TYPE 'S'.
        LEAVE LIST-PROCESSING.
      ENDIF.
      SORT i_marc BY matnr werks.
    Ranges to Filter the MRP list only for the following MRP Elements.
    MRP Elements are : BA, BE, FE, LE and PA
      wa_ran_delkz-sign = 'I'.
      wa_ran_delkz-option = 'EQ'.
      wa_ran_delkz-low = 'BA'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      wa_ran_delkz-low = 'BE'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      wa_ran_delkz-low = 'FE'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      wa_ran_delkz-low = 'LE'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      wa_ran_delkz-low = 'PA'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      LOOP AT i_marc INTO wa_marc.
        CALL FUNCTION 'MD_MRP_LIST_API'
          EXPORTING
            matnr                    = wa_marc-matnr
            werks                    = wa_marc-werks
            sinfg                    = k_x
            inper                    = p_dattp
          IMPORTING
            e_mt61d                  = wa_mt61d
          TABLES
            mdpsx                    = i_mdps
            mdezx                    = i_mdez
            mdsux                    = i_mdsu
          EXCEPTIONS
            mrp_list_not_found       = 1
            material_plant_not_found = 2
            error                    = 3
            OTHERS                   = 4.
        IF sy-subrc = 0.
          LOOP AT i_mdez INTO wa_mdez WHERE dat00 IN s_date AND
                                            delkz IN i_ran_delkz.
            CALL FUNCTION 'DATE_GET_WEEK'
              EXPORTING
                date         = wa_mdez-dat00
              IMPORTING
                week         = wa_mrp_list-week
              EXCEPTIONS
                date_invalid = 1
                OTHERS       = 2.
            IF sy-subrc = 0.
              wa_mrp_list-matnr = wa_mt61d-matnr.
              wa_mrp_list-werks = wa_mt61d-werks.
              wa_mrp_list-maktx = wa_mt61d-maktx.
              wa_mrp_list-meins = wa_mt61d-meins.
              wa_mrp_list-mtart = wa_mt61d-mtart.
              wa_mrp_list-delkz = wa_mdez-delkz.
              wa_mrp_list-mng01 = wa_mdez-mng01.
              APPEND wa_mrp_list TO i_mrp_list.
              CLEAR : wa_mrp_list,
                      wa_mdez.
            ENDIF.
          ENDLOOP.
        ENDIF.
        CLEAR: wa_marc.
      ENDLOOP.
      IF i_mrp_list IS INITIAL.
        MESSAGE text-006 TYPE 'S'.
        LEAVE LIST-PROCESSING.
      ENDIF.
      CLEAR : v_mng01.
      LOOP AT i_mrp_list INTO wa_mrp_list.
        v_mng01 = v_mng01 + wa_mrp_list-mng01.
        AT END OF week.
          wa_final-matnr = wa_mrp_list-matnr.
          wa_final-werks = wa_mrp_list-werks.
          wa_final-maktx = wa_mrp_list-maktx.
          wa_final-meins = wa_mrp_list-meins.
          wa_final-mtart = wa_mrp_list-mtart.
          wa_final-week  = wa_mrp_list-week.
          wa_final-mng01 = v_mng01.
          wa_week-week =   wa_mrp_list-week.
          APPEND : wa_final TO i_final,
                   wa_week  TO i_week.
          CLEAR : v_mng01,
                  wa_final,
                  wa_week.
        ENDAT.
        CLEAR : wa_mrp_list.
      ENDLOOP.
    **-- Populate the Field catalog
      PERFORM populate_fieldcat.
    **--Create table dynamically
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = i_fieldcat
        IMPORTING
          ep_table        = i_gp_table.
      ASSIGN i_gp_table->* TO <gt_table>.
    **--fill table with final output data
      PERFORM fill_table.
      CALL SCREEN 100.
                              SUB ROUTINES                              *
    *&      Form  validate_material                                        *
          Validating Material Number(s)                                  *
    FORM validate_material .
      TYPES : BEGIN OF l_ty_matnr,
               matnr TYPE matnr,
              END OF l_ty_matnr.
      DATA : l_i_matnr TYPE STANDARD TABLE OF l_ty_matnr.
      SELECT matnr
             FROM mara
             INTO TABLE l_i_matnr
             WHERE matnr IN s_matnr.
      IF sy-subrc <> 0.
        MESSAGE text-004 TYPE 'E'.
      ENDIF.
    ENDFORM.                    " validate_material
    *&      Form  validate_plant                                           *
          Validating Plant Number                                        *
    FORM validate_plant .
      DATA : l_v_werks TYPE werks_d.
      SELECT SINGLE werks
                    FROM t001w
                    INTO l_v_werks
                    WHERE werks = s_werks-low.
      IF sy-subrc <> 0.
        MESSAGE e019(zartc) WITH s_werks-low.
      ENDIF.
    ENDFORM.                    " validate_plant
    *&      Form  populate_fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM populate_fieldcat .
      DATA : l_v_colname TYPE char7.
      SORT i_week BY week.
      DELETE ADJACENT DUPLICATES FROM i_week COMPARING week.
      LOOP AT i_week INTO wa_week.
        AT FIRST.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 1.
          wa_fieldcat-fieldname   = 'MATNR'.
          wa_fieldcat-scrtext_l   = text-007.
          wa_fieldcat-scrtext_m   = text-007.
          wa_fieldcat-scrtext_s   = text-007.
          wa_fieldcat-fix_column  = 'X'.
          wa_fieldcat-outputlen   = 18.
          wa_fieldcat-tooltip     = text-007.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 2.
          wa_fieldcat-fieldname   = 'WERKS'.
          wa_fieldcat-scrtext_l   = text-008.
          wa_fieldcat-scrtext_m   = text-008.
          wa_fieldcat-scrtext_s   = text-008.
          wa_fieldcat-fix_column  = 'X'.
          wa_fieldcat-outputlen   = 4.
          wa_fieldcat-tooltip     = text-008.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 3.
          wa_fieldcat-fieldname   = 'MAKTX'.
          wa_fieldcat-scrtext_l   = text-009.
          wa_fieldcat-scrtext_m   = text-010.
          wa_fieldcat-scrtext_s   = text-011.
          wa_fieldcat-tooltip     = text-009.
          wa_fieldcat-outputlen   = 40.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 4.
          wa_fieldcat-fieldname   = 'MEINS'.
          wa_fieldcat-scrtext_l   = text-012.
          wa_fieldcat-scrtext_m   = text-013.
          wa_fieldcat-scrtext_s   = text-014.
          wa_fieldcat-outputlen   = 4.
          wa_fieldcat-tooltip     = text-012.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 5.
          wa_fieldcat-fieldname   = 'MTART'.
          wa_fieldcat-scrtext_l   = text-015.
          wa_fieldcat-scrtext_m   = text-015.
          wa_fieldcat-scrtext_s   = text-016.
          wa_fieldcat-tooltip     = text-015.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
        ENDAT.
        v_year = wa_week-week+0(4).
        v_week = wa_week-week+4(2).
        CONCATENATE v_week k_slash v_year INTO l_v_colname.
        wa_fieldcat-row_pos     = 0.
        wa_fieldcat-col_pos     = 6 + sy-index.
        wa_fieldcat-fieldname   = wa_week-week.
        wa_fieldcat-quantity    = 'X'.
        wa_fieldcat-outputlen   = 18.
        wa_fieldcat-scrtext_l   = l_v_colname.
        wa_fieldcat-tooltip     = l_v_colname.
        APPEND wa_fieldcat TO i_fieldcat.
        CLEAR : wa_fieldcat,
                l_v_colname,
                wa_week.
      ENDLOOP.
    ENDFORM.                    " populate_fieldcat
    *&      Form  fill_table
          text
    -->  p1        text
    <--  p2        text
    FORM fill_table .
    **--Create Work Area Dynamically
      CREATE DATA wa_gp_line LIKE LINE OF <gt_table>.
      ASSIGN wa_gp_line->* TO <gwa_table>.
      DATA : l_v_col TYPE char25,
             l_v_val TYPE char25.
      LOOP AT i_final INTO wa_final.
        l_v_col = wa_final-week.
        ASSIGN COMPONENT l_v_col OF STRUCTURE <gwa_table>
                                           TO <l_field>.
        IF <l_field> IS ASSIGNED.
          l_v_val = wa_final-mng01.
          CONDENSE l_v_val.
          <l_field> = l_v_val.
          clear : l_v_val,
                  l_v_col.
        ENDIF.
        AT END OF matnr.
         READ TABLE   i_final INTO wa_final WITH KEY matnr = wa_final-matnr
                                                              BINARY SEARCH.
          IF sy-subrc = 0.
            ASSIGN COMPONENT 'MATNR' OF STRUCTURE <gwa_table>
                                             TO <l_matnr>.
            IF <l_matnr> IS ASSIGNED.
              <l_matnr> = wa_final-matnr.
            ENDIF.
            ASSIGN COMPONENT 'WERKS' OF STRUCTURE <gwa_table>
                                             TO <l_werks>.
            IF <l_werks> IS ASSIGNED.
              <l_werks> = wa_final-werks.
            ENDIF.
            ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <gwa_table>
                                             TO <l_maktx>.
            IF <l_maktx> IS ASSIGNED.
              <l_maktx> = wa_final-maktx.
            ENDIF.
            ASSIGN COMPONENT 'MEINS' OF STRUCTURE <gwa_table>
                                             TO <l_meins>.
            IF <l_meins> IS ASSIGNED.
              <l_meins> = wa_final-meins.
            ENDIF.
            ASSIGN COMPONENT 'MTART' OF STRUCTURE <gwa_table>
                                             TO <l_mtart>.
            IF <l_mtart> IS ASSIGNED.
              <l_mtart> = wa_final-mtart.
            ENDIF.
            APPEND <gwa_table> TO <gt_table>.
            CLEAR <gwa_table>.
          ENDIF.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " fill_table
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'ZMUNNA'.
      SET TITLEBAR 'MRP'.
      IF v_custom_container IS INITIAL.
        CREATE OBJECT v_custom_container
          EXPORTING
            container_name = v_container.
        CREATE OBJECT v_grid
          EXPORTING
            i_parent = v_custom_container.
        CALL METHOD v_grid->set_table_for_first_display
          CHANGING
            it_outtab       = <gt_table>
            it_fieldcatalog = i_fieldcat.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      v_ok_code = sy-ucomm.
      CLEAR sy-ucomm.
      CASE v_ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
          SET SCREEN 000.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  exit_program
          text
    -->  p1        text
    <--  p2        text
    FORM exit_program .
      CALL METHOD v_custom_container->free.
      CALL METHOD cl_gui_cfw=>flush.
    ENDFORM.                    " exit_program
    Reward points if that helps.
    Manish

  • Update all alv (grid) displayed records to internal table

    Hi all,
    i want to update the records into the internal table which are changed by the user in the edit field.
    after he select save button.
    i  have to save the ALV grid displayed records in the internal table.
    hw can i do this ?

    ALV with EDIT and SAVE functionality
    Code:REPORT z_demo_alv_jg.*******************************************************************
    TYPE-POOLS                                                      *
    TYPE-POOLS: slis. *******************************************************************
    INTERNAL TABLES/WORK AREAS/VARIABLES     *
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
          i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
          w_field TYPE slis_fieldcat_alv,
          p_table LIKE dd02l-tabname,
          dy_table TYPE REF TO data,
          dy_tab TYPE REF TO data,
          dy_line TYPE REF TO data.*******************************************************************
    FIELD-SYMBOLS                                                   *
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                   <dyn_wa> TYPE ANY,
                   <dyn_field> TYPE ANY,
                   <dyn_tab_temp> TYPE STANDARD TABLE.*******************************************************************
    SELECTION SCREEN                                                *
    PARAMETERS: tabname(30) TYPE c,
                lines(5)  TYPE n.*******************************************************************
    START-OF-SELECTION                                              *
    START-OF-SELECTION.* Storing table name
      p_table = tabname.* Create internal table dynamically with the stucture of table name
    entered in the selection screen
      CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_table->* TO <dyn_table>.
      IF sy-subrc <> 0.
        MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.    LEAVE TO LIST-PROCESSING.
      ENDIF.
    Create workarea for the table
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.* Create another temp. table
      CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_tab->* TO <dyn_tab_temp>.  SORT i_fieldcat BY col_pos.* Select data from table
      SELECT * FROM (p_table)
      INTO TABLE <dyn_table>
      UP TO lines ROWS.  REFRESH <dyn_tab_temp>.* Display report
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = sy-repid
          i_structure_name         = p_table
          i_callback_user_command  = 'USER_COMMAND'
          i_callback_pf_status_set = 'SET_PF_STATUS'
        TABLES
          t_outtab                 = <dyn_table>
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.  IF sy-subrc <> 0.  ENDIF.&----
    *&      Form  SET_PF_STATUS
          Setting custom PF-Status
         -->RT_EXTAB   Excluding table
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.  SET PF-STATUS 'Z_STANDARD'.ENDFORM.                    "SET_PF_STATUS&----
    *&      Form  user_command
          Handling custom function codes
         -->R_UCOMM      Function code value
         -->RS_SELFIELD  Info. of cursor position in ALV
    FORM user_command  USING    r_ucomm LIKE sy-ucomm
                               rs_selfield TYPE slis_selfield.* Local data declaration
      DATA: li_tab TYPE REF TO data,
            l_line TYPE REF TO data.* Local field-symbols
      FIELD-SYMBOLS:<l_tab> TYPE table,
                    <l_wa>  TYPE ANY.* Create table
      CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN li_tab->* TO <l_tab>.* Create workarea
      CREATE DATA l_line LIKE LINE OF <l_tab>.
      ASSIGN l_line->* TO <l_wa>.  CASE r_ucomm.*   When a record is selected
        WHEN '&IC1'.*     Read the selected record
          READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
          rs_selfield-tabindex.      IF sy-subrc = 0.*       Store the record in an internal table
            APPEND <dyn_wa> TO <l_tab>.*       Fetch the field catalog info
            CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
              EXPORTING
                i_program_name         = 'Z_DEMO_PDF_JG'
                i_structure_name       = p_table
              CHANGING
                ct_fieldcat            = i_fieldcat
              EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
            IF sy-subrc = 0.*         Make all the fields input enabled except key fields
              w_field-input = 'X'.          MODIFY i_fieldcat FROM w_field TRANSPORTING input
              WHERE key IS INITIAL.        ENDIF.*       Display the record for editing purpose
            CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
              EXPORTING
                i_callback_program    = sy-repid
                i_structure_name      = p_table
                it_fieldcat           = i_fieldcat
                i_screen_start_column = 10
                i_screen_start_line   = 15
                i_screen_end_column   = 200
                i_screen_end_line     = 20
              TABLES
                t_outtab              = <l_tab>
              EXCEPTIONS
                program_error         = 1
                OTHERS                = 2.        IF sy-subrc = 0.*         Read the modified data
              READ TABLE <l_tab> INDEX 1 INTO <l_wa>.*         If the record is changed then track its index no.
            and populate it in an internal table for future
            action
              IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
                <dyn_wa> = <l_wa>.
                i_index = rs_selfield-tabindex.
                APPEND i_index.
              ENDIF.
            ENDIF.      ENDIF.*   When save button is pressed
        WHEN 'SAVE'.*     Sort the index table
          SORT i_index.*     Delete all duplicate records
          DELETE ADJACENT DUPLICATES FROM i_index.      LOOP AT i_index.*       Find out the changes in the internal table
          and populate these changes in another internal table
            READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
            IF sy-subrc = 0.
              APPEND <dyn_wa> TO <dyn_tab_temp>.
            ENDIF.      ENDLOOP.*     Lock the table
          CALL FUNCTION 'ENQUEUE_E_TABLE'
            EXPORTING
              mode_rstable   = 'E'
              tabname        = p_table
            EXCEPTIONS
              foreign_lock   = 1
              system_failure = 2
              OTHERS         = 3.      IF sy-subrc = 0.*       Modify the database table with these changes
            MODIFY (p_table) FROM TABLE <dyn_tab_temp>.        REFRESH <dyn_tab_temp>.*       Unlock the table
            CALL FUNCTION 'DEQUEUE_E_TABLE'
              EXPORTING
                mode_rstable = 'E'
                tabname      = p_table.      ENDIF.
      ENDCASE.  rs_selfield-refresh = 'X'.ENDFORM.                    "user_command

  • 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

  • Need ALV LIST for displaying Dynamic Internal Tables

    Hi Guys,
                     I have some thing like 2 Dynamic internal tables.
    Say 1st Internal table will be filled based on some condition.
    say 2nd table will be filled based on some condition.
    When appending the 1st Internal table, if that internal table is filled it creates another internal table of same kind and continues so on until some condition.
    In the same way when appending the 2nd Internal table, if that internal table is filled it creates another internal table of same kind and continues so on until some condition.
    My requirement is I need to display all these Internal tables in the output.
    The output should look something like
    1st Internal Table
    some gap
    2nd Internal Table
    some gap
    so on...................
    Is there any standard ALV List, to display all these Internal Tables in such a way.
    Thanks,
    Prasad.

    Hi.
    One thing more here is code which get 10 records from 2 tables and then show them in ALV.
    first when u execute it will show data from ist table.
    when u go back (F3) then it will sow data from 2nd table.
    But if u want to show both ALV on the same screen then u will have to use screen programin and using class u will have to create container and then have to do it.
    But as i above mentioned. that sample code is as below.
    REPORT ztn_test LINE-COUNT 100.
      data: itab_ref type ref to data.
      data: hstr type lvc_title.
    data: tabname like DD02T-TABNAME.
       tabname = 'MARA'. " First Table
      create data itab_ref type standard table of (tabname).
      field-symbols: <itab> type standard table.
      assign itab_ref->* to <itab>.
      select * UP TO 10 ROWS from (tabname) into corresponding fields of table <itab>.
      perform showalv.
       tabname = 'KNA1'. " 2nd Table
      create data itab_ref type standard table of (tabname).
      "field-symbols: <itab> type standard table.
      assign itab_ref->* to <itab>.
      select * UP TO 10 ROWS from (tabname) into corresponding fields of table <itab>.
      perform showalv.
    form showalv.
    " to show that data in alv
      type-pools: slis.
      data: myalv type ref to cl_gui_alv_grid,    "ALV Grid
            fieldcat type slis_t_fieldcat_alv,    "Field Catalog Table
            ls_fcat type slis_fieldcat_alv,       "Line of Field catalog.
            ls_heading type slis_listheader,      "Line of Heading.
            layout type slis_layout_alv,          "layout of ALV for Heading and Logo.
            event type slis_t_event,              "Event Raising to Display Heading.
            event_str type slis_alv_event.        "Event String.
    type-pools: slis.
    data: heading type slis_t_listheader.       "List Heading.
      if heading[] is initial.
        ls_heading-typ = 'H'.
        ls_heading-info = 'HR: Master Data Change History'.
        append ls_heading to heading.
      endif.
    *  ls_heading-typ = 'A'.
    *  ls_heading-info = ''.
    *  APPEND ls_heading TO heading.
    *                          ALV DISPLAY                        *
    *******Making Layout of ALV
      layout-zebra = 'X'.
      layout-colwidth_optimize = 'X'.
    *Calling function to raise event to display heading and icon above ALV
      call function 'REUSE_ALV_EVENTS_GET'
       exporting
         i_list_type           = 0
       importing
         et_events             = event[]
    * EXCEPTIONS
    *   LIST_TYPE_WRONG       = 1
    *   OTHERS                = 2
      if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    ******calling TOP_OF_PAGE Event
      read table event with key name = 'TOP_OF_PAGE' into event_str.
      if sy-subrc = 0.
        move: 'TOP_OF_PAGE' to event_str-form.
        modify event from event_str index sy-tabix.
      endif.
    **** Now use this Fuction to display ALV without any Screen Programming.
      call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = 'SAPLZFSL_HR_UTILS' "sy-cprog
    *   I_CALLBACK_PF_STATUS_SET          = ' '
    *   I_CALLBACK_USER_COMMAND           = ' '
    *   I_CALLBACK_TOP_OF_PAGE            = ' '
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
         i_structure_name                  = tabname
    *   I_BACKGROUND_ID                   = ' '
         i_grid_title                      = hstr   "Heading of ALV Grid.
    *   I_GRID_SETTINGS                   =
         is_layout                         = layout
    *   it_fieldcat                       = fieldcat[]
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           =
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
         i_default                         = 'X'
         i_save                            = 'X'
    *   IS_VARIANT                        =
         it_events                         = event[]
    *   IT_EVENT_EXIT                     =
    *   IS_PRINT                          =
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 0
    *   I_SCREEN_START_LINE               = 0
    *   I_SCREEN_END_COLUMN               = 0
    *   I_SCREEN_END_LINE                 = 0
    *   I_HTML_HEIGHT_TOP                 = 0
    *   I_HTML_HEIGHT_END                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   IR_SALV_FULLSCREEN_ADAPTER        =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
        tables
          t_outtab                          = <itab>
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
      if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.

  • 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

  • How to Refresh "Internal table values" in User EXIT.

    Dear All,
    My requirement is to place some checks in exit ZXQQMU20 in different tabs from the TCODE IW21 . IW22 etc.
    Now after placeing the checks towards the different tabs while doing "NOCO" from IW21 the conditions are fullfilled but
    when i go ahead to modify the created  "NOCO " from the TCODE IW22 by deleting the created values and saving in IW22 , the conditions written in the exit are still satisfied eventhough i have deleted the values in IW22.
    The reason for this is that the tables which are there in the exit ZXQQMU20 T_VIQMFE , T_VIQMUR , T_VIQMMA
    still contains the old values which were there at the time of creation of "NOCO"  in IW21 .
    How to refresh my " internal tables values" used in such that even at the time of modification of the NOCO through IW22 my table values should pick the current screen values and not the values which were there at the time of creation.
    Please help.
    The code i have written in the exit is as below:-
    ********************* Changed vide ******START
    *****IW21  IW22 also added in filter criteria of notification *************
    ******The purpose of this modification is that in the execution of IW21 or IW22 or IW24 or IW25 we have to give a check that if the
    ******notification type is M2 than inside the Transaction screen , if the Breakdown duration comes less than 15 min than there are
    ******no issues but if the breakdown duration is more than 15 min than the mandatory fields needs to be entered in the analysis tab.
    **    The user has to fill up either following mandatory fields in Analysis Data tab.
    **    A. Object Parts & Damages sub tab
    **    Code Group - Object Parts (OTGRP, VIQMFE)
    **                          AND
    **    Code Group - Problem / Damage (FEGRP, VIQMFE)
    **    Or
    **    Notification Item Short Text (FETXT, VIQMFE)
    **   B. Cause sub tab
    **    Code Group # Causes (URGRP, VIQMUR)
    **    Or
    **    Cause Text (URTXT, VIQMUR)
    **   C. Action Taken sub tab
    **    Code Group # Activities (MNGRP, VIQMMA)
    **    Or
    **    Activity Text (MATXT, VIQMMA)
    **            Then, allow user to complete notification (NOCO).
    CLEAR : L_VAR , L_COMP_TIME.
    IF ( SY-TCODE EQ 'IW21' OR SY-TCODE EQ 'IW22' OR SY-TCODE EQ 'IW24' OR
          SY-TCODE EQ 'IW25' ).
       IF ( E_VIQMEL-IWERK = '061' ) OR ( E_VIQMEL-IWERK = '062' ).
         IF E_VIQMEL-QMART = 'M2'.
           L_VAR = E_VIQMEL-AUSZT.
           L_COMP_TIME = L_VAR / 60.
           IF L_COMP_TIME < 15.
             EXIT.
           ELSEIF L_COMP_TIME > 15..
    *         IF ( T_VIQMFE-OTGRP IS INITIAL AND T_VIQMFE-FEGRP IS INITIAL )  OR  ( T_VIQMFE-FETXT IS INITIAL ) .
    *           MESSAGE 'Please fill the mandatory analysis data in Object Parts' TYPE 'E'.
    *         ENDIF.
             IF T_VIQMFE-OTGRP EQ '' OR T_VIQMFE-FEGRP EQ ''.
               IF T_VIQMFE-FETXT EQ ''.
                 MESSAGE 'Please fill the mandatory analysis data in Object Parts' TYPE 'E'.
               ENDIF.
             ENDIF.
             CLEAR L_TAG.
             IF T_VIQMUR[] IS INITIAL.
               MESSAGE 'Please fill the mandatory analysis data in Cause tab' TYPE 'E'.
             ELSE.
               LOOP AT T_VIQMUR.
                 IF  T_VIQMUR-URGRP IS INITIAL .
                   IF T_VIQMUR-URTXT IS INITIAL.
                     L_TAG = 'X'.
                   ENDIF.
                 ENDIF.
               ENDLOOP.
               IF L_TAG = 'X'.
                 MESSAGE 'Please fill the mandatory analysis data in Cause tab' TYPE 'E'.
               ENDIF.
             ENDIF.
             CLEAR L_TAG.
             IF T_VIQMMA[] IS INITIAL.
               MESSAGE 'Please fill the mandatory analysis data in Action' TYPE 'E'.
             ELSE.
               LOOP AT T_VIQMMA.
                 IF  T_VIQMMA-MNGRP IS INITIAL .
                   IF T_VIQMMA-MATXT IS INITIAL.
                     L_TAG = 'X'.
                   ENDIF.
                 ENDIF.
               ENDLOOP.
               IF L_TAG = 'X'.
                 MESSAGE 'Please fill the mandatory analysis data in Action' TYPE 'E'.
               ENDIF.
             ENDIF.
           ENDIF.
         ENDIF.
       ENDIF.
    ENDIF.
    <Added code tags>
    Thank you so much in advance..
    -Sudhish
    Please use the code tags when you're posting any code snippet
    Edited by: Suhas Saha on Jul 13, 2011 12:39 PM

    Hi, I was thinking just like XVBAP and YVBAP values in the USEREXIT_SAVE_DOCUMENT.
    Plz check u have x /y versions or tables like _old/ _new suffixes and then move the value accordingly.
    otherwise there may be inconsistency.
    Edited by: Prasenjit S. Bist on Jul 13, 2011 3:03 PM

  • Internal table refreshing

    Hi Experts,
       I  copyed the me2k(RM06EK00) program to Zprogram and doing some
    modification.
    My problem is I declared the internal table and some values are populating to
    the internal table in the subroute PERFORM ekpo_ausgabe(sapfm06l).
    (This is last perform statement before END-OF-Selection),
    when it comes out of the perform statement and before End-of- selection my internal table values are refreshed automatically, I didn't refreshed the internal table.
    Pls help me to get the values without refreshing my IT.
    Thanks in advance
    karthik

    For example,  lets look at program ZRICH_0001, here  I am calling a PERFORM which is in program ZRICH_0002 and then pulling that internal table out of the memory stack.
    report  zrich_0001.
    types: tt001 type table of t001.
    field-symbols: <it001> type tt001.
    data: pointer_string type string.
    data: xt001 like line of <it001>.
    start-of-selection.
    * Call the perform in other program
      perform fill_up_it001 in program zrich_0002.
    * Assign an internal table
      pointer_string = '(ZRICH_0002)IT001[]'.
      assign (pointer_string) to <it001>.
      loop at <it001> into xt001.
        write: / xt001-bukrs, xt001-butxt..
      endloop.
    And the code for the second program.
    report zrich_0002 .
    data: it001 type table of t001.
    *       FORM fill_up_it001                                            *
    form fill_up_it001.
      select * into table it001 from t001.
    endform.
    Now I think this will work for you, but the internal table from the PERFORM must be global variable in the main program, not local to the FORM, if it is local to the FORM, then this will not work.
    Regards,
    Rich Heilman

  • ALV list display is truncated though data is present in internal table

    hi
    There are total 108 columns in my internal table, but the ALV list display shows only 90 , the fieldcatalog and final ALV internal table has the same structure. Please let me know how to display the rest of the field
    Regards
    Monirul

    Hi.,
    ALV List Display will display max. 90 columns it depends on line size 1023., Some times it goes to dump in number of columns increases .,  and some times it displays some columns in one line and other columns in other line which  will not look gud.. better use ALV Grid or OO ALV with custom container .
    hope this helps u.,
    Thanks & Regards,
    Kiran

  • How internal tables are physicaly located in memory?

    Array, chained list, or else? Plese provide any opinion or documentation.
    Sincerely yours, Long Nguyen.

    A data model is an abstraction of a part of the real world which is represented using formal structures. A relational database basically uses one formal structure known as a table.
    A table can be defined as a two-dimensional matrix made of rows and columns. It can also be described as a group of records of the same type.Records are groups of fields based on existing data types. These data types are previously defined in the datadictionary. A table is a similar concept to a conventional indexed file; the difference is that in the relational model the main index is known as the primary key, which is made of one or more fields of the record. A record is also known as tuple or simply a row. The most significant feature of the primary key is that it identifies univocally one and only one record of the table: a table does not permit records with duplicated primary keys.
    Structures. The object structure refers to the definition of a compound object that does not have any content. It's like a table or a view, but it never has entries: it's only a structure. These types of objects are used in programs for defining data structures or for defining data in the interfaces from the module pools and the screens. The basic difference between structures and tables (or views) is that the
    structure does not exist at the underlying database system level; however, both tables and views do exist in the database. Structures only exist as definitions in the dictionary. As a result, structures do not need to be activated.
    Table. As previously explained, a table is a two-dimensional data matrix. A table can contain zero or many rows, corresponding to the predefined table structure (entity type). This is, at the same time, a complex structure, which can be made up of one or several fields (attributes). Every row that makes up the database table has the same structure and properties. The fields that make up the structure of the table records, as well as its attributes, permitted value range, and so on, are set when defining the table.
    Some general recommendations for internal tables:
    •     As long as all that you need from an internal table is to append lines to it and perhaps to sort it after filling it, standard tables are still the best choice. The other table kinds are too expen-sive for these simple tasks. Keep in mind that when inserting or deleting lines in index tables containing many lines, the administration of the logical index that manages the lines of the ta-ble internally can become expensive, with regard to performance and additional memory space. Only for standard tables that are filled with APPEND only, and where no lines are de-leted except for the last line, is there no need for a logical index, and hence
    no additional costs are incurred.
    •If memory space is an issue, for very large internal tables (> 500000 lines) with a
    small line size, sorted tables might be preferable to hashed tables, since for internal administration, they need only 6 bytes per line compared to 18 bytes for hashed tables.
    •When declaring internal tables, use the addition INITIAL SIZE only for inner tables in nested tables. For outer tables, the automatic allocation of initial memory size is appropriate. For inner tables, though, it may result in saving a large amount of memory.
    •When reading internal tables with READ TABLE or LOOP AT, choose the appropriate output behavior. Writing into a work area wa with the addition INTO wa is only necessary if you want to change the work area without influencing the internal table. For pure reading purposes or for modifying the contents of the internal table, the additions ASSIGNING <fs> for assigning internal table lines to a field symbol <fs> and REFERENCE INTO dref for setting a refer-ence in a data reference variable dref to internal table lines are the better choices by far.
    •Use CLEAR instead of REFRESH for internal tables. The reason is that for internal tables with-out header lines, the general statement CLEAR does exactly the same as the special state-ment REFRESH. Since internal tables with header lines should no longer be used, the state-ment REFRESH is effectively obsolete. In order to free more memory, you can consider the use of FREE.
    •The statement COLLECT should no longer be used for standard tables — use COLLECT mainly for hashed tables. The reason is that COLLECT is based on a hash algorithm. While the hash administration of a hashed table is always available and robust, for standard tables a temporary hash administration must be created when the COLLECT statement is used. This temporary hash administration is invalidated when the table is accessed for changing. If fur-ther COLLECT statements are entered after an invalidation, a linear search of all table rows must be performed. Furthermore, COLLECT only works properly on internal tables with unique lines, while a unique table key is guaranteed for hashed tables only. Therefore, for standard tables it cannot be guaranteed that the contents will always be suitable for editing using COLLECT.
    •Don’t use APPEND SORTED BY — use SORT instead. The reason is that creating a ranked list with APPEND SORTED BY is based on several assumptions about the internal table and how it is filled. Using SORT is the general method that can be applied to all kinds of table and inde-pendent from the mode of filling.
    Chk these links for more information about internal tables
    internal tables
    Regards,
    Balaji Reddy G
    **Rewards for helpful answers

Maybe you are looking for

  • Specific E-mail with links causing freeze using Mail

    My wife is getting newsletter style e-mail from Better Homes and Gardens that contain links to pictures and other websites.  These pictures only appear  if internet access is connected so I believe that they are links that only are active once the ma

  • PDF Embedded Text Invisible in Preview

    I saved a PDF out of PhotoShop embedding the text (black Arial font on white background). It looks fine in both the Acrobat ap and Reader. In Preview the text is invisible. It is there, because you can select it, copy it, and paste it into another do

  • QuickTime DVD Playback & Editing Help!

    I purchased quicktime pro & the mp2 playback component. I can't get my home made DVDs to play in it although the help says I can by simply dragging or clicking. The only thing I can get acomplished is to play the individual VOB files but no audio see

  • ITunes not launching anymore................

    Hopefully someone can point me in the right direction and help me fix this problem. A week ago iTunes 7.7.1 (the latest version just before V8), stopped working on my pc. When I say stopped working, I mean it won't launch. I can see the exe running i

  • My iPhone 5 with 6.1.2 is draining the battery in 4 hours with little use. It has just started. Any suggestions.

    My iPhone 5 with 6.1.2 is draining the battery in 4 hours with little use. It has just started. Any suggestions? Any apps that are known to cause a problem? I recently loaded Fantastical and Cobook (since deleted).