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.

Similar Messages

  • How to populate data into Dynamic Internal Table.

    Hi Experts,
    I had created one Dynamic Internal table and one static internal table.I want to move data from Static Internal table to Dynamic interal table.And aslo the number of coloum of these two tables are not same.
    So please help me for solving this issue.
    Thanks,
    <u><i><b>Seema.</b></i></u>

    Hi,
    Check out this sample program for dynamictable report.
    REPORT  YMS_DYNAMICDEMO
                 NO STANDARD PAGE HEADING
                 MESSAGE-ID zcs_c2c_001.
    type-pools : abap.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: dy_table type ref to data,
          dy_line  type ref to data,
          xfc type lvc_s_fcat,
          ifc type lvc_t_fcat.
    selection-screen begin of block b1 with frame.
    parameters: p_table(30) type c default 'T001'.
    selection-screen end of block b1.
    start-of-selection.
      perform get_structure.
      perform create_dynamic_itab.
      perform get_data.
      perform write_out.
    form get_structure.
    data : idetails type abap_compdescr_tab,
           xdetails type abap_compdescr.
    data : ref_table_des type ref to cl_abap_structdescr.
    Get the structure of the table.
      ref_table_des ?=
          cl_abap_typedescr=>describe_by_name( p_table ).
      idetails[] = ref_table_des->components[].
      loop at idetails into xdetails.
        clear xfc.
        xfc-fieldname = xdetails-name .
        xfc-datatype = xdetails-type_kind.
        xfc-intlen = xdetails-length.
        xfc-decimals = xdetails-decimals.
        append xfc to ifc.
      endloop.
    endform.
    form create_dynamic_itab.
    Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = ifc
                   importing
                      ep_table        = dy_table.
      assign dy_table->* to <dyn_table>.
    Create dynamic work area and assign to FS
      create data dy_line like line of <dyn_table>.
      assign dy_line->* to <dyn_wa>.
    endform.
    form get_data.
    Select Data from table.
      select * into table <dyn_table>
                 from (p_table).
    endform.
    form write_out.
    Write out data from table.
      loop at <dyn_table> into <dyn_wa>.
        do.
          assign component  sy-index
             of structure <dyn_wa> to <dyn_field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <dyn_field>.
          else.
            write: <dyn_field>.
          endif.
        enddo.
      endloop.
    endform.
    Thanks,
    Shankar

  • Inserting data into dynamic internal tables

    Hello everyone, i need some suggestions on the following problem:
    I have created a dynamic table that consist of storage locations(SL) belonging to a plant. Each record in the internal table would need to display all the SL on the same line. I have succesfully created it and displayed it on an ALV, the problem now is how to insert data for the dynamically created storage locations:
    EXAMPLE: Created dynamic itab
    colA | colB | SL1 | SL2 | ... | SLn | colC | <--header
    data | data | 100 | 120 | ... | 200 | data | <--record
    I would like to insert data from the fields of another itab into SL1 to SLn. How can i go about doing it?
    Data from ColA to ColC has been filled through:
    <i>loop at itab into w_itab.
    move-corresponding w_itab to <dyn_tab>.
    endloop.</i>
    I cannot do the same to the SLs as the fields is dynamically created during runtime and the fieldname is different from the data that i am to insert in into.
    Any ideas?

    Hi,
      I have the following code in my BADI:
    ct_value_list is defined in the parameters of the method as a type standard table.
    Create values list reference
    CREATE DATA lv_value_list_ref LIKE LINE OF ct_value_list.
    ASSIGN lv_value_list_ref->* TO <lfs_value_list>.
      IF CT_VALUE_LIST IS INITIAL.
        lv_tabix = sy-tabix.
        IF NOT LT_DATA[] IS INITIAL.
          LOOP AT lt_data assigning <lfs_data>.
            assign <lfs_data> to <lfs_value_list>.
          assign <lfs_value_list> to <lv_value_list>.
            ASSIGN COMPONENT lc_prvar OF STRUCTURE <lfs_value_list>
            TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
    Get the material id
            READ TABLE it_matkey_tab ASSIGNING <lfs_matkey>
              WITH KEY matnr = <lfs_attribute>.
            IF sy-subrc = 0.
              lv_matid = <lfs_matkey>-matid.
            ENDIF.
            ENDIF.
            ASSIGN COMPONENT lc_mktgr OF STRUCTURE <lfs_value_list>
              TO <lfs_attribute>.
            IF <lfs_value_list> IS ASSIGNED.
            READ TABLE it_loc ASSIGNING <lfs_loc>
              WITH KEY locno = <lfs_attribute>.
            IF sy-subrc = 0.
              lv_locid = <lfs_loc>-locid.
            ENDIF.
            READ TABLE it_matloc ASSIGNING <lfs_matloc_int>
              WITH KEY matid = lv_matid
                       locid = lv_locid.
           if sy-subrc = 0.
          MATLOC: Assignment of Values - START
              ASSIGN COMPONENT 'MATLOCID'
                OF STRUCTURE <lfs_matloc_int> TO <lfs_attribute>.
              IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_matloc_int>-matlocid.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
                INSERT <lfs_matloc_int> INTO TABLE <lv_value_list>.
              ENDIF.
              ASSIGN COMPONENT 'PLANNER_SNP'
                OF STRUCTURE <lfs_matloc_int> TO <lfs_attribute>.
              IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_matloc_int>-planner_snp.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
              ENDIF.
              ASSIGN COMPONENT 'AT101'
                OF STRUCTURE <lfs_matloc_int> TO <lfs_attribute>.
              IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_matloc_int>-at101.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
              ENDIF.
              ASSIGN COMPONENT 'AT102'
                OF STRUCTURE <lfs_matloc_int> TO <lfs_attribute>.
              IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_matloc_int>-at102.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
              ENDIF.
              ASSIGN COMPONENT 'AT103'
                OF STRUCTURE <lfs_matloc_int> TO <lfs_attribute>.
              IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_matloc_int>-at103.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
              ENDIF.
              ASSIGN COMPONENT 'AT104'
                OF STRUCTURE <lfs_matloc_int> TO <lfs_attribute>.
              IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_matloc_int>-at104.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
              ENDIF.
              ASSIGN COMPONENT 'AT105'
                OF STRUCTURE <lfs_matloc_int> TO <lfs_attribute>.
              IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_matloc_int>-at105.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
              ENDIF.
            endif.
           ENDIF.
            ASSIGN COMPONENT 'PRVAR'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
               <lfs_attribute> = <lfs_value_list>-prvar.
               INSERT <lfs_value_list> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'PARPR'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-parpr.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'VARID'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-varid.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'VARCT'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-varct.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'VARTX'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-vartx.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'DMOAP'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-dmoap.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'PRDID'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-prdid.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'BRFAM'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-brfam.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'MATKL'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-matkl.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'BRDIF'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-brdif.
               INSERT <lfs_attribute> INTO TABLE ct_value_list.
            ENDIF.
            ASSIGN COMPONENT 'MEIND'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-meind.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'MKLEN'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-mklen.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'PCKTY'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-pckty.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'ITPCK'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-itpck.
               INSERT <lfs_attribute> INTO TABLE ct_value_list.
            ENDIF.
            ASSIGN COMPONENT 'PMEIN'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-pmein.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'MKTHK'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-mkthk.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'FLIND'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
               <lfs_attribute> = <lfs_value_list>-flind.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'EDTID'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
               <lfs_attribute> = <lfs_value_list>-edtid.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'BNDTY'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-bndty.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'ITBND'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-itbnd.
                INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'ITCSE'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-itcse.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'TPCOL'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-tpcol.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'SPFLV'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-spflv.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'PRSHP'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-prshp.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'MKTGR'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-mktgr.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'SUBMK'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-submk.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'BOMHD'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
               <lfs_attribute> = <lfs_value_list>-bomhd.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'BRDSC'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-brdsc.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'MKSTR'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-mkstr.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'EDDSC'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-eddsc.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'EDCAT'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-edcat.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'CCIND'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-ccind.
             INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'CGSTY'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-cgsty.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'FLTTY'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-fltty.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'CPIND'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-cpind.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'MBIND'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-mbind.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'USPRP'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
               <lfs_attribute> = <lfs_value_list>-usprp.
             INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'EDDET'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-eddet.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'BRGEW'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
               <lfs_attribute> = <lfs_value_list>-brgew.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'NTGEW'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-ntgew.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'GEWEI'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-gewei.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'VOLUM'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-volum.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'VOLEH'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-voleh.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'DMOAPP1'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
               <lfs_attribute> = <lfs_value_list>-dmoapp1.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'MAKTX'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
               <lfs_attribute> = <lfs_value_list>-maktx.
               INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
            ASSIGN COMPONENT 'RPLVL'
                OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
            IF <lfs_attribute> IS ASSIGNED.
              <lfs_attribute> = <lfs_value_list>-rplvl.
              INSERT <lfs_attribute> INTO TABLE <lv_value_list>.
            ENDIF.
         ENDLOOP.
        ENDIF.
    ENDIF.
    I get a shortdump in the code for the above code. There are diff types of inserts that I am trying to do and each one gives a short dump.
    Looking forward to your inputs.
    Your program is not applicable in my case as I have ct_value_list passed as a changing parameter of type standard table in my APO BADI.
    cheers
    Aveek

  • How to add new field into dynamic internal table

    Hello Expert.
    how to add new field into dynamic internal table.
    PARAMETERS: P_TABLE(30).    "table name
    DATA: I_TAB TYPE REF TO DATA.
    FIELD-SYMBOLS: <TAB> TYPE standard TABLE.
    *Create dynamic FS
    create DATA I_TAB TYPE TABLE OF (p_table).
      ASSIGN I_TAB->* TO <TAB>.
    SELECT * FROM (p_table) INTO TABLE <TAB>.
       here i want to add one more field into <TAB> at LAST position and my 
       Field name  =  field_stype     and
       Field type    =  'LVC_T_STYL'
    could you please helpme out .

    Hi,
    Please find the code below.You can add the field acc to your requirement.
    Creating Dynamic internal table
    TYPE-POOLS: slis.
    FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,  u201C Dynamic internal table name
                   <fs_dyntable>,                     u201C Field symbol to create work area
                   <fs_fldval> type any.              u201C Field symbol to assign values 
    PARAMETERS: p_cols(5) TYPE c.                     u201C Input number of columns
    DATA:   t_newtable TYPE REF TO data,
            t_newline  TYPE REF TO data,
            t_fldcat   TYPE slis_t_fldcat_alv,
            t_fldcat   TYPE lvc_t_fcat,
            wa_it_fldcat TYPE lvc_s_fcat,
            wa_colno(2) TYPE n,
            wa_flname(5) TYPE c. 
    Create fields .
      DO p_cols TIMES.
        CLEAR wa_it_fldcat.
        move sy-index to wa_colno.
        concatenate 'COL'
                    wa_colno
               into wa_flname.
        wa_it_fldcat-fieldname = wa_flname.
        wa_it_fldcat-datatype = 'CHAR'.
        wa_it_fldcat-intlen = 10.
        APPEND wa_it_fldcat TO t_fldcat.
      ENDDO. 
    Create dynamic internal table and assign to FS
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = t_fldcat
        IMPORTING
          ep_table        = t_newtable. 
      ASSIGN t_newtable->* TO <t_dyntable>. 
    Create dynamic work area and assign to FS
      CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
      ASSIGN t_newline->* TO <fs_dyntable>.
    Populating Dynamic internal table 
      DATA: fieldname(20) TYPE c.
      DATA: fieldvalue(10) TYPE c.
      DATA: index(3) TYPE c. 
      DO p_cols TIMES. 
        index = sy-index.
        MOVE sy-index TO wa_colno.
        CONCATENATE 'COL'
                    wa_colno
               INTO wa_flname. 
    Set up fieldvalue
        CONCATENATE 'VALUE' index INTO
                    fieldvalue.
        CONDENSE    fieldvalue NO-GAPS. 
        ASSIGN COMPONENT  wa_flname
            OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
        <fs_fldval> =  fieldvalue. 
      ENDDO. 
    Append to the dynamic internal table
      APPEND <fs_dyntable> TO <t_dyntable>.
    Displaying dynamic internal table using Grid. 
    DATA: wa_cat LIKE LINE OF fs_fldcat. 
      DO p_cols TIMES.
        CLEAR wa_cat.
        MOVE sy-index TO wa_colno.
        CONCATENATE 'COL'
                    wa_colno
               INTO wa_flname. 
        wa_cat-fieldname = wa_flname.
        wa_cat-seltext_s = wa_flname.
        wa_cat-outputlen = '10'.
        APPEND wa_cat TO fs_fldcat.
      ENDDO. 
    Call ABAP List Viewer (ALV)
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          it_fieldcat = fs_fldcat
        TABLES
          t_outtab    = <t_dyntable>.

  • Select data into deep internal table

    Dear Experts.
    I created a dynamiv deep internal table.
    while selecting data , into the internal table it is giving a dump. saying that deep structure.
    SELECT OBJTY OBJID ARBPL WERKS from crhd
    INTO CORRESPONDING FIELDS OF TABLE <f_tab>
    where WERKS = pr_werks.
    I used the field catalog also.even same error is comming.
    how to get data into deep internal table by select statement.
    Please help me,
    Regards,
    Rahul

    HI,
    Try creating dynamic internal table like:
    Field-symbols: <dyn_table> type standard table,
                                 <dyn_wa>   ,
                                 <dyn_field>.
      Data: dy_table      type ref to data,
                ifc                  type lvc_t_fcat ,
                xfc                 type lvc_s_fcat ,
               Count             type i          ,
               Count1           type i          ,
               Index              type i          ,
               dy_line           type ref to data.
             Data counter   type i.
      Data: line   type string       ,
                List    like table of line.
      Data: idetails           type abap_compdescr_tab,
                   xdetails           type abap_compdescr    .
      Data: ref_table_des type ref to cl_abap_structdescr.
    *Looping at field cat internal table to populate another field cat to be passed
    * In method used below for creating final dynamic internal table
      Loop at fieldcat into fieldcat1.
        Clear xfc.
           Xfc-fieldname            = fieldcat1-fieldname.
           Xfc-datatype              = fieldcat1-datatype.
           Xfc-intlen                    = fieldcat1-intlen.
         Append xfc            to ifc.
      endloop.
    Clear fieldcat1.
    *Method called to create dynamic internal table on the basis of field catalog created above
      Call method cl_alv_table_create=>create_dynamic_table
        Exporting
          it_fieldcatalog = ifc                     u201Cfield catalog appended above
        Importing
          ep_table        = dy_table.            u201CDynamic internal table which will be created
      Assign dy_table->* to <dyn_table>.
    *Create dynamic work area and assign to FS
      Create data dy_line like line of <dyn_table>.
      Assign dy_line->* to <dyn_wa>.
    Then use this dynamic internal table created from above method
    in the Select Query.
    Hope it helps
    Regards
    Mansi

  • How to read a table and transfer the data into an internal table?

    Hello,
    I try to read all the data from a table (all attribute values from a node) and to write these data into an internal table. Any idea how to do this?
    Thanks for any help.

    Hi,
    Check this code.
    Here i creates context one node i.e  flights and attributes are from SFLIGHT table.
    DATA: lo_nd_flights TYPE REF TO if_wd_context_node,
            lo_el_flights TYPE REF TO if_wd_context_element,
            ls_flights TYPE if_main=>element_flights,
            it_flights type if_main=>elements_flights.
    navigate from <CONTEXT> to <FLIGHTS> via lead selection
      lo_nd_flights = wd_context->get_child_node( 'FLIGHTS' ).
    CALL METHOD LO_ND_FLIGHTS->GET_STATIC_ATTRIBUTES_TABLE
      IMPORTING
        TABLE  = it_flights.
    now the table data will be in internal table it_flights.

  • Header data and item data into same internal table

    Hi Experts,
    I WANT TO KNOW THE LOGIC TO POPULATE HEADER DATA AND ITEM DATA INTO SAME INTERNAL TABLE AND AGAIN DOWNLOAD THE SAME TO EXCEL FILE .Output file should be displayed like this format
    Header1  rectyp ,hdnum ,sbank ,bankl ,accnr , paytp , crda ,iso.
    Item1  : rectyp ,valut ,cknum ,amount,bankl,accnr,pdate,bnktc.
    Item2  : rectyp ,valut ,cknum ,amount,bankl,accnr,pdate,bnktc.
    Header2: rectyp ,hdnum ,sbank ,bankl ,accnr , paytp , crda ,iso.
    Item1  : rectyp ,valut ,cknum ,amount,bankl,accnr,pdate,bnktc.
    Thanks
    Moderator message: Please do not use all upper case in the future.
    Edited by: Thomas Zloch on May 12, 2010 3:10 PM

    Hi,
    for example we have 3 internal tables 
    1> it_header  2>it_items   3>it_final (which contains all the header and item fields)
    once  it_header   it_items  are filled
    loop at it_items.
    read table it_header with key xyz = it_item-xyz.
    if sy-subrc = 0.
      here move all the header fields to it_final like below.
    it_final -xfield  = it_header-xfield.
    endif.
      here move all the item fields to it_final like below.
    it_final -yfield  = it_item-yfield.
    append it_final.
    clear it_final.
    endloop.
    now header and item fileds will be fillled in it_item

  • How can i add two table data into third internal table see below

    hi i insert diffferent table data into different internal table i did try to insert two different internal table data into third internal table by using move
    but only single data is coming please help me
    i want this two internal table data inot third internal table.
    sELECT  * FROM J_1IEXCHDR INTO CORRESPONDING FIELDS OF ITAB1 WHERE STATUS = 'P'.
    SELECT * FROM J_1IEXCDTL INTO CORRESPONDING FIELDS OF ITAB2  WHERE LIFNR = J_1IEXCHDR-LIFNR.
                             AND DOCYR  = J_1IEXCHDR-DOCYR,
                             AND DOCNO  = J_1IEXCHDR-DOCNO.
    WRITE: /  ITAB1-LIFNR,
              ITAB1-DOCNO,
              ITAB1-EXYEAR,
              ITAB1-BUDAT,
              ITAB2-EXBED,
              ITAB2-RDOC,
              ITAB2-ECS.
    ENDSELECT.
    ENDSELECT.
    thank you .

    hi
      Two add two internal tables data.  first we need to create third internal table with all the fields of first two internal tables.
    later u move the two internal tables data to third internal table
    by looping the internal table which have more records or depending on the requirement and move the corresponding fields of first internal table to the third internal table and use the read statement with condition based on primary key of first itab and get the corresponding data of 2table into 3table.
    i am sending the sample code to u.
    check it out. i think u will understand how to move.
    select vbeln waerk netwr erdat audat kunnr
       into table it_vbeln
       from vbak
       where vbeln in s_vbeln
         and erdat in s_erdat.
      if not it_vbeln[] is initial.
      select kunnr name1
       into table it_kunnr
       from  kna1
       for all entries in it_vbeln
         where kunnr = it_vbeln-kunnr.
      endif.
      loop at it_vbeln.
      clear it_final.
       it_final-vbeln = it_vbeln-vbeln.
       it_final-waerk = it_vbeln-waerk.
       it_final-netwr = it_vbeln-netwr.
       it_final-erdat = it_vbeln-erdat.
       it_final-audat = it_vbeln-audat.
      read table it_kunnr with key kunnr = it_vbeln-kunnr.
       it_final-name1 = it_kunnr-name1.
      append it_final.
      endloop.

  • How to send multiple row data into an internal table??

    I have a view with table control.i want to select multiple row and send all the row data into an internal table.i am able to select multiple row but all the selected row data is not going to the internal table.....only a particular row data which is lead selected is going.
    Do anyone can help me regarding this issue?
    Thanks in advance,
    Subhasis.

    Hey,
    Some code example:
    declaring an internal table and work area to get all the elements from the node.
    data : lt_Elements type  WDR_CONTEXT_ELEMENT_SET,
             ls_Element type  WDR_CONTEXT_ELEMENT_SET,
    considering flights is my node.
             lt_data type sflight.
    Node_Flights is the ref of the node to which ur table is binded.
    Use Code Inspector to read the node.
    lt_Element = Node_Flights->GET_ELEMENTS
    loop at lt_elements into ls_Element.
    l_bollean =   ls_elements->is_selected ( returns abap true/false ).
        if l_bollean IS INITIAL.
           append ls_Element to lt_data.
       endif.
    Hope this would help.
    Cheers,
    Ashish

  • How to populate data in dynamic internal table

    Hi Expert,
    fyi. My dynamic internal table field is created base on data selected. Eg. select table qpcd has 5 records.  These 5 recods will become fieldname to my dynamic internal table. My dynamic internal table will be
    ...itab
          01
          02
          03
          04
          05
    The 5 records from qpcd is populated in another table call viqmel.  I need to find the occurance of each code in viqmel and populate the number of occurance in itab in each of column.  The final dynamic itab will be like this
    table itab
    01       02     03    04     05   -
    > field name
    2         0        1     0       1    -
    > data
    my source code like below
    Report ZPLYGRND2.
    TABLES: mara, makt.
    TYPE-POOLS: slis, sydes.
    DATA:it_fcat TYPE slis_t_fieldcat_alv,
         is_fcat LIKE LINE OF it_fcat,
         ls_layout TYPE slis_layout_alv.
    DATA: it_fieldcat TYPE lvc_t_fcat,
          is_fieldcat LIKE LINE OF it_fieldcat.
    DATA: new_table TYPE REF TO data,
          new_line TYPE REF TO data,
          ob_cont_alv TYPE REF TO cl_gui_custom_container,
          ob_alv TYPE REF TO cl_gui_alv_grid,
          vg_campos(255) TYPE c,
          i_campos LIKE TABLE OF vg_campos,
          vg_campo(30) TYPE c,
          vg_tables(60) TYPE c.
    types : begin of t_qpcd,
             codegruppe like qpcd-codegruppe,
             code like qpcd-code,
            end of t_qpcd.
    data:wa_qpcd type t_qpcd,
         i_qpcd type standard table of t_qpcd initial size 0.
    FIELD-SYMBOLS: <l_table> TYPE table,
                   <l_line> TYPE ANY,
                   <l_field> TYPE ANY.
    select * into corresponding fields of wa_qpcd from qpcd
    where katalogart = 'D'
    and   codegruppe = 'OOT01'.
    append wa_qpcd to i_qpcd.
    endselect.
    loop at i_qpcd into wa_qpcd.
      is_fcat-fieldname = wa_qpcd-code.
      APPEND is_fcat TO it_fcat.
    endloop.
    LOOP AT it_fcat INTO is_fcat.
        is_fieldcat-fieldname = is_fcat-fieldname.
        is_fieldcat-ref_field = is_fcat-ref_fieldname.
        is_fieldcat-ref_table = is_fcat-ref_tabname.
        APPEND is_fieldcat TO it_fieldcat.
    ENDLOOP.
    *... Create the dynamic internal table
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
            it_fieldcatalog = it_fieldcat
        IMPORTING
            ep_table = new_table.
    if sy-subrc = 0.
    endif.
    *... Create a new line
    ASSIGN new_table->* TO <l_table>.
    CREATE DATA new_line LIKE LINE OF <l_table>.
    ASSIGN new_line->* TO <l_line>.
    LOOP AT <l_table> INTO <l_line>.
    ENDLOOP.

    hello dear i m giving u a code in this a dynamic table is made on the basis of table in database , and u can download this data correct it , see it, or even change it....and upload in tht table help full if u dont know the table name...in advance.
    also the code to populate data in dynamic table is in this code like:
    SELECT * FROM (MTABLE_N)
    INTO CORRESPONDING FIELDS OF TABLE <FS_ITAB> .
    look at the whole program .hope this solve ur problem thanks.
    REPORT ZTESTA  MESSAGE-ID ZIMM    .
    TYPES : DATA_OBJECT TYPE REF TO DATA.
    DATA : MITAB TYPE REF TO DATA .
    TYPE-POOLS : SLIS .
    DATA : IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV
    WITH HEADER LINE .
    DATA : IT_FIELDCATALOG TYPE LVC_T_FCAT .
    DATA : WA_FIELDCATALOG TYPE LVC_S_FCAT .
    DATA : I_STRUCTURE_NAME LIKE DD02L-TABNAME .
    DATA : I_CALLBACK_PROGRAM LIKE SY-REPID .
    DATA : DYN_LINE TYPE DATA_OBJECT .
    FIELD-SYMBOLS : <FS_ITAB> TYPE STANDARD TABLE .
    DATA : TABLE_NAME_IS_VALID TYPE C .
    DATA : DYNAMIC_IT_INSTANTIATED TYPE C .
    CONSTANTS BUTTONSELECTED TYPE C VALUE 'X' .
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 5(29) T_TABL.
    PARAMETERS : MTABLE_N LIKE RSRD1-TBMA_VAL
    MATCHCODE OBJECT DD_DBTB_16 OBLIGATORY .
    DATA CHECKTABLED.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 5(29) T_FILE.
    PARAMETERS : MFILENAM LIKE RLGRAP-FILENAME .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 5(29) T_DOWN.
    PARAMETERS : P_DOWNLD RADIOBUTTON GROUP GRP1
    USER-COMMAND M_UCOMM .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 5(29) T_CHKF.
    PARAMETERS : P_CHKFIL RADIOBUTTON GROUP GRP1 .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 5(29) T_UPLD.
    PARAMETERS : P_UPLOAD RADIOBUTTON GROUP GRP1 .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 5(29) T_SHOW.
    PARAMETERS : P_SHOW_T RADIOBUTTON GROUP GRP1 .
    SELECTION-SCREEN END OF LINE.
    AT SELECTION-SCREEN OUTPUT .
      PERFORM CHECK_FILENAME .
    AT SELECTION-SCREEN.
      IF SY-UCOMM = 'ONLI'.
        CHECKTABLED = MTABLE_N+0(1).
        IF CHECKTABLED NE 'Z'.
          MESSAGE I017.
          LEAVE TO SCREEN 1000.
        ENDIF.
        IF SY-UNAME NE 'KAMESH.K'.
          MESSAGE I023 WITH SY-UNAME.
          LEAVE TO SCREEN 1000.
        ENDIF.
      ENDIF.
      IF SY-UCOMM = 'PRIN'.
        CHECKTABLED = MTABLE_N+0(1).
        IF CHECKTABLED NE 'Z'.
          MESSAGE I017.
          LEAVE TO SCREEN 1000.
        ENDIF.
        IF SY-UNAME NE 'KAMESH.K'.
          MESSAGE I023 WITH SY-UNAME.
          LEAVE TO SCREEN 1000.
        ENDIF.
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR MFILENAM .
      PERFORM F4_FOR_FILENAME .
    INITIALIZATION .
      T_TABL = 'Table Name' .
      T_FILE = 'File Name' .
      T_DOWN = 'Download Table' .
      T_CHKF = 'Check File to Upload' .
      T_UPLD = 'Upload File' .
      T_SHOW = 'Show Table Contents' .
    START-OF-SELECTION .
      PERFORM CHECK_TABLE_NAME_IS_VALID .
    END-OF-SELECTION .
      IF TABLE_NAME_IS_VALID EQ ' ' .
        MESSAGE I398(00) WITH 'INVALID TABLE NAME' .
      ELSE .
        PERFORM INSTANTIATE_DYNAMIC_INTERNAL_T .
        CHECK DYNAMIC_IT_INSTANTIATED = 'X' .
        CASE BUTTONSELECTED .
          WHEN P_DOWNLD .
            PERFORM SELECT_AND_DOWNLOAD .
          WHEN P_CHKFIL .
            PERFORM CHECK_FILE_TO_UPLOAD .
          WHEN P_UPLOAD .
            PERFORM UPLOAD_FROM_FILE .
          WHEN P_SHOW_T .
            PERFORM SHOW_CONTENTS .
        ENDCASE .
      ENDIF .
    FORM CHECK_TABLE_NAME_IS_VALID.
      DATA MCOUNT TYPE I .
      TABLES DD02L .
      CLEAR TABLE_NAME_IS_VALID .
      SELECT COUNT(*) INTO MCOUNT FROM TADIR
      WHERE PGMID = 'R3TR'
      AND OBJECT = 'TABL'
      AND OBJ_NAME = MTABLE_N .
      IF MCOUNT EQ 1 .
        CLEAR DD02L .
        SELECT SINGLE * FROM DD02L WHERE TABNAME = MTABLE_N .
        IF SY-SUBRC EQ 0.
          IF DD02L-TABCLASS = 'TRANSP' .
            TABLE_NAME_IS_VALID = 'X' .
          ENDIF .
        ENDIF.
      ENDIF .
    ENDFORM. " CHECK_TABLE_NAME_IS_VALID
    FORM SELECT_AND_DOWNLOAD.
      CLEAR : <FS_ITAB> .
      SELECT * FROM (MTABLE_N)
      INTO CORRESPONDING FIELDS OF TABLE <FS_ITAB> .
      PERFORM CHECK_FILENAME.
      CALL FUNCTION 'WS_DOWNLOAD'
           EXPORTING
                FILENAME                = MFILENAM
                FILETYPE                = 'DAT'
           TABLES
                DATA_TAB                = <FS_ITAB>
           EXCEPTIONS
                FILE_OPEN_ERROR         = 1
                FILE_WRITE_ERROR        = 2
                INVALID_FILESIZE        = 3
                INVALID_TYPE            = 4
                NO_BATCH                = 5
                UNKNOWN_ERROR           = 6
                INVALID_TABLE_WIDTH     = 7
                GUI_REFUSE_FILETRANSFER = 8
                CUSTOMER_ERROR          = 9
                OTHERS                  = 10.
      IF SY-SUBRC EQ 0.
        MESSAGE I398(00) WITH 'Table' MTABLE_N
        'successfully downloaded to '
        MFILENAM .
      ENDIF.
    ENDFORM. " SELECT_AND_DOWNLOAD
    FORM UPLOAD_FROM_FILE.
      DATA : ANS TYPE C .
      DATA : LINES_OF_ITAB TYPE I .
      DATA : MSY_SUBRC TYPE I .
      CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
           EXPORTING
                TEXTLINE1 = 'Are you sure you wish to upload'
                TEXTLINE2 = 'data from ASCII File to DB table '
                TITEL     = 'Confirmation of Data Upload'
           IMPORTING
                ANSWER    = ANS.
      IF ANS = 'J' .
        PERFORM CHECK_FILENAME.
        CLEAR MSY_SUBRC .
        CALL FUNCTION 'WS_UPLOAD'
             EXPORTING
                  FILENAME                = MFILENAM
                  FILETYPE                = 'DAT'
             TABLES
                  DATA_TAB                = <FS_ITAB>
             EXCEPTIONS
                  CONVERSION_ERROR        = 1
                  FILE_OPEN_ERROR         = 2
                  FILE_READ_ERROR         = 3
                  INVALID_TYPE            = 4
                  NO_BATCH                = 5
                  UNKNOWN_ERROR           = 6
                  INVALID_TABLE_WIDTH     = 7
                  GUI_REFUSE_FILETRANSFER = 8
                  CUSTOMER_ERROR          = 9
                  OTHERS                  = 10.
        MSY_SUBRC = MSY_SUBRC + SY-SUBRC .
        IF SY-SUBRC EQ 0.
          DESCRIBE TABLE <FS_ITAB> LINES LINES_OF_ITAB .
          IF LINES_OF_ITAB GT 0 .
            MODIFY (MTABLE_N) FROM TABLE <FS_ITAB> .
            MSY_SUBRC = MSY_SUBRC + SY-SUBRC .
          ENDIF .
        ENDIF.
        IF MSY_SUBRC EQ 0 .
          MESSAGE I398(00) WITH LINES_OF_ITAB
          'Record(s) inserted in table'
          MTABLE_N .
        ELSE .
          MESSAGE I398(00) WITH
          'Errors occurred No Records inserted in table'
          MTABLE_N .
        ENDIF .
      ENDIF .
    ENDFORM. " UPLOAD_FROM_FILE
    FORM F4_FOR_FILENAME.
      CALL FUNCTION 'WS_FILENAME_GET'
           EXPORTING
                DEF_PATH         = 'C:\'
                MASK             = ',.,..'
                MODE             = '0'
           IMPORTING
                FILENAME         = MFILENAM
           EXCEPTIONS
                INV_WINSYS       = 1
                NO_BATCH         = 2
                SELECTION_CANCEL = 3
                SELECTION_ERROR  = 4
                OTHERS           = 5.
    ENDFORM. " F4_FOR_FILENAME
    FORM CHECK_FILENAME.
      IF MFILENAM IS INITIAL
      AND NOT ( MTABLE_N IS INITIAL )
      AND P_SHOW_T NE BUTTONSELECTED.
        CONCATENATE 'C:\'
        MTABLE_N '.TXT' INTO MFILENAM.
      ENDIF .
    ENDFORM. " CHECK_FILENAME
    FORM INSTANTIATE_DYNAMIC_INTERNAL_T.
      CLEAR DYNAMIC_IT_INSTANTIATED .
      I_STRUCTURE_NAME = MTABLE_N .
      CLEAR IT_FIELDCAT[] .
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_STRUCTURE_NAME       = I_STRUCTURE_NAME
           CHANGING
                CT_FIELDCAT            = IT_FIELDCAT[]
           EXCEPTIONS
                INCONSISTENT_INTERFACE = 1
                PROGRAM_ERROR          = 2
                OTHERS                 = 3.
      IF SY-SUBRC EQ 0.
        LOOP AT IT_FIELDCAT .
          CLEAR WA_FIELDCATALOG .
          MOVE-CORRESPONDING IT_FIELDCAT TO WA_FIELDCATALOG .
          WA_FIELDCATALOG-REF_FIELD = IT_FIELDCAT-FIELDNAME .
          WA_FIELDCATALOG-REF_TABLE = MTABLE_N .
          APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG .
        ENDLOOP .
        CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
        IT_FIELDCATALOG = IT_FIELDCATALOG
        IMPORTING
        EP_TABLE = MITAB .
        ASSIGN MITAB->* TO <FS_ITAB> .
        DYNAMIC_IT_INSTANTIATED = 'X' .
      ENDIF.
    ENDFORM. " INSTANTIATE_DYNAMIC_INTERNAL_T
    FORM SHOW_CONTENTS.
      CLEAR : <FS_ITAB> .
      SELECT * FROM (MTABLE_N)
      INTO CORRESPONDING FIELDS OF TABLE <FS_ITAB> .
      I_CALLBACK_PROGRAM = SY-REPID .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM = I_CALLBACK_PROGRAM
                IT_FIELDCAT        = IT_FIELDCAT[]
           TABLES
                T_OUTTAB           = <FS_ITAB>
           EXCEPTIONS
                PROGRAM_ERROR      = 1
                OTHERS             = 2.
    ENDFORM. " SHOW_CONTENTS
    FORM CHECK_FILE_TO_UPLOAD.
      PERFORM CHECK_FILENAME.
      CALL FUNCTION 'WS_UPLOAD'
           EXPORTING
                FILENAME                = MFILENAM
                FILETYPE                = 'DAT'
           TABLES
                DATA_TAB                = <FS_ITAB>
           EXCEPTIONS
                CONVERSION_ERROR        = 1
                FILE_OPEN_ERROR         = 2
                FILE_READ_ERROR         = 3
                INVALID_TYPE            = 4
                NO_BATCH                = 5
                UNKNOWN_ERROR           = 6
                INVALID_TABLE_WIDTH     = 7
                GUI_REFUSE_FILETRANSFER = 8
                CUSTOMER_ERROR          = 9
                OTHERS                  = 10.
      IF SY-SUBRC EQ 0.
        I_CALLBACK_PROGRAM = SY-REPID .
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
             EXPORTING
                  I_CALLBACK_PROGRAM = I_CALLBACK_PROGRAM
                  IT_FIELDCAT        = IT_FIELDCAT[]
             TABLES
                  T_OUTTAB           = <FS_ITAB>
             EXCEPTIONS
                  PROGRAM_ERROR      = 1
                  OTHERS             = 2.
      ENDIF .
    ENDFORM. " CHECK_FILE_TO_UPLOAD
    Message was edited by:
            SAURABH SINGH
            SENIOR EXECUTIVE
            SAMSUNG INDIA ELECTRONICS LTD.,NOIDA

  • Populate data in dynamic internal table

    Hi ppl,
    I have a requirement where I need to display certain fields in the report output.
    The output contains 8 fixed fields (common for all rows in output) and some dynamic fields (number of column varies with rows) which will be determined at runtime.
    I am able to create the dunamic internal table....and at runtime I see the fields created in the internal table correctly.
    Now my requirement is to fill this table with the data from 2 internal tables.
    The values for the 8 common fields comes from the internal table t_output and the values for dynamic fields come from t_dynamic.
    Please let me know the logic to merge these 2 internal tables into the dynamic internal table <dyn_table>.
    Regards.

    Hello David,
    This has been discussed many times before in this forum. Since the table structure is dynamic the fields are determined at runtime.
    To assign data to this table you have to use [ASSIGN COMPONENT ... |http://help.sap.com/abapdocu_70/en/ABAPASSIGN_MEM_AREA_DYNAMIC_DOBJ.htm#!ABAP_ALTERNATIVE_4@4@] variant.
    Please refer to the example provided in the documentation for details.
    BR,
    Suhas

  • 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.

  • Populate data from dynamic internal table

    Hi
    I have dynamic internal table <lt_paxxxx>. Iam fillling <lt_paxxxx> in the following way.
    select * into table <lt_paxxxx> from (infty-dbname).
    I have to pass data of <lt_paxxxx> to another internal table lt_final.
    'lt_final' should contain fields like <lt_paxxxx>, infty name, DB name.
    Could you please help me out how to pass <lt_paxxxx> data to 'LT_FINAL'.

    loop at <it_table>
           into <is_table>.
        loop at it_fieldcatalog
             into is_fieldcatalog.
          assign component is_fieldcatalog-fieldname
                 of structure <is_table>
                 to <field1>.
          concatenate 'IT_TABLE-'
                              is_fieldcatalog-fieldname
                             into w_field.
         assign (w_field) to <field2>.
         check sy-subrc eq space.
          move <field1> to <field2>.
        endloop.
       append it_table
      endloop.
    regards

  • Filling Data in Dynamic internal table

    Hello,
    I have 2 internal tables TAB1 and TAB2.
    I have Created Dynamic internal table From TAB1 rows.
    Now I want to fill that Dynm. internal table from TAB2.
    But TAB2  have more Rows with diffarant  names.  I want to move particular field of TAB2 to particular field.of dynamic IT.
    kindly help.

    Hi,
    I am sending the dynamic alv report for your referenece.
    REPORT  YMS_DYNAMICALV.
    type-pools: slis.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>.
    data: alv_fldcat type slis_t_fieldcat_alv,
          it_fldcat type lvc_t_fcat.
    selection-screen begin of block b1 with frame title text-001.
    parameters: p_flds(5) type c.
    selection-screen end of block b1.
    start-of-selection.
    build the dynamic internal table
      perform build_dyn_itab.
    write 5 records to the alv grid
      do 5 times.
        perform build_report.
      enddo.
    call the alv grid.
      perform call_alv.
    Build_dyn_itab
    form build_dyn_itab.
      data: new_table type ref to data,
            new_line  type ref to data,
            wa_it_fldcat type lvc_s_fcat.
    Create fields .
      do p_flds times.
        clear wa_it_fldcat.
        wa_it_fldcat-fieldname = sy-index.
        wa_it_fldcat-datatype = 'CHAR'.
        wa_it_fldcat-intlen = 5.
        append wa_it_fldcat to it_fldcat .
      enddo.
    Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = it_fldcat
                   importing
                      ep_table        = new_table.
      assign new_table->* to <dyn_table>.
    Create dynamic work area and assign to FS
      create data new_line like line of <dyn_table>.
      assign new_line->* to <dyn_wa>.
    endform.
         Form  build_report
    form build_report.
      data: fieldname(20) type c.
      data: fieldvalue(5) type c.
      data: index(3) type c.
      field-symbols: <fs1>.
      do p_flds times.
        index = sy-index.
    Set up fieldvalue
        concatenate 'FLD' index into
                 fieldvalue.
        condense   fieldvalue no-gaps.
      <b> assign component  index  of structure <dyn_wa> to <fs1>.
       <fs1> =  fieldvalue.</b>
      enddo.
    Append to the dynamic internal table
      append <dyn_wa> to <dyn_table>.
    endform.
    CALL_ALV
    form call_alv.
      data: wa_cat like line of alv_fldcat.
      do p_flds times.
        clear wa_cat.
        wa_cat-fieldname = sy-index.
        wa_cat-seltext_s = sy-index.
        wa_cat-outputlen = '5'.
        append wa_cat to alv_fldcat.
      enddo.
    Call ABAP List Viewer (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                it_fieldcat = alv_fldcat
           tables
                t_outtab    = <dyn_table>.
    endform.
    Thanks,
    Shankar

  • How to delete data from dynamic internal table

    Hi,
    I have dynamic internal table and I have some slection screen fields , using these selection screen fields
    (select -options), I have to filter the data? assigning will work with READ , but I have select options not the parametre,
    and also delete will not work for dynamic table..
    as we cannot use assigning with delete..
    So how to do this?
    and one more thing is , I cannot filter the data while selection( in select, I cannot filter the data-> as it's not coming directly from table, it's coming from buffer),
    so now after selection of data, I need to filter the data from dynamic table.
    Is there any way to do this?
    Regards,
    Mrunal

    Hi matt,
    I tried with below code as  you said. But I am getting dump. can you help?
    here is my piece of code.
    FIELD-SYMBOLS: <LS_DATA> type any,
                               <LT_DATA> TYPE table,
                                <L_FIELD> type any.
        ASSIGN <l_buffer_entry>-dataptr->* TO <LS_DATA>.
        ASSIGN <l_buffer_entry>-dataptr->* TO <LT_DATA>.
    LOOP AT <LT_DATA> ASSIGNING <LS_DATA>.
    ASSIGN COMPONENT 'BUKRS' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
    IF <L_FIELD> NOT IN SO_BUKRS.
    DELETE <LT_DATA>.
    ENDIF.
    UNASSIGN <L_FIELD>.
    ASSIGN COMPONENT 'BELNR' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
    IF <L_FIELD> NOT IN SO_BELNR.
    DELETE <LT_DATA>.
    ENDIF.
    UNASSIGN <L_FIELD>.
    ENDLOOP.
    and here is the description of my dump:->>>
    You attempted to access an unassigned field symbol
    (data segment 32772).
    This error may occur for any of the following reasons:
    - You address a typed field symbol before it is set using ASSIGN
    - You address a field symbol that points to a line in an internal table
      that has been deleted
    - You address a field symbol that had previously been reset using
      UNASSIGN, or that pointed to a local field that no longer exists
    - You address a global function interface parameter, even
      though the relevant function module is not active,
      that is it is not in the list of active calls. You can get the list
      of active calls from the this short dump.

Maybe you are looking for

  • Can you export the date and user to Excel that appears into a Comments field in a tracking list?

    Hi everyone, Can you export the date and user to Excel that appears into a Comments field in a tracking list? When i export a tracking list with a Comment field in the Content type, the screen where you enter the data for an item, the Comments field

  • Returning Zero if not exists

    Hi All: I need some help in returning 0 value i have two queries which will display values like this query1 project_name , object_name , count(major) xxxx xxx 2 query2 project_name , object_name , count(minor) in the first query i have xxxx project r

  • Documents or a link  for basics

    Hi Experts, Can any one send a link or document which has the information about the basic deinitions like,Info object,infocube,infosource,datasource,commn structure,extract structure ..etc.. Thanks in advance! James

  • Creating SQL SERVER notification from Oracle Enterprise Manager to Outlook

    Hi, I have a requirement to configure OEM to send an email via outlook when the SQL Server fails over to the standby server. Currently we receive emails if the CPU is high or if the agent is down etc. However, I was wondering if we could send an emai

  • Tablespace vs user login

    Hi, I am a java developer trying to understand Oracle. Here is my simple question: In oracle each login/user is associated with a tablespace (default) after login. My understanding is that this tablespace serves as the schema name for the db access.