Creation of internal table dynamically based on the Date Range entered

Hi SAPgurus,
I have been facing one issue i.e creation of internal table dynamically based on the date range entered in the selection screen. For example the date range I am giving as 06/2006 to 08/2006, it should display the Fieldcatelog dynamically, this part i have completed but the only issue I am facing is to populate the sales data into that fields.
Right now my program is displaying the ALV like this.
Ex:
<b>CSR    District   06/2006  07/2006  08/2006  totals</b>      
Shiva      New York                             10.00
Shiva      new york                             30.00
Shiva      new york                             40.00
but it should display like this
<b>CSR    District 06/2006 07/2006 08/2006 totals</b>
Shiva  New York  10.00   30.00 40.00
80.00                 
Please help me in this scenario, how to acheive like this..
Thanks & Regards,
Sivaram Kandula

Hi Sivaram,
             I also got the same requirement . i saw rich and your code whatever you have uploaded.i have created dynamic internal table but i am facing the issue to populating the data to my dynamic internal table.
Sivaram, can you please explain your code after this.
*<dyn_table>
*tab_item.
  LOOP AT tab_item.
    ASSIGN COMPONENT 1 OF STRUCTURE <dyn_wa> TO <dyn_table>.
    ASSIGN COMPONENT 2 OF STRUCTURE <dyn_wa> TO <dyn_table>.
*    <dyn_wa> = tab_item-bztxt.
*    <dyn_wa> = tab_item-total.
*    APPEND <dyn_wa> TO <dyn_table>.
**    <dyn_wa> = tab_item-total.
**    ASSIGN tab_item-bezei  TO <dyn_wa>.
*  APPEND <dyn_table>.
  ENDLOOP.
how you are puting the loop at tab_item. but tab_item is already commented.
can you send me the code after that.
i am sending some part of my code.
CALL METHOD cl_alv_table_create=>create_dynamic_table
   EXPORTING
     it_fieldcatalog = gt_fCAT1
   IMPORTING
     ep_table        = new_table.
ASSIGN new_table->* TO <dyn_table>.
   create data new_line like line of <dyn_table>.
   assign new_line->* to <dyn_wa>.
select vbeln
        fkart
        vkorg
        vtweg
        fkdat
        spart
        fksto
        from vbrk
        client specified
        into table gt_vbrk
        where mandt = sy-mandt
        and fkart in ('ZF5','ZFR')
        and vkorg = '1100'
        and vtweg = '20'
        and fkdat in s_fkdat
        and spart = '06'
        and fksto = ' '.
   if gt_vbrk[] is not initial.
  select  vbeln
          fkimg
          prsdt
          netwr
          matnr
          arktx
          werks
          mwsbp
          from vbrp
          client specified
          into table gt_vbrp
          for all entries in gt_vbrk
          where vbeln = gt_vbrk-vbeln
          and werks in s_werks
          and matnr in s_matnr.
  endif.
select mnr ltx spras from t247
into table it_t247
where spras = 'E'.
data: lv_month1 type vbrp-prsdt,
       name1(3) type c,
       s_month type string,
        s_month1 type string,
         s_month2 type string.
*      lv_netwr1 type vbrp-netwr,
*          lv_mwsbp1 type vbrp-mwsbp.
      loop at gt_vbrp into gs_vbrp.
        gs_final2-matnr = gs_vbrp-matnr.
        gs_final2-arktx = gs_vbrp-arktx.
        gs_final2-fkimg = gs_vbrp-fkimg.
       lv_month1 = gs_vbrp-prsdt.
        read table it_t247 into wa_t247 with key mnr = lv_month1+4(2).
        if sy-subrc eq 0.
        name1 =  wa_t247-ltx.
        endif.
         concatenate  name1
                   lv_month1(4) into s_month SEPARATED BY '_' .
         CONCATENATE S_MONTH 'QTY' INTO S_MONTH1 SEPARATED BY ''.
          CONCATENATE S_MONTH 'VALUE' INTO S_MONTH2 SEPARATED BY ''.
         gs_final2-month = s_month.
          lv_netwr1 = gs_vbrp-netwr.
        lv_mwsbp1 = gs_vbrp-mwsbp.
        gs_final2-MONTH_QTY = S_MONTH1.
        GS_FINAL2-MONTH_VAL = S_MONTH2.
        gs_final2-value = lv_netwr1 + lv_mwsbp1.
       append gs_final2 to gt_final2.
       clear: gs_final2. "lv_name2.
       endloop.
       if gt_final2[] is not initial.
         sort gt_final2 by matnr month ascending .
         loop at gt_final2 into gs_final2.
        gs_final2_01 = gs_final2.
     collect gs_final2_01 into gt_final2_01.
    endloop.
       endif.
   ENDIF..
Regards
Ankur

