How to control internal table columns dynamically based on input

i have 2 fields in the selection screen - user and tcode
we can give any number of tcodes as in put
based on requirement i need to display all the tcodes belongs to one user in one row
in other words
the out put table columns should increase dynamically based on number of tcodes entered
in the input
how to do this?
Edited by: tummala swapna on Apr 7, 2009 11:55 AM

This may be useful to you..
FIELD-SYMBOLS : <FS_TABLE> TYPE ANY TABLE.
DATA: DREF TYPE REF TO DATA,
      WA_DREF TYPE REF TO DATA,
      DY_LINE TYPE REF TO DATA,
      ITAB_TYPE TYPE REF TO CL_ABAP_TABLEDESCR,
      WA_TYPE TYPE REF TO CL_ABAP_STRUCTDESCR,
      STRUCT_TYPE TYPE REF TO CL_ABAP_STRUCTDESCR,
      ELEM_TYPE TYPE REF TO CL_ABAP_ELEMDESCR,
      COMP_TAB TYPE CL_ABAP_STRUCTDESCR=>COMPONENT_TABLE,
      COMP_FLD TYPE CL_ABAP_STRUCTDESCR=>COMPONENT,
      OTAB TYPE ABAP_SORTORDER_TAB,
      OLINE TYPE ABAP_SORTORDER.
BEGIN DYNAMIC STRUCTURE FOR FINAL INTERNAL TABLE @@@@@@@@@@@@@@@@@@
STRUCT_TYPE ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME('table or structure name').
COMP_TAB = STRUCT_TYPE->GET_COMPONENTS( ).
STRUCT_TYPE = CL_ABAP_STRUCTDESCR=>CREATE( COMP_TAB ).
ITAB_TYPE = CL_ABAP_TABLEDESCR=>CREATE( STRUCT_TYPE ).
CREATE DATA DREF TYPE HANDLE ITAB_TYPE.
ASSIGN DREF->* TO <FS_TABLE>.
END DYNAMIC STRUCTURE FOR FINAL INTERNAL TABLE @@@@@@@@@@@@@@@@@@

