<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fetch data from Table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118369#M740521</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for u r reply.&lt;/P&gt;&lt;P&gt;I almost got solution for my questions.&lt;/P&gt;&lt;P&gt;i am using Fm &amp;lt;b&amp;gt;/SAPAPO/TS_PA_COPY_TABLE_GET&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;This is SCM system.&lt;/P&gt;&lt;P&gt;using this function module, i am geting table name for planning book name( this is my export parameter for that FM).&lt;/P&gt;&lt;P&gt;i need to fetch data from that  table (which name i got through Fm) and need to update field value in that table.&lt;/P&gt;&lt;P&gt;So, can u give me extended code for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Ina advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhaksar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Dec 2007 04:29:16 GMT</pubDate>
    <dc:creator>former_member189596</dc:creator>
    <dc:date>2007-12-03T04:29:16Z</dc:date>
    <item>
      <title>Fetch data from Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118367#M740519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using function module through Call fucntion.&lt;/P&gt;&lt;P&gt;There i am getting &amp;lt;b&amp;gt;Table Name&amp;lt;/b&amp;gt; as import Parameter.&lt;/P&gt;&lt;P&gt;Now i need to fetch data from that table (Which name we got througfh function module).&lt;/P&gt;&lt;P&gt;Is there any point to know how can we fetch data from runtime table .&lt;/P&gt;&lt;P&gt;i need some sample code for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks inn advance,&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhaskar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2007 03:37:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118367#M740519</guid>
      <dc:creator>former_member189596</dc:creator>
      <dc:date>2007-12-03T03:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch data from Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118368#M740520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if I got your question correctly&lt;/P&gt;&lt;P&gt;From what I understood, you need to fetch data from a table whose name is determined at runtime&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that is your requirement, then use the following code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : LV_FIELD_DESC TYPE STRING.
DATA : LV_DATA1 TYPE STRING.
DATA : LV_DETAIL(128).
DATA : COMMA TYPE C VALUE ','.
DATA : LV_TNAME LIKE DD02L-TABNAME.
DATA : LV_DBTAB1 LIKE DD02L-TABNAME.
DATA : DREF TYPE REF TO DATA.

FIELD-SYMBOLS: &amp;lt;ITAB&amp;gt; TYPE ANY TABLE, " used to store dynamic tables
               &amp;lt;WA&amp;gt;    TYPE ANY,      " used to store record data
                &amp;lt;WA1&amp;gt; TYPE ANY .      " used to store field data

LV_DBTAB1 = 'MARA'. " &amp;lt;-- put your table name here

* we do not know the sized of the table that must be generated beforehand
* hence we use field symbols to dynamically generate the internal table
  CREATE DATA DREF TYPE STANDARD TABLE OF (LV_DBTAB1)
                            WITH NON-UNIQUE DEFAULT KEY.
  ASSIGN DREF-&amp;gt;* TO &amp;lt;ITAB&amp;gt; .

* selects all data
  SELECT * FROM (LV_DBTAB1) INTO TABLE &amp;lt;ITAB&amp;gt; .
  LOOP AT &amp;lt;ITAB&amp;gt; ASSIGNING &amp;lt;WA&amp;gt;.

    DO.
      ASSIGN COMPONENT SY-INDEX
             OF STRUCTURE &amp;lt;WA&amp;gt; TO &amp;lt;WA1&amp;gt;.
      IF SY-SUBRC &amp;lt;&amp;gt; 0.
        EXIT.
      ENDIF.
      IF SY-SUBRC = 1.
        WRITE :/ .
      ENDIF.
      MOVE &amp;lt;WA1&amp;gt; TO LV_DETAIL.
      CONCATENATE LV_DATA1 LV_DETAIL COMMA INTO LV_DATA1.
    ENDDO.

*   display
    NEW-LINE.
    WRITE LV_DATA1.

*   file output if required
*   TRANSFER LV_DATA1 TO LV_OUTFILE.

*   clears the variable for reuse
    CLEAR LV_DATA1.

  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2007 04:12:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118368#M740520</guid>
      <dc:creator>former_member189059</dc:creator>
      <dc:date>2007-12-03T04:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch data from Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118369#M740521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for u r reply.&lt;/P&gt;&lt;P&gt;I almost got solution for my questions.&lt;/P&gt;&lt;P&gt;i am using Fm &amp;lt;b&amp;gt;/SAPAPO/TS_PA_COPY_TABLE_GET&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;This is SCM system.&lt;/P&gt;&lt;P&gt;using this function module, i am geting table name for planning book name( this is my export parameter for that FM).&lt;/P&gt;&lt;P&gt;i need to fetch data from that  table (which name i got through Fm) and need to update field value in that table.&lt;/P&gt;&lt;P&gt;So, can u give me extended code for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Ina advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhaksar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2007 04:29:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118369#M740521</guid>
      <dc:creator>former_member189596</dc:creator>
      <dc:date>2007-12-03T04:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch data from Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118370#M740522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Bhaskar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't have an SCM system, so I cannot test out that FM&lt;/P&gt;&lt;P&gt;However, I modified the above code to update the table as well&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZKRIS_DYNAMIC_TABLE_READ_MOD
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*

REPORT  ZKRIS_DYNAMIC_TABLE_READ_MOD LINE-SIZE 256.

