Call method "cl_alv_table_create= create_dynamic_table"

Hi SDN Community,
Is it possible to create dynamic tables. I tried it by call method "cl_alv_table_create=>create_dynamic_table", but the "new_table" of output parameters is empty after the call is executed.
Please suggest.
Thank You.
Pankaj.

Hi Pankaj,
Try the code written below and let me know whether it works?
report  z_dynamic_itab_test .
include z_table_fs_top.
include z_table_fs_forms.
initialization.
  perform clear_fields.
start-of-selection.
  perform fetch_data.
end-of-selection.
*&  Include           Z_TABLE_FS_TOP
Type Pools                                                           *
type-pools: slis,
            rsds.
Tables                                                               *
tables :sscrfields,                "Fields on selection screens
        dd03l.                     "Table Fields
Types                                                                *
types: begin of t_dd03l,
        tabname like dd03l-tabname,              "Table Name
        fieldname like dd03l-fieldname,          "Field Name
        keyflag   like dd03l-keyflag,            "Key Flag
        rollname  like dd03l-rollname,           "Roll Name
        position like dd03l-position,            "Position
        ddtext(30),                              "Description
       end of t_dd03l.
types : begin of t_fname,                        "To hold the field names
          fld like dd03l-fieldname,
        end of t_fname.
Internal Tables                                                      *
data : it_dd03l   type table of t_dd03l,       "To hold the field names of dd03l.
       it_flds    type table of rsdsfields,    "To hold the field names
       it_fields  type table of dd03l,         "To hold the field names
       it_cat     type table of lvc_s_fcat,    "To hold Field Catalog
       it_fname   type table of t_fname.
Work areas                                                           *
data: wa_dd03l  like line of it_dd03l,     "Workarea for IT_DD03L
      wa_flds   like line of it_flds,      "Workarea for IT_FLDS
      wa_fields like line of it_fields,    "Workarea for IT_FIELDS
      wa_cat    like line of it_cat ,      "Workarea for IT_CAT
      wa_fname  like line of it_fname.     "Workarea for IT_FNAME
*SELECTION SCREEN WITH BLOCK DEFINITION.
selection-screen begin of block b2 with frame title text-004.
parameters: p_tbname type dd03l-tabname.
select-options: s_field for dd03l-fieldname no intervals.
selection-screen end of block b2.
Variables                                                            *
data : lv_where type string,
       lv_cnt   type i value '1',
       v_records type i.
data : gv_where_cl(100) type c.              "Variable to hold Where clause
data: wa_flname(5) type c.
data: wa_fldcat type lvc_s_fcat.
data: it_fldcat type lvc_t_fcat.
data: it type ref to data.
DECLARATION OF FIELD SYMBOLS :
field-symbols: <fs_table> type table.
field-symbols: <fs_temp> type any,
               <fs_final> type any.
*&  Include           Z_TABLE_FS_FORMS
*&      Form  clear_fields
     To clear all work areas and refresh all internal tables.
form clear_fields .
  clear wa_dd03l.
  clear wa_flds.
  clear wa_fields.
  clear wa_cat.
  clear wa_fname.
  refresh it_dd03l.
  refresh it_flds.
  refresh it_fields.
  refresh it_cat.
  refresh it_fname.
endform.                    " clear_fields
*&      Form  FETCH_DATA
      Fetch data from different tables
form fetch_data .
  describe table s_field lines v_records.
Populate it_flds from s_field, to hold the fields to be Selected.
  if s_field is not initial.
    loop at s_field.
      wa_flname = s_field-low.
      write: s_field-low.
    BUILD FIELD CATALOG FOR ALL FIELDS.
      wa_flds-fieldname = wa_flname.
      append wa_flds to it_flds.
    endloop.
  endif.
Populate the Where clause as a string.
if s_where[] is not initial.
   loop at s_where.
     concatenate lv_where s_where-low into lv_where separated by space.
   endloop.
endif.
Populate it_dd03l, to hold the field names from DD03L.
  select tabname
         fieldname
         keyflag
         rollname
         position
         from dd03l
         into table it_dd03l
         where tabname eq p_tbname
               and fieldname ne 'MANDT'.
  if sy-subrc = 0.
    sort it_dd03l by position.
    delete it_dd03l where fieldname cp '.INCLU*'.          ""CP = Covers Pattern
  endif.
Populate it_fname, with fields which have to be selected (entered in selection).
  loop at it_dd03l into wa_dd03l.
  Read table it_flds.
    read table it_flds into wa_flds with key fieldname = wa_dd03l-fieldname.
    if sy-subrc = 0.
    Move data from it_dd03l to it_fname
      wa_fname-fld = wa_dd03l-fieldname.
      append wa_fname to it_fname.
      clear wa_fname.
    endif.
  endloop.
*TO CHECK IF TABLE EXISTS.
  call function 'SCPR_DB_TABLE_EXIST'
    exporting
      tabname        = p_tbname
    exceptions
      tab_dont_exist = 1
      others         = 2.
  if sy-subrc <> 0.
    if sy-subrc = 1.
    GIVE A POP UP.
      call function 'POPUP_TO_DECIDE_INFO'
        exporting
          textline1    = 'Table Does Not Exist !'
          titel        = 'Invalid Table Name'
          start_column = 25
          start_row    = 6.
    endif.
  endif.
SELECT ALL RECORDS FROM DD03L.
  select *
  into table it_fields
  from dd03l
  where tabname = p_tbname.
  if sy-subrc = 0.
    sort it_fields by position.
    delete it_fields where fieldname cp '.INCLU*'.         "CP = Covers Pattern.
  endif.
Populate IT_CAT with fields which are REQUIRED.
Display upto 150 fields only.
  loop at it_fields into wa_fields to 150.
  Read table it_fname
    read table it_fname into wa_fname with key fld = wa_fields-fieldname.
    if sy-subrc = 0.
    Move data from it_fields
      wa_cat-tabname = p_tbname.
      wa_cat-fieldname = wa_fields-fieldname.
      wa_cat-col_pos = lv_cnt.
      wa_cat-inttype    = wa_fields-inttype.
      wa_cat-datatype = wa_fields-datatype.
      wa_cat-intlen = wa_fields-intlen.
      wa_cat-seltext = wa_fields-fieldname.
      wa_cat-decimals = wa_fields-decimals.
      wa_cat-ref_field = wa_fields-fieldname.
      wa_cat-ref_table = p_tbname.
      append wa_cat to it_cat.
      clear wa_cat.
      lv_cnt = lv_cnt + 1.
    endif.
  endloop.
CREATE A DYNAMIC INTERNAL TABLE.
  call method cl_alv_table_create=>create_dynamic_table
    exporting
      it_fieldcatalog = it_cat
    importing
      ep_table        = it.
ASSIGN IT TO <FS>.
  assign it->* to <fs_table>.
*Select the data from the table given as input and populate
it into the dynamic internal table created based on the where
condition.
  select (it_fname)
         from (p_tbname)
         into table <fs_table>
         where (lv_where).
  if sy-subrc <> 0.
    message 'No data found' type 'I'.
  endif.
*Displaying dynamic internal table .
  loop at <fs_table> assigning <fs_temp>.
   write:/ <fs_temp> quickinfo 'CONTENTS'.
  endloop.
