Dynamic columns in Internal Table

Hi Experts,
We have client requirments where clients want to see the report of certain no of wage types.
The no. of wage types is variable, they can select any no. of wage type (30-50). Is there any way of dynamically declaring the no of fields in internal table?
Thanks & Regards
Manas Nayak

Hi,
use this..
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = ifc
        IMPORTING
          ep_table        = dy_month.
      ASSIGN dy_month->* TO <dyn_month>.
      CREATE DATA dy_wa LIKE LINE OF <dyn_month>.
      ASSIGN dy_wa->* TO <wa_month>.
use this in one loop.....in every loop passing you just create the field catalog ifc... i think your prob will be solved.
Arunima

Similar Messages

  • Dynamical columns in internal table

    Hi all.
    I need to make an internal table with dynamical columns(i have 3 static columns and the rest depends on the number of clients that i have in a month). If it's possible, how can i do it?
    Can anyone please help.
    Thanks & Regards

    Hi,
    type-pools : abap.
      field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
      data: dy_table type ref to data,
          dy_line  type ref to data,
          xfc type lvc_s_fcat,
          ifc type lvc_t_fcat.
      selection-screen begin of block b1 with frame.
    parameters: p_table(30) type c default 'T001'.
    selection-screen end of block b1.
      start-of-selection.
        perform get_structure.
      perform create_dynamic_itab.  <b> *Creates a dyanamic internal table **</b> 
    perform get_data.
      perform write_out.
      form get_structure.
      data : idetails type abap_compdescr_tab,
           xdetails type abap_compdescr.
      data : ref_table_des type ref to cl_abap_structdescr.
      * Get the structure of the table.
      ref_table_des ?= 
          cl_abap_typedescr=>describe_by_name( p_table ).
      idetails[] = ref_table_des->components[].
        loop at idetails into xdetails.
        clear xfc.
        xfc-fieldname = xdetails-name .
        xfc-datatype = xdetails-type_kind.
        xfc-inttype = xdetails-type_kind.
        xfc-intlen = xdetails-length.
        xfc-decimals = xdetails-decimals.
        append xfc to ifc.
      endloop.
      endform.
      form create_dynamic_itab.
      <b>* Create dynamic internal table and assign to FS</b>
      call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = ifc
                   importing
                      ep_table        = dy_table.
        assign dy_table->* to <dyn_table>.
      * Create dynamic work area and assign to FS
      create data dy_line like line of <dyn_table>.
      assign dy_line->* to <dyn_wa>.
      endform.
      form get_data.
      * Select Data from table.
      select * into table <dyn_table>
                 from (p_table).
      endform.
       Write out data from table.
      loop at <dyn_table> into <dyn_wa>.
        do.
          assign component  sy-index  
             of structure <dyn_wa> to <dyn_field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <dyn_field>.
          else.
            write: <dyn_field>.
          endif.
        enddo.
      endloop.
    Regards
    Sudheer

  • Dynamic creation of internal table based on alv layout

    Hi experts!!
    I have the following request from my client:
    I am displaying an alv report and i need to download it in txt format based on the columns showed in the current layout (i.e. if the user chooses to hide some columns, then they should not appear in the txt file ). In the alv i am using the Function Modules of the alv and not ABAP Objects.
    I thought of dynamically creating the internal table, but i am not sure how to do it.
    I also thaught of creating an internal table with only one field with the maximum length, but how can i check which fields are diplayed, and how can i get their values??
    Please Help!!
    Thank u in advance!!!
    Please - no duplicate posts
    Edited by: Rob Burbank on Feb 24, 2009 2:16 PM

    After call the above said function module you will get the exporting table for field catalog ie
              call function 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
                importing
                  es_layout     = ls_slis_layo
                  et_fieldcat   = lt_slis_fcat
    if you check the lt_slis_fcat internal table if the field are hide in the layout by the user then in this internal table check for field NO_OUT will X.
    Take the fields where NO_OUT ne X 
    then for creating dynamic internal table
      field-symbols :  <ptab>  type standard table.
      call method cl_alv_table_create=>create_dynamic_table
        exporting
          it_fieldcatalog =  lt_slis_fcat
        importing
          ep_table        = i_content.
      if sy-subrc = 0.
        assign i_content->* to <ptab>.
      else.
        write: 'Error creating internal table'.
        stop.
      endif.
    Here  is the dynamic internal table

  • How to Delete a Column in Internal Table

    Hi All,
    Does any one know ,How to Delete a Column in Internal Table?

    Hi,
       For deleting the column in the internal table, you have to eliminate the field which you want to delete.
    loop at itab into wa.
      move corresponding wa to wa1.
    append wa1 to itab1.
    clear wa1.
    clear wa.
    endloop.
    wa1 is the workarea without the field which you want to delete.
    itab1 is the internal table which consists of the deleted column.

  • Dynamicly creating an internal table with header line

    Hi experts,
    I am trying to do a read on an internal table using field symbols of type any table. To be able to read more than one row at once, I'd like to read it into another internal table (instead of just one line and instead of looping through them one by one).
    So far the following line rendered an error that the target internal table doesn't have a header line
    read table <fs_v_tab> WITH KEY (<fs_comp>) = <fs_param>-low INTO <fs_v_tab>.
    (also attempted using "<fs_v_tab>->*" & "<fs_v_tab>[]" to be silly)
    Based on the following article, I was wondering if it were possible to dynamicly create an internal table with header line.
    [http://help-abap.blogspot.com/2008/09/dynamic-internal-table-creation.html|http://help-abap.blogspot.com/2008/09/dynamic-internal-table-creation.html]
    Any help or tips on how to dynamicly filter an internal table field-symbol is greatly appreciated!

    Just read the online help:
    This statement reads a row from internal table itab.
    Or more exact:
    This statement reads one row from internal table itab.
    Therefore you can not read multiple lines into another table. The header line is needed to put the result in. And this is not what you intended, the result will be in the header line, not in the table itself.
    If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows.
    At least you have to do what you dont wanna do: looping.

  • How to add particluar column dynamically to an internal table

    Hi
    How can I add particluar column(s) to an internal table dynamically and then display in an alv.
    for eg:
    There are 5 columns and the 4th column is the <b>period (1 to 12)</b> that has been declared as select-options in the selection screen.
    col1 = bukrs
    col2 = lifnr
    col3 = akont
    <b>col4 = period</b>
    col5 = waers
    so my question is
    if period is in the range from 1 to 3 then the internal table should be
    bukrs  lifnr  akont   <b>period1   period2  period 3</b>  waers. 
    likewise if the period is in the range from 1 to n then internal table should be
    Bukrs  lifnr   akont   <b> period1   period2   period3   period4 .....  periodn  </b> waers.
    Thanks

    Hi,
    First create a global field catalog with all 12 periods ie period1, period2, ....period12.
    Once you have fieldcatalog with all 12 periods
    Then use this code arrive the dynamic field in the fieldcatalog
    data : begin of i_period occurs 0.
    data : period type i.
    data : end of i_period.
    data : v_no type i value 1.
    do.
      i_period-period = v_no.
      v_no = v_no +1.
      if v_no eq 12.
         exit.
      endif.
    enddo.
    " Here arrive the periods that are not belong to selection option period
    delete i_period where period in s_period.
    data : v_fldname like dd03l-fieldname.
    loop at i_period.
      concatenate 'PERIOD' i_period-period into v_fldname.
      condense v_fldname no-gaps.
      read table i_fieldcat with key fieldname = v_fldname.
      if sy-subrc eq 0.
         delete i_fieldcat index sy-tabix.
      endif.
    endloop.
    After this loop your field catalog contains only valid period that equal to selection option period
    aRs

  • Need suggestion in uploading dynamic excel file to corresponding columns of internal table

    Hi Friends,
    I have an excel file which doesn't have standard template. Just the users will key in their header (in row1 ) and followed by item details in excel and upload to internal table. Now by doing some internal developments in program I need to place the values in corresponding fields.
    Let me explain with some examples.
    1. I have an internal table
    data : begin of itab occurs 0,
                       f1,
                       f2,
                       f3,
                       f4,
                       f5,
              end of itab.
    2. I have excel file as below
    3 . Now i need to fill my internal table itab as below
    Need to be placed in corresponding fields.
    4. When I used GUI_UPLOAD FM it updates internal table as
    Please give me suggestion on how to achieve it.
    Thanks in advance.

    Hi Kumar,
    use a temporary table to get excel values and then parse them to a second table with the format you want.
    This is pretty basic.
    regards,
    Edgar

  • Dynamic ALV and internal table.

    Hi all,
    I have a requirement of creating a dynamic field catelog based on input values in selection screen.
    Example:
    1) When I enter date range, say  20/03/2008 to 25/03/2008 I should have 6 columns in the output for each date with column heading as date itself.
    2) For entering values for these date columns, i need to create an dynamic internal table.(values in the column will be some numbers like 10 on 20/03/2008, 15 on 21/03/2008  etc)
    A rough output format would look like this:
    Component |  20/03/2008  |  21/03/2008 | .....      |25/03/2008
    comp1        |    10            |      15         |             |      5
    comp2        |    20            |      10         |             |     10
    Please let me know how can i achieve this...
    Need it very urgently..
    Regards,
    Dhareppa

    Hi Dhareppa,
    Refer the code below. Its almost on the same line as your requirments.
    REPORT  zglo2fr_master_planing_sedul NO STANDARD PAGE HEADING.
              P  R  O  G  R  A  M    H  E  A  D  E  R                   *
                        ArthroCare Corporation                          *
    Program            : ZGLO2FR_MASTER_PLANING_SEDUL                   *
    Author             : Munvar Basha                                   *
    Creation Date      : 11Mar08                                        *
    Release            : SAP ECC 6.0                                    *
    Request            : D01K904032                                     *
    Description        : Master Schedule Planning                       *
    Change log (Revisions)                                              *
    Author     Date     Request    Description                          *
                             P  R  O  G  R  A  M                        *
                           DATA DECLARATION                             *
    **--Structure to hold matrial & plant combination records.
    TYPES : BEGIN OF ty_marc,
              matnr  TYPE matnr,
              werks  TYPE werks_d,
              dispo  TYPE dispo,
              beskz  TYPE beskz,
              mtart  TYPE mtart,
            END OF ty_marc.
    **--structure to hold MRP LIST Data.
    TYPES : BEGIN OF ty_mrp_list,
              matnr TYPE matnr,
              werks TYPE werks_d,
              maktx TYPE maktx,
              meins TYPE meins,
              mtart TYPE mtart,
              week  TYPE kweek,
              mng01 TYPE mng01,
              delkz TYPE delkz,
            END OF ty_mrp_list.
    **--structure to hold no of weeks.
    TYPES: BEGIN OF ty_week,
             week TYPE kweek,
           END OF ty_week.
    **--structure to hold output data.
    TYPES : BEGIN OF ty_final,
              matnr TYPE matnr,
              werks TYPE werks_d,
              maktx TYPE maktx,
              meins TYPE meins,
              mtart TYPE mtart,
              week  TYPE kweek,
              mng01 TYPE mng01,
            END OF ty_final.
    TYPES : BEGIN OF ty_range,
              sign   TYPE sign,
              option TYPE option,
              low    TYPE sy-datum,
              high   TYPE sy-datum,
            END OF ty_range.
              Definitions of Table types.                               *
    TYPES : ty_marctab TYPE STANDARD TABLE OF ty_marc.
               Definitions of Ranges                                    *
    *RANGES ran_delkz FOR mdez-delkz.
    DATA : i_ran_delkz TYPE RANGE OF  mdez-delkz,
           wa_ran_delkz LIKE LINE OF i_ran_delkz,
           wa_date type ty_range.
               Definitions of internal tables.                          *
    data : i_marc      type standard table of ty_marc,
           i_mrp_list  type standard table of ty_mrp_list,
           i_week      type standard table of ty_week,
           i_final     type standard table of ty_final,
           i_mdps      type standard table of mdps,
           i_mdez      type standard table of mdez,
           i_mdsu      type standard table of mdsu.
               Definitions of work areas for internal tables            *
    DATA : wa_marc     TYPE ty_marc,
           wa_mrp_list TYPE ty_mrp_list,
           wa_week     TYPE ty_week,
           wa_final    TYPE ty_final,
           wa_mt61d    TYPE mt61d,
           wa_mdez     TYPE mdez.
               Definitiions of General variables                        *
    DATA : v_matnr TYPE mara-matnr, " Material Number
           v_mtart TYPE mara-mtart, " Material Type
           v_beskz TYPE marc-beskz, " Procurement Type
           v_werks TYPE marc-werks, " Plant
           v_dispo TYPE marc-dispo. " MRP Controller (Materials Planner)
    DATA : v_mng01 TYPE mng01. "Requirement Quantity
    DATA : v_year  TYPE char4,
           v_week  TYPE char2,
           v_ok_code TYPE sy-ucomm.
               Definitiions of Constants                                *
    CONSTANTS : k_slash TYPE c     VALUE '/',
                k_6     TYPE char8 VALUE '6',
                k_x     TYPE c     VALUE 'X'.
               Definitiions of Field Catlog                             *
    DATA : wa_fieldcat        TYPE lvc_s_fcat,
           i_fieldcat         TYPE lvc_t_fcat,
           v_container        TYPE scrfname VALUE 'CONTAINER_OUTPUT',
           v_custom_container TYPE REF TO cl_gui_custom_container,
           v_grid             TYPE REF TO cl_gui_alv_grid,
           i_gp_table           TYPE REF TO data,
           wa_gp_line            TYPE REF TO data.
    FIELD-SYMBOLS: <gt_table>  TYPE STANDARD TABLE,
                   <gwa_table> TYPE ANY,
                   <l_field>   TYPE ANY,
                   <l_matnr>   TYPE ANY,
                   <l_werks>   TYPE ANY,
                   <l_maktx>   TYPE ANY,
                   <l_meins>   TYPE ANY,
                   <l_mtart>   TYPE ANY.
                 DECLERATIONS FOR SELECTION SCREEN                      *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_matnr FOR v_matnr,
                     s_mtart FOR v_mtart NO INTERVALS,
                     s_beskz FOR v_beskz NO INTERVALS NO-EXTENSION,
                     s_werks FOR v_werks NO INTERVALS NO-EXTENSION
                     OBLIGATORY,
                     s_dispo FOR v_dispo,
                     s_date  FOR sy-datum OBLIGATORY.
    PARAMETERS :     p_dattp   TYPE dattp OBLIGATORY DEFAULT '1'.
    SELECTION-SCREEN END OF BLOCK b1.
               INITIALIZATION EVENT                                     *
    INITIALIZATION.
      CALL FUNCTION '/BEV4/PLPS__ADD_MONTH_TO_DATE'
        EXPORTING
          months  = k_6
          olddate = sy-datum
        IMPORTING
          newdate = wa_date-high.
      wa_date-low = sy-datum.
      wa_date-option = 'EQ'.
      wa_date-sign = 'I'.
      APPEND wa_date to s_date.
               SELECTION SCREEN EVENT                                   *
    **--Validation for Material
    AT SELECTION-SCREEN ON s_matnr.
      PERFORM validate_material.
    **--Validation for Plant
    AT SELECTION-SCREEN ON s_werks.
      PERFORM validate_plant.
                AT SELECTION-SCREEN ENENT                               *
    AT SELECTION-SCREEN.
      IF s_matnr IS INITIAL AND s_dispo IS INITIAL.
        MESSAGE text-002 TYPE 'E'.
      ENDIF.
      IF s_date-low LT sy-datum.
        MESSAGE text-003 TYPE 'E'.
      ENDIF.
                           START-OF-SELECTION EVENT                     *
    START-OF-SELECTION.
    **--refreshing the internal tables
      REFRESH : i_marc,
                i_mrp_list,
                i_week,
                i_final,
                i_mdps,
                i_mdez,
                i_mdsu.
    **--clearing the work areas of internal tables.
      CLEAR : wa_marc,
              wa_mrp_list,
              wa_week,
              wa_final,
              wa_mt61d,
              wa_mdez.
    To get all the matrial(s) and plant combination records
      SELECT a~matnr
             a~werks
             a~dispo
             a~beskz
             b~mtart
             INTO TABLE i_marc
             FROM marc AS a INNER JOIN
                  mara AS b
                  ON a~matnr = b~matnr
             WHERE a~werks IN s_werks AND
                   a~matnr IN s_matnr AND
                   a~dispo IN s_dispo AND
                   a~beskz IN s_beskz AND
                   b~mtart IN s_mtart.
      IF sy-subrc <> 0.
        MESSAGE text-005 TYPE 'S'.
        LEAVE LIST-PROCESSING.
      ENDIF.
      SORT i_marc BY matnr werks.
    Ranges to Filter the MRP list only for the following MRP Elements.
    MRP Elements are : BA, BE, FE, LE and PA
      wa_ran_delkz-sign = 'I'.
      wa_ran_delkz-option = 'EQ'.
      wa_ran_delkz-low = 'BA'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      wa_ran_delkz-low = 'BE'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      wa_ran_delkz-low = 'FE'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      wa_ran_delkz-low = 'LE'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      wa_ran_delkz-low = 'PA'.
      APPEND wa_ran_delkz TO i_ran_delkz.
      CLEAR wa_ran_delkz-low.
      LOOP AT i_marc INTO wa_marc.
        CALL FUNCTION 'MD_MRP_LIST_API'
          EXPORTING
            matnr                    = wa_marc-matnr
            werks                    = wa_marc-werks
            sinfg                    = k_x
            inper                    = p_dattp
          IMPORTING
            e_mt61d                  = wa_mt61d
          TABLES
            mdpsx                    = i_mdps
            mdezx                    = i_mdez
            mdsux                    = i_mdsu
          EXCEPTIONS
            mrp_list_not_found       = 1
            material_plant_not_found = 2
            error                    = 3
            OTHERS                   = 4.
        IF sy-subrc = 0.
          LOOP AT i_mdez INTO wa_mdez WHERE dat00 IN s_date AND
                                            delkz IN i_ran_delkz.
            CALL FUNCTION 'DATE_GET_WEEK'
              EXPORTING
                date         = wa_mdez-dat00
              IMPORTING
                week         = wa_mrp_list-week
              EXCEPTIONS
                date_invalid = 1
                OTHERS       = 2.
            IF sy-subrc = 0.
              wa_mrp_list-matnr = wa_mt61d-matnr.
              wa_mrp_list-werks = wa_mt61d-werks.
              wa_mrp_list-maktx = wa_mt61d-maktx.
              wa_mrp_list-meins = wa_mt61d-meins.
              wa_mrp_list-mtart = wa_mt61d-mtart.
              wa_mrp_list-delkz = wa_mdez-delkz.
              wa_mrp_list-mng01 = wa_mdez-mng01.
              APPEND wa_mrp_list TO i_mrp_list.
              CLEAR : wa_mrp_list,
                      wa_mdez.
            ENDIF.
          ENDLOOP.
        ENDIF.
        CLEAR: wa_marc.
      ENDLOOP.
      IF i_mrp_list IS INITIAL.
        MESSAGE text-006 TYPE 'S'.
        LEAVE LIST-PROCESSING.
      ENDIF.
      CLEAR : v_mng01.
      LOOP AT i_mrp_list INTO wa_mrp_list.
        v_mng01 = v_mng01 + wa_mrp_list-mng01.
        AT END OF week.
          wa_final-matnr = wa_mrp_list-matnr.
          wa_final-werks = wa_mrp_list-werks.
          wa_final-maktx = wa_mrp_list-maktx.
          wa_final-meins = wa_mrp_list-meins.
          wa_final-mtart = wa_mrp_list-mtart.
          wa_final-week  = wa_mrp_list-week.
          wa_final-mng01 = v_mng01.
          wa_week-week =   wa_mrp_list-week.
          APPEND : wa_final TO i_final,
                   wa_week  TO i_week.
          CLEAR : v_mng01,
                  wa_final,
                  wa_week.
        ENDAT.
        CLEAR : wa_mrp_list.
      ENDLOOP.
    **-- Populate the Field catalog
      PERFORM populate_fieldcat.
    **--Create table dynamically
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = i_fieldcat
        IMPORTING
          ep_table        = i_gp_table.
      ASSIGN i_gp_table->* TO <gt_table>.
    **--fill table with final output data
      PERFORM fill_table.
      CALL SCREEN 100.
                              SUB ROUTINES                              *
    *&      Form  validate_material                                        *
          Validating Material Number(s)                                  *
    FORM validate_material .
      TYPES : BEGIN OF l_ty_matnr,
               matnr TYPE matnr,
              END OF l_ty_matnr.
      DATA : l_i_matnr TYPE STANDARD TABLE OF l_ty_matnr.
      SELECT matnr
             FROM mara
             INTO TABLE l_i_matnr
             WHERE matnr IN s_matnr.
      IF sy-subrc <> 0.
        MESSAGE text-004 TYPE 'E'.
      ENDIF.
    ENDFORM.                    " validate_material
    *&      Form  validate_plant                                           *
          Validating Plant Number                                        *
    FORM validate_plant .
      DATA : l_v_werks TYPE werks_d.
      SELECT SINGLE werks
                    FROM t001w
                    INTO l_v_werks
                    WHERE werks = s_werks-low.
      IF sy-subrc <> 0.
        MESSAGE e019(zartc) WITH s_werks-low.
      ENDIF.
    ENDFORM.                    " validate_plant
    *&      Form  populate_fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM populate_fieldcat .
      DATA : l_v_colname TYPE char7.
      SORT i_week BY week.
      DELETE ADJACENT DUPLICATES FROM i_week COMPARING week.
      LOOP AT i_week INTO wa_week.
        AT FIRST.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 1.
          wa_fieldcat-fieldname   = 'MATNR'.
          wa_fieldcat-scrtext_l   = text-007.
          wa_fieldcat-scrtext_m   = text-007.
          wa_fieldcat-scrtext_s   = text-007.
          wa_fieldcat-fix_column  = 'X'.
          wa_fieldcat-outputlen   = 18.
          wa_fieldcat-tooltip     = text-007.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 2.
          wa_fieldcat-fieldname   = 'WERKS'.
          wa_fieldcat-scrtext_l   = text-008.
          wa_fieldcat-scrtext_m   = text-008.
          wa_fieldcat-scrtext_s   = text-008.
          wa_fieldcat-fix_column  = 'X'.
          wa_fieldcat-outputlen   = 4.
          wa_fieldcat-tooltip     = text-008.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 3.
          wa_fieldcat-fieldname   = 'MAKTX'.
          wa_fieldcat-scrtext_l   = text-009.
          wa_fieldcat-scrtext_m   = text-010.
          wa_fieldcat-scrtext_s   = text-011.
          wa_fieldcat-tooltip     = text-009.
          wa_fieldcat-outputlen   = 40.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 4.
          wa_fieldcat-fieldname   = 'MEINS'.
          wa_fieldcat-scrtext_l   = text-012.
          wa_fieldcat-scrtext_m   = text-013.
          wa_fieldcat-scrtext_s   = text-014.
          wa_fieldcat-outputlen   = 4.
          wa_fieldcat-tooltip     = text-012.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
          wa_fieldcat-row_pos     = 0.
          wa_fieldcat-col_pos     = 5.
          wa_fieldcat-fieldname   = 'MTART'.
          wa_fieldcat-scrtext_l   = text-015.
          wa_fieldcat-scrtext_m   = text-015.
          wa_fieldcat-scrtext_s   = text-016.
          wa_fieldcat-tooltip     = text-015.
          APPEND wa_fieldcat TO i_fieldcat.
          CLEAR wa_fieldcat.
        ENDAT.
        v_year = wa_week-week+0(4).
        v_week = wa_week-week+4(2).
        CONCATENATE v_week k_slash v_year INTO l_v_colname.
        wa_fieldcat-row_pos     = 0.
        wa_fieldcat-col_pos     = 6 + sy-index.
        wa_fieldcat-fieldname   = wa_week-week.
        wa_fieldcat-quantity    = 'X'.
        wa_fieldcat-outputlen   = 18.
        wa_fieldcat-scrtext_l   = l_v_colname.
        wa_fieldcat-tooltip     = l_v_colname.
        APPEND wa_fieldcat TO i_fieldcat.
        CLEAR : wa_fieldcat,
                l_v_colname,
                wa_week.
      ENDLOOP.
    ENDFORM.                    " populate_fieldcat
    *&      Form  fill_table
          text
    -->  p1        text
    <--  p2        text
    FORM fill_table .
    **--Create Work Area Dynamically
      CREATE DATA wa_gp_line LIKE LINE OF <gt_table>.
      ASSIGN wa_gp_line->* TO <gwa_table>.
      DATA : l_v_col TYPE char25,
             l_v_val TYPE char25.
      LOOP AT i_final INTO wa_final.
        l_v_col = wa_final-week.
        ASSIGN COMPONENT l_v_col OF STRUCTURE <gwa_table>
                                           TO <l_field>.
        IF <l_field> IS ASSIGNED.
          l_v_val = wa_final-mng01.
          CONDENSE l_v_val.
          <l_field> = l_v_val.
          clear : l_v_val,
                  l_v_col.
        ENDIF.
        AT END OF matnr.
         READ TABLE   i_final INTO wa_final WITH KEY matnr = wa_final-matnr
                                                              BINARY SEARCH.
          IF sy-subrc = 0.
            ASSIGN COMPONENT 'MATNR' OF STRUCTURE <gwa_table>
                                             TO <l_matnr>.
            IF <l_matnr> IS ASSIGNED.
              <l_matnr> = wa_final-matnr.
            ENDIF.
            ASSIGN COMPONENT 'WERKS' OF STRUCTURE <gwa_table>
                                             TO <l_werks>.
            IF <l_werks> IS ASSIGNED.
              <l_werks> = wa_final-werks.
            ENDIF.
            ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <gwa_table>
                                             TO <l_maktx>.
            IF <l_maktx> IS ASSIGNED.
              <l_maktx> = wa_final-maktx.
            ENDIF.
            ASSIGN COMPONENT 'MEINS' OF STRUCTURE <gwa_table>
                                             TO <l_meins>.
            IF <l_meins> IS ASSIGNED.
              <l_meins> = wa_final-meins.
            ENDIF.
            ASSIGN COMPONENT 'MTART' OF STRUCTURE <gwa_table>
                                             TO <l_mtart>.
            IF <l_mtart> IS ASSIGNED.
              <l_mtart> = wa_final-mtart.
            ENDIF.
            APPEND <gwa_table> TO <gt_table>.
            CLEAR <gwa_table>.
          ENDIF.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " fill_table
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'ZMUNNA'.
      SET TITLEBAR 'MRP'.
      IF v_custom_container IS INITIAL.
        CREATE OBJECT v_custom_container
          EXPORTING
            container_name = v_container.
        CREATE OBJECT v_grid
          EXPORTING
            i_parent = v_custom_container.
        CALL METHOD v_grid->set_table_for_first_display
          CHANGING
            it_outtab       = <gt_table>
            it_fieldcatalog = i_fieldcat.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      v_ok_code = sy-ucomm.
      CLEAR sy-ucomm.
      CASE v_ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
          SET SCREEN 000.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  exit_program
          text
    -->  p1        text
    <--  p2        text
    FORM exit_program .
      CALL METHOD v_custom_container->free.
      CALL METHOD cl_gui_cfw=>flush.
    ENDFORM.                    " exit_program
    Reward points if that helps.
    Manish

  • Append new column to internal table

    Hi all,
    i have an internal table that was generated based on an ddic structure - now i want to add a column to that table. how can i do that ?
    thank you!
    clemens

    Hi to all, thank you for your help! here is the code that i have:
    REPORT *************_4 .
    TYPE-POOLS : abap.
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                   <dyn_wa>,
                   <dyn_field>.
    TYPE-POOLS: slis.
    TABLES: dd03l, dd04t.
    TYPES:
      BEGIN OF ty_table_struct,
        fieldname   TYPE dd03l-fieldname, " Tabellenname
        ddtext      TYPE dd04t-ddtext,    " Kurztext
        checkbox,
       END OF ty_table_struct.
    DATA:t_fieldcat TYPE slis_t_fieldcat_alv,
         w_fieldcat TYPE slis_fieldcat_main.
    DATA:
    gt_table_struct TYPE TABLE OF ty_table_struct.
    DATA: v_repid TYPE sy-repid.
    DATA:
          dy_table TYPE REF TO data,
          dy_line  TYPE REF TO data,
          xfc TYPE lvc_s_fcat,
          ifc TYPE lvc_t_fcat,
          l_tab_fields TYPE STANDARD TABLE OF ty_table_struct,
          w_tab_fields LIKE LINE OF l_tab_fields.
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(28) v_1 FOR FIELD p_table.
    PARAMETERS p_table TYPE dd03l-tabname OBLIGATORY VALUE CHECK.
    SELECTION-SCREEN END OF LINE.
    INITIALIZATION.
      v_1 = 'Tabelle für Dublettenprüfung'.
      v_repid = sy-repid.
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_display_data.
      PERFORM get_structure.
      PERFORM create_dynamic_itab.
      PERFORM get_data.
      PERFORM write_out.
    *&      Form  get_structure
    FORM get_structure.
      DATA : idetails TYPE abap_compdescr_tab,
             xdetails TYPE abap_compdescr.
      DATA : ref_table_des TYPE REF TO cl_abap_structdescr.
    * Get the structure of the table.
      ref_table_des ?=
          cl_abap_typedescr=>describe_by_name( p_table ).
      idetails[] = ref_table_des->components[].
      LOOP AT idetails INTO xdetails.
        READ TABLE l_tab_fields INTO w_tab_fields
        WITH KEY fieldname = xdetails-name.
        IF sy-subrc = 0.
          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.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "get_structure
    *&      Form  create_dynamic_itab
    *       text
    FORM create_dynamic_itab.
    * Create dynamic internal table and assign to FS
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = ifc
        IMPORTING
          ep_table        = dy_table.
      ASSIGN dy_table->* TO <dyn_table>.
    * Create dynamic work area and assign to FS
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
    ENDFORM.                    "create_dynamic_itab
    *&      Form  get_data
    *       text
    FORM get_data.
    * Select Data from table.
      SELECT (l_tab_fields) INTO CORRESPONDING FIELDS OF TABLE <dyn_table>
                 FROM (p_table).
    ENDFORM.                    "get_data
    *&      Form  write_out
    *       text
    FORM write_out.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                i_program_name         = v_repid
                i_structure_name       = p_table
           CHANGING
                ct_fieldcat            = t_fieldcat
           EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    * Show only fields that are needed
      LOOP AT t_fieldcat INTO w_fieldcat.
        READ TABLE l_tab_fields INTO w_tab_fields
        WITH KEY fieldname = w_fieldcat-fieldname.
        IF sy-subrc <> 0.
               DELETE t_fieldcat.
        ENDIF.
      ENDLOOP.
      w_fieldcat-tabname = '<dyn_table>'.
      w_fieldcat-fieldname = 'NETPR'.
      w_fieldcat-seltext_m = 'Net Price'.
      w_fieldcat-outputlen = 15.
      w_fieldcat-col_pos = 10.
    *  w_fieldcat-do_sum = 'X'. "Display column total
      w_fieldcat-datatype = 'CURR'.
      append w_fieldcat to t_fieldcat.
    * Write out data from table.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                it_fieldcat   = t_fieldcat
                I_BYPASSING_BUFFER = 'X'
           TABLES
                t_outtab      = <dyn_table>
           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.                    "write_out
    *&      Form  f_read_data
    *       text
    FORM f_read_data.
      SELECT * FROM ( dd03l
                INNER JOIN dd04t
                ON  dd03l~rollname = dd04t~rollname
                AND dd04t~ddlanguage = syst-langu
                AND dd04t~as4local = 'A' ) INTO CORRESPONDING FIELDS OF
    TABLE
      gt_table_struct WHERE dd03l~tabname = p_table .
    ENDFORM.                               " F_READ_DATA
    *      Form  f_display_data
    FORM f_display_data.
    * Macro definition
      DEFINE m_fieldcat.
        add 1 to ls_fieldcat-col_pos.
        ls_fieldcat-fieldname   = &1.
        ls_fieldcat-ref_tabname = &2.
        ls_fieldcat-rollname = &3.
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
      TYPE-POOLS: slis.                    " ALV Global types
      DATA:
        l_exit,
        ls_private  TYPE slis_data_caller_exit,
        ls_field    TYPE ty_table_struct,
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv.
    * Build the field catalog
      m_fieldcat 'FIELDNAME' 'ty_table_struct' 'FIELDNAME'.
      m_fieldcat 'DDTEXT'    'ty_table_struct' 'DDTEXT'.
    * Optimize column width
      ls_private-columnopt = 'X'.
    * Display data in a popup
      CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
           EXPORTING
                i_selection          = 'X'
                i_zebra              = 'X'
                it_fieldcat          = lt_fieldcat
                i_tabname            = 'gt_table_struct'
                i_checkbox_fieldname = 'CHECKBOX'
                is_private           = ls_private
           IMPORTING
                e_exit               = l_exit
           TABLES
                t_outtab             = gt_table_struct.
      CHECK l_exit = space.
    * write selected columns to the internal table for inclusion
    * into fieldcat
      LOOP AT gt_table_struct INTO ls_field WHERE checkbox = 'X'.
        APPEND ls_field-fieldname TO l_tab_fields.
      ENDLOOP.
    ENDFORM.
    What
    i want it to do is, have the alvgrid displaying the fields from t_fieldcat, plus some fields ( that should be appended to the internal table before, i think ? ). What went wrong ? 
    Clemens

  • Show dynamic columns in ALV table

    I have a question that i need to create report in ALV
    like this ...
    i need to select doc date e.g. from 03.11.2007 to 05.02.2008
    and the report is expected to show like this
    SO#   |  cust |  sales gp | 2007-11 order amt | 2007-12 order amt | 2008-01 order amt | 2008-02 order amt
    ____ |_____|________|________________|________________|________________|_________________
              |         |               |                            |                            |                            | 
    something like that ....
    the no. of period column which is depend on the range of selected doc date....
    so how to do that ?!?!?

    hi sky ,
      use dynamic table as:-
      Declaration for Dynamic Table:-
    FIELD-SYMBOLS: <dyn_table>  TYPE STANDARD TABLE,
                   <dyn_table1> TYPE STANDARD TABLE,
                   <dyn_wa1>,
                   <dyn_wa>.
    FIELD-SYMBOLS: <l_fs_dyn> TYPE ANY,
                   <l_fs_bom> TYPE ANY.
    *---Dynamic Internal Table
    DATA: dy_table            TYPE REF TO data,
          dy_table1           TYPE REF TO data,
          dy_line             TYPE REF TO data.
    Creation of Dynamic Internal Table:-
      CALL METHOD cl_alv_table_create=>create_dynamic_table
           EXPORTING
             it_fieldcatalog = fcat  (for which internal table needs to be built)
           IMPORTING
             ep_table = dy_table
           EXCEPTIONS
             generate_subpool_dir_full = 1
             OTHERS = 2
      IF sy-subrc <> 0.
      ENDIF.
    Population of Dynamic Internal Table:-
    CLEAR: l_tabix,
           w_tabix.
      ASSIGN dy_table->* TO <dyn_table>.
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
      ASSIGN dy_table->* TO <dyn_table1>.
      CREATE DATA dy_line LIKE LINE OF <dyn_table1>.
      ASSIGN dy_line->* TO <dyn_wa1>.
       LOOP AT it_parent.
        l_tabix = sy-tabix.
        LOOP AT fcat INTO ls_fcat TO 23."WHERE col_pos <= '19'.
            ASSIGN COMPONENT ls_fcat-fieldname
                OF STRUCTURE <dyn_wa> TO <l_fs_dyn>.
            ASSIGN COMPONENT ls_fcat-fieldname
                OF STRUCTURE it_parent TO <l_fs_bom>.
            <l_fs_dyn> = <l_fs_bom>.
          ENDIF.
        ENDLOOP
    Thanks & Regards,
    Ruchi Tiwari

  • Dynamic Structures and Internal Tables

    Hi All,
    I am doing a report to create condition records based on the condition type and condition table. Assume the condition type as PR00 and it as condition table of 304,305,306.Each condition table as its own header and item fields.Based on the  condition table that the user specifies in the selection screen
    the header and item structures of my report should change dynamically and these should be moved  to the dynamic internal table that contains both header and item fields.Can anyone give an idea how to achieve it. Thanks in advance.
    Regards,
    Chakradhar.

    Hi All,
    Thanks for your replies.
    SPLIT i_string_line-input_str AT cl_abap_char_utilities=>horizontal_tab
    INTO i_header_line-header
              i_header_line-vkorg
              i_header_line-vtweg                                                                              
              i_header_line-pltyp                                                                              
             i_header_line-waerk.    
    In the above syntax based on the condition table I selected on selection screen my flat file is as below.
    case 1: If condition table given is 304
    H    SalesOrganization    DistributionChannel    Customer
    I    Material    Releasestatus    Amount    Currency    ValidFrom    ValidTo
    case 2: If condition table given is 305
    H    SalesOrganization    DistributionChannel
    I    Material    Releasestatus    Amount    Currency    ValidFrom    ValidTo
    case 3: If condition table given is 306
    H    SalesOrganization    DistributionChannel     PriceListType     DocumentCurrency
    I    Material    Releasestatus    Amount    Currency    ValidFrom    ValidTo
    In the above code i_string_line-input_str contains the following heading of fields based on the condition table we select in selection screen.when I want to split them into respective fields
    using INTO clause my structure should change dynamically.How can I achieve it and my entire program is in OOPS ALV.Thanks in Advance.
    Regards,
    Chakradhar.

  • Multiple dynamic column in cross table

    Hi all,
    I have a cross table which stored the sale's quantity and amount.
    The layout in view result likes below:
    saler     quantity1 quantity2 quantity3 quantitysummary amount1 amount2 amount3 amount4 amountsummary
    S3           100           20
    S2           50             30
    S1           300           40
    The layout in view structure likes below:
    saler     quantity quantitysummary amount amountsummary
    S3           100           20
    S2           50             30
    S1           300           40
    the quantity1...n and amount1...n columns is not fixed.the 2 columns is dynamic.
    It's easy that only one column is dynamic,but now there are two columns is dynamic,I don't know how to achieve it.
    Has anyone an idea how to accomplish this?
    Thank you trying to help me!

    You cant do this on BO , you can add static columns but if you put some dynamic column in the left or right i turns dynamic...
    Regards

  • Inserting columns from internal table to a database table!

    Hi people,
    How do I go about to insert columns from an internal table -intab- into an data base table -dbtab-. These tables contain some similar columns, not all.
    A code example would be much appriciated!
    /Armin

    hi armin,
    INSERT  dbtab      FROM TABLE itab. oder
    INSERT (dbtabname) FROM TABLE itab.
    Extras:
    1. ... CLIENT SPECIFIED
    2. ... ACCEPTING DUPLICATE KEYS
    3. ... CONNECTION con
    Effect
    Mass insert: All lines of the internal table itab are inserted in one single operation. The lines of itab must fulfill the same conditions as the work area wa in variant 1.
    When the command has been executed, the system field SY-DBCNT contains the number of inserted lines.
    The Return Code is set as follows:
    SY-SUBRC = 0:
    All lines successfully inserted. Any other result causes a runtime error.
    Note
    If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0 after the call.
    Addition 1
    ... CLIENT SPECIFIED
    Effect
    As with variant 1.
    Addition 2
    ... ACCEPTING DUPLICATE KEYS
    Effect
    If a line cannot be inserted, the system does not
    terminate with a runtime error but only sets the return value SY-SUBRC to 4. All other lines are inserted after the command is executed.
    hope this helps,
    do reward if it helps,
    priya.

  • Reading particular column from internal table

    Hi
    I am having one internal table with one row. I know the column number. I want to read that particular column value. What should I add with the below statement.
    Read table itab index 1.
    This will give me the whole row. I want only the particular column.
    Please help me to solve this issue
    Thanks.

    Hi,
    FIELD-SYMBOLS <FS_ANY>
    ASSIGN COMPONENT N OF STRCUTURE OF WORKAREA TO <FS_ANY>
    WRITE <FS_ANY>
    Where n is the column number and workarea is the row of the internal table.
    Rgards,
    Ravi
    Note : Please mark the helpful answers

  • Function module to find the columns in Internal table

    Hi Group,
    Is there any function module which displays the columns of the internal table. I guess there is one cos when we debug any program and select the "Tables" button while debugging and enter an internal table and then do a "Find" the pop up which comes up shows the internal table columns. As this functionality is in the debugger which I cannot debug hence was wondering if some one has come across any such function module. Thanks in advance.
    Regards,
    Ankur Bhandari
    [email protected]

    Hi again,
    1. In the above FM
       Pass Program as SY-REPID (U cann pass other prg name also)
    in FieldName Pass the name of the internal table
       eg. 'ITAB'
    2. This FM will give u the details of the
       internal table.
       The u can display the COMPONENTS table
       using ALV or anyother method u like.
    Regards,
    Amit M.

