Dynamic internal table Created from current classic ALV layout?

Hi,
Currently I have a dynamic ALV column output who's number of columns is dependent on t_output.
ALV Sample:
MANTR    WK1   WK2  WK3 ...
10001        10       20      30
10002        5         10      15
I see this option, Get the ALV output, so this includes the header column name and its corresponding entries (which is easier.
Question here: How can I create a dynamic internal table for it_fieldcat  of my ALV?  Is there any FM or method?
If it will be a method, can you provide more details (I'm not that much yet familiar with method concept in ABAP)
*Note: I am not creating a dynamic table out of SELECT statements
Thanks.
Regards,
Jaime

    PERFORM f_0600-init_alv_layout     USING t_alv_layout.
    PERFORM f_0700-init_field_catalog  USING t_alv_fcat[]. "Populates the ALV Field Catalog
    PERFORM f_0800-build_alv_comment   USING t_alv_list_top_of_page[]. "title header of the report
    PERFORM f_0900-fill_alv_sort_fields.
    PERFORM f_1000-build_alv_display.
FORM f_0700-init_field_catalog USING us_vit_alv_fcat1 TYPE slis_t_fieldcat_alv.
  DATA:  w_vit_alv_fcat TYPE slis_fieldcat_alv.
  CLEAR w_vit_alv_fcat.
  MOVE : c_vit_output TO w_vit_alv_fcat-tabname,
         c_matnr      TO w_vit_alv_fcat-fieldname,
         c_material   TO w_vit_alv_fcat-seltext_l,
         c_x          TO w_vit_alv_fcat-fix_column,
         c_x          TO w_vit_alv_fcat-key.
  APPEND w_vit_alv_fcat TO us_vit_alv_fcat1.
  CLEAR w_vit_alv_fcat.
  MOVE : c_vit_output   TO w_vit_alv_fcat-tabname,
         c_maktx        TO w_vit_alv_fcat-fieldname,
         c_material_dis TO w_vit_alv_fcat-seltext_l.
  APPEND w_vit_alv_fcat TO us_vit_alv_fcat1.
  CLEAR: w_vit_alv_fcat.
  MOVE : c_vit_output   TO w_vit_alv_fcat-tabname,
         c_meins        TO w_vit_alv_fcat-fieldname,
         c_uom TO w_vit_alv_fcat-seltext_l.
  APPEND w_vit_alv_fcat TO us_vit_alv_fcat1.
  CLEAR: w_vit_alv_fcat.
  MOVE : c_vit_output   TO w_vit_alv_fcat-tabname,
         c_lifnr        TO w_vit_alv_fcat-fieldname,
         c_vendor       TO w_vit_alv_fcat-seltext_l.
  APPEND w_vit_alv_fcat TO us_vit_alv_fcat1.
  CLEAR w_vit_alv_fcat.
  MOVE : c_vit_output TO w_vit_alv_fcat-tabname,
         c_name1      TO w_vit_alv_fcat-fieldname,
         c_vendorname TO w_vit_alv_fcat-seltext_l.
  APPEND w_vit_alv_fcat TO us_vit_alv_fcat1.
  CLEAR w_vit_alv_fcat.
  MOVE : c_vit_output TO w_vit_alv_fcat-tabname,
         c_dispo      TO w_vit_alv_fcat-fieldname,
         c_mrp_cont   TO w_vit_alv_fcat-seltext_l.
  APPEND w_vit_alv_fcat TO us_vit_alv_fcat1.
  CLEAR w_vit_alv_fcat.
  MOVE : c_vit_output TO w_vit_alv_fcat-tabname,
         c_stprs      TO w_vit_alv_fcat-fieldname,
         c_std_price  TO w_vit_alv_fcat-seltext_l.
  APPEND w_vit_alv_fcat TO us_vit_alv_fcat1.
  CLEAR w_vit_alv_fcat.
  MOVE : c_vit_output TO w_vit_alv_fcat-tabname,
         c_st_pck     TO w_vit_alv_fcat-fieldname,
         c_st_pck_sz  TO w_vit_alv_fcat-seltext_l.
  APPEND w_vit_alv_fcat TO us_vit_alv_fcat1.
  CLEAR w_vit_alv_fcat.
  MOVE : c_vit_output TO w_vit_alv_fcat-tabname,
         c_kanban     TO w_vit_alv_fcat-fieldname,
         c_kanbanqty  TO w_vit_alv_fcat-seltext_l.
  APPEND w_vit_alv_fcat TO us_vit_alv_fcat1.
* To display 26 weeks historical consumptions:
  CLEAR w_vit_alv_fcat.
  UNASSIGN <fs_hwk_date>.
  LOOP AT t_hwk_date ASSIGNING <fs_hwk_date>.
    MOVE c_vit_output TO w_vit_alv_fcat-tabname.
    CONCATENATE c_hwk <fs_hwk_date>-calender_wk
    INTO         w_vit_alv_fcat-seltext_l.
    CONCATENATE c_hwk <fs_hwk_date>-index
    INTO         w_vit_alv_fcat-fieldname.
    APPEND w_vit_alv_fcat TO us_vit_alv_fcat1.
  ENDLOOP.
Edited by: Jaime Cabanban Jr on Apr 24, 2009 3:06 PM

Similar Messages

  • 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

  • Add column in the dynamic internal table

    Hi Experts,
    I have a dynamic internal table. I need add new column in the internal table and I don´t Know.
    My code:
    DATA:  it_generic TYPE REF TO Data,
    wa_generic TYPE REF TO data.
    FIELD-SYMBOLS: <table> TYPE ANY TABLE,
    <wa>    TYPE ANY,
    <field> TYPE ANY.
    CREATE DATA it_generic  TYPE STANDARD TABLE OF (wa_datoscarga-ZTBLCAR).
    CREATE DATA wa_generic  TYPE (wa_datoscarga-ZTBLCAR).
    ASSIGN it_generic->* TO <table>.
    CHECK <table> IS ASSIGNED.
    ASSIGN wa_generic->* TO <wa>.
    CHECK <wa> IS ASSIGNED.
    SELECT *
    INTO  CORRESPONDING FIELDS OF TABLE <table>
    FROM (wa_datoscarga-ZTBLCAR)
    WHERE  bukrs   EQ p_bukrs      AND
    z_petic EQ z_peticion   AND
    ZIDFASE eq 'E'.
    After this I need add one column selection at the first position of the columns.
    Thanks

    Hi,
    Please refer to the below link for the code snippet on how to create a dynamic internal table -
    [Create a dynamic internal table.|http://www.divulgesap.com/blog.php?p=MjE=]
    Cheers,
    Ravi

  • Dynamic internal  tables using field symbols

    Hello,
    Is it possible to create a dynamic table where the no of fields in the internal table can be created dynamically(using field symbols).
    Say sometimes internal tables with 10 fields and depending upon the requirement the fields can be dynamically increased or decreased in runtime.
    Thanks.

    Hi,
    Go through the following code....
    *Data definitions
    *** Tables
    data: lt_data type ref to data.
    data: lt_fieldcatalog type lvc_t_fcat.
    *** Structure
    data: ls_fieldcatalog type lvc_s_fcat.
    *** Data References
    data: new_line type ref to data,
          fs_data type ref to data.
    *** Field Symbols
    field-symbols: <fs_data> type ref to data,
                   <fs_1> type any table,
                   <fs_2>,
                   <fs_3>.
    *Populating the internal table with fieldnames required for our dynamic
    *internal table
    ls_fieldcatalog-fieldname = 'MANDT'.
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'CARRID'. "Fieldname
    ls_fieldcatalog-inttype = 'C'. "Internal Type C-> Character
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'CONNID'.
    ls_fieldcatalog-inttype = 'N'.
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'FLDATE'.
    ls_fieldcatalog-inttype = 'D'.
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'PRICE'.
    ls_fieldcatalog-inttype = 'P'.
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'CURRENCY'.
    ls_fieldcatalog-inttype = 'C'.
    append ls_fieldcatalog to lt_fieldcatalog.
    *Calling the method CREATE_DYNAMIC_TABLE
    call method cl_alv_table_create=>create_dynamic_table
         exporting
           it_fieldcatalog = lt_fieldcatalog
         importing
           ep_table = fs_data
         exceptions
           generate_subpool_dir_full = 1
           others = 2
    if sy-subrc <> 0.
    endif.
    *Assigning Field-Symbol to our dynamic internal table
    assign lt_data to <fs_data>.
    *Internal Table is ready, now to put data in that table
    *** So <FS_1> now points to our dynamic internal table.
    assign fs_data->* to <fs_1>.
    *** Next step is to create a work area for our dynamic internal table.
    create data new_line like line of <fs_1>.
    *** A field-symbol to access that work area
    assign new_line->*  to <fs_2>.
    *** And to put the data in the internal table
    select
          mandt
          carrid
          connid
          fldate
          price
          currency
                  from sflight
                  into corresponding fields of table <fs_1>.
    *** Access contents of internal table
    loop at <fs_1> assigning <fs_2>.
    do 5 times.
    assign component sy-index of structure <fs_2> to <fs_3>.
    write:  <fs_3>.
    enddo.
    skip 1.
    endloop.
    top-of-page.
    write:/5 'FUJITSU CONSULTING COMPANY' inverse color 6,
           50 sy-datum inverse color 6,
           70 sy-pagno inverse color 6.
    uline.
    <REMOVED BY MODERATOR>
    Vijay C
    Code Formatted by: Alvaro Tejada Galindo on Apr 14, 2008 1:47 PM

  • Usage of 'Select for all entries' for dynamic internal tables..

    Hi all,
    I have a situation where I need to use select for all entries for a dynamic internal table.
    select * from /BIC/AZHSD_O1500 into i_table for all entries in <b>Dynamic_table</b> where doc_number = <dynamic_table????????>
    here iam not knowing how to match the <dynamic_table????????> doc_number ?
    the dynamic_table contains the doc_number as one field.
    here dynaimc_table is the internal table which is dynamic.
    I have tried various options but couldnot find the solution.
    Please resolve.
    Sidhartha.

    data : i_dyn_where type char72 occurs 0.
    field-symbols : <fs> type table.
    assign itab[] to <fs>.
    i_dyn_where = 'docno = <fs>-docno'.
    append i_dyn_where.
    select *
    from   vbak
    into   table t_vbak
    for    all entries in <fs>
    where  (I_dyn_where).   "Populate this where condition dynamically too
    Hope this will solve ur prob.

  • How to create Dynamic Internal table in ALV?

    Hi all,
    I have to create a ALV report based on dynamic internal table. The requirement is that when I enter the months in my selection screen I should get the data relevant to those many months only. For eg if in selection I have given January to March, I should get an ALV output with columns from January to March only.
    Please help me with the coding part as I find it a bit confusing.
    Please reply immediately.
    Regards,
    Bhavani.

    Hi BHAVANI,
    first you have to prapare a field catalog [(see this)|http://help.sap.com/saphelp_470/helpdata/en/52/5f060de02d11d2b47d006094192fe3/frameset.htm]
    and than you can use a Method cl_alv_table_create=>create_dynamic_table
    I hope that help a little.
    Regards Bogdan

  • Create dynamic internal table with deep structure;cell coloring dynamic ALV

    Hi,
    My requirement is to do cell colouring for a dynamic ALV.
    So I am creating a dynamic internal table using the following method.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = i_fieldcatalog[]
        IMPORTING
          ep_table        = i_output.
    But how do I define field COLORS which should be again an internal table ?
    Is there any other way for cell colouring?
    Putting my problem in another way:
    How do I create a dynamic internal table with one field as another internal table.
    Quick replies are highly appreciated.
    Thanks,
    Nisha Vengal.

    halo Nisha
    Before building the display table . you can add the field in the feild catalog right . This display table gets generated from the field catalog right
    1 Create a global structute say ZEXTEND_FIELDCAT
    2 Have fields like STYLE type lvc_t_styl
                             COLOR type LVC_T_SCOL.
    3 Now you have to extend ur fieldcatalog
      l_fieldcat-fieldname = COLOR'.
      l_fieldcat-ref_field = 'COLOR'.
      l_fieldcat-ref_table = 'ZEXTEND_FIELDCAT'.
      APPEND l_fieldcat TO lt_field_catalog.
      CLEAR l_fieldcat.

  • How to populate field catalogue fields in ALV using  dynamic internal table

    Hi All,
    Please let me know how to populate field catalogue fields in ALV using  dynamic internal table.
    I have created <dyn_table> using code below.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
                     EXPORTING
                       it_fieldcatalog = g_t_ifc
                        it_fieldcatalog = g_t_fieldcat
                     IMPORTING
                        ep_table        = dy_table.
      ASSIGN dy_table->* TO <dyn_table>.
    Create dynamic work area and assign to FS
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
    Now this  <dyn_table>  has fields like idoc no.,creation date ,
    segment field 1, segment field 2 etc..Now idoc no.,creation date  are static fields from table EDIDC. And segment field 1, segment field 2 etc are dynamic fields from table EDSAPPL.
    In my  ALV report I am getting the final layout properly but I am unable to move values to corresponding fields in the final layout shown.Please let me know how to populate these fields from different tables.
    I tried this way but its not working.
    SORT g_t_edid4 BY docnum.
      LOOP AT g_t_edidc INTO g_r_edidc.
        READ TABLE g_t_edid4 into g_r_edid4
                         WITH KEY docnum = g_r_edidc-docnum
                                        BINARY SEARCH.
        IF sy-subrc = 0.
          <dyn_wa> =  g_r_edid4-sdata.
         MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
       CLEAR g_r_edid4.
        ENDIF.
    MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
    APPEND <dyn_wa> TO <dyn_table>.

    You have to assign each field to field symbol and then assign the value to that field symbol and asssign that field symbol to workarea field symbol.
    LOOP AT g_t_edidc INTO g_r_edidc.
    READ TABLE g_t_edid4 into g_r_edid4
    WITH KEY docnum = g_r_edidc-docnum
    BINARY SEARCH.
    IF sy-subrc = 0.
    ASSIGN COMPONENT 'SDATA' OF STRUCTURE <DYN_WA> TO <DYN_FLD>.
    <DYN_FLD> = g_r_edid4-sdata.
    " <dyn_wa> = g_r_edid4-sdata.
    " Assign each fields like this.
    " MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
    CLEAR g_r_edid4.
    ENDIF.
    " MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
    APPEND <dyn_wa> TO <dyn_table>.
    Regards,
    Naimesh Patel

  • How 2 create dynamic internal table and can we pass it to gui_download FM

    HI all,
         How can we create a dynamic internal table?
    I have a requirement where  i have to create an internal table with the no. of fields depending on the selection screen values, i think tat can be possible though dynamic creation only.
             How to solve this issue..?Pointers will be very much useful..
    Thanks
    Sunny.

    hi
    Follow the code it will help you out....
    REPORT  YUSMM_TEXT2                             .
    *TABLES
    TABLES: MARA,    " General Material Data
            MAKT,    " Material Descriptions
            T002.    " Language Keys
    * GLOBAL TYPE-POOL
    TYPE-POOLS : SLIS.
    * GLOBAL TYPES
    TYPES: BEGIN OF TP_LANG ,
             SPRAS LIKE T002-SPRAS,
             LAISO LIKE T002-LAISO,
             SRNO(3) TYPE N,
           END OF TP_LANG.
    TYPES: BEGIN OF TP_MATNR,
             MATNR LIKE MARA-MATNR,
             BEGRU LIKE MARA-BEGRU,
           END OF TP_MATNR.
    * DECLARATION FOR GLOBAL INTERNAL TABLES (WITH INCLUDE STRUCTURE)
    DATA:GT_MAKT    TYPE STANDARD TABLE OF MAKT,  "Materialkurztexte,
         GT_THEAD   TYPE STANDARD TABLE OF THEAD, "SAPscript: Text-Header,
         GT_LINETAB TYPE STANDARD TABLE OF TLINE, "SAPscript: Text-Zeilen,
         GT_T002    TYPE STANDARD TABLE OF T002. "Language key
    DATA: BEGIN OF GV_TEXT_OUTPUT_LINE,
                MATNR LIKE MARA-MATNR,
                BEGRU LIKE MARA-BEGRU,
                MAKTX LIKE MAKT-MAKTX,
                LTXT40(1250) TYPE C,
                SRNO(3) TYPE N,
                SPRAS LIKE T002-SPRAS,
             END OF GV_TEXT_OUTPUT_LINE.
    DATA: GT_MATNR TYPE STANDARD TABLE OF TP_MATNR,
          WA_GT_MATNR TYPE TP_MATNR.
    DATA: GT_LANG TYPE STANDARD TABLE OF TP_LANG,
          WA_GT_LANG TYPE TP_LANG.
    DATA: GT_TEXT_OUTPUT_LINE LIKE STANDARD TABLE OF GV_TEXT_OUTPUT_LINE,
          GT_FIELDCAT         TYPE SLIS_T_FIELDCAT_ALV,
          GV_FIELDCAT         LIKE LINE OF GT_FIELDCAT,
          CT_GT_FIELDCAT_IN LIKE GV_FIELDCAT,
          GS_LAYOUT           TYPE SLIS_LAYOUT_ALV,
          GV_REPID            TYPE SY-REPID.
    DATA: BEGIN OF GV,
            FORMER_ERROR       LIKE  SY-MARKY,     " Fehlermeldung bereits
            FILE_OPEN(1),                          " Flag open file
            REC_LENGTH         TYPE  I,            " record length
            MATNR              TYPE  MARA-MATNR,   " material
            REPID              TYPE  SYST-REPID,
            RETCO              TYPE  SY-SUBRC,
          END OF GV.
    DATA: GV_MAKT             TYPE MAKT,
          GV_T002             TYPE T002,
          GV_LANGU            TYPE THEAD-TDSPRAS.
    * DECLARATION FOR FIELD-SYMBOLS
    FIELD-SYMBOLS: <FS_DATA> TYPE REF TO DATA,
                   <FS_DATA1> TYPE REF TO DATA,
                   <FS_2>    TYPE STANDARD TABLE,
                   <FS_22>   TYPE STANDARD TABLE,
                   <FS_1>,
                   <FS_11>,
                   <F>,
                   <FA>,
                   <LWA_LINE_WA>,
                   <LWA_LINE_WA1>.
    DATA: IT_FLDCAT TYPE LVC_T_FCAT.
    DATA: T_FLDCAT1   TYPE SLIS_T_FIELDCAT_ALV.
    DATA: L_LT TYPE SLIS_LAYOUT_ALV.
    DATA: WA_IT_FLDCAT TYPE LVC_S_FCAT.
    DATA: WA_IT_FLDCAT1 TYPE SLIS_FIELDCAT_ALV.
    DATA: GP_TABLE TYPE REF TO DATA.
    DATA: WA_NEWLINE TYPE REF TO DATA.
    *DECLARATION FOR CONSTANTS
    CONSTANTS:
       BEGIN OF GC,
         TDID_GRUN     TYPE THEAD-TDID     VALUE 'GRUN',
         TDOBJECT_MAT  TYPE THEAD-TDOBJECT VALUE 'MATERIAL',
         ON(01)        TYPE C              VALUE 'X',
         YES(01)       TYPE C              VALUE 'X',
         TXT(25)       TYPE C              VALUE 'MATERIAL DETAILS',
         MAT(25)       TYPE C              VALUE 'MATERIAL NUMBER',
         AUT(25)       TYPE C              VALUE 'AUTHORIZATION GROUP',
         FOUND         TYPE SY-SUBRC       VALUE '00',  " Return-Code
         RC_OK         TYPE SY-SUBRC       VALUE '00',  " Return-Code
         OFF           TYPE SY-SUBRC       VALUE '00',  " return code
         FALSE         TYPE SY-SUBRC       VALUE '00',  " boolean
         TRUE          TYPE SY-SUBRC       VALUE '01',  " boolean
      END OF GC.
    * DECLARATION FOR VARIABLES
    DATA: V(3) TYPE N,
          STR TYPE STRING,
          STR1 TYPE STRING,
          V_VAR(3) TYPE N,
          V_VAR1(3) TYPE N,
          V_FIELDNAME(15) TYPE C,
          V_CHAR(15) TYPE C,
          V_LINES(3) TYPE N,
          MAKTEXT LIKE MAKT-MAKTX,
          LT_DATA        TYPE   REF TO DATA,
          LT_DATA1        TYPE   REF TO DATA,
          LWA_LINE       TYPE   REF TO  DATA,
          LWA_LINE1 TYPE REF TO DATA.
    *SELECTION-SCREEN AND PARAMETERS
    SELECTION-SCREEN: BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-002.
    SELECT-OPTIONS:
    S_MATNR FOR MARA-MATNR,  "MATERIAL NUMBER
    S_MTART FOR MARA-MTART,  "MATERIAL TEXT
    S_LANG FOR MAKT-SPRAS.   "LANGUAGE
    PARAMETER: GP_SIZE TYPE I DEFAULT 200. "DATA LENGTH
    SELECTION-SCREEN: END OF BLOCK A1.
    * AT SELECTION SCREEN
    AT SELECTION-SCREEN.
      IF GP_SIZE < 0.
        MESSAGE E002(00).
      ENDIF.
      IF GP_SIZE > 50000.
        MESSAGE W130(26) WITH TEXT-004.
        SET CURSOR FIELD 'gp_size'.
      ENDIF.
    * INITIALIZATION
    INITIALIZATION.
      GV-REPID = SY-REPID.
    *START-OF-SELECTION
    START-OF-SELECTION.
      PERFORM GET_MARA_DATA
                TABLES
                  GT_TEXT_OUTPUT_LINE
                USING
                  S_MATNR[]
                  S_MTART[]
                  GP_SIZE
                CHANGING
                  GV-RETCO
      PERFORM GET_MAT_TEXT
                 TABLES
                   GT_MAKT
                   GT_TEXT_OUTPUT_LINE
                   GT_THEAD
                   GT_LINETAB
                 USING
                   GC
                   GV-RETCO
                 CHANGING
                   GV_TEXT_OUTPUT_LINE
                   GV_MAKT
      PERFORM GET_LANG.
      PERFORM DYNAMIC_TABLES.
      PERFORM POPULATE_FINAL_TABLE.
      PERFORM POPULATE_DYNAMIC_TABLE.
    * END-OF-SELECTION
    END-OF-SELECTION.
      PERFORM DATA_OUTPUT.
    *&      Form  get_mara_data
    *       Materialdaten lesen
    *      <->ct_gt_text_output_line  Ausgabetabelle
    *      -->it_s_matnr  Parameter Materialnummer
    *      -->it_s_mtart  Parameter Materialart
    *      -->if_gp_size  Parameter Anzahl Materialnummern
    FORM GET_MARA_DATA  TABLES   CT_GT_TEXT_OUTPUT_LINE STRUCTURE
                                       GV_TEXT_OUTPUT_LINE
                        USING    IT_S_MATNR LIKE S_MATNR[]
                                 IT_S_MTART LIKE S_MTART[]
                                 IF_GP_SIZE
                        CHANGING IF_GV-RETCO.                   "#EC *
    * MARA in die Übergabestruktur einlesen
      SELECT MATNR BEGRU
            FROM MARA UP TO IF_GP_SIZE ROWS
            APPENDING CORRESPONDING FIELDS OF TABLE GT_MATNR
                     WHERE MATNR IN IT_S_MATNR
                       AND MTART IN IT_S_MTART.
      IF_GV-RETCO = SY-SUBRC.
    ENDFORM.                    " get_mara_data
    *&      Form  get_mat_text
    *       Kurz- und Langtexte zum Material lesen
    *      <->ct_gt_makt              Materialkurztexte
    *      <->ct_gt_text_output_line  Ausgabetabelle
    *      <->ct_gt_thead             Kopftabelle für ALV
    *      <->ct_gt_linetab           Zeilentabelle für ALV
    *      -->if_gc                   Globale Konstanten
    *      <--cf_gv_text_output_line  Struktur Ausgabetabelle
    *      <--cf_gv_makt              Struktru Materialkurztexte
    FORM GET_MAT_TEXT  TABLES   CT_GT_MAKT             STRUCTURE MAKT
                                CT_GT_TEXT_OUTPUT_LINE STRUCTURE
                                                    GV_TEXT_OUTPUT_LINE
                                CT_GT_THEAD            STRUCTURE THEAD
                                CT_GT_LINETAB          STRUCTURE TLINE
                       USING
                                IF_GC                  LIKE GC
                                IF_GV-RETCO
                       CHANGING CF_GV_TEXT_OUTPUT_LINE LIKE
                                                       GV_TEXT_OUTPUT_LINE
                                CF_GV_MAKT             LIKE GV_MAKT
      DATA: STRG TYPE STRING,
            STRG1(1255) TYPE C.
      IF IF_GV-RETCO = IF_GC-FOUND.
    * Materialkurztexte in alles Sprachen einlesen
        SELECT * FROM MAKT APPENDING TABLE CT_GT_MAKT
                 FOR ALL ENTRIES IN GT_MATNR "ct_gt_text_output_line
                 WHERE MATNR = GT_MATNR-MATNR " ct_gt_text_output_line-matnr
    * Kurztexte in die sprachabhängigen Felder bringen
        LOOP AT GT_MATNR INTO WA_GT_MATNR.
          LOOP AT CT_GT_MAKT INTO CF_GV_MAKT
                 WHERE MATNR = WA_GT_MATNR-MATNR.
            CF_GV_TEXT_OUTPUT_LINE-MATNR = WA_GT_MATNR-MATNR.
            CF_GV_TEXT_OUTPUT_LINE-BEGRU = WA_GT_MATNR-BEGRU.
            CF_GV_TEXT_OUTPUT_LINE-MAKTX = CF_GV_MAKT-MAKTX.
            CF_GV_TEXT_OUTPUT_LINE-SPRAS = CF_GV_MAKT-SPRAS.
    * LANGTEXT
            CLEAR CT_GT_THEAD[].
            CT_GT_THEAD-TDOBJECT = IF_GC-TDOBJECT_MAT.
            CT_GT_THEAD-TDNAME   = WA_GT_MATNR-MATNR.
            CT_GT_THEAD-TDID     = IF_GC-TDID_GRUN.
            CT_GT_THEAD-TDSPRAS  = CF_GV_MAKT-SPRAS.
            CALL FUNCTION 'TEXT_READ'
              EXPORTING
                I_HEADER   = CT_GT_THEAD
                I_READONLY = IF_GC-ON
              IMPORTING
                E_HEADER   = CT_GT_THEAD
              TABLES
                T_LINES    = CT_GT_LINETAB[]
              EXCEPTIONS
                NOTFOUND   = 1.
            IF SY-SUBRC = IF_GC-FOUND.
              LOOP AT  CT_GT_LINETAB.
                STRG = CT_GT_LINETAB-TDLINE.
                IF STRG1 <> ' '.
                  CONCATENATE STRG1 ';' STRG INTO STRG1.
                ELSE.
                  STRG1 = STRG.
                ENDIF.
              ENDLOOP.
              CF_GV_TEXT_OUTPUT_LINE-LTXT40 = STRG1.
              APPEND CF_GV_TEXT_OUTPUT_LINE TO CT_GT_TEXT_OUTPUT_LINE.
              CLEAR CF_GV_TEXT_OUTPUT_LINE.
              STRG1 = ' '.
            ELSE.
              APPEND CF_GV_TEXT_OUTPUT_LINE TO CT_GT_TEXT_OUTPUT_LINE.
            ENDIF.
          ENDLOOP.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " get_mat_text
    *&      Form  data_output
    *       Daten mit ALV ausgeben
    *      <->ct_GT_FIELDCAT          Feldkatalog für ALV
    *      <->ct_gt_text_output_line  Ausgabetabelle
    *      -->P_GS_LAYOUT             Layout für ALV
    *      -->if_gc                   Globale Konstanten
    *      <--cf_GV_REPID             Zur Zeit aufgerufener Reportname
    *      <--cf_gv_fieldcat          Struktur Feldkatalog
    *      <--cf_gv                   Globale Variablen
    FORM DATA_OUTPUT.
      PERFORM FIELDCATBUILD.
      PERFORM LAYOUT.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM       = GV-REPID
          I_CALLBACK_PF_STATUS_SET = 'EVENT_SET_STATUS_01'
          I_CALLBACK_USER_COMMAND  = 'EVENT_USER_COMMAND'
          IS_LAYOUT                = L_LT
          IT_FIELDCAT              = T_FLDCAT1[]
        TABLES
          T_OUTTAB                 = <FS_2>
        EXCEPTIONS
          PROGRAM_ERROR            = 1
          OTHERS                   = 2.
      IF SY-SUBRC <> GC-FOUND.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " data_output
    *&      Form  fieldcatbuild
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM FIELDCATBUILD. " TABLES   ct_gt_fieldcat_in STRUCTURE gv_fieldcat.
      LOOP AT IT_FLDCAT INTO WA_IT_FLDCAT.
        WA_IT_FLDCAT1-FIELDNAME = WA_IT_FLDCAT-FIELDNAME.
        WA_IT_FLDCAT1-TABNAME =  WA_IT_FLDCAT-TABNAME.
        WA_IT_FLDCAT1-SELTEXT_L = WA_IT_FLDCAT-FIELDNAME.
        APPEND WA_IT_FLDCAT1 TO T_FLDCAT1.
        CLEAR : WA_IT_FLDCAT,WA_IT_FLDCAT1.
      ENDLOOP.
    ENDFORM.                    " fieldcatbuild
    * Form event_set_status_01*
    FORM EVENT_SET_STATUS_01 USING LT_EXCL TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'ABCD' .
    ENDFORM. "EVENT_SET_STATUS_01
    *& Form Name: event_user_command *
    *& Form Desc: For Handling USER_COMMAND *
    FORM EVENT_USER_COMMAND USING
    IF_UCOMM TYPE SY-UCOMM
    IS_SELFIELD TYPE SLIS_SELFIELD.
      CASE IF_UCOMM.
        WHEN 'DOWNLOAD'.
          PERFORM POPULATE_DOWNLOAD_TABLE.
          DATA: L_LENGHT TYPE I.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              FILENAME              = 'C:data.xls'
              FILETYPE              = 'ASC'
              WRITE_FIELD_SEPARATOR = 'X'
              TRUNC_TRAILING_BLANKS = 'X'
              DAT_MODE              = 'X'
            IMPORTING
              FILELENGTH            = L_LENGHT
            TABLES
              DATA_TAB              = <FS_22>.
          IF SY-SUBRC <> GC-FOUND.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          IF L_LENGHT NE GC-FOUND.
            MESSAGE S398(00) WITH 'DATA downloaded to c:data.xls'.
          ENDIF.
      ENDCASE.
    ENDFORM.                    "event_user_command
    *&      Form  get_lang
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM GET_LANG.
      SELECT SPRAS
               LAISO FROM T002 INTO CORRESPONDING FIELDS OF TABLE GT_LANG
                      WHERE SPRAS IN S_LANG.
      DESCRIBE TABLE GT_LANG LINES V_LINES.
      LOOP AT GT_LANG INTO WA_GT_LANG.
        V = V + 1.
        WA_GT_LANG-SRNO = V.
        MODIFY GT_LANG FROM WA_GT_LANG TRANSPORTING SRNO.
      ENDLOOP.
      LOOP AT GT_LANG INTO WA_GT_LANG.
        CONCATENATE 'MATEDESC-' WA_GT_LANG-LAISO INTO V_FIELDNAME.
        CLEAR WA_IT_FLDCAT.
        WA_IT_FLDCAT-FIELDNAME = V_FIELDNAME.
        WA_IT_FLDCAT-SELTEXT = V_FIELDNAME.
        WA_IT_FLDCAT-DATATYPE = 'CHAR'.
        WA_IT_FLDCAT-INTLEN = 40.
        WA_IT_FLDCAT-TABNAME = '<FS_2>'.
        APPEND WA_IT_FLDCAT TO IT_FLDCAT .
        CLEAR WA_GT_LANG.
      ENDLOOP.
      LOOP AT GT_LANG INTO WA_GT_LANG.
        CONCATENATE 'BASDAT-' WA_GT_LANG-LAISO INTO V_FIELDNAME.
        CLEAR WA_IT_FLDCAT.
        WA_IT_FLDCAT-FIELDNAME = V_FIELDNAME.
        WA_IT_FLDCAT-DATATYPE = 'CHAR'.
        WA_IT_FLDCAT-INTLEN = 255.
        WA_IT_FLDCAT-SELTEXT = V_FIELDNAME.
        WA_IT_FLDCAT-TABNAME = '<FS_2>'.
        APPEND WA_IT_FLDCAT TO IT_FLDCAT .
        CLEAR WA_GT_LANG.
      ENDLOOP.
      V_FIELDNAME = 'MATNR'.
      CLEAR WA_IT_FLDCAT.
      WA_IT_FLDCAT-FIELDNAME = V_FIELDNAME.
      WA_IT_FLDCAT-DATATYPE = 'CHAR'.
      WA_IT_FLDCAT-SELTEXT =  'Matnr'.
      WA_IT_FLDCAT-INTLEN = 18.
      WA_IT_FLDCAT-TABNAME = '<FS_2>'.
      INSERT WA_IT_FLDCAT INTO IT_FLDCAT INDEX 1.
      V_FIELDNAME = 'BEGRU'.
      CLEAR WA_IT_FLDCAT.
      WA_IT_FLDCAT-FIELDNAME = V_FIELDNAME.
      WA_IT_FLDCAT-DATATYPE = 'CHAR'.
      WA_IT_FLDCAT-SELTEXT =  'BEGRU'.
      WA_IT_FLDCAT-INTLEN = 4.
      WA_IT_FLDCAT-TABNAME = '<FS_2>'.
      INSERT WA_IT_FLDCAT INTO IT_FLDCAT INDEX 2.
    ENDFORM.                    " get_lang
    *&      Form  dynamic_tables
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DYNAMIC_TABLES.
      ASSIGN LT_DATA TO <FS_DATA>.
    * Creating the Dynamic Internal Table
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG           = IT_FLDCAT      " Fieldcatalogue
        IMPORTING
          EP_TABLE                  = <FS_DATA>     " Dynamic Internal Table
        EXCEPTIONS
          GENERATE_SUBPOOL_DIR_FULL = 1
          OTHERS                    = 2.
    * Assign Dyn Table To Field Sumbol
      ASSIGN <FS_DATA>->* TO <FS_1>.
    * Assigning the Internal Table TYPE ANY to Standard internal Table
      ASSIGN <FS_1> TO <FS_2>.
    * Creating a Workarea
      CREATE DATA LWA_LINE LIKE LINE OF <FS_2> .
    * Assigning the Content to the workares as a Pointer
      ASSIGN LWA_LINE->* TO <LWA_LINE_WA>.
    ENDFORM.                    " dynamic_tables
    *&      Form  populate_final_table
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM POPULATE_FINAL_TABLE.
      LOOP AT GT_TEXT_OUTPUT_LINE INTO GV_TEXT_OUTPUT_LINE.
        READ TABLE GT_LANG INTO WA_GT_LANG
                  WITH KEY SPRAS = GV_TEXT_OUTPUT_LINE-SPRAS.
        IF SY-SUBRC EQ GC-FOUND.
          GV_TEXT_OUTPUT_LINE-SRNO = WA_GT_LANG-SRNO.
        ENDIF.
        MODIFY GT_TEXT_OUTPUT_LINE FROM GV_TEXT_OUTPUT_LINE.
      ENDLOOP.
    ENDFORM.                    " populate_final_table
    *&      Form  populate_dynamic_table
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM POPULATE_DYNAMIC_TABLE.
      DATA: INDX TYPE SY-TABIX.
      LOOP AT GT_TEXT_OUTPUT_LINE INTO GV_TEXT_OUTPUT_LINE.
        AT NEW MATNR.
          INDX = SY-TABIX.
          ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA> TO <F>.
          <F> = GV_TEXT_OUTPUT_LINE-MATNR.
          ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA> TO <F>.
          <F> = GV_TEXT_OUTPUT_LINE-BEGRU.
        ENDAT.
        LOOP AT GT_LANG INTO WA_GT_LANG.
          IF GV_TEXT_OUTPUT_LINE-SRNO = WA_GT_LANG-SRNO.
            V_VAR = GV_TEXT_OUTPUT_LINE-SRNO + 2.
            ASSIGN COMPONENT V_VAR OF STRUCTURE <LWA_LINE_WA> TO <F>.
            <F> = GV_TEXT_OUTPUT_LINE-MAKTX.
            V_VAR = GV_TEXT_OUTPUT_LINE-SRNO + V_LINES + 2.
            ASSIGN COMPONENT V_VAR OF STRUCTURE <LWA_LINE_WA> TO <F>.
            <F> = GV_TEXT_OUTPUT_LINE-LTXT40.
          ENDIF.
        ENDLOOP.
        AT END OF MATNR.
          APPEND <LWA_LINE_WA> TO <FS_2>.
          CLEAR <LWA_LINE_WA>.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " populate_dynamic_table
    *&      Form  LAYOUT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM LAYOUT.
      CLEAR L_LT.
      L_LT-ZEBRA = GC-YES.
      L_LT-COLWIDTH_OPTIMIZE = 'X'.
      L_LT-WINDOW_TITLEBAR = GC-TXT.
    ENDFORM.                    " LAYOUT
    *&      Form  populate_download_table
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM POPULATE_DOWNLOAD_TABLE.
      ASSIGN LT_DATA1 TO <FS_DATA1>.
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG           = IT_FLDCAT         " Fieldcatalogue
        IMPORTING
          EP_TABLE                  = <FS_DATA1>  " Dynamic Internal table
        EXCEPTIONS
          GENERATE_SUBPOOL_DIR_FULL = 1
          OTHERS                    = 2.
    * Assign Dyn Table To Field Sumbol
      ASSIGN <FS_DATA1>->* TO <FS_11>.
    * Assigning the Internal Table TYPE ANY to Standard internal Table
      ASSIGN <FS_11> TO <FS_22>.
    * Creating a Workarea
      CREATE DATA LWA_LINE1 LIKE LINE OF <FS_22> .
    * Assigning the Content to the workares as a Pointer
      ASSIGN LWA_LINE1->* TO <LWA_LINE_WA1>.
      DATA: STRN1 TYPE STRING,
            STRN2 TYPE STRING,
            INDX TYPE SY-TABIX.
      ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
      <FA> = GC-MAT.
      ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
      <FA> = GC-AUT.
      LOOP AT GT_LANG INTO WA_GT_LANG.
        V_VAR1 = WA_GT_LANG-SRNO + 2.
        CONCATENATE 'MATERIALDESCRIPTION-'  WA_GT_LANG-LAISO INTO STRN1.
        ASSIGN COMPONENT V_VAR1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = STRN1.
        V_VAR1 = WA_GT_LANG-SRNO + V_LINES + 2.
        CONCATENATE 'BASICDATA-' WA_GT_LANG-LAISO INTO STRN2.
        ASSIGN COMPONENT V_VAR1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = STRN2.
      ENDLOOP.
      APPEND <LWA_LINE_WA1> TO <FS_22>.
      CLEAR <LWA_LINE_WA1>.
      APPEND <LWA_LINE_WA1> TO <FS_22>.
      V_VAR1 = 0.
      LOOP AT GT_TEXT_OUTPUT_LINE INTO GV_TEXT_OUTPUT_LINE.
        AT NEW MATNR.
          INDX = SY-TABIX.
          ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
          <FA> = GV_TEXT_OUTPUT_LINE-MATNR.
          ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
          <FA> = GV_TEXT_OUTPUT_LINE-BEGRU.
        ENDAT.
        LOOP AT GT_LANG INTO WA_GT_LANG.
          IF GV_TEXT_OUTPUT_LINE-SRNO EQ WA_GT_LANG-SRNO.
            V_VAR1 = GV_TEXT_OUTPUT_LINE-SRNO + 2.
            ASSIGN COMPONENT V_VAR1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
            <FA> = GV_TEXT_OUTPUT_LINE-MAKTX.
            V_VAR1 = GV_TEXT_OUTPUT_LINE-SRNO + V_LINES + 2.
            ASSIGN COMPONENT V_VAR1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
    *        STR = GV_TEXT_OUTPUT_LINE-LTXT40.
    *        SEARCH STR FOR ';'.
    *        DO.
    *          IF SY-SUBRC = 0.
    *            SPLIT STR AT ';' INTO STR1 STR.
    *            <FA> = STR1.
    *            APPEND <LWA_LINE_WA1> TO <FS_22>.
    *            SEARCH STR FOR ';'.
    *            CLEAR <LWA_LINE_WA1>.
    *          ELSE.
    *            EXIT.
    *          ENDIF.
    *        ENDDO.
    *        <FA> = STR.
    *        APPEND <LWA_LINE_WA1> TO <FS_22>.
            <FA> = GV_TEXT_OUTPUT_LINE-LTXT40.
          ENDIF.
        ENDLOOP.
        AT END OF MATNR.
          APPEND <LWA_LINE_WA1> TO <FS_22>.
          CLEAR <LWA_LINE_WA1>.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " populate_download_table
    thanks
    Nitya

  • SET_TABLE_FOR_DISPLAY - Edited value from dynamic internal table need to be captured

    Hi all,
    I have created  2 tabstrip screns which contain ALV GRID DISPLAY  in a container with dynamic internal table and editable columns .I want to capture the edited value from this ALV GRID display.I have used SET_TABLE_FOR_DISPLAY  and for this dynamc internal table is passed which is Field symbol and editable columns have to be captured for further updation into another ztable.
    When i used check_changed_data  i am getting dump as field symbol not assigned.
    Below is the code :  How can i get edited column value from below code
    call method alv_list->set_table_for_first_display
        exporting
                is_layout                     = gs_layout
        changing
          it_outtab                     = <fs_dynamic_table>
          it_fieldcatalog               = it_fieldcat[]
        exceptions
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          others                        = 4.
      if sy-subrc <> 0.
    * Implement suitable error handling here
      endif.
    Kindly help me to solve this.
    With Thanks,
    Dina.

    please provide more info about the dump to try to help you
    as max said, it could be because the field symbol is not global and if its global maybe you are not refering well to the column
    i assume that you are using "ASSIGN COMPONENT comp OF STRUCTURE struc TO <fs>" to capture the value changed
    validate always the sy-subrc after the assignment.
    but the check changed data have parameters that have the old and new values
    please provide more info...
    Regards

  • Populate Final internal table from Dynamic internal table

    Hello,
    I have ti display data in ALV grid whose structure is fixed. I am dynamically selecting data iin an internal table.
    Now from this dynamic internal table, i need to populate my final internal table whose structurte is fixed.
    Please help.
    Rgds,
    Himanshu

    Hello Himanshu,
    When you say dynamic internal table there are two things one is the actual structure and other one is field table that holds information for all the fields used to create dynamic internal table.
    No if you want to move data from dynamic table to fixed internal table then you can try as follows:
    1.
    field-symbols <field_name> TYPE C.
    field-symbols <field_value> TYPE C.
    Now you either use
    LOOP AT fields_itab.
    ASSIGN fields_itab-fieldname to <field_name>.
    ASSIGN COMPONENT <field_name> OF STRUCTURE <structure_name> TO <field_value>
    Now you move value from <field_value> to required field in fixed internal table.
    i.e.
    itab-fieldname = <field_value>.
    Other way to do this:
    If you fields order is constant then you can also use index in assign component statement.
    do <no_of_fields> times.
        ASSIGN COMPONENT sy-index OF STRUCTURE <structure_name> TO <field_value>.
    rest is same as first method.
    Hope this help!
    I have given sudo code and you need to work on it little.
    Thanks,
    Augustin.

  • To create a deep structure for dynamic internal table.

    Hello
    My ALV has fields which are defined dynamically during execution.
    so, i did it in the following way,
    Declared Field symbolds, DREF and fieldcatalog as,
    FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
                  <fs_dyntable>.
    DATA:   dref_dyntab    TYPE REF TO data,
            dref_dynwa     TYPE REF TO data.
    DATA: ts_fieldcatalog TYPE lvc_t_fcat.
    DATA: wa_fieldcatalog TYPE lvc_s_fcat.
    Updated Fieldcatalog dynamically as,
    *function module to read segment structure
        CALL FUNCTION 'SEGMENT_READ'
          EXPORTING
            segmenttyp           = v_segment_name
          TABLES
            segmentstructure     = ts_seg_structure
          EXCEPTIONS
            no_authority         = 1
            segment_not_existing = 2
            OTHERS               = 3.
        IF sy-subrc <> 0.
          CASE sy-subrc.
            WHEN '1'.
              MESSAGE e024.
              STOP.
            WHEN '2'.
              MESSAGE e025 WITH v_segment_name.
              STOP.
            WHEN OTHERS.
              MESSAGE e023.
          ENDCASE.
        ENDIF.
    *FETCH FIELDS FROM STRUCTURE OF SEGMENT AND CREATE FIELDCATALOG FOR
    EACH FIELD OF SEGMENT (DYNAMIC FIELD CATALOG)
        LOOP AT ts_seg_structure INTO wa_seg_structure.
          ADD 1 TO v_counter.
          wa_fieldcatalog-fieldname = wa_seg_structure-fieldname.
          wa_fieldcatalog-col_pos   = v_counter.
          wa_fieldcatalog-ref_table = wa_seg_structure-segtyp.
          APPEND wa_fieldcatalog TO ts_fieldcatalog.
          CLEAR wa_fieldcatalog.
        ENDLOOP.
    and generated dynamic internal table using fieldcatalog as,
    *--Method to get the structure of table using fieldcatalog.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = ts_fieldcatalog
        IMPORTING
    *--Variable of type REF TO DATA.
          ep_table        = dref_dyntab.
      IF sy-subrc <> 0.
        MESSAGE e023.
      ENDIF.
    *--Dynamic internal tables required when show segments selected
      IF p_selseg IS NOT INITIAL.
        ASSIGN dref_dyntab->* TO <t_dyntable>.
    *--Create dynamic work area and assign to FS
      CREATE DATA dref_dynwa LIKE LINE OF <t_dyntable>.
        ASSIGN dref_dynwa->* TO <fs_dyntable>.
    And then i populated this <t_dyntable> which is being passed as data-table to method
    CL_GUI_ALV_GRID => SET_TABLE_FOR_FIRST_DISPLAY
    for ALV grid Display along with above used filedcatalog ts_fieldcatalog.
    Things are fine till here, but now i have the requirement to edit selected rows of the ALV display..
    As you might be aware, we need a field
            TS_STYLEROW  TYPE lvc_t_styl, (i.e, a field of type 'h' and we can say as an internal table inside an internal table or else as a deep structure)
    in the output internal table <t_dyntable> to meet our requirement.
    My issue is about declaring one such field of type 'h' in this dynamically created internal table ''<t_dyntable>".
    I tried in the following way by adding one such field to fieldcatalog :
    *Field for Styling
      ADD 1 TO v_counter.
      wa_fieldcatalog-fieldname   = 'TS_STYLEROW'.
      wa_fieldcatalog-tabname     = 'TS_STYLE'.
      wa_fieldcatalog-col_pos     = v_counter.
      wa_fieldcatalog-no_out      = 'X'.
      wa_fieldcatalog-inttype     = 'h'.      " I even mentioned this
      APPEND wa_fieldcatalog TO ts_fieldcatalog.
      CLEAR  wa_fieldcatalog.
    But this is creating a field of type 'C' in the table <t_dyntable> instead of what i was expecting
    Guyz and respected,
    Please advice me with the solution or ur ideas....
    Note : The overall requirement is create a deep structure for dynamically generated internal table.
    Your help is highly appreciated and unforgettable..!!!!!!!

    hi,
    Dynamic append
    Dynamic internal table
    Dynamic internal table
    dynamic columns in ALV
    Variant for dynamic selection
    thanks

  • Passing dynamic internal table into ALV

    I have made one ALV report where i had created one button 'GENERATE'.  ON CLICKING THIS BUTTON the data in the ALV report is downloaded to excel file.
    i have used this:-
    CALL METHOD cl_gui_frontend_services=>file_save_dialog
        EXPORTING
          window_title         = l_title
          default_extension    = 'XLS'
          initial_directory    = 'C:\'
        CHANGING
          filename             = filename
          path                 = path
          fullpath             = fullpath
          user_action          = user_action
        EXCEPTIONS
          cntl_error           = 1
          error_no_gui         = 2
          not_supported_by_gui = 3
          OTHERS               = 4.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
    Check which button is pressed
      IF user_action <> cl_gui_frontend_services=>action_ok.
        EXIT.
      ENDIF.
    Download error data collected from the internal table
      CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          filename                = fullpath
          filetype                = 'ASC'
          write_field_separator   = '#'
         codepage                = '4103'
         write_bom               = c_true
        CHANGING
          data_tab                = gi_final
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          not_supported_by_gui    = 22
          error_no_gui            = 23
          OTHERS                  = 24.
    If selection is successful
      IF sy-subrc EQ 0.
        MESSAGE s004 . " File  created successfully
      ELSE.
        MESSAGE i005 . " File is not created successfully
      ENDIF.
    In the table i have passed the internal table . this is working fine.
    <b>But,
    The problem is if i want to display the data in diferent layout based on selection screen criteria the data downloaded are same as default layout.
    how to pass a dynamic internal table in the
    CALL METHOD cl_gui_frontend_services=>gui_download</b>

    Hi    ,
    here is the Program for  Download  
    REPORT yrs_download_transport_request.
    PARAMETERS:
      p_reqest TYPE trkorr OBLIGATORY,
      p_folder(255) TYPE c LOWER CASE, p_sepr OBLIGATORY.
    DATA:
      folder TYPE string,
      retval LIKE TABLE OF ddshretval WITH HEADER LINE,
      fldvalue LIKE help_info-fldvalue,
      transdir TYPE text255,
      filename(255),
      trfile(20) TYPE c,
      datatab TYPE TABLE OF text8192 WITH HEADER LINE,
      len TYPE i,
      flen TYPE i.
    TYPE-POOLS: sabc, stms, trwbo.
    INITIALIZATION.
      CONCATENATE sy-sysid 'K*' INTO p_reqest.
      IF sy-opsys = 'Windows NT'.
        p_sepr = ''.
      ELSE.
        p_sepr = '/'.
      ENDIF.
    *  CALL FUNCTION 'WSAF_BUILD_SEPARATOR'
    *       IMPORTING
    *            separator                  = p_sepr
    *       EXCEPTIONS
    *            separator_not_maintained   = 1
    *            wrong_call                 = 2
    *            wsaf_config_not_maintained = 3
    *            OTHERS                     = 4.
    *  IF sy-subrc NE 0.
    *    MESSAGE s001(00)
    *      WITH
    *      'Unable to find out the separator symbol for the system.'(011).
    *  ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_reqest.
      DATA:
        tt_system TYPE TABLE OF tmscsys WITH HEADER LINE,
        es_selected_request TYPE trwbo_request_header,
        es_selected_task TYPE trwbo_request_header,
        iv_organizer_type TYPE trwbo_calling_organizer,
        is_selection TYPE trwbo_selection.
      iv_organizer_type = 'W'. is_selection-reqstatus = 'R'.
      CALL FUNCTION 'TR_PRESENT_REQUESTS_SEL_POPUP'
        EXPORTING
          iv_organizer_type   = iv_organizer_type
          is_selection        = is_selection
        IMPORTING
          es_selected_request = es_selected_request
          es_selected_task    = es_selected_task.
      p_reqest = es_selected_request-trkorr.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.
      DATA: title TYPE string.
      title = 'Select target folder'(005).
      CALL METHOD cl_gui_frontend_services=>directory_browse
        EXPORTING
          window_title    = title
        CHANGING
          selected_folder = folder
        EXCEPTIONS
          cntl_error      = 1
          error_no_gui    = 2
          OTHERS          = 3.
      CALL FUNCTION 'CONTROL_FLUSH'
        EXCEPTIONS
          cntl_system_error = 1
          cntl_error        = 2
          OTHERS            = 3.
      p_folder = folder.
    AT SELECTION-SCREEN ON p_reqest.
      DATA: request_info TYPE stms_wbo_request,
            request_infos TYPE stms_wbo_requests.
      REFRESH request_infos.
      CALL FUNCTION 'TMS_MGR_READ_TRANSPORT_REQUEST'
        EXPORTING
          iv_request                 = p_reqest
          iv_header_only             = 'X'
        IMPORTING
          et_request_infos           = request_infos
        EXCEPTIONS
          read_config_failed         = 1
          table_of_requests_is_empty = 2
          system_not_available       = 3
          OTHERS                     = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CLEAR request_info.
      READ TABLE request_infos INTO request_info INDEX 1.
      IF sy-subrc NE 0
      OR request_info-e070-trkorr IS INITIAL.
        MESSAGE e398(00) WITH 'Request'(006) p_reqest 'not found'(007).
      ELSEIF request_info-e070-trstatus NE 'R'.
        MESSAGE e398(00)
        WITH 'You must release request'(008)
             request_info-e070-trkorr
             'before downloading'(009).
      ENDIF.
    START-OF-SELECTION.
      folder = p_folder.
      CONCATENATE p_reqest+3(7) '.' p_reqest(3) INTO trfile.
      CALL FUNCTION 'RSPO_R_SAPGPARAM'
        EXPORTING
          name   = 'DIR_TRANS'
        IMPORTING
          value  = transdir
        EXCEPTIONS
          error  = 0
          OTHERS = 0.
      PERFORM copy_file USING 'cofiles' trfile.
      trfile(1) = 'R'.
      PERFORM copy_file USING 'data' trfile.
      trfile(1) = 'D'.
      PERFORM copy_file USING 'data' trfile.
    * FORM copy_file *
    * --> SUBDIR * * --> FNAME *
    FORM copy_file USING subdir fname.
      DATA:
        auth_filename TYPE authb-filename,
        gui_filename TYPE string.
      CONCATENATE transdir subdir fname
        INTO filename
        SEPARATED BY p_sepr.
      REFRESH datatab.
      CLEAR flen.
      auth_filename = filename.
      CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
        EXPORTING
          activity         = sabc_act_read
          filename         = auth_filename
        EXCEPTIONS
          no_authority     = 1
          activity_unknown = 2
          OTHERS           = 3.
      IF sy-subrc <> 0.
        FORMAT COLOR COL_NEGATIVE.
        WRITE: / 'Read access denied. File'(001),
                  filename.
        FORMAT COLOR OFF. EXIT.
      ENDIF.
      OPEN DATASET filename FOR INPUT IN BINARY MODE.
      IF sy-subrc NE 0.
        FORMAT COLOR COL_TOTAL.
        WRITE: / 'File open error'(010), filename.
        FORMAT COLOR OFF. EXIT.
      ENDIF.
      DO.
        CLEAR len.
        READ DATASET filename INTO datatab LENGTH len.
        flen = flen + len.
        IF len > 0. APPEND datatab. ENDIF.
        IF sy-subrc NE 0.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET filename.
      CONCATENATE p_folder '' fname INTO gui_filename.
      CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          bin_filesize            = flen
          filename                = gui_filename
          filetype                = 'BIN'
        CHANGING
          data_tab                = datatab[]
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          OTHERS                  = 24.
      IF sy-subrc = 0.
        WRITE: / 'File'(002), filename, 'downloaded. Length'(003), flen.
      ELSE.
        FORMAT COLOR COL_NEGATIVE.
        WRITE: / 'File download error. Filename:'(004), filename.
        FORMAT COLOR OFF.
      ENDIF.
    ENDFORM. "copy_file
    Reward  points if it is usefull....
    Girish

  • Need ALV LIST for displaying Dynamic Internal Tables

    Hi Guys,
                     I have some thing like 2 Dynamic internal tables.
    Say 1st Internal table will be filled based on some condition.
    say 2nd table will be filled based on some condition.
    When appending the 1st Internal table, if that internal table is filled it creates another internal table of same kind and continues so on until some condition.
    In the same way when appending the 2nd Internal table, if that internal table is filled it creates another internal table of same kind and continues so on until some condition.
    My requirement is I need to display all these Internal tables in the output.
    The output should look something like
    1st Internal Table
    some gap
    2nd Internal Table
    some gap
    so on...................
    Is there any standard ALV List, to display all these Internal Tables in such a way.
    Thanks,
    Prasad.

    Hi.
    One thing more here is code which get 10 records from 2 tables and then show them in ALV.
    first when u execute it will show data from ist table.
    when u go back (F3) then it will sow data from 2nd table.
    But if u want to show both ALV on the same screen then u will have to use screen programin and using class u will have to create container and then have to do it.
    But as i above mentioned. that sample code is as below.
    REPORT ztn_test LINE-COUNT 100.
      data: itab_ref type ref to data.
      data: hstr type lvc_title.
    data: tabname like DD02T-TABNAME.
       tabname = 'MARA'. " First Table
      create data itab_ref type standard table of (tabname).
      field-symbols: <itab> type standard table.
      assign itab_ref->* to <itab>.
      select * UP TO 10 ROWS from (tabname) into corresponding fields of table <itab>.
      perform showalv.
       tabname = 'KNA1'. " 2nd Table
      create data itab_ref type standard table of (tabname).
      "field-symbols: <itab> type standard table.
      assign itab_ref->* to <itab>.
      select * UP TO 10 ROWS from (tabname) into corresponding fields of table <itab>.
      perform showalv.
    form showalv.
    " to show that data in alv
      type-pools: slis.
      data: myalv type ref to cl_gui_alv_grid,    "ALV Grid
            fieldcat type slis_t_fieldcat_alv,    "Field Catalog Table
            ls_fcat type slis_fieldcat_alv,       "Line of Field catalog.
            ls_heading type slis_listheader,      "Line of Heading.
            layout type slis_layout_alv,          "layout of ALV for Heading and Logo.
            event type slis_t_event,              "Event Raising to Display Heading.
            event_str type slis_alv_event.        "Event String.
    type-pools: slis.
    data: heading type slis_t_listheader.       "List Heading.
      if heading[] is initial.
        ls_heading-typ = 'H'.
        ls_heading-info = 'HR: Master Data Change History'.
        append ls_heading to heading.
      endif.
    *  ls_heading-typ = 'A'.
    *  ls_heading-info = ''.
    *  APPEND ls_heading TO heading.
    *                          ALV DISPLAY                        *
    *******Making Layout of ALV
      layout-zebra = 'X'.
      layout-colwidth_optimize = 'X'.
    *Calling function to raise event to display heading and icon above ALV
      call function 'REUSE_ALV_EVENTS_GET'
       exporting
         i_list_type           = 0
       importing
         et_events             = event[]
    * EXCEPTIONS
    *   LIST_TYPE_WRONG       = 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.
    ******calling TOP_OF_PAGE Event
      read table event with key name = 'TOP_OF_PAGE' into event_str.
      if sy-subrc = 0.
        move: 'TOP_OF_PAGE' to event_str-form.
        modify event from event_str index sy-tabix.
      endif.
    **** Now use this Fuction to display ALV without any Screen Programming.
      call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = 'SAPLZFSL_HR_UTILS' "sy-cprog
    *   I_CALLBACK_PF_STATUS_SET          = ' '
    *   I_CALLBACK_USER_COMMAND           = ' '
    *   I_CALLBACK_TOP_OF_PAGE            = ' '
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
         i_structure_name                  = tabname
    *   I_BACKGROUND_ID                   = ' '
         i_grid_title                      = hstr   "Heading of ALV Grid.
    *   I_GRID_SETTINGS                   =
         is_layout                         = layout
    *   it_fieldcat                       = fieldcat[]
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           =
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
         i_default                         = 'X'
         i_save                            = 'X'
    *   IS_VARIANT                        =
         it_events                         = event[]
    *   IT_EVENT_EXIT                     =
    *   IS_PRINT                          =
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 0
    *   I_SCREEN_START_LINE               = 0
    *   I_SCREEN_END_COLUMN               = 0
    *   I_SCREEN_END_LINE                 = 0
    *   I_HTML_HEIGHT_TOP                 = 0
    *   I_HTML_HEIGHT_END                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   IR_SALV_FULLSCREEN_ADAPTER        =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
        tables
          t_outtab                          = <itab>
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 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.
    endform.

  • Create object/structure like dynamic internal table

    Hi,
    We have created dynamic internal table with some fields.
    for the above how to create structure or internal table like dynamic internal table structure .
    Scenario: internal table itab1 ( with header line) have 5 fields.
    Based on some of the conditions in layout of the report.
    we have to create dynamic internal table.
    field-symbols: <FS> type standard table.
    we are able to create dynamic internal table with 3 fields
    with assignment <fs> = itab1[]
    the columns are not appearing but data appearing in next column.
    how to solve this one
    Thanks
    Ramesh

    Hi Ramesh,
      I hope this code works...
    report  yup_alv_datbase                         .
    *-Display Database table contents in ALV Grid Format
    >********************************************************************
    This report displays data from SAP tables, views (like SE16)        *
    FM : REUSE_ALV_GRID_DISPLAY                                         *
    tables:
      dd02l,                               " SAP tables
      dd03l.                               " Table Fields
    type-pools: slis.                      " ALV Global Types
    selection-screen :
    begin of line, comment 1(35) v_1 for field p_table.         "#EC NEEDED
    parameters p_table like dd03l-tabname obligatory memory id dtb.
    selection-screen end of line.
    selection-screen :
    begin of line, comment 1(35) v_2 for field p_max.           "#EC NEEDED
    parameters p_max(2) type n default '20' obligatory.
    selection-screen end of line.
    at selection-screen.
      select single * from dd02l where tabname  = p_table
                                   and as4local = 'A'
                                   and as4vers  = '0000'.
      if sy-subrc ne 0.
      Table & is not active in the Dictionary
        message e402(mo) with p_table.
      elseif dd02l-tabclass = 'INTTAB'.
      & is a structure, not a table
        message e403(mo) with p_table.
      endif.
    initialization.
      v_1 = 'Table'.
      v_2 = 'Maximum of records'.
    start-of-selection.
      perform f_display_data.
         Form  F_DISPLAY_DATA
    form f_display_data.
    Macro definition
      define m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        ls_sort-up = 'X'.
        append ls_sort to lt_sort.
      end-of-definition.
      data:
        l_long type i,
        lp_struct   type ref to data,
        lp_table    type ref to data,      " Pointer to dynamic table
        of_sdescr   type ref to cl_abap_structdescr,
        ls_lvc_cat  type lvc_s_fcat,
        lt_lvc_cat  type lvc_t_fcat,       " Field catalog
        ls_fieldcat type slis_fieldcat_alv,
        lt_fieldcat type slis_t_fieldcat_alv,  " Field catalog
        ls_layout   type slis_layout_alv,
        lt_sort     type slis_t_sortinfo_alv,  " Sort table
        ls_sort     type slis_sortinfo_alv.
      field-symbols :
        <fieldcat>   type slis_fieldcat_alv,
        <lt_data>    type table,           " Data to display
        <fs>         type any,
        <components> type abap_compdescr.
    Dynamic creation of a structure
      create data lp_struct type (p_table).
      assign lp_struct->* to <fs>.
    Fields Structure
      of_sdescr ?= cl_abap_typedescr=>describe_by_data( <fs> ).
      loop at of_sdescr->components assigning <components>.
      Field MANDT not displayed
        if sy-tabix = 1 and <components>-name = 'MANDT'.
          continue.                        " Next loop
        endif.
      Build Fieldcatalog
        ls_lvc_cat-fieldname = <components>-name.
        ls_lvc_cat-ref_table = p_table.
        append ls_lvc_cat to lt_lvc_cat.
      Build Fieldcatalog
        ls_fieldcat-fieldname = <components>-name.
        ls_fieldcat-ref_tabname = p_table.
        append ls_fieldcat to lt_fieldcat.
      endloop.
    Create internal table
      call method cl_alv_table_create=>create_dynamic_table
        exporting it_fieldcatalog = lt_lvc_cat
        importing ep_table = lp_table.
      assign lp_table->* to <lt_data>.
    Read data
      select * from (p_table) up to p_max rows
        into corresponding fields of table <lt_data>
       order by primary key.
      if <lt_data>[] is initial.
      No table entries found for specified key
        message i429(mo).
        exit.
      endif.
    Read key field to Build Sort Table
      select * from dd03l where tabname  = p_table
                            and fieldname <> '.INCLUDE'
                            and as4vers  = '0000'
                            and as4local = 'A'
                          order by position.
        read table lt_fieldcat assigning <fieldcat>
                                with key fieldname = dd03l-fieldname.
        check sy-subrc eq 0.
        add dd03l-leng to l_long.
        if dd03l-keyflag = 'X'.
        Build Sort Table
          m_sort dd03l-fieldname.
          <fieldcat>-key = 'X'.
        elseif l_long > 150.
          <fieldcat>-tech = 'X'.
        endif.
      endselect.
      ls_layout-zebra = 'X'.
      ls_layout-colwidth_optimize = 'X'.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                is_layout   = ls_layout
                it_fieldcat = lt_fieldcat
                it_sort     = lt_sort
           tables
                t_outtab    = <lt_data>.
    endform.                               " F_DISPLAY_DATA
    END OF PROGRAM Z_ALV_DYNAMIC_DATA *********************
    Regards,
    Sampath

Maybe you are looking for

  • BEX QUERRY

    i have a requirement compare the data from two dso can we add both dso fields in one querry and create a report?

  • Is it possible to make an object to always face the camera (in 3d)?

    I have an animation with a camera flying through a map in 3D. Is it possible to make all my texts layers automatically "face" the camera, no matter what movement the camera makes in 3d? Thanks in advance, Morimitsu Yamauchi

  • Adobe Media Encoder 5.5 (64bit) freezes at the start of encoding

    Hey everyone. I have this problem since ever and never found solution for it even at google. The thing is that after I finish my project in Adobe Premiere and going to export it, Media Encoder starts encoding but freezes at connecting to dynamic medi

  • New bookmarks are generated with wrong adress, how to fix?

    When I want to add a new bookmark, firefox adds not the adress of the page I am currently visiting, it takes a total random one. For example: I just wanted to add: http://www.medscape.com/, so I hit the star and then went to recent bookmarks and when

  • Is abap suitable for me?

    If I show experience in abap, then whatever degree and percentage I hv don't matter. Is it true? I hv UG degree BA(non collegiate student) then regular MSc degree in computer science. Edited by: Mathew Parera on Feb 18, 2008 3:56 PM