DATA : LV_FIELD_DESC TYPE STRING.
DATA : LV_DATA1 TYPE STRING.
DATA : LV_DETAIL(128).
DATA : COMMA TYPE C VALUE ','.
DATA : LV_TNAME LIKE DD02L-TABNAME.
DATA : LV_DBTAB1 LIKE DD02L-TABNAME.
DATA : DREF TYPE REF TO DATA.
DATA : FLAG_MODIFIED.  " determines if database needs to be updated

FIELD-SYMBOLS: &amp;lt;ITAB&amp;gt; TYPE ANY TABLE, " used to store dynamic tables
               &amp;lt;WA&amp;gt;    TYPE ANY,      " used to store record data
                &amp;lt;WA1&amp;gt; TYPE ANY .      " used to store field data

* call Fm /SAPAPO/TS_PA_COPY_TABLE_GET here
LV_DBTAB1 = 'ZGSTSET'. " &amp;lt;-- put your table name here

DATA: IT_FIELDS TYPE X031L OCCURS 0.
DATA: WA_FIELDS LIKE LINE OF IT_FIELDS.

CALL FUNCTION 'DDIF_NAMETAB_GET'
  EXPORTING
    tabname           = LV_DBTAB1
*   ALL_TYPES         = ' '
*   LFIELDNAME        = ' '
*   GROUP_NAMES       = ' '
*   UCLEN             =
* IMPORTING
*   X030L_WA          =
*   DTELINFO_WA       =
*   TTYPINFO_WA       =
*   DDOBJTYPE         =
*   DFIES_WA          =
*   LINES_DESCR       =
 TABLES
   X031L_TAB         = IT_FIELDS
*   DFIES_TAB         =
 EXCEPTIONS
   NOT_FOUND         = 1
   OTHERS            = 2
          .
IF sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

* we do not know the sized of the table that must be generated beforehand
* hence we use field symbols to dynamically generate the internal table
  CREATE DATA DREF TYPE STANDARD TABLE OF (LV_DBTAB1)
                            WITH NON-UNIQUE DEFAULT KEY.
  ASSIGN DREF-&amp;gt;* TO &amp;lt;ITAB&amp;gt; .

* selects all data
  SELECT * FROM (LV_DBTAB1) INTO TABLE &amp;lt;ITAB&amp;gt; .

  LOOP AT &amp;lt;ITAB&amp;gt; ASSIGNING &amp;lt;WA&amp;gt;.

    FLAG_MODIFIED = ''.
    LOOP AT IT_FIELDS INTO WA_FIELDS.
      ASSIGN COMPONENT WA_FIELDS-FIELDNAME OF STRUCTURE &amp;lt;WA&amp;gt;
        TO &amp;lt;WA1&amp;gt;.

      IF WA_FIELDS-FIELDNAME = 'FIRSTNAME'. " fieldname in the table you wish to modify
        IF &amp;lt;WA1&amp;gt; = 'Kris'. " old value
          &amp;lt;WA1&amp;gt; = 'NewName'. " new value
          MODIFY TABLE &amp;lt;ITAB&amp;gt; FROM &amp;lt;WA&amp;gt;.
          FLAG_MODIFIED = 'X'.
        ENDIF.
      ENDIF.

      WRITE &amp;lt;WA1&amp;gt;. " comment this line to remove the display
    ENDLOOP.
    IF FLAG_MODIFIED = 'X'. " updates database only if the record was changed
      UPDATE (LV_DBTAB1) FROM &amp;lt;WA&amp;gt;.
*     note that if the field you choose is a key field, sy-subrc will be set to 4
    ENDIF.

*   display
    NEW-LINE.

  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2007 05:17:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118370#M740522</guid>
      <dc:creator>former_member189059</dc:creator>
      <dc:date>2007-12-03T05:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch data from Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118371#M740523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kris,&lt;/P&gt;&lt;P&gt;Thanks for quick reply.&lt;/P&gt;&lt;P&gt;Small doubt here.&lt;/P&gt;&lt;P&gt;Actuvally , in The fucntion mdoule &amp;lt;b&amp;gt;/SAPAPO/TS_PA_COPY_TABLE_GET&amp;lt;/b&amp;gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;they are called the function module wht you mention in answer &amp;lt;b&amp;gt;'DDIF_NAMETAB_GET'&amp;lt;/b&amp;gt;. shall i call the fucntion module again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Bhaskar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2007 06:40:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118371#M740523</guid>
      <dc:creator>former_member189596</dc:creator>
      <dc:date>2007-12-03T06:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch data from Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118372#M740524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Bhaskar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Function Module 'DDIF_NAMETAB_GET' returns the fields of the database table name you pass to it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It may have been used in '/SAPAPO/TS_PA_COPY_TABLE_GET'&lt;/P&gt;&lt;P&gt;If it returns a table parameter with the field names, then you will not need to use it here, but instead loop at that returned table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Else, you will have to use it separately in this program&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can check what it returns by testing the FM in SE37&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2007 06:55:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-table/m-p/3118372#M740524</guid>
      <dc:creator>former_member189059</dc:creator>
      <dc:date>2007-12-03T06:55:06Z</dc:date>
    </item>
  </channel>
</rss>