Similar Messages

  • How to Create a Table Component Dynamically based on the Need

    Hello all,
    I have a problem i need to create dynamically tables based on the no of records in the database. How can i create the table object using java code.
    Please help.

    Winston's blog will probably be helpful:
    How to create a table component dynamically:
    http://blogs.sun.com/roller/page/winston?entry=creating_dynamic_table
    Adding components to a dynamically created table
    http://blogs.sun.com/roller/page/winston?entry=dynamic_button_table
    Lark
    Creator Team

  • How to find internal table column names

    Hi Friends,
    I have declared one internal table with 45 fields.
    Here is my situation.
    I need to create dynamic table with all above 45 fields and some more fields (approx 10 fields).
    I got the solution for creating dynamic table. Only thing is
    I have to assign all the above 75 columns to  other internal table.
    is there any way we can read internal table field names in the program.
    we can acheive this by hard coding the all 75 field names.
    since it is 75 columns, i want to pass one by one field dynamically to the other table.
    Pls give me a solution.
    thanks in advance.

    HI,
    Find the code for dynamical internal table., which helps to increase the fields in the internal table dynamically.
    REPORT ZTEST_R3.
    FIELD-SYMBOLS: <L_TABLE> TYPE TABLE,
    <L_LINE> TYPE ANY,
    <L_FIELD> TYPE ANY.
    DATA: IS_LVC_CAT TYPE LVC_S_FCAT,
    IT_LVC_CAT TYPE LVC_T_FCAT.
    DATA: NEW_TABLE TYPE REF TO DATA,
    NEW_LINE TYPE REF TO DATA.
    START-OF-SELECTION.
    IS_LVC_CAT-FIELDNAME = 'KUNNR'.
    APPEND IS_LVC_CAT TO IT_LVC_CAT.
    IS_LVC_CAT-FIELDNAME = 'NAME1'.
    APPEND IS_LVC_CAT TO IT_LVC_CAT.
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
    EXPORTING
    IT_FIELDCATALOG = IT_LVC_CAT
    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>.
    DO 2 TIMES.
    ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <L_LINE> TO <L_FIELD>.
    <L_FIELD> = SY-INDEX.
    ASSIGN COMPONENT 'NAME1' OF STRUCTURE <L_LINE> TO <L_FIELD>.
    <L_FIELD> = 'A'.
    INSERT <L_LINE> INTO TABLE <L_TABLE>.
    ENDDO.
    LOOP AT <L_TABLE> INTO <L_LINE>.
    WRITE:/ <L_LINE>.
    ENDLOOP.
    READ TABLE <L_TABLE> INTO <L_LINE> INDEX 2.
    <L_LINE>+10(2) = 'B'.
    MODIFY <L_TABLE> FROM <L_LINE> INDEX 2.
    LOOP AT <L_TABLE> INTO <L_LINE>.
    WRITE:/ <L_LINE>.
    ENDLOOP.

  • How to convert internal table with dynamic fields to XML

    Dear all,
    I met a problem like the following:
    The aim is to transform the following parameter to XML
    IT_FIELD stores the dynamic filed name of the internal table,with these fields, the dynamic internal can be created by cl_abap_tabledescr=>create(it_field)
    IT_VALUE stores the value of the internal table dynamically created with dynamic fields.
    For example
    IT_FIELD =>
    line1: FIELD1
    line2: FIELD2
    line3: FIELD3,
    three lines in this internal table.
    dynamically created internal table structure FIELD1 FIELD2 FIELD3
    And IT_VALUE=>
    1          2          3   (First line)
    11        22        33
    two lines of data.
    Do you have any idea about how to transform the IT_VALUE to XML here? And also the transformed XML to the IT_VALUE.( we may need remember IT_FIELD here for later XML to IT_VALUE.)
    Hope I describe the problem clearly.
    Any inputs will be appreciated.
    Edited by: Max Tang on Jan 12, 2009 3:46 PM
    Edited by: Max Tang on Jan 12, 2009 4:14 PM

    Hi,
    you need to implement a bit of coding for that.
    With the 'do varying' statement abap provides a loop over those fields. Within this loop you can build up a new internal table with one entry for each period and amount.
    kind regards
    Siggi
    PS: I am not very familiar with CO, but I guess there will be a standard extractor for that.

  • How to add/remove table columns dynamically?

    Please help urgently!

    Don't access the view layout (UI element references) in action event handlers. You have to place this code in wdDoModifyView().
    In the action handler, store the information needed (e.g. table column ID, insertion position, whatever) in some context attribute or in some member variable of the view.
    In wdDoModifyView(), check if table modification should be done, get the table instance using view.getElement(<tableID>), use the IWDTable API to modify the table.
    Finally, reset the flag or configuration data indicating that the table should have been modified.
    This is not really elegant, but that's the way it is...
    Armin

  • How to create table columns dynamically ?

    Hi All,
    I am working on an SSRS report that will show sales in the past 5 years. If the user selected to view sales of past 3 years he will only see 3 columns. so How can I create table columns dynamically at run time and how can I make sure that their dimensions
    will adjust to fit the report page size.

    Hi Developer life,
    According to your description that you want to dynamically increase and decrease the numbers of the columns in the table, right?
    As Jason A Long mentioned that we can use the matrix to do this and put the year field in the column group, amount fields(Numric  values) in the details,  add  an filter to filter the data base on this column group, but if
    the data in the DB not suitable to add to the matrix directly, you can use the unpivot function to turn the column name of year to a single row and then you can add it in the column group.
    If there are too many columns in the column group, it will fit the page size automatically and display the extra columns in the next page.
    Similar threads with details steps for your reference:
    https://social.technet.microsoft.com/Forums/en-US/339965a1-8cca-41d8-83ef-c2548050799a/ssrs-dataset-column-metadata-dynamic-update?forum=sqlreportings 
    If your still have any problem, please try to provide us more details information, such as the data structure in the DB and the table structure you are currently designing.
    Any question, please feel free to let me know.
    Best Regards
    Vicky Liu

  • How to add column dynamically based on user input in oracle?

    **how to add column dynamically based on user input in oracle?**
    I am generating monthly report based on from_date to to_date below is my requirement sample table
    EMPLOYEE_CODE| Name | CL_TAKEN_DATE | CL_BALANCE | 01-OCT-12 | 02-OCT-12 | 03-OCT-12
    100001.............John...........02-OCT-12...............6
    100002.............chris...........01-OCT-12...............4
    Based on user input, that is, if user need the report from 01-OCT-12 TO 03-OCT-12, i need to add that dates as column in my table, like 01-OCT-12 | 02-OCT-12 | 03-OCT-12....
    below is my code
    create or replace
    procedure MONTHLY_LVE_NEW_REPORT_demo
    L_BUSINESS_UNIT IN SSHRMS_LEAVE_REQUEST_TRN.BUSINESS_UNIT%TYPE,
    --L_LEAVE_TYPE_CODE           IN SSHRMS_LEAVE_REQUEST_TRN.LEAVE_TYPE_CODE%TYPE,
    L_DEPARTMENT_CODE IN VARCHAR2,
    --L_MONTH                    IN SSHRMS_LEAVE_REQUEST_TRN.LVE_FROM_DATE%TYPE,
    L_FROM_DATE IN SSHRMS_LEAVE_REQUEST_TRN.LVE_FROM_DATE%TYPE,
    L_TO_DATE in SSHRMS_LEAVE_REQUEST_TRN.LVE_TO_DATE%type,
    MONTHRPT_CURSOR OUT SYS_REFCURSOR
    AS
    O_MONTHRPT_CURSOR_RPT clob;
    v_return_msg clob;
    BEGIN
    IF (L_BUSINESS_UNIT IS NOT NULL
    AND L_FROM_DATE IS NOT NULL
    and L_TO_DATE is not null
    -- AND L_DEPARTMENT_CODE IS NOT NULL
    THEN
    OPEN MONTHRPT_CURSOR FOR
    select EMPLOYEE_CODE, EMPLOYEE_NAME AS NAME, DEPARTMENT_CODE AS DEPARTMENT,DEPARTMENT_DESC, CREATED_DATE,
    NVL(WM_CONCAT(CL_RANGE),'') as CL_TAKEN_DATE,
    case when NVL(SUM(CL2),0)<0 then 0 else (NVL(SUM(CL2),0)) end as CL_BALANCE,
    from
    SELECT DISTINCT a.employee_code,
    a.EMPLOYEE_FIRST_NAME || ' ' || a.EMPLOYEE_LAST_NAME as EMPLOYEE_NAME,
    a.DEPARTMENT_CODE,
    a.DEPARTMENT_DESC,
    B.LEAVE_TYPE_CODE,
    B.LVE_UNITS_APPLIED,
    B.CREATED_DATE as CREATED_DATE,
    DECODE(b.leave_type_code,'CL',SSHRMS_LVE_BUSINESSDAY(L_BUSINESS_UNIT,to_char(b.lve_from_date,'mm/dd/yyyy'), to_char(b.lve_to_date,'mm/dd/yyyy'))) CL_RANGE,
    DECODE(B.LEAVE_TYPE_CODE,'CL',B.LVE_UNITS_APPLIED)CL1,
    b.status
    from SSHRMS_EMPLOYEE_DATA a
    join
    SSHRMS_LEAVE_BALANCE C
    on a.EMPLOYEE_CODE = C.EMPLOYEE_CODE
    and C.STATUS = 'Y'
    left join
    SSHRMS_LEAVE_REQUEST_TRN B
    on
    B.EMPLOYEE_CODE=C.EMPLOYEE_CODE
    and c.EMPLOYEE_CODE = b.EMPLOYEE_CODE
    and B.LEAVE_TYPE_CODE = C.LEAVE_TYPE_CODE
    and B.STATUS in ('A','P','C')
    and (B.LVE_FROM_DATE >= TO_DATE(L_FROM_DATE, 'DD/MON/RRRR')
    and B.LVE_TO_DATE <= TO_DATE(L_TO_DATE, 'DD/MON/RRRR'))
    join
    SSHRMS_LEAVE_REQUEST_TRN D
    on a.EMPLOYEE_CODE = D.EMPLOYEE_CODE
    and D.LEAVE_TYPE_CODE in ('CL')
    AND D.LEAVE_TYPE_CODE IS NOT NULL
    group by EMPLOYEE_CODE, EMPLOYEE_NAME, DEPARTMENT_CODE, DEPARTMENT_DESC, CREATED_DATE
    else
    v_return_msg:='Field should not be empty';
    end if;
    END;
    my code actual output
    EMPLOYEE_CODE| Name | CL_TAKEN_DATE | CL_BALANCE
    100001....................John............02-OCT-12.................6
    100001....................chris...........01-OCT-12.................4
    how to add column dynamically based on from_date to to_date?
    Thanks and Regards,
    Chris Jerome.

    You cannot add columns dynamically. But you can define a maximum number of numbers and then hide unused columns in your form useing SET_ITEM_PROPERTY(..,VISIBLE, PROPERTY_FALSE);

  • How to Populate Internal table data to Table Control in a Report Program

    Dear All,
           How to Populate Internal table data to Table Control in a Report Program? It is a pure report program with out any Module pool coding involved, which is just used to display data. Till now it is being displayed in a report. Now the user wants the data to be displayed in a table control. Could someone tell me how to go about with this.
    Thanks in Advance,
    Joseph Reddy

    If you want to use a table control, you will need to create a screen.
    In your report....
    start-of-selection.
    perform get_data.  " Get all your data here
    call screen 100. " Now present to the user.
    Double click on the "100" in your call screen statement.  This will forward navigate you to the screen.  If you have not created it yet, it will ask you if you want to create it, say yes.  Go into screen painter or layout of the screen.  Use the table control wizard to help you along the process.  It will write the code for you.  Since it is an output only table control, it will be really easy with not a lot of code. 
    A better way to present the data to the user would be to give it in a ALV grid.  If you want to go that way, it is a lot easier.  Here is a sample of the ALV function module.  You don't even have to create a screen.
    report zrich_0004
           no standard page heading.
    type-pools slis.
    data: fieldcat type slis_t_fieldcat_alv.
    data: begin of imara occurs 0,
          matnr type mara-matnr,
          maktx type makt-maktx,
          end of imara.
    * Selection Screen
    selection-screen begin of block b1 with frame title text-001 .
    select-options: s_matnr for imara-matnr .
    selection-screen end of block b1.
    start-of-selection.
      perform get_data.
      perform write_report.
    *  Get_Data
    form get_data.
      select  mara~matnr makt~maktx
                into corresponding fields of table imara
                  from mara
                   inner join makt
                     on mara~matnr = makt~matnr
                        where mara~matnr in s_matnr
                          and makt~spras = sy-langu.
    endform.
    *  WRITE_REPORT
    form write_report.
      perform build_field_catalog.
    * CALL ABAP LIST VIEWER (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                it_fieldcat = fieldcat
           tables
                t_outtab    = imara.
    endform.
    * BUILD_FIELD_CATALOG
    form build_field_catalog.
      data: fc_tmp type slis_t_fieldcat_alv with header line.
      clear: fieldcat. refresh: fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Number'.
      fc_tmp-fieldname  = 'MATNR'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '18'.
      fc_tmp-col_pos    = 2.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material'.
      fc_tmp-fieldname  = 'MAKTX'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '40'.
      fc_tmp-col_pos    = 3.
      append fc_tmp to fieldcat.
    endform.
    Regards,
    Rich Heilman

  • How to fill internal table dynamically

    Hi All,
       how to fill internal table dynamically.
    for example:
    begin of itab occurs 0,
    empid like pa0000-pernr,
    empname like pa0001-ename,
    grade(5),
    end of itab.
    now i want to append dynamically field itab-grade along with rest fields.
    is this possible?? if yes kindly let me know how to do that.
    Regards,
    Kiran I

    Hi kiran,
    To fill and create and internal table dynamically you can use this code.
    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.
    is_fieldcat-fieldname = 'FIELD1'.
    is_fieldcat-ref_field = 'MATNR'.
    is_fieldcat-ref_table = 'MARA'.
    APPEND is_fieldcat TO it_fieldcat.
    is_fieldcat-fieldname = 'FIELD2'.
    is_fieldcat-ref_field = 'SPRPS'.
    is_fieldcat-ref_table = 'PA0001'.
    APPEND is_fieldcat TO it_fieldcat.
    is_fieldcat-fieldname = 'FIELD3'.
    is_fieldcat-ref_field = 'BEGDA'.
    is_fieldcat-ref_table = 'PA0002'.
    APPEND is_fieldcat TO it_fieldcat.
    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 40 times.
      ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <l_line> TO <l_field>.
      <l_field> = '12345'.
      ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <l_line> TO <l_field>.
      <l_field> = 'X'.
      ASSIGN COMPONENT 'FIELD3' OF STRUCTURE <l_line> TO <l_field>.
      <l_field> = '20030101'.
      INSERT <l_line> INTO TABLE <l_table>.
    ENDDO.
    LOOP AT <l_table> ASSIGNING <l_line>.
    ASSIGN COMPONENT 'field1' OF STRUCTURE <l_line> TO <l_field>.
      WRITE  / <l_line>.
    ENDLOOP.
    regards,
    Aashish Garg

  • Populating values to internal table created dynamically

    Hi,
    I am creating an internal table(it1) dynamically and assigned it to a field symbol. now i want to upload values
    which are present in a field of another internal table being populated from a Funct Module.Could you tell me
    how to assign those values across the fields of field symbol?
    loop at itab_char.
    LS_ALV_CAT-FIELDNAME = itab_char-charact.
    append LS_ALV_CAT to I_ALV_CAT.
    endloop.
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
      EXPORTING
        IT_FIELDCATALOG = I_ALV_CAT
      IMPORTING
        EP_TABLE        = D_REF.
    ASSIGN D_REF->* TO <F_FS>.
    (Above my int tab is generated and now stored in <f_FS>)
    loop at itab into w_lifnr.
    CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
      EXPORTING
       CLASS                      = p_cname
       CLASSTYPE                  = w_ctype
       OBJECT                     = w_lifnr
      TABLES
        T_CLASS                    = t_class
        T_OBJECTDATA               = t_objectdata
    w-lifnr is vendor number. and here we are populating t_objectdata with that vendor related datas. now i want to pass t_objectdata-ausp1 values for each vendor across the fields in <F_FS>.
    FIELD-SYMBOLS : <F_FS> TYPE TABLE.
    Please refer me the solution to this problem.
    Thanks

    Check below code and try to add in ur code....
        IF NOT it_bom_expl[] IS INITIAL.
    The material number data varies from run to run. For this purpose
    the data is been used to build dynamic internal table which stores the
    material number data along the x-axis
          PERFORM build_matnr_table.
    The material numbers data which is stored in the temp internal table
    is been assigned to the dynamic internal table created along the
    x-axis for the materials
          PERFORM assign_matnr_val_fields.
    The component data which is stored in the internal table needs to be
    moved to the dynamic internal table
          PERFORM move_bom_data_to_matnr_table.
    *&      Form  build_matnr_table
    Using the material number data the dynamic internal tables are been
    built which holds the material number data along x-axis. Here the
    first 3 columns are always constant which are Components-List,
    Description, Count. From 4th column it depends on number of materials
    FORM build_matnr_table .
      DATA: l_val(3) TYPE n,
            lf_mat(18) TYPE c.
    Moving the Components-List details to the internal table 1st column
    which will be used for creation of dynamic internal table
      CLEAR gf_xfc.
      gf_xfc-fieldname = text-t03.
      gf_xfc-datatype = c_val_c.
      gf_xfc-inttype = c_val_c.
      gf_xfc-intlen = 18.
      gf_xfc-decimals = 0.
      APPEND gf_xfc TO gf_ifc.
      APPEND gf_xfc TO gf_ipc.
      CLEAR gf_xfc.
    Moving the Description details to the internal table 2nd column
    which will be used for creation of dynamic internal table
      gf_xfc-fieldname = text-t04.
      gf_xfc-datatype = c_val_c.
      gf_xfc-inttype = c_val_c.
      gf_xfc-intlen = 40.
      gf_xfc-decimals = 0.
      APPEND gf_xfc TO gf_ipc.
      CLEAR gf_xfc.
    Moving the Count details to the internal table 3rd column which will
    be used for creation of dynamic internal table
      gf_xfc-fieldname = text-t05.
      gf_xfc-datatype = c_val_c.
      gf_xfc-inttype = c_val_c.
      gf_xfc-intlen = 5.
      gf_xfc-decimals = 0.
      APPEND gf_xfc TO gf_ifc.
      APPEND gf_xfc TO gf_ipc.
    Moving the Material numbers are moved to the internal table from 4th
    column onwards till all the material numbers are moved to the columns
    which will be used for creation of dynamic internal table. Here
    columns will be reffered to as Material001 ..... Materialxxn
      LOOP AT it_mat.
        CLEAR gf_xfc.
        l_val = l_val + 1.
        CONCATENATE text-t06 l_val INTO lf_mat.
        gf_xfc-fieldname = lf_mat.
        gf_xfc-datatype = c_val_c.
        gf_xfc-inttype = c_val_c.
        gf_xfc-intlen = 18.
        gf_xfc-decimals = 0.
        APPEND gf_xfc TO gf_ifc.
        APPEND gf_xfc TO gf_ipc.
      ENDLOOP.
    Using the above data dynamic internal table is been created
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = gf_ifc
        IMPORTING
          ep_table        = gf_table.
    The dynamic internal table which is created is been assigned to
    field-symbol which holds the data of the columns of X-axis
      ASSIGN gf_table->* TO <fs_dyn_table>.
    Dynamic work area is been created usng the reference to the
    field-symbol which has the data and the line item is been assign to
    field-symbol to hold line item data for reading purposes line by line
      CREATE DATA gf_line LIKE LINE OF <fs_dyn_table>.
      ASSIGN gf_line->* TO <fs_dyn_wa>.
    Using the above data dynamic internal table is been created
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = gf_ipc
        IMPORTING
          ep_table        = gf_table1.
    The dynamic internal table which is created is been assigned to
    field-symbol which holds the data of the columns of X-axis
      ASSIGN gf_table1->* TO <fs_dyn_table1>.
    Dynamic work area is been created usng the reference to the
    field-symbol which has the data and the line item is been assign to
    field-symbol to hold line item data for reading purposes line by line
      CREATE DATA gf_line1 LIKE LINE OF <fs_dyn_table1>.
      ASSIGN gf_line1->* TO <fs_dyn_wa1>.
    Using the above data dynamic internal table is been created
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = gf_ifc
        IMPORTING
          ep_table        = gf_table2.
    The dynamic internal table which is created is been assigned to
    field-symbol which holds the data of the columns of X-axis
      ASSIGN gf_table2->* TO <fs_dyn_table2>.
    Dynamic work area is been created usng the reference to the
    field-symbol which has the data and the line item is been assign to
    field-symbol to hold line item data for reading purposes line by line
      CREATE DATA gf_line2 LIKE LINE OF <fs_dyn_table2>.
      ASSIGN gf_line2->* TO <fs_dyn_wa2>.
    ENDFORM.                    " build_matnr_table
    *&      Form  assign_matnr_val_fields
    The material numbers data stored in the temp internal table needs to
    be assigned to the dynamic internal table along x-axis as the first
    record. The temp internal table is been looped and using the field
    symbol concept the data is moved to the dynamic internal table
    FORM assign_matnr_val_fields .
      DATA: l_cnt(3) TYPE n,
            l_nam(12),
            g_total(3) TYPE n.
      DESCRIBE TABLE it_mat LINES g_total.
      CLEAR l_cnt.
    Looping the temp internal table and concatenating material as
    material001 and the same is been checked against the dynamic
    internal table and the material number value is moved to the
    internal table. Finally, the data is been appened as first record.
      LOOP AT it_mat.
        l_nam = c_mat.
        l_cnt = l_cnt + 1.
        CONCATENATE l_nam l_cnt INTO l_nam.
    Material which is in form Materialxxn is been assigned to the field
    symbol which is checked against the field of dynamic internal table
    and the value of the Material Number is been passed to the dynamic
    internal table field value.
    After all materials are been assigned the record is been appended
    to the dynamic internal table.
        ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa> TO <fs_field>.
        <fs_field> = it_mat-matnr.
        IF l_cnt = g_total.
          INSERT <fs_dyn_wa> INTO TABLE <fs_dyn_table>.
        ENDIF.
      ENDLOOP.
    Looping the temp internal table and concatenating material as
    material001 and the same is been checked against the dynamic
    internal table and the material number value is moved to the
    internal table. Finally, the data is been appened as first record.
    This is been used for downloading of data to excel sheet as it
    contains additional field which is Description field.
      CLEAR l_cnt.
      LOOP AT it_mat.
        l_nam = c_mat.
        l_cnt = l_cnt + 1.
        CONCATENATE l_nam l_cnt INTO l_nam.
    Material which is in form Materialxxn is been assigned to the field
    symbol which is checked against the field of dynamic internal table
    and the value of the Material Number is been passed to the dynamic
    internal table field value.
    After all materials are been assigned the record is been appended
    to the dynamic internal table.
        ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa1> TO <fs_field>.
        <fs_field> = it_mat-matnr.
        IF l_cnt = g_total.
          INSERT <fs_dyn_wa1> INTO TABLE <fs_dyn_table1>.
        ENDIF.
      ENDLOOP.
    The contents of one internal table is passed on to other internal
    table for use while moving the component data for count purposes.
      <fs_dyn_table2>[] = <fs_dyn_table>[].
    ENDFORM.                    " assign_matnr_val_fields
    *&      Form  move_bom_data_to_matnr_table
    The component data is been appended to the dynamic internal table
    The component is checked against a material and if exists the corresp-
    onding level is been appended to the record
    The total count is derived as the in how many materials the component
    exists
    FORM move_bom_data_to_matnr_table .
      DATA: l_cnt(2) TYPE n,
            l_cnt1(3) TYPE n,
            l_nam(12),
            l_con(18) TYPE c,
            l_con1(18) TYPE c,
            lf_mat TYPE matnr.
      SORT it_bom_expl BY bom_comp bom_mat level.
      CLEAR: l_cnt1, <fs_dyn_wa>.
    Looping the component internal table
      LOOP AT it_bom_expl INTO gf_it_bom_expl.
        CLEAR: l_cnt1.
        AT NEW bom_comp.
          CLEAR: l_cnt, <fs_dyn_wa>, lf_mat.
    For every new bom component the material data is moved to
    temp material table which will be used for assigning the levels
    checking the count
          it_mat_temp[] = it_mat[].
    Component data is been assigned to the field symbol which is checked
    against the field of dynamic internal table and the value of the
    component number is been passed to the dynamic internal table field
    value.
          ASSIGN COMPONENT c_comp_list OF STRUCTURE <fs_dyn_wa> TO
          <fs_check>.
          <fs_check> = gf_it_bom_expl-bom_comp.
        ENDAT.
        AT NEW bom_mat.
          CLEAR l_con.
        ENDAT.
        lf_mat = gf_it_bom_expl-bom_mat.
    Looping the temp internal table and looping the dynamic internal table
    *by reading line by line into workarea, the materialxxn is been assigned
    to field symbol which will be checked and used.
        LOOP AT it_mat_temp.
          l_nam = c_mat.
          l_cnt1 = l_cnt1 + 1.
          CONCATENATE l_nam l_cnt1 INTO l_nam.
          LOOP AT <fs_dyn_table2> ASSIGNING <fs_dyn_wa2>.
            ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa2> TO <fs_xy>.
          ENDLOOP.
          IF <fs_xy> = lf_mat.
            CLEAR lf_mat.
            l_con1 = l_con.
          ENDIF.
    Checking whether the material exists for a component and if so it is
    been assigned to the field symbol which is checked against the field
    of dynamic internal table and the level of the component number
    against material is been passed to the dynamic internal table field
    value.
          IF <fs_xy> = gf_it_bom_expl-bom_mat.
            ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
            CLEAR l_con.
            MOVE gf_it_bom_expl-level TO l_con.
            CONCATENATE c_val_l l_con INTO l_con.
            CONDENSE l_con NO-GAPS.
            IF l_con1 NE space.
              CONCATENATE l_con1 l_con INTO l_con SEPARATED BY c_comma.
              CLEAR l_con1.
              l_cnt = l_cnt - 1.
            ENDIF.
            <fs_check> = l_con.
            l_cnt = l_cnt + 1.
          ENDIF.
        ENDLOOP.
        AT END OF bom_comp.
    At end of every new bom component the count is moved to the field
    symbol which is checked against the field of dynamic internal table
    and the count is been passed to the dynamic internal table field
    value.
          ASSIGN COMPONENT c_count OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
          <fs_check> = l_cnt.
          INSERT <fs_dyn_wa> INTO TABLE <fs_dyn_table>.
        ENDAT.
      ENDLOOP.
    Looping the component internal table. This is used for the additional
    Description field which is shown in the excel sheet
      LOOP AT it_bom_expl INTO gf_it_bom_expl.
        CLEAR: l_cnt1.
        AT NEW bom_comp.
          CLEAR: l_cnt, <fs_dyn_wa1>, lf_mat.
    For every new bom component the material data is moved to
    temp material table which will be used for assigning the levels
    checking the count
          it_mat_temp[] = it_mat[].
    Component data is been assigned to the field symbol which is checked
    against the field of dynamic internal table and the value of the
    component number is been passed to the dynamic internal table field
    value.
          ASSIGN COMPONENT c_comp_list OF STRUCTURE <fs_dyn_wa1> TO
          <fs_check>.
          <fs_check> = gf_it_bom_expl-bom_comp.
        ENDAT.
        AT NEW bom_mat.
          CLEAR l_con.
        ENDAT.
        lf_mat = gf_it_bom_expl-bom_mat.
    Looping the temp internal table and looping the dynamic internal table
    *by reading line by line into workarea, the materialxxn is been assigned
    to field symbol which will be checked and used.
        LOOP AT it_mat_temp.
          l_nam = c_mat.
          l_cnt1 = l_cnt1 + 1.
          CONCATENATE l_nam l_cnt1 INTO l_nam.
          LOOP AT <fs_dyn_table2> ASSIGNING <fs_dyn_wa2>.
            ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa2> TO <fs_xy>.
          ENDLOOP.
          IF <fs_xy> = lf_mat.
            CLEAR lf_mat.
            l_con1 = l_con.
          ENDIF.
    Checking whether the material exists for a component and if so it is
    been assigned to the field symbol which is checked against the field
    of dynamic internal table and the level of the component number
    against material is been passed to the dynamic internal table field
    value.
          IF <fs_xy> = gf_it_bom_expl-bom_mat.
            ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa1> TO <fs_check>.
            CLEAR l_con.
            MOVE gf_it_bom_expl-level TO l_con.
            CONCATENATE c_val_l l_con INTO l_con.
            CONDENSE l_con NO-GAPS.
            IF l_con1 NE space.
              CONCATENATE l_con1 l_con INTO l_con SEPARATED BY c_comma.
              CLEAR l_con1.
              l_cnt = l_cnt - 1.
            ENDIF.
            <fs_check> = l_con.
            l_cnt = l_cnt + 1.
          ENDIF.
        ENDLOOP.
    The description is moved to the field symbol which is checked against
    the field of dynamic internal table and the count is been passed to
    the dynamic internal table field value.
        ASSIGN COMPONENT c_description OF STRUCTURE <fs_dyn_wa1> TO
        <fs_check>.
        <fs_check> = gf_it_bom_expl-ojtxp.
    At end of every new bom component the count is moved to the field
    symbol which is checked against the field of dynamic internal table
    and the count is been passed to the dynamic internal table field
    value.
        AT END OF bom_comp.
          ASSIGN COMPONENT c_count OF STRUCTURE <fs_dyn_wa1> TO <fs_check>.
          <fs_check> = l_cnt.
          INSERT <fs_dyn_wa1> INTO TABLE <fs_dyn_table1>.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " move_bom_data_to_matnr_table

  • Determining internal table structure dynamically

    Hi,
    I have a number of internal tables in my program which I declare using types. As an example:
    TYPES: begin of ty_hierarchy,
                   control_id(6)   type c,
                   node_id(10)     type c,
                   node_name       type bezei40,
                   material        type matnr,
                   node_level      type prodh_stuf,
                   node_parent(10) type c,
                end of ty_hierarchy.
    DATA: it_hierarchy type ty_hierarchy occurs 0.
    Further down my program I need to determine the structure of internal table IT_HIERARCHY dynamically. Because I have a number of internal tables, I need to determine which internal table is being processed. Therefore it's important that I know the structure of the table that I'm currently processing.
    I am aware of CL_ABAP* classes and functions like GET_COMPONENT_LIST. However because I have declared my tables using the TYPE statement the method/function cannot read my table structure correctly. If I changed my declaration to be as below, the method/function work! However I don't want to do this as I use field symbols to reference my internal tables and need to use the TYPE statement.
    DATA: begin of ty_hierarchy,
                   control_id(6)   type c,
                   node_id(10)     type c,
                   node_name       type bezei40,
                   material        type matnr,
                   node_level      type prodh_stuf,
                   node_parent(10) type c,
                end of ty_hierarchy.
    DATA: begin of it_hierarchy occurs 0.
                 include structure ty_hierarchy
    DATA: end of it_hierarchy.
    Does anyone know on how I can determine my  internal table structure dynamically but still keeping my internal table declarations using TYPE statement?
    Any help would be greatly appreciated with reward points .....
    Thanks
    Liam

    Hello Liam
    Both the ABAP-OO as well as the FM-based approach described by Eswar work well with your way of defining the itabs. I described three different ways how to get the structure of your itab dynamically:
    - directly using the itab
    - using a field symbol
    - using a data reference
    REPORT  zus_sdn_dynamic_itabs.
    TYPE-POOLS: abap.
    TYPES: BEGIN OF ty_hierarchy,
    control_id(6) TYPE c,
    node_id(10) TYPE c,
    node_name TYPE bezei40,
    material TYPE matnr,
    node_level TYPE prodh_stuf,
    node_parent(10) TYPE c,
    END OF ty_hierarchy.
    DATA:
      gs_hierarchy    TYPE ty_hierarchy,
      it_hierarchy    TYPE ty_hierarchy OCCURS 0.
    DATA:
      gt_comp         TYPE abap_compdescr_tab,
      gs_comp_a       LIKE LINE OF gt_comp,
      gd_type         TYPE abap_typekind,
      gs_comp    TYPE rstrucinfo,
      it_comp TYPE TABLE OF rstrucinfo.
    DATA:
      go_struct    TYPE REF TO cl_abap_structdescr,
      go_table     TYPE REF TO cl_abap_tabledescr,
      gdo_data     TYPE REF TO data.
    FIELD-SYMBOLS:
      <gt_itab>    TYPE table.
    START-OF-SELECTION.
      GET REFERENCE OF it_hierarchy INTO gdo_data.
      ASSIGN gdo_data->* TO <gt_itab>.
    * (1) Describe directly by using the itab
    *  go_table  ?= cl_abap_structdescr=>describe_by_data( it_hierarchy ).
    * (2) Describe indirectly by using field symbol
    *  go_table  ?= cl_abap_structdescr=>describe_by_data( <gt_itab> ).
    * (3) Describe by data reference to itab
      go_table  ?= cl_abap_structdescr=>describe_by_data_ref( gdo_data ).
      go_struct ?= go_table->get_table_line_type( ).
      WRITE: / 'ABAP-OO Version:'.
      gt_comp = go_struct->components.
      LOOP AT gt_comp INTO gs_comp_a.
        WRITE: / gs_comp_a-name,
                 gs_comp_a-length,
                 gs_comp_a-type_kind,
                 gs_comp_a-decimals.
      ENDLOOP.
      SKIP 2.
      CALL FUNCTION 'GET_COMPONENT_LIST'
        EXPORTING
          program    = sy-repid
          fieldname  = 'GS_HIERARCHY'
        TABLES
          components = it_comp.
      WRITE: / 'Function Module Version:'.
      LOOP AT it_comp INTO gs_comp.
        WRITE: / gs_comp-compname,
                 gs_comp-level,
                 gs_comp-leng,
                 gs_comp-type,
                 gs_comp-olen,
                 gs_comp-decs.
      ENDLOOP.
    END-OF-SELECTION.
    Regards
      Uwe

  • How to access internal table data from webdynpro to Flex application.

    Hi Connoisseur
    The data transfer from Abap WebDeypro to flex island works well. I followed , there is an example from Thomas Jung (by the way as always Great Work) and  Karthikeyan Venkatesan (Infosys) but this example covers simple type only.
    There is no example with complex types like arrayCollection which handle the transfer of data from flex to WebDynpro.
    i tried to do pass internal table value  to flex-datagrid.but its not work.
    i would like to know
    1.how to access internal table data from webdynpro to Flex application.
    2.how to pass the internal table to flex-datagrid.
    2.how to pass dynamically in ADOBE flex.
    3. how to do Flex is receiving the wd context data?
    4. how can we update WD context with FLEX data.
    Ple give me sample example and step by step procedure.
    Regards
    laxmikanth

    Hi Laxmikanth,
    Please refer this...
    Flash island: update complex type from flex
    Cheers..
    kris.

  • Sum function for internal table column

    Dear Experts,
    how can I sum a complete internal table column.
    Regards
    ertas

    Hi,
    Use SUM in AT END of event in the loop of an internal table.
    Example
    Loop at ITAB into wa_itab.
    at end of wa_itab-field.
    sum.  " Here all numric fields will be summed and stored in that filed(wa_itab-field)
    endat.
    Endloop.
    Regards
    Krishna

  • Data allocation for internal table rows Dynamically

    Hi Friends
    I have requirement like below:
    I have one internal table with 400 amounts columns, I will get the value from another program
    that indicates to which column I have to add the values. I dont want to write the case statement
    because I need to write 400 WHEN statements.
    Is there any alternative way dynamically I can choose the internal table column and assign the value which
    I am getting from external program.
    Please help on this as soon as possible.
    Points will be rewarded
    Thanks
    Praveen

    Hi Praveen,
    you may use the ASSIGN COMPONENT ... OF STRUCTURE ... statement.
    It allows to assign the field by name or by sequence.
    Assume you columns have names like amount_001 to amount_999 and are fields of structure ls_amounts. The do as decribed here roughly:
    data:
      lv_fieldseq type NUMC_3,
      lv_fieldname type fieldname,
      lv_amount type (???).
    fieldsymbols:
      <amount> type any.
    * fetch amount and field sequence from external data into  lv_amount and lv_fieldseq
    concatenate 'AMOUNT_' lv_fieldseq into lv_fieldname.
    * <amount> is something like a pointer
    assign component (lv_fieldname) of structure ls_amounts to <amount>.
    add lv_amount  to <amount>. 
    if you are sure you have the correct position of the amount field in the structure stored in variable lv_position, you may use
    assign component lv_position of structure ls_amounts to <amount>.
    I prefer the ASSIGN (fieldname) for reasons of more transparency and less danger in case of structural changes.
    Regards,
    Clemens
    Regards,
    Clemens

  • Internal table with Dynamic and Non dynamic fileds

    Hi Experts,
    How to get the internal table with Dynamic and Non-Dynamic Fields.
    Could u please help me.
    Thanks,
    Varun

    Hi,
       Execute the below sample code or analyze it there is appropriate description provided.
    *& Report  ZTEST_PRM_DYN_ALV
    REPORT  ZTEST_PRM_DYN_ALV.
    type-pools: slis.
    field-symbols: <dyn_table> type standard table,
    <dyn_wa>.
    data: alv_fldcat type slis_t_fieldcat_alv,
    it_fldcat type lvc_t_fcat.
    selection-screen begin of block b1 with frame title text-001.
    parameters: p_flds(5) type c.
    selection-screen end of block b1.
    start-of-selection.
    *build the dynamic internal table
    perform build_dyn_itab.
    *write 5 records to the alv grid
    do 5 times.
    perform build_report.
    enddo.
    *call the alv grid.
    perform call_alv.
    *Build_dyn_itab
    form build_dyn_itab.
    data: new_table type ref to data,
    new_line type ref to data,
    wa_it_fldcat type lvc_s_fcat.
    *Create fields .
    clear wa_it_fldcat.
    wa_it_fldcat-fieldname = 'name1'.
    wa_it_fldcat-datatype = 'mara-matnr'.
    wa_it_fldcat-intlen = 5.
    append wa_it_fldcat to it_fldcat .
    *clear wa_it_fldcat.
    wa_it_fldcat-fieldname = sy-index.
    wa_it_fldcat-datatype = 'CHAR'.
    wa_it_fldcat-intlen = 5.
    append wa_it_fldcat to it_fldcat .
    do p_flds times.
    clear wa_it_fldcat.
    wa_it_fldcat-fieldname = sy-index.
    wa_it_fldcat-datatype = 'CHAR'.
    wa_it_fldcat-intlen = 6.
    append wa_it_fldcat to it_fldcat .
    enddo.
    *Create dynamic internal table and assign to FS
    call method cl_alv_table_create=>create_dynamic_table
    exporting
    it_fieldcatalog = it_fldcat
    importing
    ep_table = new_table.
    assign new_table->* to <dyn_table>.
    *Create dynamic work area and assign to FS
    create data new_line like line of <dyn_table>.
    assign new_line->* to <dyn_wa>.
    endform.
    *Form build_report
    form build_report.
    data: fieldname(20) type c.
    data: fieldvalue(5) type c.
    data: index(3) type c.
    field-symbols: <fs1>.
    do p_flds times.
    index = sy-index.
    *Set up fieldvalue
    concatenate 'FLD' index into
    fieldvalue.
    condense fieldvalue no-gaps.
    assign component index of structure <dyn_wa> to <fs1>.
    <fs1> = fieldvalue.
    enddo.
    *Append to the dynamic internal table
    append <dyn_wa> to <dyn_table>.
    endform.
    *CALL_ALV
    form call_alv.
    data: wa_cat like line of alv_fldcat.
    *clear wa_cat.
    wa_cat-fieldname = 'matnr'.
    wa_cat-seltext_s = sy-index.
    wa_cat-outputlen = '10'.
    append wa_cat to alv_fldcat.
    do p_flds times.
    clear wa_cat.
    wa_cat-fieldname = sy-index.
    wa_cat-seltext_s = sy-index.
    wa_cat-outputlen = '6'.
    append wa_cat to alv_fldcat.
    enddo.
    *Call ABAP List Viewer (ALV)
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    it_fieldcat = alv_fldcat
    tables
    t_outtab = <dyn_table>.
    endform.
    Hope this will help, reward if found usefull.
    Cheers,
    Ram.

Maybe you are looking for

  • Need Help about Certificate based Authentication

    Hi friends.. Currently, i'm trying to develop an applet that using Certificate Based Authentication.. i have looked at this thread : http://forums.sun.com/thread.jspa?threadID=5433603 these is what Safarmer says about steps to generate CSR : 0. Gener

  • Color 1.0.2 and QT 7.4

    I've read that QuickTime 7.4 works best with Color 1.0.2 and QuickTime 7.5 causes problems. If you're running FCP 6.0.3 or 6.0.4, how is it possible to run 7.4 QT with FCP? You can't right?

  • Set cursor on error field in selection screen

    Hi ALL, How to place the cursor on a particular selection screen field?I am doing validation if validation fails for a particular field the program should give error mesg and the cursor should place on the error field only but it's going to the Ist f

  • Can't convert .DV to any format in Quicktime

    Hi! I've recently created a movie project in iMovie and exported it to Quicktime, for it to keep it's full resolution. The problem is... the file measures about 1.09 Gb, for a 5:49 movie. I want to convert it to .avi to reduce it's size, maintain qua

  • IPhone sometimes won't delete all the photos after I import into iPhoto

    Every so often, my iPhone 3GS won't delete some photos after importing into iPhoto and choosing "delete originals." It deletes most of the originals but strangely keeps a certain number around. My basic routine is to "Import All" and then "Delete Ori