Similar Messages

  • How to create internal table dynamically based on a table entry

    hi Experts,
      I have table yprod_cat. It has product categories.
      In my ABAP program I need to create internal table dynamically based on the number of entries in the table.
      For example:
      If the table has 3 entries for product category
      1. Board
      2. Micro
      3. Syst
    Then create three (3) internal tables.
    i_board
    i_micro
    i_syst
    How can we do this? Any sample code will be very usefull
    Thanks & Regards
    Gopal
    Moderator Message: No sample codes can be given. Please search for them or work it!
    Edited by: kishan P on Jan 19, 2011 4:22 PM

    Our APEX version is 4.2We are using below SQL query to display radio groups dynamically..
    SELECT APEX_ITEM.RADIOGROUP (1,deptno,'20',dname) dt
    FROM dept
    ORDER BY 1;
    Created a form using SQL type and given abouve SQL query as source.. But when we run the page, there were no radio groups displayed in the page..
    Below is the output of the query..
    <input type="radio" name="f01" value="10" />ACCOUNTING
    <input type="radio" name="f01" value="20" checked="checked" />RESEARCH
    <input type="radio" name="f01" value="30" />SALES
    <input type="radio" name="f01" value="40" />OPERATIONS
    >
    If Tabular Form:
    Edit Region > Report Attributes > Edit Column > Change the Column type to "Standard Report Column"
    If normal Page Item:
    Edit Page Item > Security > Escape special characters=No.
    Pl read the help on that page item to understand the security risk associated with =NO.
    Cheers,
    Edited by: Prabodh on Dec 3, 2012 5:59 PM

  • Query output based on the date range ...

    Hi All,
    I have an issue related to the jump query, main query based on the time frame. For Example if he selects Sold_To : 6895 for the Calday 10/01/2007 – 01/31/2008 and when jumps to jump query , the jump query should display the data based on the input given in the main query. That is it should show the data individually for four months.
    Expecting the reply from your side...
    Thanks in advance…
    Regards,
    Sruthi

    Sruthi,
    Make sure that u have those 3 fields in 2nd Query and CALDAY with Variable.
    Create settings in RSBBS.
    Click on ASSIGNMENT DETAILS tab
    CALDAY  >  Type = Variable  > Selection Type = Selection/Single value/Multiple single values ( same like ur first query )
    All other fields ( 3 na ) > Type = Generic
    Click on Continue / Save.
    If you need more info...if possible come to yahoo chat my ID is [email protected]....and am online now.
    Regards,
    Ramkumar.

  • How to create New columns for the Internal Table Dynamically?

    HI Guys,
                          In my logic i have to create new columns depending on the logic which i am executing.
    My requirement is .I have to display o/p like this
    Material || Year || Period  ||  Mix ratio || Vendor ||Mix Ratio || Vendor || Mix Ratio Vendor || Mix ratio || Vendor || Mix ratio.............................from table's CKMLMV003 and CKMLMV001.Her i have to display the o/p in the above format and i have to display Vendor and Mix Ratio for 5 columns irrespective of data .If i have more than 5 columns for any record then i have to create a New columns dynamically for Vendor and Mix ratio.If anybody want my code i can Submit But plz tell with example how to do?
                    <b>The O/P must be finally shown in ALV Grid</b>
    Thanks,
    Gopi

    You must create the entire internal table dynamically, you can not add columns to a statically define internal table.  Here is an example of creating a dynamic internal table.
    Creation of internal table dynamically based on the Date Range entered
    Regards,
    Rich Heilman

  • Create internal table dynamically for IDoc fields

    Hi,
    I need to create an internal table dynamically based on the segment field names that are returned in the table pt_fields when calling function 'IDOCTYPE_READ_COMPLETE'.  I see many posts suggesting classes such as 'cl_wrf_dynamic_table=>create_dynamic_table', but it does not work for me.  The problem I have with the classes is that it doesn't allow you to have the same column name more than once.  But in the scenario I am testing, I have some column names that are duplicated, and I cannot remove the duplicates.  Are there any functions or classes that I can use to create a dynamic internal table that will not check if a column name is used twice?
    Thanks,
    Carrie

    Hello Carrie
    My first thought was that RTTI might be able to do this but it does not (see the dump below). And it is obvious that RTTI behave likes this.
    Error analysis
        An exception occurred which is explained in detail below.
        The exception, which is assigned to class 'CX_SY_STRUCT_COMP_NAME', was not
         caught and
        therefore caused a runtime error.
        The reason for the exception is:
        Multiple Specification of the Name 'CUSTOMER' as a Component Name (Component 7)
    Just think about any way  to define statically an itab or structure containing duplicated field names. You will always get a syntax error irrespective of whether you use a DDIC structure, a TYPE or a DATA variable.
    If there is no way to define such a structure statically why should it be different when defining dynamically?
    Regards
      Uwe

  • How to increase the length of internal table dynamically

    How to increase the length of internal table dynamically depending on the number of fields fetched into the internal table ?
    The requirement code :
    types: begin of t_data,
             form          like zscr_data_hdr-form,
             werks         like zscr_data_hdr-werks,
             matnr         like zscr_data_hdr-matnr,
             verid         like zscr_data_hdr-verid,
             lot           like zscr_data_hdr-lot,
             lot_qty       like zscr_data_hdr-lot_qty,
             udate         like zscr_data_hdr-udate,
             utime         like zscr_data_hdr-utime,
             zuser         like zscr_data_hdr-zuser,
             processed     like zscr_data_hdr-processed,
             defect        like zscr_defect_data-defect,
             vornr         like zscr_route_data-vornr,
             fld1          like zscr_defect_data-defect_val,
             fld2          like zscr_defect_data-defect_val,
             fld3          like zscr_defect_data-defect_val,
             fld4          like zscr_defect_data-defect_val,
             fld5          like zscr_defect_data-defect_val,
             fld6          like zscr_defect_data-defect_val,
             fld7          like zscr_defect_data-defect_val,
             fld8          like zscr_defect_data-defect_val,
             fld9          like zscr_defect_data-defect_val,
             fld10         like zscr_defect_data-defect_val,
             fld11         like zscr_defect_data-defect_val,
             fld12         like zscr_defect_data-defect_val,
             fld13         like zscr_defect_data-defect_val,
             fld14         like zscr_defect_data-defect_val,
             fld15         like zscr_defect_data-defect_val,
             fld16         like zscr_defect_data-defect_val,
             fld17         like zscr_defect_data-defect_val,
             fld18         like zscr_defect_data-defect_val,
             fld19         like zscr_defect_data-defect_val,
             fld20         like zscr_defect_data-defect_val,
             fld21         like zscr_defect_data-defect_val,
             fld22         like zscr_defect_data-defect_val,
             fld23         like zscr_defect_data-defect_val,
             fld24         like zscr_defect_data-defect_val,
             fld25         like zscr_defect_data-defect_val,
             fld26         like zscr_defect_data-defect_val,
             fld27         like zscr_defect_data-defect_val,
             fld28         like zscr_defect_data-defect_val,
             fld29         like zscr_defect_data-defect_val,
             fld30         like zscr_defect_data-defect_val,
             fld31         like zscr_defect_data-defect_val,
             fld32         like zscr_defect_data-defect_val,
             fld33         like zscr_defect_data-defect_val,
             fld34         like zscr_defect_data-defect_val,
             fld35         like zscr_defect_data-defect_val,
             fld36         like zscr_defect_data-defect_val,
             fld37         like zscr_defect_data-defect_val,
             fld38         like zscr_defect_data-defect_val,
             fld39         like zscr_defect_data-defect_val,
             fld40         like zscr_defect_data-defect_val,
             fld41         like zscr_defect_data-defect_val,
             fld42         like zscr_defect_data-defect_val,
             fld43         like zscr_defect_data-defect_val,
             fld44         like zscr_defect_data-defect_val,
             fld45         like zscr_defect_data-defect_val,
             fld46         like zscr_defect_data-defect_val,
             fld47         like zscr_defect_data-defect_val,
             fld48         like zscr_defect_data-defect_val,
             fld49         like zscr_defect_data-defect_val,
             fld50         like zscr_defect_data-defect_val,
             fld51         like zscr_defect_data-defect_val,
             fld52         like zscr_defect_data-defect_val,
             fld53         like zscr_defect_data-defect_val,
             fld54         like zscr_defect_data-defect_val,
             fld55         like zscr_defect_data-defect_val,
             fld56         like zscr_defect_data-defect_val,
             fld57         like zscr_defect_data-defect_val,
             fld58         like zscr_defect_data-defect_val,
             fld59         like zscr_defect_data-defect_val,
             fld60         like zscr_defect_data-defect_val,
             fld61         like zscr_defect_data-defect_val,
             fld62         like zscr_defect_data-defect_val,
             fld63         like zscr_defect_data-defect_val,
             fld64         like zscr_defect_data-defect_val,
             fld65         like zscr_defect_data-defect_val,
             fld66         like zscr_defect_data-defect_val,
             fld67         like zscr_defect_data-defect_val,
             fld68         like zscr_defect_data-defect_val,
             fld69         like zscr_defect_data-defect_val,
             fld70         like zscr_defect_data-defect_val,
             fld71         like zscr_defect_data-defect_val,
             fld72         like zscr_defect_data-defect_val,
             fld73         like zscr_defect_data-defect_val,
             fld74         like zscr_defect_data-defect_val,
             fld75         like zscr_defect_data-defect_val,
             fld76         like zscr_defect_data-defect_val,
             fld77         like zscr_defect_data-defect_val,
             fld78         like zscr_defect_data-defect_val,
             fld79         like zscr_defect_data-defect_val,
             fld80         like zscr_defect_data-defect_val,
             fld81         like zscr_defect_data-defect_val,
             fld82         like zscr_defect_data-defect_val,
             fld83         like zscr_defect_data-defect_val,
             fld84         like zscr_defect_data-defect_val,
             fld85         like zscr_defect_data-defect_val,
             fld86         like zscr_defect_data-defect_val,
             fld87         like zscr_defect_data-defect_val,
             fld88         like zscr_defect_data-defect_val,
             fld89         like zscr_defect_data-defect_val,
             fld90         like zscr_defect_data-defect_val,
             fld91         like zscr_defect_data-defect_val,
             fld92         like zscr_defect_data-defect_val,
             fld93         like zscr_defect_data-defect_val,
             fld94         like zscr_defect_data-defect_val,
             fld95         like zscr_defect_data-defect_val,
             fld96         like zscr_defect_data-defect_val,
             fld97         like zscr_defect_data-defect_val,
             fld98         like zscr_defect_data-defect_val,
             fld99         like zscr_defect_data-defect_val,
             fld100         like zscr_defect_data-defect_val,
             fld101         like zscr_defect_data-defect_val,
             fld102         like zscr_defect_data-defect_val,
             fld103         like zscr_defect_data-defect_val,
             fld104         like zscr_defect_data-defect_val,
             fld105         like zscr_defect_data-defect_val,
             fld106         like zscr_defect_data-defect_val,
             fld107         like zscr_defect_data-defect_val,
             fld108         like zscr_defect_data-defect_val,
             fld109         like zscr_defect_data-defect_val,
             fld110         like zscr_defect_data-defect_val,
             fld111         like zscr_defect_data-defect_val,
             fld112         like zscr_defect_data-defect_val,
             fld113         like zscr_defect_data-defect_val,
             fld114         like zscr_defect_data-defect_val,
             fld115         like zscr_defect_data-defect_val,
             fld116         like zscr_defect_data-defect_val,
             fld117         like zscr_defect_data-defect_val,
             fld118         like zscr_defect_data-defect_val,
             fld119         like zscr_defect_data-defect_val,
             fld120         like zscr_defect_data-defect_val,
             fld121         like zscr_defect_data-defect_val,
             fld122         like zscr_defect_data-defect_val,
             fld123         like zscr_defect_data-defect_val,
             fld124         like zscr_defect_data-defect_val,
             fld125         like zscr_defect_data-defect_val,
             fld126         like zscr_defect_data-defect_val,
             fld127         like zscr_defect_data-defect_val,
             fld128         like zscr_defect_data-defect_val,
             fld129         like zscr_defect_data-defect_val,
             fld130         like zscr_defect_data-defect_val,
             fld131         like zscr_defect_data-defect_val,
             fld132         like zscr_defect_data-defect_val,
             fld133         like zscr_defect_data-defect_val,
             fld134         like zscr_defect_data-defect_val,
             fld135         like zscr_defect_data-defect_val,
             dayst         like zscr_data_hdr-dayst,
           end of t_data.
    In this fld1 to fld135 are defined in internal table.
    But if the number of fields are more than 135 then the program is going to short dump.
    Some times fld1 to fid170 or more fields will be there in my internal table.
    Please suggest me how to make my requirement dynamic and display this data fetched into this internal table onto a .XLS file in the presentation server ?

    Hi
    You can try to use the type string:
    form like zscr_data_hdr-form,
    werks like zscr_data_hdr-werks,
    matnr like zscr_data_hdr-matnr,
    verid like zscr_data_hdr-verid,
    lot like zscr_data_hdr-lot,
    lot_qty like zscr_data_hdr-lot_qty,
    udate like zscr_data_hdr-udate,
    utime like zscr_data_hdr-utime,
    zuser like zscr_data_hdr-zuser,
    processed like zscr_data_hdr-processed,
    defect like zscr_defect_data-defect,
    vornr like zscr_route_data-vornr,
    fieldxx type string,
    dayst like zscr_data_hdr-dayst,
    end of t_data.
    So you can save you informations of every fld<n> concatenating their values into fieldxx.
    Max

  • Create Fieldcatalog based on internal table (dynamic)

    Hi ,
    Is there a way to create Create Fieldcatalog based on internal table (dynamic).
    while creating fieldcat we usually many give the fields "fieldname" and "tabname".
    is there a way to get the fieldname from the main table ?
    Eg ..
    I have i_tab as the output table. It has 3 fields "a", "b" and "c"
    Now when i created fieldcat manually ( in case i cannot use fieldcat_merge FM) , i have to append 3 throws in fieldcat table.
    These rows would have "a", "b" and "c".
    Now i want to know if there is a way in which i can find "a" "b" and "c" fieldnames from the createdd internal tables.
    i can then append the same to fieldcat.

    Hi Anuj,
    I created a FORM routine for this 4 or 5 years ago and made a couple of refinements. Meanwhile it has prooved as very useful.
    The disadvantag is that it creates the oldfashioned field catalog for the function calls. But I already used it for OO fieldcatalog of LVC type - there is a function module for this but I do not have the name here.
    You need the two forms (second called in first) to build the field catalog from any internal table that can be used for ALV display.
    *&      Form  ALV_FIELDCAT_FOR_ITAB
    *       Feldkatalog from (arbitrary) internal Table (c) Clemens Li
    *       * build field catalog from        type description
    form alv_fieldcat_for_itab                                  "#EC *
      tables   pt_outtab                      type table        "#EC *
      changing pt_alv_fieldcat                type slis_t_fieldcat_alv."#EC *
      data:
        lv_desc                               type sydes_desc,
        ls_alv_fieldcat                       type slis_fieldcat_alv,
        lv_longfield                          type text80."CRM<=R/3 fname.
      field-symbols:
        <typeinfo>                            type sydes_typeinfo,
        <nameinfo>                            type sydes_nameinfo.
      describe field pt_outtab into lv_desc.                    "#EC *
      loop at lv_desc-types
          assigning <typeinfo>
          where not idx_name is initial
            and table_kind is initial "no entries for deep table like color
            and back                          = 1. "top-level-entries only.
        read table lv_desc-names index <typeinfo>-idx_name
          assigning <nameinfo>.
        check <nameinfo>-name                 <> 'INCLUDE'.
        ls_alv_fieldcat-fieldname             = <nameinfo>-name.
        while not <nameinfo>-continue is initial.
          add 1 to <typeinfo>-idx_name.
          read table lv_desc-names index <typeinfo>-idx_name
            assigning <nameinfo>.
          concatenate
            ls_alv_fieldcat-fieldname
            <nameinfo>-name
            into ls_alv_fieldcat-fieldname.
        endwhile." not <nameinfo>-continue IS INITIAL.
        read table lv_desc-names index <typeinfo>-idx_help_id
          assigning <nameinfo>.
        if sy-subrc                           = 0.
    * Caution: Help-ID may be Tablename-Fieldname and thus longer
    * than 30 Chars; ls_alv_fieldcat-rollname is 30 Chars only
          ls_alv_fieldcat-rollname            = <nameinfo>-name.
          lv_longfield                        = <nameinfo>-name.
          while not <nameinfo>-continue is initial.
            add 1 to <typeinfo>-idx_help_id.
            read table lv_desc-names index <typeinfo>-idx_help_id
              assigning <nameinfo>.
            concatenate
              lv_longfield
              <nameinfo>-name
              into lv_longfield.
          endwhile." not lv_desc-continue is initial.
    * help id may be data element or <table>-<field>
          if lv_longfield ca '-'.
    * get data                                type for table field
            perform get_rollname_4_tabfield
              using lv_longfield changing ls_alv_fieldcat.
          endif." lv_longfield ca '-'.
        else.
    * No Help-ID: Use Fieldname as text
          ls_alv_fieldcat-seltext_s           =
          ls_alv_fieldcat-seltext_m           =
          ls_alv_fieldcat-seltext_l           =
          ls_alv_fieldcat-reptext_ddic        =
          <nameinfo>-name.
        endif." sy-subrc                      = 0.
    * Starting 4.7: get edit mask
        if not <typeinfo>-idx_edit_mask is initial.
          read table lv_desc-names index <typeinfo>-idx_edit_mask
            assigning <nameinfo>.
          ls_alv_fieldcat-edit_mask           = <nameinfo>-name.
          if not <nameinfo>-continue is initial.
            add 1 to <typeinfo>-idx_edit_mask.
            read table lv_desc-names index <typeinfo>-idx_edit_mask
              assigning <nameinfo>.
            concatenate
              ls_alv_fieldcat-edit_mask
              <nameinfo>-name
              into ls_alv_fieldcat-edit_mask.
          endif." not <nameinfo>-continue IS INITIAL.
        endif." not <typeinfo>-IDX_EDIT_MASK is initial.
    * assign length, output length and decimals
        ls_alv_fieldcat-intlen                = <typeinfo>-length.
        ls_alv_fieldcat-outputlen             = <typeinfo>-output_length.
        ls_alv_fieldcat-decimals_out          = <typeinfo>-decimals.
        ls_alv_fieldcat-inttype               = <typeinfo>-type.
        append ls_alv_fieldcat to pt_alv_fieldcat.
        clear:  "prevent anything 2 B  taken for subsequent fields
          ls_alv_fieldcat.
      endloop." at lv_desc-types where not IDX_NAME is in initial.
    endform.                    " ALV_FIELDCAT_FOR_ITAB
    *&      Form  get_rollname_4_tabfield
    *       Get Data                          type for Table field
    form get_rollname_4_tabfield
      using    p_fname                        type text80 ""CRM<=R/3 fname
      changing p_alv_fieldcat                 type slis_fieldcat_alv.
      field-symbols:
        <dfies>                               type dfies.
      data:
        lv_tabname                            type tabname,
         lt_dfies                             type table of dfies,
        lv_fieldname                          type fieldname.
      split p_fname at '-'
        into lv_tabname lv_fieldname.
      clear p_alv_fieldcat-rollname.
      call function 'DDIF_FIELDINFO_GET'
        exporting
          tabname                             = lv_tabname
          fieldname                           = lv_fieldname
    *   LANGU                                 = SY-LANGU
    *   LFIELDNAME                            = ' '
    *   ALL_TYPES                             = ' '
    * IMPORTING
    *   X030L_WA                              =
    *   DDOBJTYPE                             =
    *   DFIES_WA                              =
    *   LINES_DESCR                           =
       tables
         dfies_tab                            =  lt_dfies
    *   FIXED_VALUES                          =
       exceptions
         not_found                            = 1
         internal_error                       = 2
         others                               = 3
      if sy-subrc                             <> 0.
        message id sy-msgid                   type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      else.
        read table   lt_dfies assigning <dfies> index 1.
        p_alv_fieldcat-rollname               = <dfies>-rollname.
    * Und wenn keinerlei Twexte gepflegt sind?
        if <dfies>-reptext is initial and
           <dfies>-scrtext_s is initial and
           <dfies>-scrtext_m is initial and
           <dfies>-scrtext_l is initial.
    * No Text: Use Fieldname as text
          p_alv_fieldcat-seltext_s            =
          p_alv_fieldcat-seltext_m            =
          p_alv_fieldcat-seltext_l            =
          p_alv_fieldcat-reptext_ddic         =
          p_alv_fieldcat-fieldname.
        endif." <dfies>-reptext IS INITIAL AND
      endif.
    endform.                    " get_rollname_4_tabfield
    Regards,
    Clemens

  • How to find the number of columns in an internal table DYNAMICALLY ?

    Hi,
    How to find the number of columns in an internal table DYNAMICALLY ?
    Thanks and Regards,
    saleem.

    Hi,
    you can find the number of columns and their order using
    the <b>'REUSE_ALV_FIELDCATALOG_MERGE'</b>
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = sy-repid
       I_INTERNAL_TABNAME           = 'ITAB'
       I_INCLNAME                   = sy-repid
      changing
        ct_fieldcat                  = IT_FIELDCAT
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif
    now describe your fieldcat . and find no of columns.
    and their order also..
    regards
    vijay

  • Dynamic creation of internal tables

    Hi all,
    i very urgently need a sample code which will help me to create an internal table dynamically at the click of a pushbutton using alv.Awaiting reply shortly .
    thank you.
    Regards,
    Lailu Philip

    Hi,
    Check this.I got it from SDN.
    REPORT zmaschl_create_data_dynamic .
    TYPE-POOLS: slis.
    DATA: it_fcat TYPE slis_t_fieldcat_alv,
          is_fcat LIKE LINE OF it_fcat.
    DATA: it_fieldcat TYPE lvc_t_fcat,
          is_fieldcat LIKE LINE OF it_fieldcat.
    DATA: new_table TYPE REF TO data.
    DATA: new_line  TYPE REF TO data.
    FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
                   <l_line>  TYPE ANY,
                   <l_field> TYPE ANY.
    Build fieldcat
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
               i_structure_name = 'SYST'
           CHANGING
               ct_fieldcat      = it_fcat[].
       LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.
            MOVE-CORRESPONDING is_fcat TO is_fieldcat.
            is_fieldcat-fieldname = is_fcat-fieldname.
            is_fieldcat-ref_field = is_fcat-fieldname.
            is_fieldcat-ref_table = is_fcat-ref_tabname.
            APPEND is_fieldcat TO it_fieldcat.
       ENDLOOP.
    Create a new Table
    CALL METHOD cl_alv_table_create=>create_dynamic_table
           EXPORTING
            it_fieldcatalog = it_fieldcat
           IMPORTING
            ep_table        = new_table.
    Create a new Line with the same structure of the table.
    ASSIGN new_table->* TO <l_table>.
    CREATE DATA new_line LIKE LINE OF <l_table>.
    ASSIGN new_line->* TO <l_line>.
    Test it...
       DO 30 TIMES.
          ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
          <l_field> = sy-index.
          INSERT <l_line> INTO TABLE <l_table>.
       ENDDO.
       LOOP AT <l_table> ASSIGNING <l_line>.
          ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
          WRITE <l_field>.
       ENDLOOP.

  • Problem creating an internal table dynamically

    Hi,
    I'm trying to create an internal table dynamically as i would be able to determine the structure of the table based on the user input.
    I've used the sample code from this forum ...
    REPORT  ZRICH_0003       .
    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>.
    <b>* Select Data from table.
    select * into table <dyn_table>           from
    (p_table).</b>
    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.
    I'm able to get the structure of the table that i want, but when i'm trying to select data from the table into this internal table..as highlighted in the sample code above..i'm getting a short dump...saying that ' the database table is 600 bytes wide but the internal table is only 576 bytes wide.
    The internal table is declared as
    field-symbols: <dyn_table> type standard table..
    Could anyone please tell me how to rectify this.
    Thanks in advance,
    Harsha.

    Hi Smitha,
    I'm building the internal table by getting the structure using the method
    cl_abap_typedescr=>describe_by_name( p_table ).
    where p_table is the table name determined dynamically..
    Now using this structure, i'm building an internal table by calling the method
    call method cl_alv_table_create=>create_dynamic_table
    I've checked all the fields after the internal table has been created .. and it contains all the fields of the table that i'm supplying initially..
    But when i read data into that internal table, it gives me that dump..I've described it in this post earlier.
    Any more suggestions would be very helpful.
    Thanks,
    Harsha

  • Internal Table dynamic query

    Hello,
    I have an internal table which needs to be queried with set of attributes which change dynamically. How can I do it?
    Eg: Internal Table i_tab contains attributes a,b,c,d,e etc... Now I should extract a single line from the table based based on the values I supply for the attributes.
    Say if I give a=23 b='' c='abc' d='' e=''. Then the query should be able to return be the line where all the initial field attributes (here in this case b,d, and e) should not be considered for the query.
    It shoud be
    read table i_tab with key a= 23 c='abc'.
    The next time a query can be shooted with the foll values
    a='' b='SAP' c='ERP' d='' e=''.
    Then the query shd be
    read table i_tab with key b= 'SAP' c='ERP'.
    In short can I get the functionality of the "select statement dynamic search string"?
    select * from tab where ( search string ) .
    and search string would be generated dynamically based on the inputs?
    I would be really thankful if you can provide me an immediate answer.
    Thanks and Regards,
    Sandhya

    I think one of the simplest way is to define ranges for the variables a, b, c, d and e.
    ranges : r_a for a, r_b for b...r_e for e.
    refresh : r_a, r_b, r_c, r_d, r_e. 
    clear :  r_a, r_b, r_c, r_d, r_e. 
    if a is not initial.
       r_a-sign = 'I'.
       r_a-option = 'EQ'.
       r_a-low = value.
       append r_a.
    endif.
    ....similarly build for b, c, d and e.
    Loop at itab.
      check itab-a in r_a.
      check itab-b in r_b.
      check itab-e in r_e.
      move-corresponding itab to <b>urval</b>.
      exit.
    endloop.

  • Passing internal tables dynamically to a subroutine

    Hi All,
    How to pass internal tables dynamically to a subroutine?
    In subroutine logic i'm fetching data from MARA table for all entries in the internal table passed to the subroutine. Based on some condition the internal table varies. I'm placing the code below
    Both GT_AUFM & GT_AUFM1 are of 2 different structures having MATNR.
    IF WA_AUFM1-BWART EQ '261'.
        PERFORM GET_IF_SEMIFINISHED USING GT_AUFM1.
    ELSE IF WA_AUFM1-BWART EQ '262'.
        PERFORM GET_IF_SEMIFINISHED TABLES GT_AUFM.
    ENDIF.
    FORM GET_IF_SEMIFINISHED  USING P_TABLE TYPE ANY TABLE.
      REFRESH GT_MARA.
      SELECT MATNR FROM MARA INTO TABLE GT_MARA
                     FOR ALL ENTRIES IN P_TABLE
                     WHERE MATNR EQ P_TABLE-MATNR
                       AND MTART IN R_MTART.
      ENDFORM.
    With this logic i'm getting an error that the specified type has no structure and therefore no component called MATNR.
    Thanks,
    Anil.

    refer this link
    dynamic internal table

  • Header row in ALV Grid, based on the data in the table

    Hi All,
    I have a requirement wherein, based on the data in the table used for ALV, i need to add rows as sort of header in the ALV display.
    For e.g. my table has
    Appl No.  Item  Material  Desc.           Cost                 -> Column Heading
    1             10     400        Excavation    10.00               -> Data
    1             20     400        Footing         10.00
    2             10     400        Excavation    10.00
    2             20     400        Footing         10.00
    For every new Appl No., i need to add a row, or sort of header specifying the appl no. details. means
    Appl No.  Item  Material  Desc.           Cost
    Appli. No. 1                   Date: 01/01/1009                   -> my requirement
    1             10     400        Excavation    10.00
    1             20     400        Footing         10.00
    Appli. No. 2                   Date: 02/01/1009
    2             10     400        Excavation    10.00
    2             20     400        Footing         10.00
    Is this possible in ALV my any means? Currently i m using normal ALV Grid
    Regards,
    Janaki

    Hi..
         Try like this... I think u have Application number and date in ur table ... First get the total table data into internal table.. and to add the row
         *Declare the var1 as 0 and var2.
    loop at internal table
         *var1 = var1 +1
    when application number =var1
             concatenate : 'Appli. No.' (table- appli no field) 'Date:'  (table-date field) into var2.
    perform display(some name)
         *endloop.
         *form display...
              alv display part.. first give that var2 like eg.. wa_alv-field= 'var2'.
    end form.
        Hope this will help u .....
    Regards,
    Abaper

  • How to create internal table dynamically?

    hi all
    I have a particular internal table in memory area( thru EXPORT TO MEMORY ID ....)
    how can i create an internal table of this type in another program at runtime  ?
    this internal table need not be a data dictionary type.
    i.e., i need to create an internal table of type which
    is stored in a particular memory-id.
    Regards,
    Naveen........
    null

    Hi,
    Check this code :
    TYPE-POOLS: slis.
    FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE, 
                    <fs_dyntable>,                    
                    <fs_fldval> type any.             
    PARAMETERS: p_cols(5) TYPE c.   
    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>.
    DATA it_fieldcatalog TYPE lvc_t_fcat.
    DATA lr_table TYPE REF TO data.
    FIELD-SYMBOLS <lt_table> TYPE table.
    *-- Import the fieldcatalog
    IMPORT it_fieldcatalog TO it_fieldcatalog
           FROM MEMORY ID 'CREATE_DYNAMIC_TABLE'.
    IF sy-subrc <> 0.
      EXIT.
    ENDIF.
    *-- Create the dynamic table with the field catalog as structure
    CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
        it_fieldcatalog           = it_fieldcatalog
      IMPORTING
        ep_table                  = lr_table
      EXCEPTIONS
        generate_subpool_dir_full = 1
        OTHERS                    = 2.
    IF sy-subrc <> 0.
      EXIT.
    ENDIF.
    *-- Convert the reference into a table
    ASSIGN lr_table->* TO <lt_table>.
    IF sy-subrc <> 0.
      EXIT.
    ENDIF.
    *-- Export the created table so that the function module can import it
    EXPORT lt_table FROM <lt_table>
           TO MEMORY ID 'CREATE_DYNAMIC_TABLE'.
    Regards
    L Appana

  • Can we create internal table dynamically ? how?

    hi to all experts,
                           can we create internal table dynamically ? how?plz explain me with an example.Anybody with good example  will be rewarded.it was asked in an interview what the answer for it

    HI
    Yes you can create
    see this
    /people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
    JUST USE THIS CODE AND DO THE ESSENTIAL CHANGES ACCORDING TO YOU
    STEP: 1 - get backend field catalog (currently displayed alv)
    CLEAR: tl_fieldcatalog. REFRESH: tl_fieldcatalog.
    CALL METHOD w_grid->get_backend_fieldcatalog
    IMPORTING
    et_fieldcatalog = tl_fieldcatalog.
    STEP: 2 - create a new fieldcatalog for dynamic internal table
    CLEAR: sl_fieldcatalog.
    CLEAR: t_outtab_fieldname. REFRESH: t_outtab_fieldname.
    CLEAR: tl_fieldcatalog_new. REFRESH: tl_fieldcatalog_new.
    CLEAR: t_download_fieldname. REFRESH: t_download_fieldname.
    CLEAR: t_download_fieldheading. REFRESH: t_download_fieldheading.
    LOOP AT tl_fieldcatalog INTO sl_fieldcatalog.
    STEP: 2.1 - populate data in T_OUTTAB_FIELDNAME
    APPEND sl_fieldcatalog-fieldname TO t_outtab_fieldname.
    STEP: 2.2 - populate TL_FIELDCATALOG_NEW & T_DOWNLOAD_FIELDNAME
    IF sl_fieldcatalog-no_out EQ ''.
    IF sl_fieldcatalog-fieldname NE 'STATUS'
    OR sl_fieldcatalog-fieldname NE 'MESG_STATUS'
    OR sl_fieldcatalog-fieldname NE 'ZLOCK'
    OR sl_fieldcatalog-fieldname NE 'T_PLANT'
    OR sl_fieldcatalog-fieldname NE 'T_CSR'.
    If field is COMM_PLANT, change its length
    IF sl_fieldcatalog-fieldname EQ 'COMM_PLANT'.
    sl_fieldcatalog-outputlen = 1800.
    sl_fieldcatalog-intlen = 1800.
    sl_fieldcatalog-dd_outlen = 1800.
    ENDIF. "comm_plant
    sl_fieldcatalog_new = sl_fieldcatalog.
    APPEND sl_fieldcatalog_new TO tl_fieldcatalog_new.
    APPEND sl_fieldcatalog-fieldname TO t_download_fieldname.
    APPEND sl_fieldcatalog-scrtext_l TO t_download_fieldheading.
    CLEAR: sl_fieldcatalog, sl_fieldcatalog_new.
    ENDIF.
    ENDIF.
    ENDLOOP.
    STEP: 3 - create dynamic internal table
    FREE: ref_download.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    I_STYLE_TABLE =
    it_fieldcatalog = tl_fieldcatalog_new
    IMPORTING
    ep_table = ref_download
    E_STYLE_FNAME =
    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 ref_download->* TO <ft_download>.
    CREATE DATA ref_wa LIKE LINE OF <ft_download>.
    ASSIGN ref_wa->* TO <fs_download>.
    STEP: 4 - populate data in dynamic internal table
    LOOP AT t_outtab INTO wa_outtab.
    LOOP AT t_download_fieldname.
    ASSIGN COMPONENT t_download_fieldname OF STRUCTURE
    <fs_download> TO <fs_download_field>.
    IF t_download_fieldname-field EQ 'COMM_PLANT'.
    STEP: 4.1 - get long text from database table
    CLEAR: wal_table.
    SELECT SINGLE * FROM zshaven_plnt_txt
    INTO wal_table
    WHERE vbeln = wa_outtab-vbeln
    AND posnr = wa_outtab-posnr
    AND del_no = wa_outtab-del_no
    AND del_itm = wa_outtab-del_itm.
    IF sy-subrc EQ 0.
    STEP: 4.2 - break long-text into separate lines
    CLEAR: tl_text. REFRESH: tl_text.
    SPLIT wal_table-plant_comm
    AT '~'
    INTO TABLE tl_text.
    STEP: 4.3 - Combine these separate lines with space in
    between two lines
    CLEAR: wal_text, final_text.
    LOOP AT tl_text INTO wal_text.
    IF final_text IS INITIAL.
    final_text = wal_text.
    ELSE.
    CONCATENATE final_text '-' wal_text
    INTO final_text.
    REPLACE '-' WITH ' ' INTO final_text.
    ENDIF.
    ENDLOOP.
    STEP: 4.4 - move long text to work-area
    <fs_download_field> = final_text.
    ENDIF. "subrc
    ELSE. "t_download_fieldname
    READ TABLE t_outtab_fieldname
    WITH KEY field = t_download_fieldname-field.
    ASSIGN COMPONENT t_outtab_fieldname-field OF STRUCTURE
    wa_outtab TO <fs_outtab_field>.
    <fs_download_field> = <fs_outtab_field>.
    ENDIF.
    ENDLOOP.
    STEP: 4.5 - Move data from work-area to dynamic internal table
    APPEND <fs_download> TO <ft_download>.
    CLEAR: <fs_download>.
    ENDLOOP.
    STEP: 5 - download
    CALL FUNCTION 'DOWNLOAD'
    EXPORTING
    filename = 'C:\zshaven.xls'
    filetype = 'DAT'
    filetype_no_show = 'X'
    filetype_no_change = 'X'
    TABLES
    data_tab = <ft_download>
    fieldnames = t_download_fieldheading
    EXCEPTIONS
    invalid_filesize = 1
    invalid_table_width = 2
    invalid_type = 3
    no_batch = 4
    unknown_error = 5
    gui_refuse_filetransfer = 6
    customer_error = 7
    OTHERS = 8.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

