Using where condition with dynamic internal table

Hi Friends.
How to use where condition with dynamic internal table ?
Regards,
Amit Raut

Hai Amit
REPORT  ZDYNAMIC_SELECT                         .
TABLES: VBAK.
DATA: CONDITION TYPE STRING.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
CONCATENATE 'VBELN' 'IN' 'S_VBELN.'
INTO CONDITION SEPARATED BY SPACE.
SELECT VBELN POSNR FROM VBAP INTO TABLE ITAB
WHERE (CONDITION).
LOOP AT ITAB.
WRITE 'hello'.
ENDLOOP.
Thanks & Regards
Sreenivasulu P

Similar Messages

  • How to do parallel processing with dynamic internal table

    Hi All,
    I need to implement parallel processing that involves dynamically created internal tables. I tried doing so using RFC function modules (using starting new task and other such methods) but didn't get success this requires RFC enabled function modules and at the same time RFC enabled function modules do not allow generic data type (STANDARD TABLE) which is needed for passing dynamic internal tables. My exact requirement is as follows:
    1. I've large chunk of data in two internal tables, one of them is formed dynamically and hence it's structure is not known at the time of coding.
    2. This data has to be processed together to generate another internal table, whose structure is pre-defined. But this data processing is taking very long time as the number of records are close to a million.
    3. I need to divide the dynamic internal table into (say) 1000 records each and pass to a function module and submit it to run in another task. Many such tasks will be executed in parallel.
    4. The function module running in parallel can insert the processed data into a database table and the main program can access it from there.
    Unfortunately, due to the limitation of not allowing generic data types in RFC, I'm unable to do this. Does anyone has any idea how to implement parallel processing using dynamic internal tables in these type of conditions.
    Any help will be highly appreciated.
    Thanks and regards,
    Ashin

    try the below code...
      DATA: w_subrc TYPE sy-subrc.
      DATA: w_infty(5) TYPE  c.
      data: w_string type string.
      FIELD-SYMBOLS: <f1> TYPE table.
      FIELD-SYMBOLS: <f1_wa> TYPE ANY.
      DATA: ref_tab TYPE REF TO data.
      CONCATENATE 'P' infty INTO w_infty.
      CREATE DATA ref_tab TYPE STANDARD TABLE OF (w_infty).
      ASSIGN ref_tab->* TO <f1>.
    * Create dynamic work area
      CREATE DATA ref_tab TYPE (w_infty).
      ASSIGN ref_tab->* TO <f1_wa>.
      IF begda IS INITIAL.
        begda = '18000101'.
      ENDIF.
      IF endda IS INITIAL.
        endda = '99991231'.
      ENDIF.
      CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          pernr           = pernr
          infty           = infty
          begda           = '18000101'
          endda           = '99991231'
        IMPORTING
          subrc           = w_subrc
        TABLES
          infty_tab       = <f1>
        EXCEPTIONS
          infty_not_found = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
        subrc = w_subrc.
      ELSE.
      ENDIF.

  • How to upload data with dynamic internal table

    Hi,
    I have to upload the basic , sales, purchasing view data by using bapi depend on check box selected for views.
    i have filled fieldcatalog for selected views and pass the field catalog structure to dynamic int table and
    import it into the field symbol <fs_data>. this field symbol assigned to <fs_1>.
    then callED the 'GUI_UPLOAD '  and  when i pass field symbo for function module i am getting first 10 rows 0f the file .
    flat file has basic data,sales ,purchase fields data
    ex: i was selected basicview and purchase view and execute i am getting basic,sales view data.
    how can i get only basic and purchase data.

    hi ,
    please find code.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = lt_fieldcatalog
        IMPORTING
          ep_table                  = <fs_data>
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
      IF sy-subrc <> 0.                                         "#EC NEEDED
      ENDIF.
    So <FS_1> now points to our dynamic internal table.
      ASSIGN <fs_data>->* TO <fs_1>.
    Next step is to create a work area for our dynamic internal table.
      CREATE DATA new_line LIKE LINE OF <fs_1>.
    A field-symbol to access that work area
      ASSIGN new_line->*  TO <fs_2>.
      ASSIGN new_line->*  TO <fs_3>.
    CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = p_f
          filetype                = 'DAT'
        TABLES
          data_tab                = <fs_1>
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  • Working with dynamic internal tables

    Hi,
    I've created dynamic internal table and then assigned it to field symbol structure.
    This is part of the code.
    wa_tab  = cl_abap_structdescr=>create( comp_tab ).
      i_tab   = cl_abap_tabledescr=>create( wa_tab ).
      create data i_table type handle i_tab.
      assign i_table->* to <f_tab1>.
    As a second step I am populationg that structure <f_tab1> with data using dynamic select:
    select (sel_list) from (p_table)
            into table <f_tab1>
            up to p_row rows.
    So far so good but I need to copy the data from <f_tab1> into internal table with the same structure and to use that internal table on a later stage as a driver table in select...for all entries.
    How can I doo that ?
    Thanks,
    Stefan
    <Code tags added>
    Edited by: Suhas Saha on Oct 27, 2011 4:23 PM

    Hello Stefan,
    You might be interested in reading this thread How to use dynamic internal table with FOR ALL ENTRIES.
    Do let us know if you find any alternative solution
    Cheers,
    Suhas

  • Problem with dynamic internal table updation

    Hello Folks,
      I created  a dynamic internal table
    CALL METHOD cl_alv_table_create=>create_dynamic_table
          EXPORTING
            it_fieldcatalog           = i_fieldcat
          IMPORTING
            ep_table                  = i_dyntab
          EXCEPTIONS
            generate_subpool_dir_full = 1
            OTHERS                    = 2.
    ASSIGN i_dyntab->* TO <f_dyntable>.
    and created a work area
    CREATE DATA wg_f_split LIKE LINE OF <f_dyntable>.
        ASSIGN wg_f_split->* TO <f_wg_dyntable>.
    My requirement is that , i have to loop a normal internal table and append those records to the filed symbol internal table.
    READ TABLE i_normal_itab INTO wg_split INDEX wl_rows-index.
          IF sy-subrc EQ 0.
            ASSIGN wg_split to <f_wg_dyntable>.
             APPEND <f_wg_dyntable> to <f_dyntable>.
           endif.
    here i am geeting dump as "MOVE src TO dst" ... i can get the data in the work area FSymbol but cannot append it in Internal table Field Symbol.. Please help..
    <Added code tags>
    Edited by: Suhas Saha on Aug 3, 2011 10:52 AM

    Hello Sandra,
    Thanks for the reply..
    First i tried  appending the normal work area to the fieldsymbol  internal table.
      append wg_split to <f_dyntable>
    This is hiting dump the same dump and so i created a fieldsymbol work area. ( <f_wg_dyntable>.)and tried to append the field symbol internal table with this work area. which is again giving the dump
    APPEND <f_wg_dyntable> to <f_dyntable>. ( Again a Dump)
    Edited by: Charan-SAP on Aug 2, 2011 9:40 PM
    Edited by: Charan-SAP on Aug 2, 2011 9:42 PM

  • Coloring an ALV Cell with DYNAMIC INTERNAL TABLES

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

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

  • How to write a perform with dynamic internal table

    Hi to all experts,
    i have to read infotype 2001 2003 2002 with same pernr, begin date, end date im calling hr_read_infotype three times
    can i write a single perform and call it three how to pass different tables (2001, 2002, 2003).

    try the below code...
      DATA: w_subrc TYPE sy-subrc.
      DATA: w_infty(5) TYPE  c.
      data: w_string type string.
      FIELD-SYMBOLS: <f1> TYPE table.
      FIELD-SYMBOLS: <f1_wa> TYPE ANY.
      DATA: ref_tab TYPE REF TO data.
      CONCATENATE 'P' infty INTO w_infty.
      CREATE DATA ref_tab TYPE STANDARD TABLE OF (w_infty).
      ASSIGN ref_tab->* TO <f1>.
    * Create dynamic work area
      CREATE DATA ref_tab TYPE (w_infty).
      ASSIGN ref_tab->* TO <f1_wa>.
      IF begda IS INITIAL.
        begda = '18000101'.
      ENDIF.
      IF endda IS INITIAL.
        endda = '99991231'.
      ENDIF.
      CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          pernr           = pernr
          infty           = infty
          begda           = '18000101'
          endda           = '99991231'
        IMPORTING
          subrc           = w_subrc
        TABLES
          infty_tab       = <f1>
        EXCEPTIONS
          infty_not_found = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
        subrc = w_subrc.
      ELSE.
      ENDIF.

  • How to delete records from dynamic internal table.

    Hi Experts,
    Need urgent help!!!
    Issue is with Dynamic internal tables.
    Below is code written by me :
    FORM select_query USING Lw_tabnam
                      TYPE  t682i-kotabnr.
      DATA :  lw_line  TYPE REF TO data,
              lw_line1 TYPE REF TO data.
        CREATE DATA Lw_line    TYPE (lw_TABNAM).
        ASSIGN      Lw_line->* TO   <WA_tbl>.
        CREATE DATA LW_LINE    TYPE STANDARD TABLE OF (Lw_tabnam)
                               WITH NON-UNIQUE DEFAULT KEY.
        ASSIGN      Lw_line->* TO <TBL>.
        SELECT * FROM  (Lw_tabnam)
                 INTO CORRESPONDING FIELDS OF TABLE <TBL>
                 WHERE (t_keys).
    Endform.
    code is working fine.
    here even the table name and where condition are dynamic,everything is fine upto this point.
    Now i have to delete some record from <TBL> based on some conditons.
         for ex : ( here lc_fieldname is KUNNR)
          loop at t_kunnr.
              lw_tabix = sy-tabix.
            Read table <tbl>
                    with key (lc_fieldname) = t_kunnr-kunnr ASSIGNING <wa_tbl>.
            If sy-subrc = 0.
            *Delete
            delete <tbl> from <wa_tbl>
    delete <tbl> index  lw_tabix.
            Endif.
         Endloop.
    The above delete statement doesn't work ,even we can't use index as it gives a syntax error " something related to "index is not allowed in standard table or hash table.
    Can you help me ab't how to delete records in Dynamic internal table?
    Other option that i am thinking of is to create a static table of type dynamic table.
    means, data itab type standard table of <tbl> .I know the syntax is wrong ,however is there any way to do this?
    Thanks in advance ,
    If you have any suggestion ab't this then do let me know.
    bye,
    Gaurav.

    Hi
    I wrote this code and it works fine:
    DATA LW_TABNAM(10) VALUE 'LFA1'.
    DATA : LW_LINES TYPE REF TO DATA,
           LW_LINE  TYPE REF TO DATA.
    FIELD-SYMBOLS: <TABLE> TYPE TABLE,
                   <WA>    TYPE ANY.
    CREATE DATA LW_LINES TYPE TABLE OF (LW_TABNAM)
    WITH NON-UNIQUE DEFAULT KEY.
    ASSIGN LW_LINES->* TO <TABLE>.
    CREATE DATA LW_LINE TYPE (LW_TABNAM).
    ASSIGN LW_LINE->* TO <WA>.
    DO 10 TIMES.
      APPEND INITIAL LINE TO <TABLE>.
    ENDDO.
    SY-TABIX = 4.
    DELETE <TABLE> INDEX SY-TABIX.
    WRITE SY-SUBRC.
    I hope it help you
    Max

  • Dynamic internal table operations

    Hi,
    I have an issue with dynamic internal table wherein I need to write  a  select statement with For All Entries on dynamic internal table and populating the record into another dynamic internal table.
    I am trying with the code below but its not working.
    SELECT (FLD)
    FROM (T_TABLE)
    INTO CORRESPONDING FIELDS OF TABLE <DYN1_TABL>
    FOR ALL ENTRIES IN <DYN_TABL>
    WHERE KEY_FNAME = <DYN_TABL>-KEY_FNAME.
    FLD is the dynamic field.
    T_TABLE is the dynamic database table.
    DYN1_TABL is the dynamic internal table
    DYN_TABL is the dynamic internal table
    KEY_FNAME is the dynamic key field of T_TABLE.
    Pls help me on this issue.
    Response with code snippets will be appreciated.
    Thanks in advance.

    Thanks for your reply Nikki but my issue is to reference  a field in dynamic internal table to be used with 'For All Entries' satement.
    like for static we use
    For All Entries in Itab where <fieldname> = itab-<fieldname>
    I was looking for the same statement for dynamic tables

  • Popualting data into dynamic internal table

    Hi all,
        I am working on Dynamic internal tables.I have created the structure of internal table but i am unable to populate data into it.Though i have seen some of the forums but those didn't help me. please provide me the solution. Here is my code what i did.I have the data in itab and itab1.
      My requirement is meinh fileds are dynamic.thie meinh and umren are two fileds in mvke table.for one record ihave to populate umren value for that particular meinh value.Pls help me.
    mtart     vkorg     werks     mtanr     Meinh(kg)         Meinh(gl)
    fert     0353     0303     3231     Umren value  Umren value
    REPORT  z123.
                  T Y P E - P O O L S
    TYPE-POOLS :slis,abap.
                  T A B L E S
    *Tables
    TABLES: mara,marm,mvke,marc.
                  F I E L D - S Y M B O L S
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                    <dyn_wa> ,
                    <dyn_field>.
                    I N T E R N A L         T A B L E S
    Internal Tables declaration for ALV GRID/LIST
    DATA: ls_fieldcat TYPE slis_fieldcat_alv,    "FIELD CATALOG LIST
          tb_uom_cat TYPE slis_t_fieldcat_alv,   "FIELD CATALOG
          ls_fieldcat1 TYPE lvc_s_fcat,
          tb_dy_cat TYPE lvc_t_fcat,             "FIELD CATALOG
          tb_outputcat TYPE slis_t_fieldcat_alv,
          tb_events TYPE slis_t_event,
          ref_grid TYPE REF TO cl_gui_alv_grid,
          t_events LIKE LINE OF tb_events.
    DATA: BEGIN OF itab OCCURS 0,
          mtart LIKE mara-mtart,
          vkorg LIKE mvke-vkorg,
          werks LIKE marc-werks,
          matnr TYPE mara-matnr,
          END OF itab.
    DATA: BEGIN OF itab1 OCCURS 0,
          matnr TYPE marm-matnr,
          umren TYPE marm-umren,
          meinh TYPE marm-meinh,
          END OF itab1.
                            V A R I A B L E S
    Global Variables
    DATA: g_repid   LIKE sy-repid.       "Report ID
    DATA: dy_table TYPE REF TO data,
          dy_line TYPE REF TO data.
                      S E L E C T I O N   S C R E E N
    For User Input(Selection Criteria)
    SELECTION-SCREEN BEGIN OF BLOCK b0 WITH FRAME TITLE text-001.
    SELECT-OPTIONS :
      s_mtart FOR mara-mtart OBLIGATORY,    " Material type
      s_vkorg FOR mvke-vkorg OBLIGATORY,    " Sales Organization
      s_plant FOR marc-werks,               " Plant
      s_meinh FOR marm-meinh.               " Unit of Measure
    SELECTION-SCREEN END OF BLOCK b0.
                         I N I T I A L I Z A T I O N
    INITIALIZATION.
    Program ID
      g_repid = sy-repid.                      " Prog ID
                     A T   S E L E C T I O N -  S C R E E N
    AT SELECTION-SCREEN.
    Validate Material Type
      PERFORM check_mtart.
    Validate Sales Organization
      PERFORM check_vkorg.
    Validate Plant
      PERFORM check_werks.
    Validate Unit of Measure (UOM)
      PERFORM check_meinh.
                      S T A R T - O F  - S E L E C T I O N
    START-OF-SELECTION.
    Get Data
      PERFORM get_data.
    FIELD CATALOG FOR ALV
      PERFORM fill_field_catalog_uom USING tb_uom_cat.
    FIELD CATALOG FOR CREATING DYNAMIC INTERNAL TABLE
      PERFORM fill_field_catalog_dy USING tb_dy_cat.
    CREATING DYNAMIC INTERNAL TABLE
      PERFORM dy_tab_create.
                       End of selection                                  *
                              F O R M S
    *&      Form  CHECK_MTART
          Validate Material Type
    FORM check_mtart .
    Material Type
      DATA :l_mtart LIKE t134-mtart.
      CHECK NOT s_mtart IS INITIAL.
      SELECT mtart UP TO 1 ROWS
        INTO l_mtart
        FROM t134
       WHERE mtart IN s_mtart.
      ENDSELECT.
      IF sy-subrc <> 0.
        MESSAGE e899(mm) WITH 'Invalid Material Type'(002).
      ENDIF.
    ENDFORM.                    " CHECK_MTART
    *&      Form  CHECK_VKORG
          Validate Sales Organization
    FORM check_vkorg .
    Sales Oraganization
      DATA :l_vkorg LIKE tvko-vkorg.
      CHECK NOT s_vkorg IS INITIAL.
      SELECT vkorg UP TO 1 ROWS
        INTO l_vkorg
        FROM tvko
       WHERE vkorg IN s_vkorg.
      ENDSELECT.
      IF sy-subrc <> 0.
        MESSAGE e899(mm) WITH 'Invalid Sales Organization'(003).
      ENDIF.
    ENDFORM.                    " CHECK_VKORG
    *&      Form  CHECK_WERKS
          Validate Plant
    FORM check_werks .
    Plant
      DATA :l_werks LIKE t001w-werks.
      CHECK NOT s_plant IS INITIAL.
      SELECT werks UP TO 1 ROWS
        INTO l_werks
        FROM t001w
       WHERE werks IN s_plant.
      ENDSELECT.
      IF sy-subrc <> 0.
        MESSAGE e899(mm) WITH 'Invalid Plant'(004).
      ENDIF.
    ENDFORM.                    " CHECK_WERKS
    *&      Form  CHECK_MEINH
          Validate Unit of Measure (UOM)
    FORM check_meinh .
    Unit of Measure (UOM)
      DATA :l_meinh LIKE t006-msehi.
      CHECK NOT s_meinh IS INITIAL.
      SELECT msehi UP TO 1 ROWS
        INTO l_meinh
        FROM t006
        WHERE msehi IN s_meinh.
      ENDSELECT.
      IF sy-subrc <> 0.
        MESSAGE e899(mm) WITH 'Invalid Unit of Measure'(005).
      ENDIF.
    ENDFORM.                    " CHECK_MEINH
    *&      Form  FILL_FIELD_CATALOG_UOM
          text
         FIELD CATALOG FOR ALV
    FORM fill_field_catalog_uom  USING l_fieldcat TYPE  slis_t_fieldcat_alv.
      DATA: BEGIN OF l_itab OCCURS 0,
            meinh TYPE marm-meinh,
            END OF l_itab.
    DATA: l_count TYPE i.
      DATA: l_fieldcat_col_pos TYPE i.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname   = 'MTART'.
      ls_fieldcat-key         = ''.
      ls_fieldcat-col_pos     = 1.
      ls_fieldcat-ref_fieldname = 'MTART'.
      ls_fieldcat-ref_tabname   = 'MARA'.
      APPEND ls_fieldcat TO l_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname   = 'VKORG'.
      ls_fieldcat-key         = ''.
      ls_fieldcat-col_pos     = 2.
      ls_fieldcat-ref_fieldname = 'VKORG'.
      ls_fieldcat-ref_tabname   = 'MVKE'.
      APPEND ls_fieldcat TO l_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname   = 'WERKS'.
      ls_fieldcat-key         = ''.
      ls_fieldcat-col_pos     = 3.
      ls_fieldcat-ref_fieldname = 'WERKS'.
      ls_fieldcat-ref_tabname   = 'MARC'.
      APPEND ls_fieldcat TO l_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname   = 'MATNR'.
      ls_fieldcat-key         = 'x'.
      ls_fieldcat-col_pos     = 4.
      ls_fieldcat-ref_fieldname = 'MATNR'.
      ls_fieldcat-ref_tabname   = 'MARA'.
      APPEND ls_fieldcat TO l_fieldcat.
      CLEAR ls_fieldcat.
      l_fieldcat_col_pos = 5.
    Getting the UOM as per user selection
      SELECT  msehi  FROM t006
        INTO TABLE l_itab
        WHERE msehi IN s_meinh.
      LOOP AT l_itab.
        ls_fieldcat-fieldname   = l_itab-meinh.
        ls_fieldcat-key         = ''.
        ls_fieldcat-col_pos     = l_fieldcat_col_pos.
        ls_fieldcat-ref_fieldname = 'MSEHI'.
        ls_fieldcat-ref_tabname   = 'T006'.
        APPEND ls_fieldcat TO l_fieldcat.
        CLEAR ls_fieldcat.
        l_fieldcat_col_pos = l_fieldcat_col_pos + 1.
      ENDLOOP.
    ENDFORM.                    " FILL_FIELD_CATALOG_UOM
    *&      Form  DISPLAY_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM display_data .
    ENDFORM.                    " DISPLAY_DATAENDFORM.                    " FILL_FIELD_CATALOG_UOM
    *&      Form  DY_TAB_CREATE
          text
    -->  p1        text
    <--  p2        text
    FORM dy_tab_create .
    CREATE DYNAMIC INTERNAL TABLE AND ASSIGN TO FS
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = tb_dy_cat
        IMPORTING
          ep_table        = dy_table.
      ASSIGN dy_table->* TO <dyn_table>.
    *CREATE DYNAMIC WORK AREA AND AASIGN TO FS
      CREATE DATA dy_line LIKE LINE OF  <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
    ENDFORM.                    " DY_TAB_CREATE
    *&      Form  FILL_FIELD_CATALOG_DY
          text
        FIELD CATALOG FOR CREATING A DYNAMIC TABLE
    FORM fill_field_catalog_dy  USING  l_fieldcat TYPE lvc_t_fcat.
      DATA: BEGIN OF l_itab OCCURS 0,
           meinh TYPE marm-meinh,
           END OF l_itab.
      DATA: l_count TYPE i.
      DATA: l_fieldcat_col_pos TYPE i.
      DATA: l_umren TYPE string.
      DATA: l_var TYPE string.
      CLEAR ls_fieldcat.
      ls_fieldcat1-fieldname   = 'MTART'.
      ls_fieldcat1-key         = ''.
      ls_fieldcat1-col_pos     = 1.
      ls_fieldcat1-datatype = 'char'.
      ls_fieldcat1-intlen = 4.
      APPEND ls_fieldcat1 TO l_fieldcat.
      CLEAR ls_fieldcat1.
      ls_fieldcat1-fieldname   = 'VKORG'.
      ls_fieldcat1-key         = ''.
      ls_fieldcat1-col_pos     = 2.
      ls_fieldcat1-datatype = 'char'.
      ls_fieldcat1-intlen = 4.
      APPEND ls_fieldcat1 TO l_fieldcat.
      CLEAR ls_fieldcat1.
      ls_fieldcat1-fieldname   = 'WERKS'.
      ls_fieldcat1-key         = ''.
      ls_fieldcat1-col_pos     = 3.
      ls_fieldcat1-datatype = 'char'.
      ls_fieldcat1-intlen = 4.
      APPEND ls_fieldcat1 TO l_fieldcat.
      CLEAR ls_fieldcat1.
      ls_fieldcat1-fieldname   = 'MATNR'.
      ls_fieldcat1-key         = 'x'.
      ls_fieldcat1-col_pos     = 4.
      ls_fieldcat1-datatype = 'char'.
      ls_fieldcat1-intlen = 18.
      APPEND ls_fieldcat1 TO l_fieldcat.
      CLEAR ls_fieldcat1.
      l_fieldcat_col_pos = 5.
    Getting the UOM as per user selection
      SELECT  msehi  FROM t006
        INTO TABLE l_itab
        WHERE msehi IN s_meinh.
      SORT l_itab ASCENDING.
      DESCRIBE TABLE l_itab LINES l_count.
      LOOP AT l_itab.
        ls_fieldcat1-fieldname   = l_itab-meinh.
        ls_fieldcat1-key         = ''.
        ls_fieldcat1-col_pos     = l_fieldcat_col_pos.
        ls_fieldcat1-datatype = 'dec'.
        ls_fieldcat1-intlen = 5.
        APPEND ls_fieldcat1 TO l_fieldcat.
        CLEAR ls_fieldcat1.
        l_fieldcat_col_pos = l_fieldcat_col_pos + 1.
      ENDLOOP.
    ENDFORM.                    " FILL_FIELD_CATALOG_DY
    *&      Form  GET_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM get_data .
      SELECT
      amtart bvkorg cwerks amatnr
      INTO TABLE itab
      FROM mara AS a
      JOIN mvke AS b ON  bmatnr = amatnr
      JOIN marc AS c ON  cmatnr = bmatnr
      JOIN marm AS d ON  dmatnr = cmatnr
      WHERE a~mtart IN s_mtart
       AND  b~vkorg IN s_vkorg
       AND  c~werks IN s_plant.
      SORT itab ASCENDING.
      DELETE ADJACENT DUPLICATES FROM itab.
      SELECT matnr umren meinh FROM marm
      APPENDING TABLE itab1
      FOR ALL ENTRIES IN itab
      WHERE matnr = itab-matnr
      AND meinh IN s_meinh .
    ENDFORM.                    " GET_DATA

    can you check this for creation of dynamic table
    ******DATA DECLARATION*****************************
    FIELD-SYMBOLS : <it_final> TYPE STANDARD TABLE,
                    <wa_final> TYPE ANY,
                    <w_field> TYPE ANY.
    ***DYNAMIC CREATION OF FIELDCATALOG****************
    *FIRST 2 FIELDS FIELDS FIELD1 AND FIELD2 ARE CONSTANT, FIELDS OBTAINED IN THE LOOP ENDLOOP ARE DYNAMIC,
    *LIKEWISE DYNAMIC FIELDCATALOG IS CREATED
      wa_fieldcatalog-fieldname  = 'FIELD1'.
      wa_fieldcatalog-ref_table  = 'E070'.
      wa_fieldcatalog-outputlen  = '13'.
      wa_fieldcatalog-reptext    = 'Created On'.
      wa_fieldcatalog-seltext    = 'Created On'.
      APPEND wa_fieldcatalog TO it_fieldcatalog.
      CLEAR wa_fieldcatalog.
      wa_fieldcatalog-fieldname  = 'FIELD1'.
      wa_fieldcatalog-ref_table  = 'E070'.
      wa_fieldcatalog-outputlen  = '13'.
      wa_fieldcatalog-reptext    = 'Created On'.
      wa_fieldcatalog-seltext    = 'Created On'.
      APPEND wa_fieldcatalog TO it_fieldcatalog.
      CLEAR wa_fieldcatalog.
      LOOP AT it_mandt WHERE mandt IN s_mandt.
        CONCATENATE 'CLNT' it_mandt INTO wa_fieldcatalog-fieldname.
        wa_fieldcatalog-inttype    = 'NUMC'.
        wa_fieldcatalog-outputlen  = '14'.
        wa_fieldcatalog-reptext    = it_mandt.
        wa_fieldcatalog-seltext    = it_mandt.
        APPEND wa_fieldcatalog TO it_fieldcatalog.
        CLEAR :wa_fieldcatalog ,it_mandt.
      ENDLOOP.
    ********CREATE DYNAMIC TABLE************************
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = it_fieldcatalog
        IMPORTING
          ep_table                  = new_table
        EXCEPTIONS
          generate_subpool_dir_full = 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.
      ASSIGN new_table->* TO <it_final>.
    *********CREATE WORK AREA****************************
    CREATE DATA new_line LIKE LINE OF <it_final>.
      ASSIGN new_line->* TO <wa_final>.
    *********INSERTTING WORK AREAR TO INTERNAL TABLE******
        INSERT <wa_final> INTO TABLE <it_final>.
    *******POPULATING DATA******************************* 
      LOOP.
       ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_final> TO <w_field>.
       <w_field> = '12345'.
        ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_final> TO <w_field>.
       <w_field> = '21453DD'.
       FIELD1 AND FIELD2 ARE COMPONENTS OF FIELDCATALOG.
    ENDLOOP.     
      ENDLOOP.

  • SET_TABLE_FOR_DISPLAY - Edited value from dynamic internal table need to be captured

    Hi all,
    I have created  2 tabstrip screns which contain ALV GRID DISPLAY  in a container with dynamic internal table and editable columns .I want to capture the edited value from this ALV GRID display.I have used SET_TABLE_FOR_DISPLAY  and for this dynamc internal table is passed which is Field symbol and editable columns have to be captured for further updation into another ztable.
    When i used check_changed_data  i am getting dump as field symbol not assigned.
    Below is the code :  How can i get edited column value from below code
    call method alv_list->set_table_for_first_display
        exporting
                is_layout                     = gs_layout
        changing
          it_outtab                     = <fs_dynamic_table>
          it_fieldcatalog               = it_fieldcat[]
        exceptions
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          others                        = 4.
      if sy-subrc <> 0.
    * Implement suitable error handling here
      endif.
    Kindly help me to solve this.
    With Thanks,
    Dina.

    please provide more info about the dump to try to help you
    as max said, it could be because the field symbol is not global and if its global maybe you are not refering well to the column
    i assume that you are using "ASSIGN COMPONENT comp OF STRUCTURE struc TO <fs>" to capture the value changed
    validate always the sy-subrc after the assignment.
    but the check changed data have parameters that have the old and new values
    please provide more info...
    Regards

  • Read dynamic internal table

    hi all,
    i am working with dynamic internal table. how to use a read statement for the dynamic internal table.
    Thanks

    hi
    try with this sample code.
    DATA: tab TYPE TABLE OF mara,
          field_key TYPE char100.
    FIELD-SYMBOLS: <tab> TYPE ANY TABLE,
                   <wa> TYPE ANY.
    SELECT * UP TO 10 ROWS FROM mara INTO TABLE tab[].
    ASSIGN tab[] TO <tab>.
    field_key = 'MATNR'.
    READ TABLE <tab> ASSIGNING <wa>
    WITH KEY (field_key) = '000000000000000200'.
    Cheers,
    Madhu

  • Smartforms - pass dynamic internal tables

    Hello experts,
    In my smartform print program, I have created a dynamic internal table using method CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE where in my dynamic internal table <DYN_TABLE> is declared as
    FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
                   <DYN_WA>.
    I am populating <DYN_TABLE> and passing it on to my smartform. Now my question is, inside my smartform, how can I declare this dynamic table <DYN_TABLE> in form interface? Please let me know. Thanks.

    This could be one of the solution.
    1. Create table type using data element EDI_SDATA (char 1000) , say ZTTDYN .
    2. Use this as importing paramter your smarform.
    3. In print program transfer the content from dynamic internal table to internal table define using ZTTDYN. You can comma seperate then fields.
    4. Pass this comma separated internal table to smartform.
    5. And finally proces this data in smartform.

  • Populate data from itab to dynamic internal table

    Hi All,
    I have internal table it_tab with below data
    "-----internal table it_tab data
    1 0000123 GBP DA S 6265.45
    2 0000123 GBP DA H 240.51
    3 0000123 GBP DA S 35.82
    4 0000123 GBP D1 H 281.85
    5 0000123 GBP D1 S 23.41
    6 0000123 GBP D1 S 34.23
    7 0000123 GBP RV H 97.02
    8 0000123 GBP RV S 52.90
    9 0000123 GBP RV S 148.31
    I have created dynamic internal table <t_dyn_table> using field-symbol based in dynamic fieldcatelog it_fldcat, using below code
    Create dynamic internal table and assign to Field Symbol
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = it_fldcat
        IMPORTING
          ep_table                  = it_dynamic_table
        EXCEPTIONS
          generate_subpool_dir_full = 1
          others                    = 2.
      IF sy-subrc eq 0.
        ASSIGN it_dynamic_table->* TO <t_dyn_table>.
    Create dynamic work area and assign to Field Symbol
        CREATE DATA it_newline LIKE LINE OF <t_dyn_table>.
        ASSIGN it_newline->* TO <wa_dyn>.
      ENDIF.
    Now I want to put the data from it_tab to <t_dyn_table> as shown below
    Customer ___DAS ___D1S___RVS___DAH___D1H___RVH___DAT____D1T____RVT
    0000123____6265.45__________________________________6265.45
    0000123________________________240.51_______________240.51
    0000123____35.82____________________________________35.82
    Please help me out, Thanks in Advance
    Thanks & Regards
    Sekhar
    Thanks in Advance
    Sekhar

    Hi Sekhar_tech,
    Hope this helps. I made the code in notepad may have any syntax errors but the idea of the code is.
      loop at it_tab into wa_tab.
        UNASSIGN  <wa_dyn>.
        ASSIGN it_newline->* TO <wa_dyn>.
        if <wa_dyn> is assigned.
          UNASSIGN <lf_field_Value>.        
          ASSIGN COMPONENT 'CUSTOMER' OF STRUCTURE
                           <wa_dyn> TO <lf_field_value>. 
          IF <lf_field_Value> IS ASSIGNED.
             <lf_field_value> = wa_tab-customer.
          ENDIF.    
          UNASSIGN <lf_field_Value>.        
          ASSIGN COMPONENT 'DAS' OF STRUCTURE
                           <wa_dyn> TO <lf_field_value>. 
          IF <lf_field_Value> IS ASSIGNED.
             <lf_field_value> = wa_tab-das.
          ENDIF.    
    #same logic to other fields...
    #The final step
          APPEND <wa_dyn> TO <t_dyn_table>.
        endif.
      endloop.
    Regards
    Bruno Xavier.

  • Read statement on dynamic internal tables

    Hello All,
    I have a dynamic internal table <G_T_ITAB> with fields F1, F2, F3 & F4 .
    I want to read the internal table <G_T_ITAB>. So im using the below code.
    LOOP AT G_T_DATA.
      READ TABLE <G_T_ITAB> INTO <G_R_ITAB> WITH KEY F1 = G_T_DATA-F1.
      IF SY-SUBRC <> 0.
      ELSE.
      ENDIF.
    ENDLOOP.
    But this is giving syntax error that F1 is not the field of <G_T_ITAB>. But the field is there in <G_T_ITAB>.
    Can you suggest me to solve this issue. Or is there any other approach to use READ statement on dynamic internal tables.
    Thanks in advance.
    Best Regards,
    Sasidhar Reddy Matli.

    Hi ,
    Read this way....
    FIELD-SYMBOLS:
    <fs_str> type any,
    <fs_lf_fval> type any,
    <fs_lt_result_rate> type any table,
    <fs_ls_result_rate> type any.
    DATA:
      lv_fname type string.
    lv_fname = 'MATNR'.
    assign component 'matnr' of structure <fs_str> to <fs_lf_fval>.
    READ TABLE <fs_lt_result_rate> INTO <fs_ls_result_rate>
                WITH KEY (lv_fname) = <fs_lf_fval>.
    Thanks,
    Shailaja Ainala.

Maybe you are looking for