Get Fields In Table Dynamically

I am trying to create a dynamic query that will allow me to
query a table, pull all of the fields and dump all of the data into
a text file: I have been able to make the dynamic query, but I am
unable to display all of the data on the page when I loop through
my fields... Does anyone know how to do this... Here is my query to
get the fields dynamically... How would I go about actually
querying the datasource and grabbing all of the data from the
fields?
<cfquery name="getfields" datasource="#db#">
select *
from billing
</cfquery>
<cfset thecolumnlist = getfields.columnlist>
<cfloop list="#thecolumnlist#" index="i">
<cfoutput>
#i#
</cfoutput>
</cfloop>
Thanks to anyone who can help me!!!

There are pros/cons to using SELECT *. Its easier typing, but
more db work. Its also easier
to accidentally include columns like "Password" or "Salary".
You can output the query values using array syntax:
#QueryName[ColumnName][rowNumber]# .
<cfoutput query="getFields">
<cfloop list="#getfields.ColumnList#"
index="columnName">
#getFields[columnName][currentRow]#
</cfloop>
<br/>
</cfoutput>
There are a few functions at cflib.org for converting a query
to a CSV file
http://www.cflib.org/udf.cfm?id=1197.
http://www.cflib.org/udf.cfm?ID=404
Or you could do it yourself. Loop through the query and
append the values to a string variable, adding a newline after each
record. Use cffile if you want to save the output to disk. Use
cfcontent/cfheader if you want the output to be downloaded. This is
a popular question so there are many examples. Google for
ColdFusion CSV or ColdFusion CSV download