Maybe you are looking for

  • Printer and Scanner don't work anymore since Yosemite updating

    Hello and thanks for your welcome, After OS X Mountain lion and lion (all my softwares working) i update to Mavericks (no more scanner)  and after to Yosemite (no more printer) and my computer said that PPC applications no longer supported...  (i'm s

  • The sound delays when it in my compressor 1.2.1, somebody can help me

    I tried the same problems that you people, now that I was to think that the problems had finished, is when I discover another one. In the DVD Studio Pro when I make preview, I repair that the sound is delayed, not in the begining of the film but in t

  • Problem w/desktop pictures

    I all of a sudden w/my desktop pics loading. I went under system preferences and my pics from iPhoto are not there. Then Dragged a pic from the desktop and loaded it and it worked. But the pic has to stay on the desktop to remain a desktop photo. If

  • Please help! iMessage failing to verify apple Id

    Hi all, I am trying to add my add my apple Id (email address) in order for me to send and receive iMessage. But when ever I am prompted for user name nd password of my apple Id , I get a message saying that my username or password is incorrect. I hav

  • Can XMLBeans validate Web Services Input Parameters in Weblogic8.1?

    Hi, I am very new to XMLBeans and Web Services. From my understanding, schemas can be used to validate an xml document. However, I would like to find out: 1. Can I validate my web service inputs againest the generated XMLBeans objects/schema, in Webl