ABAP dynamic tables add fields

Hi, i have to extend a dynamic table like this:
FIELD-SYMBOLS: <g_data> TYPE table.
I have to build a custom structure with all the fields
of g_data plus some other fixed fields.
In other words if g_data looks like this
AUFNR POSNR
100   10
200   20
My structure must be:
AUFNR POSNR F1  F2
100   10    23  21
200   20    234 32
Thanks in advance.
Is anybody here who haves some ideas

Here is a sample program of how to build a dynamic internal table.
report zrich_0003
       no standard page heading.
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_check type c.
selection-screen end of block b1.
start-of-selection.
  perform build_dyn_itab.
  perform build_report.
  loop at <dyn_table> into <dyn_wa>.
    write:/ <dyn_wa>.
  endloop.
*  Build_dyn_itab
form build_dyn_itab.
  data: index(3) type c.
  data: new_table type ref to data,
        new_line  type ref to data,
        wa_it_fldcat type lvc_s_fcat.
  clear wa_it_fldcat.
  wa_it_fldcat-fieldname  = 'AUFNR'.
  wa_it_fldcat-datatype = 'CHAR'.
  wa_it_fldcat-intlen = 12.
  append wa_it_fldcat to it_fldcat .
  clear wa_it_fldcat.
  wa_it_fldcat-fieldname  = 'POSNR'.
  wa_it_fldcat-datatype = 'CHAR'.
  wa_it_fldcat-intlen = 6.
  append wa_it_fldcat to it_fldcat .
* Create fields
  clear index.
  do 2 times.
    index = sy-index.
    clear wa_it_fldcat.
    concatenate 'Field' index into
             wa_it_fldcat-fieldname .
    condense  wa_it_fldcat-fieldname no-gaps.
    wa_it_fldcat-datatype = 'CHAR'.
    wa_it_fldcat-intlen = 5.
    append wa_it_fldcat to it_fldcat .
  enddo.
* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=>create_dynamic_table
               exporting
                  it_fieldcatalog = it_fldcat
               importing
                  ep_table        = new_table.
  assign new_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
  create data new_line like line of <dyn_table>.
  assign new_line->* to <dyn_wa>.
endform.
*      Form  build_report
form build_report.
  data: fieldname(20) type c.
  data: fieldvalue(5) type c.
  data: index(3) type c.
  field-symbols: <fs1>.
  assign component  'AUFNR'  of structure <dyn_wa> to <fs1>.
  <fs1> =  '123456789'.
  assign component  'POSNR'  of structure <dyn_wa> to <fs1>.
  <fs1> =  '000001'.
  do 2 times.
    index = sy-index.
* Set up fieldname
    concatenate 'FIELD' index into
             fieldname .
    condense   fieldname  no-gaps.
* Set up fieldvalue
    concatenate 'FLD' index into
             fieldvalue.
    condense   fieldvalue no-gaps.
    assign component  fieldname  of structure <dyn_wa> to <fs1>.
    <fs1> =  fieldvalue.
  enddo.
* Append to the dynamic internal table
  append <dyn_wa> to <dyn_table>.
endform.
Regards,
Rich Heilman
Message was edited by: Rich Heilman
I have modified the sample to include your requirement