endform.                    " FETCH_DATA
Best Regards,
Deepa Kulkarni

Similar Messages

  • Decimals on CALL METHOD cl_alv_table_create= create_dynamic_table

    Hello experts:
    I have a little problem, I want to create an ALV field with 4 decimales, it's a dinamic table, but when the alv report shows the fields it shows only 2 decimals, here the main code for explaining me better:
    Here the code for create the field with decimals:
    * Netpr
      lv_cols = lv_cols + 1.
      MOVE lv_cols TO wa_it_fldcat-col_pos.
      MOVE 'NETPR'      TO wa_it_fldcat-fieldname.
      MOVE 'Net Price'  TO wa_it_fldcat-scrtext_l.
      MOVE 'Net Price'  TO wa_it_fldcat-scrtext_m.
      MOVE 'Net Pr'     TO wa_it_fldcat-scrtext_s.
      MOVE 'CURR'       TO wa_it_fldcat-datatype.
      MOVE 'P'          TO wa_it_fldcat-inttype.
      MOVE 11           TO wa_it_fldcat-intlen.
      MOVE 4            TO wa_it_fldcat-decimals.
      MOVE ''           TO wa_it_fldcat-ref_field.
      MOVE ''           TO wa_it_fldcat-ref_table.
      APPEND wa_it_fldcat TO t_fldcat.
    After create more fields, here the code for create the dinamic ALV table:
    * 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>.
    After this method, the structure of the work area having the data type of the fields and all the atributes, the decimals of the NETPR fields just have 2 decimals =(
    I hope my explanation it's clear.
    Any help with this issue it's very welcome, thank you very much for your time.
    Miriam

    Hi
    Xiaonan Hu is right: u need to delete the row where u transfer CURR as type:
    * Netpr
      lv_cols = lv_cols + 1.
      MOVE lv_cols TO wa_it_fldcat-col_pos.
      MOVE 'NETPR'      TO wa_it_fldcat-fieldname.
      MOVE 'Net Price'  TO wa_it_fldcat-scrtext_l.
      MOVE 'Net Price'  TO wa_it_fldcat-scrtext_m.
      MOVE 'Net Pr'     TO wa_it_fldcat-scrtext_s.
      *MOVE 'CURR'       TO wa_it_fldcat-datatype.
      MOVE 'P'          TO wa_it_fldcat-inttype.
      MOVE 11           TO wa_it_fldcat-intlen.
      MOVE 4            TO wa_it_fldcat-decimals.
      MOVE ''           TO wa_it_fldcat-ref_field.
      MOVE ''           TO wa_it_fldcat-ref_table.
      APPEND wa_it_fldcat TO t_fldcat.
    If you transfer CURR, the method will defined a type p with 2 decimals by default, so it's useless to indicate the decimals in this case.
    Infact the method calls the fm ALV_TABLE_CREATE, and here the abap code is:
    - for CURR type:
    elseif ls_fieldcat-datatype = 'CURR'.
            concatenate 'DATA:'
                        ls_fieldcat-fieldname
                        'TYPE'
                        ls_fieldcat-inttype
                        'DECIMALS 2.'
                        into lt_source-line separated by space.
    - for P type
    if ls_fieldcat-inttype = 'P' and not ls_fieldcat-decimals is
               initial.
              replace '.' with 'DECIMALS' into lt_source-line.
              concatenate lt_source-line ls_fieldcat-decimals '.' into
                          lt_source-line separated by space.
            endif.
    Max

  • Create dynamic table CALL METHOD cl_alv_table_create= create_dynamic_table

    Hi gurus i have a problem i have created a dinamic internal table but the lenght of the internal table fields is 10 i need longer fields
    here is my code thanks
    data: begin of it_campos OCCURS 0,
                campo1(12) type c,
            END OF it_campos.
    do n times.
           clear nocamptmp.
           add 1 to incont.
           CONDENSE incont NO-GAPS.
           cont = incont.
           CONCATENATE nocamp cont  into nocamptmp.
           wa_campos-campo1 = nocamptmp.
           append wa_campos to it_campos.
        enddo  .
        loop at  it_campos into wa_campos.
          t_fieldcat_wa-col_pos = SY-TABIX.
          t_fieldcat_wa-fieldname = wa_campos-campo1.
          APPEND t_fieldcat_wa TO t_fieldcat.
        endloop  .
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
            it_fieldcatalog           = t_fieldcat
        IMPORTING
            ep_table                  = tabla
        EXCEPTIONS
            GENERATE_SUBPOOL_DIR_FULL = 1
        others                         = 2.
    ASSIGN tabla->* TO <l_table>.
        CREATE DATA ep_line LIKE LINE OF <l_table>.
    all is fine but the fields of  <l_table>  are char(10) and my data is longer than 10 how can i increase the lenght of the table fields
    any idea thanks

    Modify the fieldcatalog accordingly for e.g.,
    LOOP AT it_campos INTO wa_campos.
      t_fieldcat_wa-col_pos = sy-tabix.
      t_fieldcat_wa-fieldname = wa_campos-campo1.
      t_fieldcat_wa-inttype = 'C'. " Character Type
      t_fieldcat_wa-intlen = '50'. "50 character length
      APPEND t_fieldcat_wa TO t_fieldcat.
    ENDLOOP .
    BR,
    Suhas

  • Error in Call Method 'create_dynamic_table'.

    Hi Experts,
    i am working on Dynamic ALV.I have created a Dynamic Fieldcatalog,which is storing the correct field values as per requirement.
    When I debbug the code: I get the following error when I am calling method 'create_dynamic_table'.
    "Unable to interpret "MATERIALS(000010)". Possible 10 MATERIALS(000010)"
    DATA: g_table TYPE REF TO data.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = i_fieldcat
        IMPORTING
          ep_table                  = g_table.
    *    EXCEPTIONS
    *      generate_subpool_dir_full = 1
    *      OTHERS                    = 2.
    Please advice how do I approach this error.Is some change required in  my piece of code?
    Thanks.

    Hi Marcin,
    Thanks for all the help,finally solved the issue.I made a small error while coding the Fieldcatalog:
    now the changed code looks like the following code:
    LOOP AT i_tckh3 INTO w_tckh3.
          LOOP AT i_tckh1 INTO w_tckh1 WHERE elemt = w_tckh3-elemt.
            lcount = lcount + 1.
            WRITE w_tckh1-txele TO w_fieldcat-seltext   LEFT-JUSTIFIED.
            CONCATENATE 'KST' w_tckh3-el_hv INTO w_fieldcat-fieldname.
            TRANSLATE w_fieldcat-fieldname              TO UPPER CASE.
            w_fieldcat-col_pos   =  lcount.
            w_fieldcat-ref_field = 'KST001'.
            w_fieldcat-ref_table = 'KEPH'.
            w_fieldcat-datatype  = 'CURR'.
            APPEND w_fieldcat TO i_fieldcat.
            CLEAR  w_fieldcat.
            CLEAR: w_tckh1.
          ENDLOOP.
          CLEAR:w_tckh3.
        ENDLOOP.
    Emphasis on the COncatenate statement in the loop.Earlier I was passing the TXELE field to fieldname,which was wrong.
    Thanks a Ton!!!!
    I have a small dount in the next step:While assigning the values to the final internal table:
    LOOP AT i_final INTO w_final.
        ASSIGN COMPONENT 'WERKS' OF STRUCTURE <i_value> TO <fs1>.
        <fs1> = w_final-werks.
        ASSIGN COMPONENT 'MATNR' OF STRUCTURE <i_value> to <fs1>.
        <fs1> = w_final-matnr.
         LOOP AT i_keph INTO w_keph WHERE kalnr = w_final-kalnr.
          ASSIGN COMPONENT  'KST001' OF STRUCTURE <i_value> TO <fs1>.
          <fs1> = <FS1> + w_keph-kst001.
        ENDLOOP.
        APPEND <i_value> TO <i_table>.
        CLEAR: <i_value>.
      ENDLOOP.
    Now the LOOP AT I_KEPH: has all the values of the cost fields.I need to assign the appropriate value of KSTXXX to the corresponding Dynamic fieldcatalog:What should the procedure be.I am NOT able to check what values are there in dynamic calatog.
    Hope this point is not too confusing.

  • Cl_alv_table_create= create_dynamic_table in ALV Grid

    Hallo everybody
    i have created a dynamic_table with cl_alv_table_create class. Now i want this dynamic_table integration in my ALV Grid. I try this, but without successfull
    Can anybody help?
    PROGRAM zliefervolu.
    * Definition                                                          *
    TABLES: likp, "Vertriebsbeleg: Lieferung: Kopfdaten
            lips, "Vertriebsbeleg: Lieferung: Positionsdaten
            kna1, "Kundenstamm (allgemeiner Teil)
            marm. "Mengeneinheiten zum Material
    FIELD-SYMBOLS: <fs_data> TYPE REF TO data,
                   <fs_1> TYPE ANY TABLE,
                   <fs_2>,
                   <fs_3>.
    DATA: BEGIN OF i_vbeln OCCURS 1,
          faktor(5) TYPE n,
          END OF i_vbeln.
    DATA: BEGIN OF v_lief OCCURS 1,
          faktor TYPE string,
          END OF v_lief.
    DATA: BEGIN OF lieferschein OCCURS 1,
          vbeln TYPE vbeln,
          END OF lieferschein.
    DATA: ok_code LIKE sy-ucomm, "Bildschirmbilder, Funktionscode, der PAI ausgelöst hat
          v_volurech(10) TYPE n, "Volumenberechnung
          volutot TYPE string,
          v_debit TYPE kunnr,
          v_lifg TYPE vrkme,
          v_datumkl TYPE wadat,
          v_datumgr TYPE wadat,
          v_faktor(5) TYPE n,
          v_faktors TYPE string,
          v_datum TYPE string,
          v_count TYPE i,
          lt_fieldcatalog TYPE lvc_t_fcat,
          ls_fieldcatalog TYPE lvc_s_fcat,
          new_table TYPE REF TO data,
          new_line  TYPE REF TO data,
          lt_data TYPE REF TO data,
          v_datumlow(10) TYPE c,
          v_datumhigh(10) TYPE c,
          v_text TYPE string,
          name_catolog TYPE lvc_t_fcat, "Ändern von Spaltenname
          l_field LIKE LINE OF name_catolog, "Kurzspeicher für Spaltenname
          g_container TYPE scrfname VALUE 'BCALV_GRID_CONTROL',
          grid1 TYPE REF TO cl_gui_alv_grid, "ALV Grid Definition
          creattable TYPE REF TO cl_alv_table_create,
          g_custom_container TYPE REF TO cl_gui_custom_container.
    DATA: i_tabledata TYPE TABLE OF zvolutable.
    SELECT-OPTIONS: s_kunnr FOR likp-kunnr, "Lieferung
                    s_wadat FOR likp-wadat OBLIGATORY, "Geplantes Datum der Warenbewegung
                    s_vbeln FOR likp-vbeln. "Warenempfänger
    * Main Program                                                        *
    START-OF-SELECTION.
      CLEAR: likp.
    * Selektion Vertriebsbeleg: Lieferung: Kopfdaten
      SELECT * FROM likp WHERE vbeln IN s_vbeln
                         AND wadat IN s_wadat
                         AND kunnr IN s_kunnr
                         ORDER BY vbeln.
    *    CLEAR: kna1.
    **   Selektion Kundenstamm (allgemeiner Teil)
    *    SELECT SINGLE * FROM kna1 WHERE kunnr EQ likp-kunnr.
    *    CONCATENATE likp-kunnr ` ` kna1-name1 INTO i_datatable-kunnr.
    *    CLEAR: lips.
    *   Selektion Vertriebsbeleg: Lieferung: Positionsdaten
        SELECT * FROM lips WHERE vbeln EQ likp-vbeln.
          CLEAR: marm.
    *     Selektion Mengeneinheiten zum Material
          SELECT SINGLE * FROM marm WHERE matnr EQ lips-matnr
                                    AND meinh EQ lips-vrkme.
          CLEAR v_volurech.
          v_volurech = lips-lfimg * marm-hoehe.
    *     Volumentotal
          volutot = volutot + v_volurech.
          MOVE lips-umvkz TO i_vbeln-faktor.
          APPEND i_vbeln.
        ENDSELECT.
        MOVE likp-vbeln TO lieferschein-vbeln.
        APPEND lieferschein.
      ENDSELECT.
      CLEAR: i_vbeln, lieferschein.
      SORT i_vbeln BY faktor.
    * Datumsfeld             *
      MOVE s_wadat-low TO v_datumkl.
      v_datumlow = v_datumkl+6.
      WRITE '.' TO v_datumlow+2.
      WRITE v_datumkl+4(2) TO v_datumlow+3.
      WRITE '.' TO v_datumlow+5.
      WRITE v_datumkl(4) TO v_datumlow+6.
      LOOP AT s_wadat WHERE high IS NOT INITIAL.
        MOVE s_wadat-high TO v_datumgr.
      ENDLOOP.
      v_datumhigh = v_datumgr+6.
      WRITE '.' TO v_datumhigh+2.
      WRITE v_datumgr+4(2) TO v_datumhigh+3.
      WRITE '.' TO v_datumhigh+5.
      WRITE v_datumgr(4) TO v_datumhigh+6.
      IF v_datumgr IS NOT INITIAL.
        CONCATENATE v_datumlow '-' v_datumhigh INTO v_datum.
      ELSE.
        MOVE v_datumlow TO v_datum.
      ENDIF.
      CLEAR v_text.
      v_text = 'DATUM'.
      MOVE v_text TO v_lief-faktor.
      APPEND v_lief.
    * Faktorfelder           *
      CLEAR: v_count.
      LOOP AT i_vbeln.
        IF i_vbeln-faktor NE v_faktor.
          MOVE i_vbeln-faktor TO v_faktor.
          PACK i_vbeln-faktor TO v_faktors.
          CONDENSE v_faktors.
          MOVE v_faktors TO v_lief-faktor.
          v_count = v_count + 1.
          APPEND v_lief.
        ENDIF.
      ENDLOOP.
      CLEAR v_text.
      v_text = 'VOLUMEN'.
      MOVE v_text TO v_lief-faktor.
      APPEND v_lief.
      CLEAR: v_lief.
    * Erstellen von Dym. Struktur *
      LOOP AT v_lief.
        ls_fieldcatalog-fieldname = v_lief-faktor.
        APPEND ls_fieldcatalog TO lt_fieldcatalog.
      ENDLOOP.
      ASSIGN lt_data TO <fs_data>.
      IF v_count NE 0.
        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.
    *    CALL METHOD cl_alv_table_create=>table_copy
    *      EXPORTING
    *        it_outtab       = i_tabledata
    *        it_fieldcatalog = lt_fieldcatalog
    *      IMPORTING
    *        ep_table        = <fs_data>.
        IF sy-subrc <> 0.
        ENDIF.
        ASSIGN <fs_data>->* TO <fs_1>.
        CREATE DATA new_line LIKE LINE OF <fs_1>.
        ASSIGN new_line->* TO <fs_2>.
      ELSE.
        CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT_LO'
          EXPORTING
            titel        = text-tit
            textline1    = text-feh
            start_column = 15 "Abstand von Links
            start_row    = 6. "Abstand von Oben
      ENDIF.
      CALL SCREEN 100.
    END-OF-SELECTION.
    *       MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'MAIN100'.
    *** Definition von Feldkatalog
    *  l_field-fieldname = 'DEBITOR'.
    *  l_field-coltext = v_datum4.
    *  APPEND l_field TO name_catolog.
      IF g_custom_container IS INITIAL.
        CREATE OBJECT g_custom_container
               EXPORTING container_name = g_container.
        CREATE OBJECT grid1
               EXPORTING i_parent = g_custom_container.
    *   ALV Methode aufruf für Ausgabe
        CALL METHOD grid1->set_table_for_first_display
    *      EXPORTING
    *        i_structure_name = 'lvc_t_fcat'
          CHANGING
            it_outtab        = <fs_1>
            it_fieldcatalog  = lt_fieldcatalog.
      ENDIF.
    ENDMODULE.                    "PBO OUTPUT
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
    *   to react on oi_custom_events:
      CALL METHOD cl_gui_cfw=>dispatch.
      CASE ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
        WHEN OTHERS.
    *     do nothing
      ENDCASE.
      CLEAR ok_code.
    ENDMODULE.                    "PAI INPUT
    *       FORM EXIT_PROGRAM                                             *
    FORM exit_program.
    *  CALL METHOD G_CUSTOM_CONTAINER->FREE.
    *  CALL METHOD CL_GUI_CFW=>FLUSH.
      LEAVE PROGRAM.
    ENDFORM.                    "EXIT_PROGRAM
    thx & regards paul

    Hi,
    Herewith i am sending the sample report for the dynamic report. Kindly go through it.
    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

  • Duplicate dynamic table in - cl_alv_table_create= create_dynamic_table

    Hi Gurus,
    I have done the following code, but it is not treating <alv_table> and <alv_table_new> as different tables.
    How can I create a duplicate table of <alv_table> in the below context ??
    DATA :   ldtab         TYPE REF TO data,
                  ldtab_NEW      TYPE REF TO data.
    FIELD-SYMBOLS: <alv_table> TYPE table,
                   <alv_table_NEW> TYPE table.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = gt_fcat
        IMPORTING
          ep_table        = ldtab.
      IF sy-subrc = 0.
         ldtab_new = ldtab.
        ASSIGN ldtab->* TO <alv_table>.
        ASSIGN ldtab_new->* TO <alv_table_new>.
      ENDIF.
    Regards,
    Sandip.

    hi,
    Both field symbols i.e. <alv_table> and <alv_table_new> are pointing to same memory area because of the statements
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = gt_fcat
    IMPORTING
    ep_table = ldtab.
    IF sy-subrc = 0.
    ldtab_new = ldtab.                    <----
    do not perform this step
    ASSIGN ldtab->* TO <alv_table>.
    ASSIGN ldtab_new->* TO <alv_table_new>.
    endif.
    instead write -
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = gt_fcat
    IMPORTING
    ep_table = ldtab.
    IF sy-subrc = 0.
      ASSIGN ldtab->* TO <alv_table>.
    endif.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = gt_fcat
    IMPORTING
    ep_table = ldtab_new.
    IF sy-subrc = 0.
      ASSIGN ldtab_new->* TO <alv_table_new>.
    endif.
    try the above mentioned code.
    I hope this will resolve your issue.
    Regards,
    Sambaran Ray

  • Cl_alv_table_create= create_dynamic_table error

    Hi  Gurus,
    Method cl_alv_table_create=>create_dynamic_table
    is giving dump.When i am trying to create internal table from fieldcatalog values.Program"  "not found.
    Please suggest some solution.
    Good answers will be rewarded with points.
    Thanks,
    Twinkle

    Check this program as reference .
    report zrich_0002.
    type-pools: slis.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: alv_fldcat type slis_t_fieldcat_alv,
          it_fldcat type lvc_t_fcat.
    type-pools : abap.
    data : it_details type abap_compdescr_tab,
           wa_details type abap_compdescr.
    data : ref_descr type ref to cl_abap_structdescr.
    data: new_table type ref to data,
          new_line  type ref to data,
          wa_it_fldcat type lvc_s_fcat.
    selection-screen begin of block b1 with frame title text .
    parameters: p_table(30) type c.
    selection-screen end of block b1.
    * Get the structure of the table.
    ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
    it_details[] = ref_descr->components[].
    loop at it_details into wa_details.
      clear wa_it_fldcat.
      wa_it_fldcat-fieldname = wa_details-name .
      wa_it_fldcat-datatype = wa_details-type_kind.
      wa_it_fldcat-inttype = wa_details-type_kind.
      wa_it_fldcat-intlen = wa_details-length.
      wa_it_fldcat-decimals = wa_details-decimals.
      append wa_it_fldcat to it_fldcat .
    endloop.
    * 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>.
    * Select Data from table.
    select * into corresponding fields of table <dyn_table>
               from (p_table).
    * 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.
    Regards,
    Rich Heilman

  • Cl_alv_table_create= create_dynamic_table is dumping

    Dear Xperts,
    cl_alv_table_create=>create_dynamic_table is dumping with message "LOAD_PROGRAM_NOT_FOUND"
    Pls Help:
    Thanks
    Raj

    My Code:
    DATA: T_DATA TYPE REF TO DATA,
          T_FIELDCAT TYPE LVC_T_FCAT,
          T_HEADER  TYPE  SLIS_T_LISTHEADER,
          T_SORT    TYPE  SLIS_T_SORTINFO_ALV.
    Field Symbols
    FIELD-SYMBOLS : <FS_DATA> TYPE STANDARD TABLE," REF TO DATA,
                    <FS_BATCH> TYPE STANDARD TABLE,
                    <FS_FREE> TYPE STANDARD TABLE,
                    <FS_STOR> TYPE STANDARD TABLE,
                    <FS_WA_FREE>,
                    <FS_WA_STOR>,
                    <FS_WA_BATCH>,
                    <FS_VAR>,
                    <FS_VAL> TYPE KONP-KBETR .
    To create the dynamic Internal Table.
    The fields of this table are obtained at runtime
        CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
          EXPORTING
            IT_FIELDCATALOG = T_FIELDCAT
          IMPORTING
            EP_TABLE = T_DATA
          EXCEPTIONS
            GENERATE_SUBPOOL_DIR_FULL = 1
            OTHERS = 2
        IF SY-SUBRC <> 0.
          MESSAGE E074 WITH TEXT-015. " Error Creating int table.
          EXIT.
        ENDIF.
        ASSIGN T_DATA->* TO <FS_BATCH>.

  • Cl_alv_table_create= create_dynamic_table

    Hi,
    When I use this method it is dumping
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fieldcat
        IMPORTING
          ep_table        = <new_table>.
    The error What I am getting is "LOAD_PROGRAM_NOT_FOUND" "CX_SY_PROGRAM_NOT_FOUND" MESSAGE IS  ' Program " " Not Found '.
    Please help us in this issue
    Thanks & Regards,
    Sivaram Kandula

    Dear Rich,
    I am facing very similar problem to the solution you gave here, but I couldn't get through with this, Hope you can certainly help me and I am pasting my code here: pls look into it.
    Awards will be rewarded for sure...
    Material Field properties are set here
      WA_FIELDCAT-FIELDNAME = 'MATNR'.
      WA_FIELDCAT-SELTEXT = TEXT-018.
      WA_FIELDCAT-INTTYPE = 'C'.
      WA_FIELDCAT-INTLEN = 18.
      WA_FIELDCAT-OUTPUTLEN = 18.
      APPEND WA_FIELDCAT TO T_FIELDCAT.
      CLEAR WA_FIELDCAT.
    Material Desc properties are set here
      WA_FIELDCAT-FIELDNAME = 'MAKTX'.
      WA_FIELDCAT-SELTEXT = TEXT-019.
      WA_FIELDCAT-INTTYPE = 'C'.
      WA_FIELDCAT-INTLEN = 35.
      WA_FIELDCAT-OUTPUTLEN = 35.
      WA_FIELDCAT-JUST = 'X'.
      APPEND WA_FIELDCAT TO T_FIELDCAT.
      CLEAR WA_FIELDCAT.
    *added by sarath Dt:03.08.06,Ticket#483.
      IF P_BATCH = 'X' OR P_FREEST = 'X'.
        WA_FIELDCAT-FIELDNAME = 'CAT_DESC'.
        WA_FIELDCAT-SELTEXT = TEXT-041.
        WA_FIELDCAT-INTTYPE = 'C'.
        WA_FIELDCAT-INTLEN = 35.
        WA_FIELDCAT-OUTPUTLEN = 35.
        WA_FIELDCAT-JUST = 'X'.
        APPEND WA_FIELDCAT TO T_FIELDCAT.
        CLEAR WA_FIELDCAT.
      ENDIF.
    *end of additoin by sarath Dt:03.08.06,Ticket#483.
    Plant properties are set here
      WA_FIELDCAT-FIELDNAME = 'WERKS'.
      WA_FIELDCAT-SELTEXT = TEXT-020.
      WA_FIELDCAT-INTTYPE = 'C'.
      WA_FIELDCAT-INTLEN = 4.
      WA_FIELDCAT-OUTPUTLEN = 4.
      APPEND WA_FIELDCAT TO T_FIELDCAT.
      CLEAR WA_FIELDCAT.
    Plant properties are set here
    *added by sarath Dt:03.08.06,Ticket#483.
      IF P_BATCH = 'X' OR P_FREEST = 'X'.
        WA_FIELDCAT-FIELDNAME = 'SPART'.
        WA_FIELDCAT-SELTEXT = TEXT-042.
        WA_FIELDCAT-INTTYPE = 'C'.
        WA_FIELDCAT-INTLEN = 35.
        WA_FIELDCAT-OUTPUTLEN = 35.
        WA_FIELDCAT-JUST = 'X'.
        APPEND WA_FIELDCAT TO T_FIELDCAT.
        CLEAR WA_FIELDCAT.
      ENDIF.
    *end of additoin by sarath Dt:03.08.06,Ticket#483.
      WA_FIELDCAT-FIELDNAME = 'MVGR1'.
      WA_FIELDCAT-SELTEXT = TEXT-026.
      WA_FIELDCAT-INTTYPE = 'C'.
      WA_FIELDCAT-INTLEN = 9.
      WA_FIELDCAT-OUTPUTLEN = 9.
      APPEND WA_FIELDCAT TO T_FIELDCAT.
      CLEAR WA_FIELDCAT.
    Storage Location properties are set here
      IF P_STOR = 'X'.
        WA_FIELDCAT-FIELDNAME = 'LGORT'.
        WA_FIELDCAT-SELTEXT = TEXT-021.
        WA_FIELDCAT-INTTYPE = 'C'.
        WA_FIELDCAT-INTLEN = 4.
        WA_FIELDCAT-OUTPUTLEN = 4.
        APPEND WA_FIELDCAT TO T_FIELDCAT.
        CLEAR WA_FIELDCAT.
    Stock Type properties are set here
        WA_FIELDCAT-FIELDNAME = 'STOCKTYP'.
        WA_FIELDCAT-SELTEXT = TEXT-022.
        WA_FIELDCAT-INTTYPE = 'C'.
        WA_FIELDCAT-INTLEN = 15.
        WA_FIELDCAT-OUTPUTLEN = 15.
        APPEND WA_FIELDCAT TO T_FIELDCAT.
        CLEAR WA_FIELDCAT.
      ENDIF.
    added by gopal for ticket#536
    This is for sorting the numeric fields only
      DATA: IDX TYPE SY-TABIX,
            D_IND TYPE SY-TABIX.
      LOOP AT T_SIZES INTO T1 WHERE SIZE CO TEXT-043.
        IDX = SY-TABIX.
        IF T1-SIZE < 10.
          CONCATENATE '0' T1-SIZE INTO T1-SIZE.
        ELSEIF T1-SIZE = '9.5'.
          CONCATENATE '0' T1-SIZE INTO T1-SIZE.
        ENDIF.
        APPEND T1.
        CLEAR T1.
        DELETE T_SIZES INDEX IDX .
        CLEAR : IDX.
      ENDLOOP.
      CLEAR : IDX.
      LOOP AT T_SIZES INTO T2 WHERE SIZE CO TEXT-044.
        IDX = SY-TABIX.
        APPEND T2.
        CLEAR T2.
        DELETE T_SIZES INDEX IDX .
        CLEAR : IDX.
      ENDLOOP.
      SORT T2 BY SIZE .
      APPEND LINES OF T2[] TO T1[].
      SORT T1 BY SIZE .
      IF T_SIZES[] IS INITIAL.
        T_SIZES[] = T1[].
      ELSE.
        APPEND LINES OF  T_SIZES[] TO T1[].
        DESCRIBE TABLE T1[].
        D_IND = SY-TABIX.
        DELETE T_SIZES[] FROM 1 TO D_IND.
        T_SIZES[] = T1[].
      ENDIF.
    **end of addition by gopal for ticket#536
      LOOP AT T_SIZES INTO WA_SIZES.
        IF WA_SIZES-SIZE CA '.'.
    DEIK905030 for Ticket#691 by harsha on 31052007
         REPLACE '.' WITH '_' INTO WA_SIZES-SIZE .
    **End of changes for  DEIK905030.
        ENDIF.
    Sizes of the material field properties are set here
        WA_FIELDCAT-FIELDNAME = WA_SIZES-SIZE.
        WA_FIELDCAT-SELTEXT = WA_SIZES-SIZE.
        WA_FIELDCAT-INTTYPE = 'I'.
        WA_FIELDCAT-INTLEN = 11.
        WA_FIELDCAT-DO_SUM = 'X'.
        WA_FIELDCAT-OUTPUTLEN = 11.
        WA_FIELDCAT-NO_ZERO = 'X'.
        APPEND WA_FIELDCAT TO T_FIELDCAT.
        CLEAR WA_FIELDCAT.
      ENDLOOP.
    Total Field properties are set here
      WA_FIELDCAT-FIELDNAME = 'TOTAL'.
      WA_FIELDCAT-SELTEXT = TEXT-023.
      WA_FIELDCAT-INTTYPE = 'I'.
      WA_FIELDCAT-INTLEN = 13.
      WA_FIELDCAT-OUTPUTLEN = 13.
      WA_FIELDCAT-DO_SUM = 'X'.
      APPEND WA_FIELDCAT TO T_FIELDCAT.
      CLEAR WA_FIELDCAT.
    maximum Retail Price field properties are set here
      WA_FIELDCAT-FIELDNAME = 'MRPRT'.
      WA_FIELDCAT-SELTEXT = TEXT-028.
      WA_FIELDCAT-INTTYPE = 'C'.
      WA_FIELDCAT-DECIMALS = 2.
      WA_FIELDCAT-INTLEN = 13.
    WA_FIELDCAT-OUTPUTLEN = 13.
      APPEND WA_FIELDCAT TO T_FIELDCAT.
      CLEAR WA_FIELDCAT.
    maximum Retail Price field properties are set here
      WA_FIELDCAT-FIELDNAME = 'MRP'.
      WA_FIELDCAT-SELTEXT = TEXT-024.
      WA_FIELDCAT-DO_SUM = 'X'.
      WA_FIELDCAT-INTTYPE = 'C'.
      WA_FIELDCAT-DECIMALS = 2.
      WA_FIELDCAT-INTLEN = 13.
    WA_FIELDCAT-OUTPUTLEN = 13.
      APPEND WA_FIELDCAT TO T_FIELDCAT.
      CLEAR WA_FIELDCAT.
    Moving Average Value properties are set here
      WA_FIELDCAT-FIELDNAME = 'MAV'.
      WA_FIELDCAT-SELTEXT = TEXT-025.
      WA_FIELDCAT-DO_SUM = 'X'.
      WA_FIELDCAT-INTTYPE = 'C'.
      WA_FIELDCAT-DECIMALS = 2.
      WA_FIELDCAT-INTLEN = 13.
    WA_FIELDCAT-OUTPUTLEN = 13.
      APPEND WA_FIELDCAT TO T_FIELDCAT.
      CLEAR WA_FIELDCAT.
    To create the dynamic Internal Table.
    The fields of this table are obtained at runtime
        CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
          EXPORTING
            IT_FIELDCATALOG = T_FIELDCAT
          IMPORTING
            EP_TABLE = T_DATA
          EXCEPTIONS
            GENERATE_SUBPOOL_DIR_FULL = 1
            OTHERS = 2
        IF SY-SUBRC <> 0.
          MESSAGE E074 WITH TEXT-015. " Error Creating int table.
          EXIT.
        ENDIF.
        ASSIGN T_DATA->* TO <FS_BATCH>.
        CREATE DATA WA_NEWTAB LIKE LINE OF <FS_BATCH>.

  • Dump  after 36 times in CL_ALV_TABLE_CREATE= CREATE_DYNAMIC_TABLE.

    Hi friends,
    I have a problem while creating dynamic table by using
    CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE.
    this method is only executing for 36 times, i saw some threads which were on similar topic but none was answered fully.
    i have to execute this method more times not exactly like 36 times it will not be senseful in my application if i execute it only 36 times.
    Some one suggest me that i'll have  to use was 6.0 but it's a limitation for me that i have to use 4.7 so pls suggest me according to keep in mind 4.7 n in my application none one isstatic all things in my application is dybanic.
    how to solve this problem?
    I will be thankful for your replies,
    regards,

    hi anuj
    try this example may be it wil help you.
    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.      *********Creates a dyanamic internal table*********
      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-inttype = 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.
       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.
    one more
    REPORT ZCLUST1 .
    Example: how to create a dynamic internal table
    The dynamic internal table stucture
    DATA: BEGIN OF STRUCT OCCURS 10,
        FILDNAME(8) TYPE C,
        ABPTYPE TYPE C,
        LENGTH TYPE I,
    END OF STRUCT.
    The dynamic program source table
    DATA: BEGIN OF INCTABL OCCURS 10,
        LINE(72),
    END OF INCTABL.
    DATA: LNG TYPE I, TYPESRTING(6).
    Sample dynamic internal table stucture
    STRUCT-FILDNAME = 'field1'. STRUCT-ABPTYPE = 'c'. STRUCT-LENGTH = '6'.
    APPEND STRUCT. CLEAR STRUCT.
    STRUCT-FILDNAME = 'field2'. STRUCT-ABPTYPE = 'd'.
    APPEND STRUCT. CLEAR STRUCT.
    STRUCT-FILDNAME = 'field3'. STRUCT-ABPTYPE = 'i'.
    APPEND STRUCT. CLEAR STRUCT.
    Create the dynamic internal table definition in the dyn. program
    INCTABL-LINE = 'program zdynpro.'. APPEND INCTABL.
    INCTABL-LINE = 'data: begin of dyntab occurs 10,'. APPEND INCTABL.
    LOOP AT STRUCT.
      INCTABL-LINE = STRUCT-FILDNAME.
      LNG = STRLEN( STRUCT-FILDNAME ).
      IF NOT STRUCT-LENGTH IS INITIAL .
          TYPESRTING(1) = '('.
          TYPESRTING+1 = STRUCT-LENGTH.
          TYPESRTING+5 = ')'.
          CONDENSE TYPESRTING NO-GAPS.
          INCTABL-LINE+LNG = TYPESRTING.
      ENDIF.
      INCTABL-LINE+15 = 'type '.
      INCTABL-LINE+21 = STRUCT-ABPTYPE.
      INCTABL-LINE+22 = ','.
      APPEND INCTABL.
    ENDLOOP.
    INCTABL-LINE = 'end of dyntab. '.
    APPEND INCTABL.
    Create the code processes the dynamic internal table
    INCTABL-LINE = ' '. APPEND INCTABL.
    INCTABL-LINE = 'dyntab-field1 = ''aaaaaa''.'. APPEND INCTABL.
    INCTABL-LINE = 'dyntab-field1 = ''19970814''.'. APPEND INCTABL.
    INCTABL-LINE = 'dyntab-field1 = 1.'. APPEND INCTABL.
    INCTABL-LINE = 'append dyntab.'. APPEND INCTABL.
    INCTABL-LINE = ' '. APPEND INCTABL.
    INCTABL-LINE = 'loop at dyntab.'. APPEND INCTABL.
    INCTABL-LINE = 'write: / dyntab.'. APPEND INCTABL.
    INCTABL-LINE = 'endloop.'. APPEND INCTABL.
    Create and run the dynamic program
    INSERT REPORT 'zdynpro'(001) FROM INCTABL.
    SUBMIT ZDYNPRO.
    or Just try out this simpler dynamic internal tables
    DATA: itab TYPE STANDARD TABLE OF spfli,
                  wa LIKE LINE OF itab.
    DATA: line(72) TYPE c,
                list LIKE TABLE OF line(72).
    START-OF-SELECTION.
    *line = ' CITYFROM CITYTO '.
      line = ' AIRPTO '.
    APPEND line TO list.
    SELECT DISTINCT (list)
           INTO CORRESPONDING FIELDS OF TABLE itab
                FROM spfli.
    IF sy-subrc EQ 0.
      LOOP AT itab INTO wa.
        WRITE: / wa-cityfrom, wa-cityto.
           WRITE :/ wa-airpto.
      ENDLOOP.
    ENDIF.
    thanks & regards
    pardeep kharb
    Edited by: pardeep kumar on Jul 29, 2008 5:18 PM

  • Program with 2 dynamic i_tabs (cl_alv_table_create= create_dynamic_table)

    Dear Expers
    I created a ABAP with dynamic internal table using cl_alv_table_create=>create_dynamic_table more or less according to this example here:
    cl_alv_table_create=>create_dynamic_table error
    Now I need a second dynamic internal table in the same program. So in a first try I just process the same code a second time (copy+paste) with new variables and new fieldsymbols. But when the program runs and the method is called a second time there is this error: "LT_GENTAB-xyz has laready been declared 7 xyz".
    I believe I must free/initialize/delete/undeclare LT_GENTAB before calling the method a second time. Can anybody tell me how to do that? Or is there any other advice on how to create 2 internal tables dynamically in the same program (if possible using the same approach)?
    Many thanks

    Hi,
    Here is the sample code from the link in your message :
    Filling a table for field declarations :
    loop at it_details into wa_details.
      clear wa_it_fldcat.
      wa_it_fldcat-fieldname = wa_details-name .
      wa_it_fldcat-datatype = wa_details-type_kind.
      wa_it_fldcat-inttype = wa_details-type_kind.
      wa_it_fldcat-intlen = wa_details-length.
      wa_it_fldcat-decimals = wa_details-decimals.
      append wa_it_fldcat to it_fldcat .
    endloop.
    Call the method for dynamic creation :
    call method cl_alv_table_create=>create_dynamic_table
                 exporting
                    it_fieldcatalog = it_fldcat
                 importing
                    ep_table        = new_table
    I meant you didn't refresh table it_fldcat as you fields declaration table.
    Did u refresh this table before your second copy code?

  • Field names for cl_alv_table_create= create_dynamic_table

    Morning All
    My client is currently implementing SAP QM at one of the labs and I have come across a situation where the fieldnames required for a dynamic table creation can potentially contain spaces and special characters.  So far I have urged them to remove all such characters as the call to the cl_alv_table_create=>create_dynamic_table method will dump if they are present.
    My question therefore is, is there a definitive list of characters that cannot be used as part of a fieldname?  I intend to use such a list to then search and replace the special characters to enable me to match fieldnames.
    For those of you that know QM, we cannot use internally assigned numbers for master characteristics (client decision) and special characters are frequently used as names in the lab.  My client sees it as a limitation to remove the spaces and special characters from the names but unfortunately it causes problems for me if they don't.
    I need to match the names to determine results for a report so substition seems to be the way forward - unless some else has another suggestion?
    Thanks in advance
    Ian

    There is a form called SAACHECK in module pool RDDU0001 that the data dictionary program uses to check the validity of field names.  You should probably have a look at the logic.
    But why use the Master characteristics as the field name anyway?  Why not instead create a cross reference in an internal table and generate a simple sequence for each unique master characteristic.  That way your field names are just the sequence number, but you can still match up your data with a binary read on the cross reference internal table.

  • Issue in  using CL_ALV_TABLE_CREATE= CREATE_DYNAMIC_TABLE

    Hi,
    I am using  CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE to create dynamic internal table. I am displaying a tree in the output, based on the value selected in the tree, dynamic internal table is generated. If I continuously select the tree value for more than 36 times. This method is giving me a dump.
    Kindly help me in resolving this issue.
    Thanks in advance.
    Regards.

    once you build the field catalog use the following code to create the itab. this doesnt have the limitation of 36
    data: struct_type type ref to cl_abap_structdescr,
    tab_type type ref to cl_abap_tabledescr ,
          comp_tab type cl_abap_structdescr=>component_table,
          comp like line of comp_tab,
          dref type ref to data ,
          dref1 type ref to data ,
          op_len type i .    
    clear: comp , comp_tab ,is_fieldcat .
          refresh comp_tab .
          loop at it_fieldcat into is_fieldcat .
            clear op_len .
            op_len = is_fieldcat-outputlen .
            comp-name = is_fieldcat-fieldname.
            comp-type = cl_abap_elemdescr=>get_c( op_len ).
            append comp to comp_tab.
            clear : is_fieldcat , comp .
          endloop .
          clear struct_type .
    call method cl_abap_structdescr=>create
      exporting
        p_components = comp_tab
        p_strict     = cl_abap_structdescr=>false
      receiving
        p_result     =  struct_type .
    *      struct_type = cl_abap_structdescr=>create( comp_tab ).
          clear tab_type .
          call method cl_abap_tabledescr=>create
            exporting
              p_line_type  = struct_type
              p_table_kind = cl_abap_tabledescr=>tablekind_std
    *    P_UNIQUE     = ABAP_FALSE
    *    P_KEY        =
    *    P_KEY_KIND   = KEYDEFKIND_DEFAULT
            receiving
              p_result     = tab_type .
          create data dref1 type handle tab_type.

  • Table Type in cl_alv_table_create= create_dynamic_table

    Hi guys,
    The method create_dynamic_table from  cl_alv_table_create has as exporting parameter a fielcatalog table. I want to insert a table type in this table, basically the field INTTYPE from LVC_S_FCAT can do that if u put the value 'h' in it. But I notice, that in method implementations all the cases are considered:
    C
    Character String
    N
    Character String with Digits Only
    D
    Date (Date: YYYYMMDD)
    T
    Time (Time: HHMMSS)
    X
    Byte Sequence (heXadecimal)
    I
    Integer number (4-byte integer with sign)
    b
    1-byte integer, integer number <= 254
    s
    2-byte integer, only for length field before LCHR or LRAW
    P
    Packed number
    F
    Floating point number to accuracy of 8 bytes
    and other, but not 'h'.
    Does anybody knows how create a dynamic table with a table type inside ? The table type has the structure from data dictionary  lvc_t_scol.
    Ionut.

    cl_alv_table_create=>create_dynamic_table( ) is no longer recommended to build dynamic tables.
    RTTC classes are very intuitive and quite easy to maintain.
    DATA:
          gt_struct_fields TYPE cl_abap_structdescr=>component_table,
          gwa_struct_field TYPE cl_abap_structdescr=>component.
    DATA:
          goref_table TYPE REF TO cl_abap_tabledescr,
          gdref_table TYPE REF TO data.
    FIELD-SYMBOLS <gt_dynamic> TYPE STANDARD TABLE.
    TRY.
    *   f1 TYPE c LENGTH 10
        gwa_struct_field-name = `F1`.
        gwa_struct_field-type = cl_abap_elemdescr=>get_c( 10 ).
        APPEND gwa_struct_field TO gt_struct_fields.
        CLEAR gwa_struct_field.
    *   f2 TYPE bukrs
        gwa_struct_field-name = `F2`.
        gwa_struct_field-type ?= cl_abap_typedescr=>describe_by_name( `BUKRS` ).
        APPEND gwa_struct_field TO gt_struct_fields.
        CLEAR gwa_struct_field.
    *   f3 TYPE flighttab
        gwa_struct_field-name = `F3`.
        gwa_struct_field-type ?= cl_abap_typedescr=>describe_by_name( `FLIGHTTAB` ).
        APPEND gwa_struct_field TO gt_struct_fields.
        CLEAR gwa_struct_field.
    *   Use the structure object to build the table
        goref_table = cl_abap_tabledescr=>get(
                      cl_abap_structdescr=>get( gt_struct_fields )
        CREATE DATA gdref_table TYPE HANDLE goref_table.
        ASSIGN gdref_table->* TO <gt_dynamic>.
      CATCH ##no_handler
        cx_sy_struct_creation
        cx_parameter_invalid_range
        cx_sy_table_creation.
    ENDTRY.
    BR,
    Suhas

  • Error calling methods CL_GUI_FRONTEND_SERVICES

    Hi all,
    I have a requirement in BAPI (integrating solman to portal) to download file from app. server to local directory. I used the below FM to get temp directory of presntation server.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_TEMP_DIRECTORY
       CHANGING
         TEMP_DIR             =  LV_TEMP_DIR
       EXCEPTIONS
         CNTL_ERROR           = 1
         ERROR_NO_GUI         = 2
         NOT_SUPPORTED_BY_GUI = 3
         others               = 4.
       CALL METHOD cl_gui_cfw=>flush.
    It works fine in R3, but when i called it from portal it shows Access not possible using 'NULL' object reference with a short dump .
    st22 shows
    Error in ABAP application program.
    The current ABAP program "CL_GUI_FRONTEND_SERVICES======CP" had to be
    terminated because one of the
    statements could not be executed.
    This is probably due to an error in the ABAP program.
    An exception occurred. This exception is dealt with in more detail belo
    . The exception, which is assigned to the class 'CX_SY_REF_IS_INITIAL',
    neither
    caught nor passed along using a RAISING clause, in the procedure
    "GET_TEMP_DIRECTORY" "(METHOD)"
    Since the caller of the procedure could not have expected this exceptio
    to occur, the running program was terminated.
    The reason for the exception is:
    Attempt to access a component using 'NULL' object reference (points
    to nothing).
    An object reference must point to an object (an instance of a class)
    before you can use it to access components (variable:
    "CL_GUI_FRONTEND_SERVICES=>HANDLE").
    Either the reference has not yet been set, or it has been reset to
    'NULL' by a CLEAR statement.
    When i put external break point and the dump comes during execution of CALL METHOD cl_gui_cfw=>flush.
    Is it not possible to use CL_GUI_FRONTEND_SERVICES in RFC ??.
    thanks and regards
    Jijo

    Hi,
    the dump is because you cannot use that function from a BSP application, which runs in internet or intranet. The procedure in this case is different:
    DATA: flights  TYPE flighttab,
            flight   LIKE LINE OF flights,
            appl     TYPE string,
            filetype TYPE string,
            output   TYPE string,
            output2  TYPE xstring,
            response     TYPE REF TO if_http_response,
            l_len        TYPE i,
            seatsmax     TYPE string,
            seatsocc     TYPE string.
      appl = 'application/msexcel'.
      filetype = 'attachment;filename=mi archivo.xls'.
      SELECT * FROM sflight
         INTO TABLE flights
         UP TO 20 ROWS.
      LOOP AT flights INTO flight.
        seatsmax = flight-seatsmax. CONDENSE seatsmax.
        seatsocc = flight-seatsocc. CONDENSE seatsocc.
        CONCATENATE output
        flight-carrid cl_abap_char_utilities=>horizontal_tab
        flight-connid cl_abap_char_utilities=>horizontal_tab
        flight-fldate cl_abap_char_utilities=>horizontal_tab
        flight-planetype cl_abap_char_utilities=>horizontal_tab
        seatsmax cl_abap_char_utilities=>horizontal_tab
        seatsocc cl_abap_char_utilities=>horizontal_tab
        cl_abap_char_utilities=>cr_lf
        INTO output.
      ENDLOOP.
      response = runtime->server->response.
      response->delete_header_field( name = if_http_header_fields=>cache_control ).
      response->delete_header_field( name = if_http_header_fields=>expires ).
      response->delete_header_field( name = if_http_header_fields=>pragma ).
      response->set_header_field( name = if_http_header_fields=>content_type
                                  value = appl ).
      response->set_header_field( name = 'content-disposition'
                                  value = filetype ).
      CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          text     = output
          mimetype = 'text/unicode; charset=utf-16le'
        IMPORTING
          buffer   = output2.
      CONCATENATE cl_abap_char_utilities=>byte_order_mark_little
                  output2 INTO output2 IN BYTE MODE.
      l_len = XSTRLEN( output2 ).
      response->set_data( data = output2
                          length = l_len ).
      navigation->response_complete( ).
    This is the code for downloading an Excel file.

Maybe you are looking for

  • OTA-HTTP-SEND-1005 Error while sending to destination B2B

    Hi, While sending ebxml message to destination B2B, we are getting error as Message Transmission Transport Exception Transport Error Code is OTA-HTTP-SEND-1005 StackTrace oracle.tip.transport.TransportException: [IPT_HttpSendConnectionRefused] HTTP c

  • Images removed from Albums

    Browsing through some old projects, I came accross one in which 12 out of 13 albums are mysteriously empty. The masters are still there in the project but they have been removed from the albums into which they were imported. Is this something that th

  • To use this tool you must first connect to server.

    Hi all: I am new to Oracle. After installing Oracle 10g I tried to run it but I had Directory Server Connection window popup. It said "To use this tool you must first connect to server. Click on the OK button to select a server". I did not see any se

  • Mapping handling unit IDs to material numbers

    Dear Gurus, I want to map handling unit IDs to material numbers (MATNR from /SAPAPO/MATKEY). How can I do this? Which tables do I need to join with /SCWM/ORDIM_C? I found attribute MATID in table /SCWM/ORDIM_C which contains 32 digits and is a hex co

  • Is B.Tech in distance learning has value in SAP?

    Please provide me suggestion asap. Please help me can I go head and do B.Tech in distance learning? Thanks Hello Sir, I am Venkatesh, completed my B.Sc CS in Bangalore university in 2005 but i have 2 back logs in final year but after my completion th