Similar Messages

  • Getting field  and table

    hai all
    Is there any easy method to find the table name and field name from short description for a particular field?
    (i had only short description of a particular field..i need field name and table name )
    kindly help
    rewards will be given for useful answers

    DD02T is table which contains all table names texts
    DD03T is table which contains all fields names texts
    u can go through these tables and find the table and field
    required
    reward if helpful
    raam

  • Where can i get   SALES  ORGANIZATION    FIELD and TABLE

    Can anybody tell me   where can i get   FIELD  and   TABLE  Name   OF  " sales organization    "

    Dear Sandeep,
    u will find VKORG is the Sales Organisation .
    u will find this Field in every related SD Module Table...
    Like ...VBAP,BKPF ..etc..
    Hope it helps...!!!
    Pls reward if Helpful...!!!

  • How to delete a field from a Dynamically created internal table

    Hi friends,
    I have got a requirement in which, I will be entering the table name and Excel file from seletion-screen.
    based on the Table I have entered in the selection-screen I need to create a dynamic internal table so that I can fill that Execel data into that internal table and later i using BDC i can I can fill the database table using SM30 transaction.
    here. my problem is that, When I am creating internal table dynamically, MANDT filed is also getting created in the internal table.
    please, help in deleteing the filed MANDT from the internal able.
    following is the code which creates the dynamic internal table.
    CREATE DATA dy_table TYPE TABLE OF (p_tabname).
    assign dy_table->* to <dyn_table>.
    please provide, if any sample code is available.
    Regards,
    Xavier.P

    Hi,
    You can use this logic,
    While creating the Dynamic filed catalog try to avoid MANDT field.
    Ex:
    *Dynamic creation of a structure
      CREATE DATA LP_STRUCT TYPE (V_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 = V_TABLE.
        APPEND LS_LVC_CAT TO LT_LVC_CAT.
        CLEAR LS_LVC_CAT.
      ENDLOOP.

  • Dynamic Fields in Table control......

    hi friends,
    i wan to knw , is it possible to add fields dynamically in table control? actually the requirement is like, it is not fixed how many fields will be their in table control, it may change depending upon date. so if u knw, please help me out....
    good points will be awarded to helpful answer.....
    Thanks,
    Brij

    Hi Harsha,
    I generated a table control (ERP 6.2) and somewhere I found the coding like this (the name of the table control is TABLE_CONTROL):
    *&spwizard: output module for tc 'TABLE_CONTROL'. do not change this lin
    *&spwizard: get lines of tablecontrol
    module TABLE_CONTROL_get_lines output.
      g_TABLE_CONTROL_lines = sy-loopc.
    If I do a loop at the screen at this place, I can control the individual input/output for the screen fields (the table fields). In my work area (WA_CONTROL) I can see the actual value of fields. Depending on this, I choose to enable/disable input via:
    loop at screen.
    if wa_control-material <> ' '.
    screen-input = '0'.
    modify screen.
    endif.
    endloop.

  • Create internal table dynamically for IDoc fields

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

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

  • Field KZWI4 is not getting updated in table EKPO

    I have a case where for two scheduling agreements the pricing procedure getting determined is the same, but the field KZWI4 (subtotal 4) in table EKPO is getting updated for one SA and not for the other. The only difference in the two SAs are the tax codes. Do tax codes have any bearing on the field KZWI4 getting updated in table EKPO?
    Regards,
    Pratima.

    Hi Pratima,
    unfortunately i can only write that I am facing the same challenge at the moment. I will update the discussion as soon as I have a solution.
    Best regards
    Bjoern

  • CJ20N-fields are not getting updated in table PROJ

    Hi all,
    I have a requirement where I need to transfer the WBS element data created in one system to another using IDOC.
    The idoc has generated sucessfully and was also sent/processed successfully in the recieving system but fields STSPD and STSPR are not getting poulated in table PROJ.
    In the confic I have assigned FM:IDOC_INPUT_PROJECT to the process code.
    Thanks,
    Gaurav

    Hi,
    Please check with the Customer and Material Statistics group in the Customer and material master respectively.
    Further check with the LIS settings (Sales Area combination with the Update group).
    Reward points if this helps you.
    Regards,
    Harsh

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

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

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

  • Dynamic Field in Table TCJ1

    Hello Experts,
    I have doubt how the description get automatically populated in Table TCJ1.
    When I see the fields in TCJ1, I see only 2 fields present. But when I see the table value another field Description gets automatically populated. It fetches the description from TCJ1T and populate the table TCJ1.
    How actually this happens? How does TCJ1 table know, its description is present in TCJ1T? Is it specified in Table?
    Well reason I am asking is I have simillar requirement in report KKRC.
    I have added some fields in table PSMERK (For summarization characteristic tab tcode CJ20n). Now customs fields are added in KKRO ( Customization for KKRC report) .
    Currently when KKRC gets executed , description of the custom fields is not getting populated. I dont know how will KKRC know description of the custom fields needs to be fetched from another table.
    Thanks,

    Hi Sankar ,
    In tables there is a concept called Text Tables , which usually is used to store description.
    Now you might think my we need a text table  , the reason is the text can be stored in a number of diffrent languages, so a text table will have value for which description is to be stored , language and the description.
    Now how u see the text table
    SE11--> Enter the table name TCJ1 --> GoTo(In the dropdown there is some thing called text Tables , click on it you go to a table called TCJ1T )
    Another very comman example is for MARA , see what is the text table for MARA.
    Regards
    Arun
    Reward with point if found helpful

  • Are field symbols and Dynamic internal tables consistant?

    Hi,
    Are field symbols and Dynamic internal tables
    always consistent?
    In my program I m creating a dynamic itab and assignig values to it using <FS>, sometimes the program fails to execute assign <Fs> statement...
    this happens once in 3 to 4 runs
    any solution...
    I have proper clear and refresh statements in program.
    Thanks,
    Hardik

    Anurag,
    Thanks for a quick reply. Here I am sending a small piece of my code.
    MOVE-CORRESPONDING OUTTAB TO DYNTAB.
          CLEAR IT_UDATE.
          CLEAR : T_KBETR .
          READ TABLE IT_UDATE WITH KEY UDATE = OUTTAB-UDATE.
          CONCATENATE 'DYNTAB-KBETR' IT_UDATE-CO_POS INTO T_KBETR.
          ASSIGN (T_KBETR) TO <FS> .
          SUBRC5 = SY-SUBRC .
          IF SUBRC5 = 0 .
              <FS> =  OUTTAB-KBETR .
          ENDIF .
    read statement will always return CO_POS .
    while debuging this code a few times
    <b>ASSIGN (T_KBETR) TO <FS> .</b>
    returns sy-subrc = 4
    and that was leading the program to short dump earlier.
    now, as I have a check DYNTAB-KBETR holds no value on display.
    this happens very few times. (most of the times report is displaying desired output)
    Thanks,
    Hardik

  • How to create table field inside the dynamically created table?

    Hi, All!
    I have created dynamic internal table (using field catalog and CALL METHOD cl_alv_table_create=>create_dynamic_table )
    and put this table  into FM REUSE_ALV_GRID_DISPLAY. ALV grid work. Now I need to color rows of my ALV, therefore  I have to insert new column with name "COLORS" and type lvc_t_scol. I  see three ways to do it , but all ones are unsuccessful:
    1. Insert column into field catalog. FM REUSE_ALV_FIELDCATALOG_MERGE does not return info about "COLORS" I guess because COLORS is a table.
    2. Insert column into field catalog manually. It provides a short dump during dynamic table creating or during call of REUSE_ALV_GRID_DISPLAY.
    3. Create dyn table first, then add new field . I could not find a way how to do it :(((((((
    Can somebody help me?
    Tatiana

    Hi,
    Here is the solution for this problem, Sample code:
    *& Report  ZCHA_ALV_GRID_CELL_COLOR                                    *
    REPORT  ZCHA_ALV_GRID_CELL_COLOR                .
    TABLES:MARA.
    DATA: W_CONTAINER         TYPE SCRFNAME VALUE 'ALV_CONTAINER',
          W_GRID              TYPE REF TO CL_GUI_ALV_GRID,
          W_CUSTOM_CONTAINER  TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
         W_EVENT_RECEIVER    TYPE REF TO LCL_EVENT_RECEIVER.
    *layout
    DATA: WA_LAYOUT           TYPE LVC_S_LAYO.
    *field catalog
    DATA: IT_FIELDCAT_WRT_OFF TYPE LVC_T_FCAT,
          WA_FIELDCAT_WRT_OFF TYPE LVC_S_FCAT.
    DATA:BEGIN OF IT_MARA OCCURS 0,
         MATNR LIKE MARA-MATNR,
         MAKTX LIKE MAKT-MAKTX,
         CELLCOLORS TYPE LVC_T_SCOL,
         END OF IT_MARA.
    SELECT P~MATNR
           Q~MAKTX
           INTO CORRESPONDING FIELDS OF TABLE IT_MARA
           FROM MARA AS P INNER JOIN
                MAKT AS Q ON
                PMATNR = QMATNR.
    CALL SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'STATUS'.
    SET TITLEBAR 'xxx'.
      IF NOT W_CONTAINER IS INITIAL.
        CREATE OBJECT W_CUSTOM_CONTAINER
                 EXPORTING CONTAINER_NAME = W_CONTAINER.
        CREATE OBJECT W_GRID
                 EXPORTING I_PARENT = W_CUSTOM_CONTAINER.
      ENDIF.
      CLEAR IT_FIELDCAT_WRT_OFF.
      REFRESH IT_FIELDCAT_WRT_OFF.
      WA_FIELDCAT_WRT_OFF-FIELDNAME = 'MATNR'.
      WA_FIELDCAT_WRT_OFF-COL_POS   = '1'.
      WA_FIELDCAT_WRT_OFF-OUTPUTLEN = '35'.
      WA_FIELDCAT_WRT_OFF-SCRTEXT_L = 'Material No'.
      APPEND WA_FIELDCAT_WRT_OFF TO IT_FIELDCAT_WRT_OFF.
      CLEAR WA_FIELDCAT_WRT_OFF.
      WA_FIELDCAT_WRT_OFF-FIELDNAME = 'MAKTX'.
      WA_FIELDCAT_WRT_OFF-COL_POS   = '2'.
      WA_FIELDCAT_WRT_OFF-OUTPUTLEN = '45'.
      WA_FIELDCAT_WRT_OFF-SCRTEXT_L = 'Material Desc'.
      APPEND WA_FIELDCAT_WRT_OFF TO IT_FIELDCAT_WRT_OFF.
      CLEAR WA_FIELDCAT_WRT_OFF.
      DATA LS_CELLCOLOR TYPE LVC_S_SCOL.
      READ TABLE IT_MARA INDEX 5 .
      LS_CELLCOLOR-FNAME = 'MATNR'.
      LS_CELLCOLOR-COLOR-COL = '3'.
      LS_CELLCOLOR-COLOR-INT = '1'.
      APPEND LS_CELLCOLOR TO IT_MARA-CELLCOLORS.
      MODIFY IT_MARA INDEX 5.
      WA_LAYOUT-CTAB_FNAME = 'CELLCOLORS'.
      CALL METHOD W_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IS_LAYOUT       = WA_LAYOUT
        CHANGING
          IT_FIELDCATALOG = IT_FIELDCAT_WRT_OFF
          IT_OUTTAB       = IT_MARA[].
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    Try to assign appropriate points.
    Regards,
    Suman

  • ALV display using dynamic field catalog and dynamic internal table

    hi ,
    please guide me for ALV display using dynamic field catalog and dynamic internal table.
    Thank you.

    Hi Rahul,
    maybe thread dynamic program for alv is helpful for you. More information about the [SAP List Viewer (ALV)|http://help.sap.com/saphelp_nw70/helpdata/EN/5e/88d440e14f8431e10000000a1550b0/frameset.htm]. Also have a look into the example programs SALV_DEMO_TABLE*.
    Regards Rudi

  • How to hide fields in table maintenance generator dynamically.

    Hello Experts,
                         I have one requirement and that needs to do dynamically display the fields in table maintenance generator based on the selected radio button.I have written the code in pbo but it is not working properly,can anyone figure me out in this.
    Thanks,
    Vinod Bhaskar.

    Hi vinod
         when you are creating tmg , you will specific a function group name  and sap generate a func group which contains that tmg . you can view in se80 , specifying function group name. In that , screen contains single screen 100 or two screen 100,200 .
         screen you can create module in pbo .u can find all field name in that screen.
        loop at screen.
       if screen-name = ''.
       screen-visible = 0.
       endif.
       modify screen.
       endloop.
    regards,
    vijay.

  • How to Copy data from field symbol to Dynamic Internal Table

    Hi,
    I want to copy the data between two dynamic Internal tables . Following is the code were I have data in the field symbol wanted to transfer it to the other Internal table :
    REPORT  ztest.
    DATA:
           gd_dref          TYPE REF TO data,
           gd_dref1          TYPE REF TO data.
    FIELD-SYMBOLS:  <fs1>   TYPE any,
                               <fs_wa> TYPE any,
                                <field>    TYPE any,                  
                                <fs_wa1> TYPE ANY TABLE.  * Contains data from p_src
    *Copy data from p_src to p_dest*
    PARAMETERS: p_src LIKE dd02l-tabname .    * Name of Dynamic Internal table *
                             p_dest LIKE dd02l-tabname .  * Name of Dynamic Internal table*
    *DATA : lt_csks LIKE p_dest WITH HEADER LINE.
    START-OF-SELECTION.
      CREATE DATA gd_dref TYPE (p_src).
      CREATE DATA gd_dref1 TYPE TABLE OF (p_src).
       ASSIGN gd_dref->* TO <fs_wa>.
       ASSIGN gd_dref1->* TO <fs_wa1>.
       SELECT * FROM (p_src) INTO TABLE <fs_wa1>.
    *Write out data from FIELD SYMBOLS TO Table.
       loop at <fs_wa1> into <fs_wa>.
         do.
           assign component  sy-index
              of structure <fs_wa> to <field>.
           if sy-subrc <> 0.
           exit.
           endif.
           if sy-index = 1.
             write:/ <field>.
           else.
           write: / <field>.
           endif.
         enddo.
       endloop.
    *Need Logic To Copy the Data to p_dest table from <fs_wa1>.
    *p_dest is a table having a similar structure to table p_src .
    *Need Logic To Copy the Data to p_dest table from <fs_wa1>.
    EXIT.
    Thanks in Advance.

    try this...
    I have extended your source code and just used vbak/vbap as an example as they have some common fields like vbeln/erdat etc which corresponds with your requirement of 'similar structure' i.e. shared/common fields in both.
    Cheers...
    report  ztest.
    data:
      gd_dref type ref to data,
      gd_dref1 type ref to data,
      gd_dref_str type ref to data,
      gd_dref_tab type ref to data.
    field-symbols:
      <fs1> type any,
      <fs_wa> type any,
      <fs1_dest_str> type any,
      <fs_dest_tab> type any table,
      <field> type any,
      <fs_wa1> type any table.
    * contains data from p_src
    *Copy data from p_src to p_dest*
    parameters: p_src like dd02l-tabname default 'vbak',
    * name of dynamic internal table *
                p_dest like dd02l-tabname default 'vbap'.
    * name of dynamic internal table*
    *data : lt_csks like p_dest with header line.
    start-of-selection.
      create data gd_dref type (p_src).
      create data gd_dref1 type table of (p_src).
      assign gd_dref->* to <fs_wa>.
      assign gd_dref1->* to <fs_wa1>.
      select * from (p_src) into corresponding fields of table <fs_wa1>
      up to 3 rows
      where vbeln ne space.
      create data gd_dref_str type (p_dest).
      create data gd_dref_tab type standard table of (p_dest).
      assign gd_dref_str->* to <fs1_dest_str>.
      assign gd_dref_tab->* to <fs_dest_tab>.
    *write out data from field symbols to table.
      loop at <fs_wa1> into <fs_wa>.
        " break-point here - can see vbeln/waers/create date/ etc move over to new structure
        " the 'common' fields of your structures - the same will happen. if they not the same name you will have to do an
        " explicit move i.e. if fieldname = xyz ....move fieldxyz to new field123....after the move-corre
        break-point.
        move-corresponding <fs_wa> to <fs1_dest_str>.
        insert <fs1_dest_str> into table <fs_dest_tab>.
    **    do.
    **      assign component  sy-index
    **         of structure <fs_wa> to <field>.
    **      if sy-subrc <> 0.
    **        exit.
    **      endif.
    **      if sy-index = 1.
    **        write:/ <field>.
    **      else.
    **        write: / <field>.
    **      endif.
    **    enddo.
      endloop.
      " write out some dest data from the dest table build from previous loop
      loop at <fs_dest_tab> assigning <fs1_dest_str>.
        do.
          assign component sy-index of structure <fs_wa> to <field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <field>.
          else.
            write: / <field>.
          endif.
        enddo.
      endloop.

Maybe you are looking for

  • Can 2 users on a macbook pro share an iPhoto library?

    We have 2 users on the one laptop and would like to be able to share the iphoto library between us. Is it possible?

  • Multiple appointments in iCal

    I'm one week into using iCal as an appointment diary for a healthcare practice.  We often need to book 2 patients in at the same time.  Mostly, these sit side by side but occasionally they overlap - is there anyway to sort this out?  This is especial

  • Why can't I download the latest iTunes to my mac which is a 10.5.8

    I have got myself in a real mess, I installed the new iOS 7 onto my iPad and I don't like it so I imported all my new photos to my mac, then I reset all my settings on my iPad thinking that it would go back to the original settings but alas didn't wo

  • SQL Loader ISSUE- when invoking function in a package - in Direct Path- SPK

    This is the loader file a.ctl load data append into table emp when eno='4' (eno number, ename varchar2(20)) when (1)<>'4' into table detpt (deptno number, deplogid "Log.get_logid('logid')" Note: the deptlogid field is not null column. The par fie is

  • Link error for distribution

    Hi, I received an email with the link to download the new version of flash player for distribution, but does not work Dear Miguel Ángel Abarca, Thank you for submitting a request to distribute Adobe® Software. Your request has been approved, and you