Similar Messages

  • Sum for Dynamic Fields in a Dynamic Table with Field Symbol

    Hi All,
    I currently have an report which I am looking to update with some totals.  The information is currently output in an ALV which is fed data from a dynamic table defined with a field symbol.  The modification that needs to be applied is a summation per currency code where each of the fields to be summed is a dynamically named field at runtime.  I am now just looking to see if anyone has any recommendations on how to obtain these totals it would be appreciated.  I have no problem doing the leg work in piecing the solution together but am just stuck on which approach I should be investigating here.  I have looked into several options but do to the fact that the totals are for dynamic fields in a dynamic table and it is a field symbol I am having some difficulties thinking of the easiest approach to obtain these totals.
    Below is a simple sample of what the report currently looks like and what we are looking to add.
    ====================================================================================
    As-Is Report:
    DETAILED DATA ALV
    Company Code  |  Plant  |  2006 Total  |  2007 Total  |  2008 Total |  CURRENCY
    0001          |   ABCD  |    1,500     |    1,200     |    1,700    |    USD
    0001          |   BCDE   |    2,300     |    4,100     |    3,600    |    GBP
    0003          |   DBCA  |    3,200     |    1,600     |    6,200    |    USD
    Addition 1:
    TOTALS PER CURRENCY
    Currency                |  2006 Total  |  2007 Total  |  2008 Total |
    USD              |    4,700     |    2,800     |    7,900    |
    GBP                       |    2,300     |    4,100     |    3,600    |
    Addition 2:
    CONVERSIONS TO USD
                                          |  2006 Curr   |  2006 USD    |  2008 Curr   |  2006 USD   |
    USD                       |  4,700 USD   |  4,700 USD   |  7,900 USD  |  7,900 USD  |
    GBP   (1.5GBP/1 USD)    |  2,300 GBP   |  1,150 USD   |  2,300 GBP  |  1,800 USD  |
    ====================================================================================
    Any recommendations will be appreciated.

    Hi,
    We cannot use the key word SUM in the loop at assigning statement.
    The way i see is
    When  you are creating the first dynamic internal table , create one more with  the structure below:
    Currency | 2006 Total | 2007 Total | 2008 Total |
    Then while populating the data into first itab,also move the contents to the second itab using collect statement.

  • Dynamic table with field type table

    Hi,
    I´m using "cl_alv_table_create=>create_dynamic_table" to create a dynamic table for ALV Grid.
    But...I need to use colors in ALV, then I need to declare a field type LVC_S_SCOL in dynamic table from "cl_alv_table_create=>create_dynamic_table".
    How can I declare this in fieldcat?
    The code:
    Creating dynamic table
    DATA: table_agrup TYPE REF TO data,
            line_agrup  TYPE REF TO data.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = t_fieldcat
        IMPORTING
          ep_table                  = table_agrup
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
        ASSIGN table_agrup->* TO .
    Printing ALV
      CALL METHOD obj_grid->set_table_for_first_display
        EXPORTING
          is_variant                    = w_variant
          i_save                        = 'A'
          is_layout                     = w_layout
        CHANGING
          it_outtab                     =
          it_fieldcatalog               = t_fieldcat
          it_sort                       = t_sort
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
    Thanks.

    It is not possible with the  METHOD cl_alv_table_create=>create_dynamic_table to include another table inside that newly generated table.
    I have tried to do it with the code and I got the dynamic table created after at the end of the program.
    In the code,
    <DYN_TABLE> has same effect as your <table> variable
    <DYN_WA> has same effect as your <HEADER>
    REPORT  ZTEST_NP_DYNAMIC.
    DATA: DY_TABLE TYPE REF TO DATA,
          DY_LINE  TYPE REF TO DATA.
    FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
                   <DYN_WA>,
                   <DYN_FIELD>.
    FIELD-SYMBOLS: <FS> TYPE ANY.
    * To generate the Dyanmic table with the COLOR
    DATA: LS_SOURCE TYPE STRING.
    DATA: LT_SOURCE LIKE STANDARD TABLE OF LS_SOURCE WITH HEADER LINE.
    DATA: L_NAME LIKE SY-REPID.
    DATA: L_MESSAGE(240) TYPE C,
          L_LINE TYPE I,
          L_WORD(72) TYPE C.
    DATA: L_FORM(30) TYPE C VALUE 'TABLE_CREATE'.
    LT_SOURCE = 'REPORT ZTEST_SUBROUTINE_POOL.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'FORM  TABLE_CREATE USING I_FS TYPE ANY.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: BEGIN OF LT_GENTAB OCCURS 0.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: BUKRS TYPE BUKRS. '.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: BKTXT TYPE BKTXT. '.
    APPEND LT_SOURCE.
    * you can add your fields here.....
    LT_SOURCE = 'DATA: COLOR TYPE lvc_t_scol. '.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: END OF LT_GENTAB.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: POINTER TYPE REF TO DATA.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'CREATE DATA POINTER LIKE STANDARD TABLE OF LT_GENTAB.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'I_FS = POINTER.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'ENDFORM. '.
    APPEND LT_SOURCE.
    L_NAME = 'ZTEST_SUBROUTINE_POOL'.
    CATCH SYSTEM-EXCEPTIONS GENERATE_SUBPOOL_DIR_FULL = 9.
      GENERATE SUBROUTINE POOL LT_SOURCE NAME L_NAME
               MESSAGE L_MESSAGE LINE L_LINE WORD L_WORD.  "#EC CI_GENERATE
    ENDCATCH.
    IF NOT L_MESSAGE IS INITIAL.
      MESSAGE E000(0K) WITH L_MESSAGE L_LINE L_WORD.
    ENDIF.
    ASSIGN DY_TABLE TO <FS>.
    PERFORM (L_FORM) IN PROGRAM (L_NAME) USING <FS>.
    ASSIGN DY_TABLE->* TO <DYN_TABLE>.
    * Create dynamic work area and assign to FS
    CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>.
    ASSIGN DY_LINE->* TO <DYN_WA>.
    Write: 'bye'.
    Regards,
    Naimesh Patel

  • Dynamic table - some fields of different rows in one column

    Hey guys,
    i have the following problem:
    i habe a itab with some data like:
    name | id | date | number
    pete  | 1 | 27.07 |    2
    pete  | 1 | 28.07 |    2
    pete  | 1 | 30.07 |    2
    ann   | 1 | 28.07 |    3
    ann   | 2 | 30.07 |    2
    the user can define a period of time, e.g. 28-29.07
    so my dynamic table will consist of the "hard" columns name and id and the dynamic added columns for every day:
    name | id | 28.07 | 29.07
    that's what i already have!
    so my problem is, that i have to read the data from the itab into the new dynamic table (field-symbol) like:
    name | id | 28.07 | 29.07
    pete   |  1 |    2     |    2
    ann    |  1 |    3     |    -
    i hope you can understand what i want! please give me code sample or a example report!
    many thanks in adance!
    best regards,
    ludwig

    hey Asik, you have understand what i want!
    here is my table:
    http://img181.imageshack.us/my.php?image=wh20080916113004ym8.png
    after the loop, the 4 rows should be in my field-symbol only one row (no sum)!
    but after the loop, there are to many rows! only one row is needed!
    Look at the screenshot:
    http://img185.imageshack.us/my.php?image=wh20080916113547wl0.png
    So the second row at column "tag20080801" should be initial and with the next loop, the next day "tag20080730" should be filled with the number!
    LOOP AT LT_OUT INTO LS_OUT.
      ASSIGN COMPONENT 'RESSOURCEN' OF STRUCTURE <FS_LINE> TO <fs_field>.
      <fs_field> = 'Ressource'.
      ASSIGN COMPONENT 'NAME' OF STRUCTURE <FS_LINE> TO <fs_field>.
      <fs_field> = LS_OUT-name.
      ASSIGN COMPONENT 'PROJEKT' OF STRUCTURE <FS_LINE> TO <fs_field>.
      <fs_field> = LS_OUT-PROJECTID.
      CONCATENATE 'DATE' LS_OUT-DATE INTO LF_DATE_COL.
      ASSIGN COMPONENT LF_DATE_COL OF STRUCTURE <FS_LINE> TO <fs_field>.
      <fs_field> = LS_OUT-COUNT.
      COLLECT <FS_LINE> INTO <FS_TABLE>.
    ENDLOOP.
    the right output data should look like this:
    Ressourcen | Ludwig Heinz | 20080702LHZ  | 4 | 4 | 4 | 1

  • ADF Query Panel with Tree Table -- Add Fields

    I created ADF Query Panel with Tree Table using JDeveloper 11G. Under Advance Search, Add Fields pull down only list the fields in the master table. My questions are,
    1) Can I search fields in detail table? If yes, how can I do it?
    2) How can I customized this pull down list? Currently it just show the entire view of master table with unnecessary id type data.
    Thanks in advance.
    Edited by: kxc on Nov 9, 2009 9:21 AM

    1) Can I search fields in detail table? If yes, how can I do it?
    Are there anyway to search the second level node?You can. But you need to evaluate if the arrangement works for you.
    I assume you have a view link from the master to detail VO.
    To do so, in your master view criteria (the one which you use in the query panel), shuttle the attributes of your detail VO (in master attributes list, you'l see the detail view link accessor - on selecting this, the detail atteributes are available to you)
    In the Add Fields, it shows as student_id AND student_name. I was unable to delete the student_id field in the view since it is PKYou can set its 'display' UI hint to 'hide' in your VO.

  • Dynamic Table Input Field - Disabled in runtime

    Hi,
    I have dynamically created a node. The node as a string attribute X.
    Then dynamically created a IWDTable to bind to the node.
    In the table I have a column, then a tablecelleditor of inputfield.
    The inputfield 'value' is binded to node->X attribute info.
    inputField.bindValue(attributeInfo).
    Then I created a few entries of the node, populating X with some dummy value.
    In runtime, my inputfields are disabled, and the dummy values don't appear.
    I believe it is something to do with my binding.
    Then I replaced the inputfield with a textview. textview text is binded to the node->X
    attribute info.
    textview.bindText(attributeInfo)
    (i.e. exact same attribute info I used for the inputfield)
    In runtime I see my textview with the dummy values.
    Can anyone point me in the right direction?
    Cheers,
    Michael.

    Hi Guys,
    I think to be clear I better include my code here.
    I did bind the table to the nodeInfo, and I did bind the textView/inputfield to the particular attribute.
    As mentioned before, it does show for the textView, but not for the inputfield.
    Create the new node:
              IWDNodeInfo newNode = wdContext.getNodeInfo().getChild("nodeName");
                   newNode =
                        wdContext.getNodeInfo().addChild(
                             "nodeName",
                             null,
                             true,
                             true,
                             true,
                             false,
                             false,
                             true,
                             null,
                             null,
                             null);
    Create the attribute:
                   IWDAttributeInfo detailAttribute =
                        newNode.addAttribute(
                             "xyz",
                             "ddic:com.sap.dictionary.string");
    Get the node
                             IWDNode specificNode =
                                  wdContext.getChildNode(
                                       "nodeName",
                                       0);
    Create the element from the node
                             newElement =
                                       specificNode.createElement();
    Set the attribute value:
                                  newElement.setAttributeValue(
                                       "xyz",
                                       "1234");
    Add the new element:
                                  specificNode.addElement(newElement);
    Create the table now:
                   IWDTable someTable =
                        (IWDTable) view.createElement(
                             IWDTable.class,
                             "TAB_ArticleQty" + articleElement.getArticleId());
                   someTable.setEnabled(true);
                   someTable.setReadOnly(false);
                   someTable.setRowSelectable(true);
                   someTable.setFooterVisible(false);
                   someTable.setSelectionMode(WDTableSelectionMode.NONE);
                   someTable.setVisibleRowCount(-1);
                   someTable.bindDataSource(
                   specificNode.getNodeInfo());
                   TC.addChild(someTable);
    Loop at all the attributes and create the column
    The code for the textView has been commented out
    The code is now for the input field
                    * LOOP AT ALL THE ATTRIBUTES IN THE NODE:
                    * CREATE ONE COLUMN FOR EACH ATTRIBUTE
                   Iterator allAttributes =
                   specificNode.getNodeInfo().iterateAttributes();
                   while (allAttributes.hasNext()) {
                        IWDAttributeInfo attrInfo =
                             (IWDAttributeInfo) allAttributes.next();
                        String attrName = attrInfo.getName();
                                  // Text View
                                  IWDTextView TV_info =
                                       (IWDTextView) view.createElement(
                                            IWDTextView.class,
                                            "TV_AQ_"
                                                 + counter
                                                 + attrName);
                                  TV_info.bindText(attrInfo);
                                  COL_qty.setTableCellEditor(TV_info);
                                  //input field for the user to enter the value
                                  IWDInputField input_Qty =
                                       (IWDInputField) view.createElement(
                                            IWDInputField.class,
                                            "input_Qty"
                                                 + counter
                                                 + attrName);
                                  input_Qty.setEnabled(true);
                                  input_Qty.bindValue(attrInfo);
                                  input_Qty.setWidth("4");
                                  COL_qty.setTableCellEditor(input_Qty);
                             someTab.addColumn(COL_qty);

  • Dynamic Table - Add rows and columns in same table

    Hi there,
    I wonder if someone could help please? I'm trying to create and table where a user can add both rows and columns (preferably with separate buttons) but am having trouble trying to figure out how to do this. Is it possible? If so how? I'm not familar with script but have found examples of seprate tables where you can add a row and then another table where you can add columns and essentailly want to merge the two but cannot make it work.
    Any help much appreciated!
    Thanks,
    Ken

    It is great example....you can learn the concepts there and apply....however you may have to think twice before you implement column adding dynamically....because the technique here is make copy of what we already have and reproduce it as a new item and this technique works great for rows as they all have every thing in common. But when it comes to columns it may have unique visible identity as column head and displaying repeatedly the same column head may not look good. Of-Course you can do few extra lines of code and change the column appearance based on users input each time. Situations where users need to add additional column is very unlikely (sure your requirement might be an exception).
    Key in allowing adding/removing instances is managing design mode settings under Object>>Binding>>....and select the checkbox "Repeat <subform/row/...> for Each Data Item" and then set Min, Max and Initial count values.
    Also you need to club your effots by using simple scipt with button clicks....
    for the example refered in URL you posted following is what I did to make the first table allow Adding/Removing Rows....
    1. Opened the form in LC designer.
    2. Add two buttons AddRow & RemoveRow right next to RemoveColumn
    3. For AddRow I used following JS code....
          Table1._Row1.addInstance(1);//that means any time this button is clicked a new instance of Row1 is added use _Row2 or Row3 based on your needs
          var fVersion = new Number(xfa.host.version); // this will be a floating point number like "7.05"
          if (fVersion < 8.0) // do this for Acrobat versions earlier than 8.0
           // make sure that the new instance is properly rendered
           xfa.layout.relayout();
    4.  For RemoveRow I used following JS code....
         Table1._Row1.removeInstance(1);//Syntax is...<objectReference>.removeInstance(<index of the repeating object that needs to be removed>); //in this case since we used 1 alwasys second object from top gets deleted.
          var fVersion = new Number(xfa.host.version); // this will be a floating point number like "7.05"
          if (fVersion < 8.0) // do this for Acrobat versions earlier than 8.0
           // make sure that the new instance is properly rendered
           xfa.layout.relayout();
    5. Now time to update settings at Object>>Binding tab and set "Repeat......" and also set Min, Max and Initial count as explained above.
         Those settings needs to be updated for Row1 (or your choice of row) of the table
    6. Set the Height to Expand of the Subform, where the table is housed....  this is done under Layout pallet
    7. Save the PDF as dynamic template and verify the results...
    If you still run into issues I can send you copy that works on my machine, but you need send me an email at n_varma(AT)lycos.com
    Good luck,

  • ABAP - Dynamic Table in Smart Form

    Dear All,
                 Can i assign a table at run time mens table rows and column will depend on user selection and no. of records fetched by query.  Is there any utility.
    Plz let me know ASAP if there is any. Looking forward to your co-operation.
    Thanks & Regards,
    Gulrez Alam

    Dear All,
                 At the time of table creation in Smart Form, we had to assign no. of columns and its width.
    In the case when no. of coulumns will be decided by the no of records return from the query. how can i link smart form with that records.
    No. of coulms in the smart form will be decided on the i/p no. given by the user. it can be any no.
    Plz suggest me the appropriate things.
    Is it possible or not in the smart forms.
    Thanks in Advance
    Gulrez Alam

  • Internal table to field symbol

    hi all,
    type-pools : abap.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: dy_table type ref to data,
    dy_line type ref to data,
    xfc type lvc_s_fcat,
    ifc type lvc_t_fcat.
    *data : dyn_itab2 type ANY table.
    selection-screen begin of block b1 with frame.
    parameters: p_table(30) type c.
    selection-screen end of block b1.
    start-of-selection.
    BREAK-POINT.
    perform get_structure.
    perform create_dynamic_itab.
    perform get_data.
    PERFORM OUTPUT.
    *perform write_out.
    form get_structure.
    data : idetails type abap_compdescr_tab,
    xdetails type abap_compdescr.
    data : ref_table_des type ref to cl_abap_structdescr.
    Get the structure of the table.
    ref_table_des ?=
    cl_abap_typedescr=>describe_by_name( p_table ).
    idetails = ref_table_des->components.
    *idetails] = ref_table_des->components[.
    loop at idetails into xdetails.
    clear xfc.
    xfc-fieldname = xdetails-name .
    xfc-datatype = xdetails-type_kind.
    xfc-inttype = xdetails-type_kind.
    xfc-intlen = xdetails-length.
    xfc-decimals = xdetails-decimals.
    append xfc to ifc.
    endloop.
    endform.
    form create_dynamic_itab.
    Create dynamic internal table and assign to FS
    call method cl_alv_table_create=>create_dynamic_table
    exporting
    it_fieldcatalog = ifc
    importing
    ep_table = dy_table.
    here i want  to assighn the structure of dy_table to internal atble.
    assign dy_table->* to <dyn_table>.
    Create dynamic work area and assign to FS
    create data dy_line like line of <dyn_table>.
    assign dy_line->* to <dyn_wa>.
    endform.
    form get_data.
    Select Data from table.
    select * into table <dyN_table> UP TO 10 ROWS
    from (p_table).
    endform.
    Write out data from table.
    FORM OUTPUT.
    loop at <dyn_table> into <dyn_wa>.
    do.
    assign component sy-index
    of structure <dyn_wa> to <dyn_field>.
    if sy-subrc = 0.
    exit.
    endif.
    if sy-index = 1.
    write:/ <dyn_field>.
    else.
    write: <dyn_field>.
    endif.
    enddo.
    endloop.
    ENDFORM.
    how can i achieve this one.
    regards
    siva

    Hi,
    Check this Code ...
    LOOP AT <dyn_table> INTO <dyn_wa>.
        DO.
          ASSIGN COMPONENT sy-index
          OF STRUCTURE <dyn_wa> TO <fs_field> .
          IF sy-subrc NE 0.
            EXIT.
          ENDIF.
          IF sy-index = 1.
            WRITE:/ <fs_field>.
          ELSE.
            WRITE: <fs_field>.
          ENDIF.
        ENDDO.
      ENDLOOP.
    For reference check below code
    DATA: it_fieldcat        TYPE lvc_t_fcat                         . " Field catalog
    DATA: wa_fieldcat  LIKE LINE OF it_fieldcat. " Field catalog
    DATA: it_dyn_table      TYPE REF TO data,     " Dynamic table
          it_wa_dyn_table   TYPE REF TO data.     " Dynamic table
    *       Field sysmbols           Begin with <fs>                      *
    FIELD-SYMBOLS:  <fs_dyn_table>       TYPE STANDARD TABLE, " Dynamic tbale
                    <fs_dyn_table_temp>  TYPE ANY           , " Dynamic tbale
                    <fs_field>           TYPE ANY           , " Temp field for data assignment
                    <fs_field_temp>      TYPE ANY           . " Temp field for data assignment
    *       Macro                                                         *
    * Macro Defination
    * Building field catalog using macro defination
    DEFINE m_fieldcat.
      wa_fieldcat-fieldname   = &1.
      wa_fieldcat-scrtext_l   = &2.
      wa_fieldcat-coltext     = &2.
      wa_fieldcat-no_zero     = &3.
      wa_fieldcat-hotspot     = &4.
      wa_fieldcat-outputlen   = &5.
      wa_fieldcat-emphasize   = &6.
    * Appending workarea to internal table
      append wa_fieldcat to it_fieldcat.
      clear wa_fieldcat.
    END-OF-DEFINITION.
    *&      Form  f005_prepare_field_catalog
    *       text
    form f005_prepare_field_catalog .
      REFRESH: it_fieldcat.
    * Build the field catalog
      m_fieldcat text-007 text-008 c_blank  c_blank c_30 c_blank.
      m_fieldcat text-009 text-010 c_blank  c_blank c_30 c_blank.
      SORT it_final_temp BY equnr point.
      SORT it_final BY equnr point psort idate.
      w_date1 = so_date-low.
    * Loop to generate grid column at run time
    * Loop - Till the lower date not equal to higer date
      WHILE so_date-high GE w_date1.
    * Changing date into actual date format using edit mask
        WRITE w_date1 TO w_var4 USING EDIT MASK '__-__-____'.
        m_fieldcat w_var4 w_var4 c_flag c_blank c_12 c_blank.
        w_date1 = w_date1 + c_count.
        CLEAR w_var4.
      ENDWHILE.
    *&      Form  f007_create_dynamic_table
    *       text: Create dynamic table
    form f007_create_dynamic_table .
    * Call method to create dynamic internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = it_fieldcat
        IMPORTING
          ep_table                  = it_dyn_table
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      SORT it_final_temp BY equnr point.
      SORT it_final BY equnr point psort idate.
      ASSIGN it_dyn_table->* TO <fs_dyn_table>.
      CREATE DATA it_wa_dyn_table LIKE LINE OF <fs_dyn_table>.
      ASSIGN it_wa_dyn_table->* TO <fs_dyn_table_temp>.
      IF it_final_temp IS NOT INITIAL.
        LOOP AT it_final_temp INTO wa_final_temp.
    * Assign equipment number and it's field data to field symbols (Dynamic table)
    * Assign field name to field symbol
          ASSIGN text-007 TO <fs_field_temp>.
    * Assign component name and it's value to dynamic table
          ASSIGN COMPONENT <fs_field_temp> OF STRUCTURE <fs_dyn_table_temp> TO <fs_field>.
    * Assign equipment number value to field symbol
          <fs_field> = wa_final_temp-equnr.
    * Assign Short Description and it's field data to field symbols (Dynamic table)
    * Assign field name to field symbol
          ASSIGN text-009 TO <fs_field_temp>.
    * Assign component name and it's value to dynamic table
          ASSIGN COMPONENT <fs_field_temp> OF STRUCTURE <fs_dyn_table_temp> TO <fs_field>.
    * Assign short description value to field symbol
          <fs_field> = wa_final_temp-psort.
    * Loop to assign value of run time generated column.
          IF it_final IS NOT INITIAL.
            LOOP AT it_final INTO wa_final WHERE equnr = wa_final_temp-equnr
                                            AND point = wa_final_temp-point.
              w_date1 = wa_final-idate.
              WRITE w_date1 TO w_var4 USING EDIT MASK '__-__-____'.
              ASSIGN w_var4 TO <fs_field_temp>.
              ASSIGN COMPONENT <fs_field_temp> OF STRUCTURE <fs_dyn_table_temp> TO <fs_field>.
              <fs_field> = wa_final-cdiff.
              CLEAR: wa_final, w_var4, w_date1.
            ENDLOOP.
          ENDIF.
          CLEAR: wa_final_temp.
    * Assign field symbol temporary table to final dynamic table
          APPEND <fs_dyn_table_temp> TO <fs_dyn_table>.
          CLEAR: <fs_dyn_table_temp>.
        ENDLOOP.
      ENDIF.
    endform.                    " f007_create_dynamic_table

  • Add field dynamically in ABAP Query Report.

    Hi All,
    Can we add fields dynamically in the ABAP Query Report?
    There is a field in my report which should occupy the line only if it has value. But if we drag-drop the filed in the report it automatically occupy the line though it doesn't have value.
    Thanks in Advance!!!

    hi rohini,
    we can add fields dynamically in the ABAP Query Report,in this way we can to,
    first of all u create ur selection-screen with all the fields and make the field invisible i.e the one which u want to add dynamically. and based on ur requirement change that invisible to visible and use modify screen.
    in this way we can solve.
    search for invisible and modify screen in sdn u can get better information and u can understand what i am saying.

  • Add Fields dynamically to table control

    Hello Folks ,
    i'm trying to add some filed to standard table control and this require from me to take action of repair (modification ) .
    insted of make repair i consider the option of make an enhancement and dynamically (by code ) add the required fileds to table control .
    is there anyone that know if it's possible or not and how to do this .
    Regards,
    Herzel .

    Hi,
        You can use ALV for input purpose as well. Check out OO ALV programs. SE38 -> BCAlVEDIT* , tons of programs available.
    a) Input from user - In ALV, this is possible
    b) F4 help - Possible with ALV
    Not sure why would you need material number and description in the same column and that too one below another. It is possible with lot of tweaking but still requirement is strange and you need to have at least two rows for the same MATNR, one with the number and other with description.
    Refer the links:
    Re: Adding dynamic columns in Table Control
    Re: Adding dynamic columns in Table Control
    Could anyone tell me how can I add columns in a internal table dynamically?
    Re: Dynamic Table Control
    <b>Reward points</b>
    Regards

  • Reading Dynamic Table Values in interactive form (web Dynpro ABAP)

    Hi All,
    I have created a Web Dynpro ABAP application which contains an Interactive Form, That Adobe Interactive Form contains Dynamic table (New rows can be added manually and deleted using a button).
    I am not able to read the Dynamic table values in Web Dynpro u201COn Submitu201D.
    In the Adobe form I have web Dynpro native button (I am using ZCI), while clicking the native button I need to read the dynamic table values.
    How can I resolve this problem.
    Thanks and Regards,
    Boopathi M

    that means, when u add the table instance at runtime, you will also have to add an element to the node that is bound to the table.
    probably addNew() mathos may be useful to you.
    it appends a new record to the record set.
    xfa.sourceSet.dataConnectionName.addNew()
    also when on the exit event of the table field, do the following:
    var i = xfa.parent.index
    $record.rootnodename.tablenodename.data<i>.fieldname = $.rawValue
    xfa.host.messageBox($record.rootnodename.tablenodename.data<i>.fieldname)

  • Use the value of a field as column-name of a dynamic table

    Hi All
    I have the following situation:
    a) Internal table TB_ORDER_CONDITION ==>  data: tb_order_condition type standard table of bapicond.
         sample of the internal table TB_ORDER_CONDITION:
    CONT_TYPE # CONDVALUE# CONDBASEVAL  
        ZR00         #    38.800000#  1.000000
        ZR30         #    2.800000  #  0.000000
        SKTO        #    0.000000  #  57.8500000
    b) dynamic-table  <L_TABLE_II> has the following columns:
    ZR00#ZR30#ICM3#IPS2  SKTO  
    c) I would like to move as below:
    ZR00#ZR30# ICM3#IPS2# SKTO 
    38.800000#2.800000#57.8500000
    Observation:
    I used this symbol just to show the separationfrom one column from another.
    Items a) and b) are OK. The problem is that I don't know how to make this move as showed in item c).
    Could you please advise?
    Thanks in advance.
    Gaia

    Hello,
    Check the code snippet below:
    FIELD-SYMBOLS: <wa_order_creation>  TYPE bapicond,
                   <l_table_ii>         TYPE STANDARD TABLE,
                   <l_wa_ii>            TYPE ANY,
                   <l_fieldval>         TYPE ANY.
    SORT tb_order_condition BY itm_number. "Sort by Item Number
    LOOP AT tb_order_condition ASSIGNING <wa_order_creation>.
    * Add a record to the dynamic table for each item
      AT NEW itm_number.
        APPEND INITIAL LINE TO <l_table_ii> ASSIGNING <l_wa_ii>.
      ENDAT.
      ASSIGN COMPONENT <wa_order_creation>-cond_type
      OF STRUCTURE <l_wa_ii> TO <l_fieldval>.
      IF sy-subrc = 0.
        <l_fieldval> = <wa_order_creation>-cond_value.
      ENDIF.
    ENDLOOP.
    BR,
    Suhas

  • How to Add fields in dynamic selection LDB BRF

    Hi All,
    I have requirement to add a field BSEG-ZLSCH in Logical Database BRF dynamic selection.
    I have tried doing the same by using below mentioned link but its not appearing in the report dynamic selection screen
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0e0039a-0d79-2c10-0aaf-9f6c062c0ffb?quicklink=index&overridelayout=true
    Could you please help me a Legal change delivery is pending due to this issue.
    Thanks and best regards,
    Niteesh Rai

    Dear Niteesh,
    The Logical Data Base BRF reads table BKPF and BSEG, but there is no
    option to include fields from BSEG in the dynamic selection.
    You can display all the tables included in BRF, but only fields from
    BKPF could be included in the dynamic selection. You cannot add
    entries from BSEG, BSET, KNB1, KNBK, and so on that are listed here.
    You are right, there is not note that explains this behaviour, but I
    inform you what is the system design. This has been confirmed by my
    Development colleagues.
    Regarding to note 832997, this is valid for releases 500 and 600 when
    New G/L is available. The system functionality has been enhanced in
    release 500 so you can add fields from FAGLFREESEL that is similar
    to BSEG with New G/L.
    BR, Hana

  • Add field in an internal table

    Hi There,
    How to add a field in an internal table created at the runtime using
    CREATE DATA D1 TYPE TABLE OF (VAR).
    where say var contains name of a DDIC table.
    Rgds,
    deb.

    after creating internal table use the method for creation of dynamic table and try , i am not sure
    DATA: LineType TYPE string,
          ItabRef  TYPE REF TO DATA.
    FIELD-SYMBOLS:   TYPE STANDARD TABLE.
    LineType = 'SFLIGHT'.
    " Create internal table and attach a field-symbol
    CREATE DATA ItabRef TYPE STANDARD TABLE OF (LineType).
    ASSIGN ItabRef->* TO .
    <b>after this check this and try</b>
    ******DATA DECLARATION*****************************
    FIELD-SYMBOLS : <it_final> TYPE STANDARD TABLE,
                    <wa_final> TYPE ANY,
                    <w_field> TYPE ANY.
    ***DYNAMIC CREATION OF FIELDCATALOG****************
    *FIRST 2 FIELDS FIELDS FIELD1 AND FIELD2 ARE CONSTANT, FIELDS OBTAINED IN THE LOOP ENDLOOP ARE DYNAMIC,
    *LIKEWISE DYNAMIC FIELDCATALOG IS CREATED
      wa_fieldcatalog-fieldname  = 'FIELD1'.
      wa_fieldcatalog-ref_table  = 'E070'.
      wa_fieldcatalog-outputlen  = '13'.
      wa_fieldcatalog-reptext    = 'Created On'.
      wa_fieldcatalog-seltext    = 'Created On'.
      APPEND wa_fieldcatalog TO it_fieldcatalog.
      CLEAR wa_fieldcatalog.
      wa_fieldcatalog-fieldname  = 'FIELD1'.
      wa_fieldcatalog-ref_table  = 'E070'.
      wa_fieldcatalog-outputlen  = '13'.
      wa_fieldcatalog-reptext    = 'Created On'.
      wa_fieldcatalog-seltext    = 'Created On'.
      APPEND wa_fieldcatalog TO it_fieldcatalog.
      CLEAR wa_fieldcatalog.
      LOOP AT it_mandt WHERE mandt IN s_mandt.
        CONCATENATE 'CLNT' it_mandt INTO wa_fieldcatalog-fieldname.
        wa_fieldcatalog-inttype    = 'NUMC'.
        wa_fieldcatalog-outputlen  = '14'.
        wa_fieldcatalog-reptext    = it_mandt.
        wa_fieldcatalog-seltext    = it_mandt.
        APPEND wa_fieldcatalog TO it_fieldcatalog.
        CLEAR :wa_fieldcatalog ,it_mandt.
      ENDLOOP.
    ********CREATE DYNAMIC TABLE************************
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = it_fieldcatalog
        IMPORTING
          ep_table                  = new_table
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
      IF sy-subrc <> 0.
    *  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      ASSIGN new_table->* TO <it_final>.
    *********CREATE WORK AREA****************************
    CREATE DATA new_line LIKE LINE OF <it_final>.
      ASSIGN new_line->* TO <wa_final>.
    *********INSERTTING WORK AREAR TO INTERNAL TABLE******
        INSERT <wa_final> INTO TABLE <it_final>.
    *******POPULATING DATA******************************* 
      LOOP.
       ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_final> TO <w_field>.
       <w_field> = '12345'.
        ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_final> TO <w_field>.
       <w_field> = '21453DD'.
       FIELD1 AND FIELD2 ARE COMPONENTS OF FIELDCATALOG.
    ENDLOOP.     
      ENDLOOP.

Maybe you are looking for