Maybe you are looking for

  • Leopard won't install on PPC iMac G5

    Hello, I've had my iMac G5 (non-intel) since 2005. I've recently upgraded my iphone to a 4, and I want to install Leopard so I can sync with my computer. After going to all the trouble and expense to get the software, I stick it in and click upgrade.

  • How to show PDFs from a shared library?

    Hi, is it possible to share also PDFs from another library? I am sharing my library from my own itunes account. It also contains PDFs and the whole library is shared. On the account of my wife my shared library shows up with all the music etc. Howeve

  • UJ-845 + Sony DVD-R media: VIDEO at 8X, DATA at only 2X????

    Drive: Model: MATSHITADVD-R UJ-845 Revision: D8PB Media: Sony DVD-R, 250MR47LS3. 120 min, 4.7 GB, 1x-8x compatible. When I create a Finder burn folder and try to burn a data DVD, to the Sony DVD, the only choices it offers me are 1X and 2X. But, when

  • WTMG withholding tax conversion

    Hello to you all, Once I run Tcode WTMG withholding tax conversion, I was surprised to receive an error message FWTM379 "Table T059Z, country IL, percentage rate for type 06, code 01 (==> long txt)". The classic WT codes based on the idea that the pe

  • App dilema

    Any time i try to download an app I get a message that reads "We could not complete your request. There was an error in the App store. Please try again later. (4) This happens for any app.