<?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 Dynamic Where Condition for Info Structures in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-for-info-structures/m-p/7393397#M1545800</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;My Requirement is to read  the data from Information Structure(For Ex: S980) entered on selection screen at Run time.              User will enter the technical field names of any three Key Figures on Selection Screen. Based on the keyfigures entered on selection screen the data should be selected. I am through with building the dynamic internal table.                                                    But how do I put a dynamic where clause in the select query for the keyfigures selected at run time?                                      Kindly suggest me a solution. Please let me know if the information provided is not sufficient. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards, &lt;/P&gt;&lt;P&gt;Sailaja.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Nov 2010 14:12:26 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-11-01T14:12:26Z</dc:date>
    <item>
      <title>Dynamic Where Condition for Info Structures</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-for-info-structures/m-p/7393397#M1545800</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;My Requirement is to read  the data from Information Structure(For Ex: S980) entered on selection screen at Run time.              User will enter the technical field names of any three Key Figures on Selection Screen. Based on the keyfigures entered on selection screen the data should be selected. I am through with building the dynamic internal table.                                                    But how do I put a dynamic where clause in the select query for the keyfigures selected at run time?                                      Kindly suggest me a solution. Please let me know if the information provided is not sufficient. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards, &lt;/P&gt;&lt;P&gt;Sailaja.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Nov 2010 14:12:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-for-info-structures/m-p/7393397#M1545800</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-01T14:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Where Condition for Info Structures</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-for-info-structures/m-p/7393398#M1545801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1/ *******************BUILD WHERE CONDITION&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;      gt_cond      type table of line,&lt;/P&gt;&lt;P&gt;      gs_cond      type          line.&lt;/P&gt;&lt;P&gt;  ifIWERKS is NOT initial.&lt;/P&gt;&lt;P&gt;    perform append_cond using 'MARD~WERKS' '=' 'IWERKS'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;  if SLGORT is NOT initial.&lt;/P&gt;&lt;P&gt;    perform append_cond using 'MARD~LGORT' 'IN' 'ILGORT'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2/ ******Subroutine for apend where condition *************&lt;/P&gt;&lt;P&gt;FORM append_cond  USING    pfield1&lt;/P&gt;&lt;P&gt;                           pop&lt;/P&gt;&lt;P&gt;                           pfield2.&lt;/P&gt;&lt;P&gt;  if gt_cond[] is initial.&lt;/P&gt;&lt;P&gt;    concatenate pfield1 pop pfield2 into gs_cond-line SEPARATED BY space.&lt;/P&gt;&lt;P&gt;  else.&lt;/P&gt;&lt;P&gt;    concatenate 'AND' pfield1 pop pfield2 into gs_cond-line separated by space.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;  append gs_cond to gt_cond.&lt;/P&gt;&lt;P&gt;ENDFORM.                    " append_cond&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3/ ***********************SELECT STATEMENT ******************************************&lt;/P&gt;&lt;P&gt;    select * into CORRESPONDING FIELDS OF TABLE OMATNR&lt;/P&gt;&lt;P&gt;         from mard inner join  MVKE ON  MVKE&lt;SUB&gt;matnr = mard&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;                   inner join  marc on  marc&lt;SUB&gt;matnr = mard&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;                                    and  marc&lt;SUB&gt;werks = mard&lt;/SUB&gt;werks&lt;/P&gt;&lt;P&gt;         where (gt_cond).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Nov 2010 01:30:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-for-info-structures/m-p/7393398#M1545801</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-02T01:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Where Condition for Info Structures</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-for-info-structures/m-p/7393399#M1545802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jan, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the below example the field WERKS and LGORT will not vary everytime. &lt;/P&gt;&lt;P&gt;  ifIWERKS is NOT initial.&lt;/P&gt;&lt;P&gt;    perform append_cond using 'MARD~WERKS' '=' 'IWERKS'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;  if SLGORT is NOT initial.&lt;/P&gt;&lt;P&gt;    perform append_cond using 'MARD~LGORT' 'IN' 'ILGORT'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in my case the Information Structure is selected at run time and even the Key figures of each information structure will vary &lt;/P&gt;&lt;P&gt;every time. The selection of the Key figures is also Dynamic. Based on this criteria I have to build the where clause. &lt;/P&gt;&lt;P&gt;Kindly suggest me a solution for this scenario. Please let me know if the information provided is not clear. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Sailaja.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Nov 2010 04:57:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-for-info-structures/m-p/7393399#M1545802</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-02T04:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Where Condition for Info Structures</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-for-info-structures/m-p/7393400#M1545803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am not sure 100% I understand your issue, but if your key are dynamically created and you table where you have list of keyfields, you can use program modification describe in next rows.&lt;/P&gt;&lt;P&gt;You will have set keys they are dynamically created and they are in some table(they have column table/structure and fieldname)&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;field&amp;gt; type any&lt;/P&gt;&lt;P&gt;GT_COND_LST&lt;/P&gt;&lt;P&gt;row    TABLE NAME FIELDNAME&lt;/P&gt;&lt;P&gt;1        TABLE1          KEYFIELD1&lt;/P&gt;&lt;P&gt;2        TABLE1          KEYFIELD2&lt;/P&gt;&lt;P&gt;3        TABLE1          KEYFIELD3&lt;/P&gt;&lt;P&gt;4        TABLE2          KEYFIELD4&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1/ *******************BUILD WHERE CONDITION&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;gt_cond type table of line,&lt;/P&gt;&lt;P&gt;gs_cond type line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at GT_COND_LST into GS_COND_LST.&lt;/P&gt;&lt;P&gt;assign (GS_COND_LST-FIELDNAME) into &amp;lt;field&amp;gt;.&lt;/P&gt;&lt;P&gt;if &amp;lt;field&amp;gt; is not initial.&lt;/P&gt;&lt;P&gt;concatenate GS_COND_LST-TABLE '~' GS_COND_LST-FIELDNAME into lv_cond.&lt;/P&gt;&lt;P&gt;perform append_cond using 'MARD~LGORT' 'IN' GS_COND_LST-FIELDNAME.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endlloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2/ ******Subroutine for apend where condition *************&lt;/P&gt;&lt;P&gt;FORM append_cond USING pfield1&lt;/P&gt;&lt;P&gt;pop&lt;/P&gt;&lt;P&gt;pfield2.&lt;/P&gt;&lt;P&gt;if gt_cond[] is initial.&lt;/P&gt;&lt;P&gt;concatenate pfield1 pop pfield2 into gs_cond-line SEPARATED BY space.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;concatenate 'AND' pfield1 pop pfield2 into gs_cond-line separated by space.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;append gs_cond to gt_cond.&lt;/P&gt;&lt;P&gt;ENDFORM. " append_cond&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3/ ***********************SELECT STATEMENT ******************************************&lt;/P&gt;&lt;P&gt;select * into CORRESPONDING FIELDS OF TABLE OMATNR&lt;/P&gt;&lt;P&gt;from mard inner join MVKE ON MVKE&lt;SUB&gt;matnr = mard&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;inner join marc on marc&lt;SUB&gt;matnr = mard&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;and marc&lt;SUB&gt;werks = mard&lt;/SUB&gt;werks&lt;/P&gt;&lt;P&gt;where (gt_cond).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Nov 2010 06:15:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-for-info-structures/m-p/7393400#M1545803</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-04T06:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Where Condition for Info Structures</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-for-info-structures/m-p/7393401#M1545804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jan, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot. I have resolved this issue in the following way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Build the field catalog for creation of Dynamic Internal Table&lt;/P&gt;&lt;P&gt;*First Keyfigure&lt;/P&gt;&lt;P&gt;  wa_dyn_fieldcat-fieldname  =   p_key1.&lt;/P&gt;&lt;P&gt;  wa_dyn_fieldcat-ref_field  =   p_key1.&lt;/P&gt;&lt;P&gt;  wa_dyn_fieldcat-ref_table  =   p_itab.&lt;/P&gt;&lt;P&gt;  APPEND wa_dyn_fieldcat TO gt_dyn_fieldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Second Keyfigure&lt;/P&gt;&lt;P&gt;  wa_dyn_fieldcat-fieldname =   p_key2.&lt;/P&gt;&lt;P&gt;  wa_dyn_fieldcat-ref_field  =  p_key2 .&lt;/P&gt;&lt;P&gt;  wa_dyn_fieldcat-ref_table =   p_itab.&lt;/P&gt;&lt;P&gt;  APPEND wa_dyn_fieldcat TO gt_dyn_fieldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Third Keyfigure&lt;/P&gt;&lt;P&gt;  wa_dyn_fieldcat-fieldname =   p_key3.&lt;/P&gt;&lt;P&gt;  wa_dyn_fieldcat-ref_field  =  p_key3.&lt;/P&gt;&lt;P&gt;  wa_dyn_fieldcat-ref_table =   p_itab.&lt;/P&gt;&lt;P&gt;  APPEND wa_dyn_fieldcat TO gt_dyn_fieldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Build the Field Catalog for Dynamic Selection list&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*First Keyfigure&lt;/P&gt;&lt;P&gt;  wa_mseg_fields =  p_key1 .&lt;/P&gt;&lt;P&gt;  APPEND wa_mseg_fields TO gt_mseg_fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Second Keyfigure&lt;/P&gt;&lt;P&gt;  wa_mseg_fields =  p_key2 .&lt;/P&gt;&lt;P&gt;  APPEND wa_mseg_fields TO gt_mseg_fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Third Keyfigure&lt;/P&gt;&lt;P&gt;  wa_mseg_fields =  p_key3 .&lt;/P&gt;&lt;P&gt;  APPEND wa_mseg_fields TO gt_mseg_fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Create the dynamic internal table&lt;/P&gt;&lt;P&gt;  CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      it_fieldcatalog = gt_dyn_fieldcat&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      ep_table        = gt_new_table.&lt;/P&gt;&lt;P&gt;*Create a new line&lt;/P&gt;&lt;P&gt;  ASSIGN gt_new_table-&amp;gt;* TO &amp;lt;gt_table&amp;gt;.&lt;/P&gt;&lt;P&gt;  CREATE DATA wa_new_line LIKE LINE OF &amp;lt;gt_table&amp;gt;.&lt;/P&gt;&lt;P&gt;  ASSIGN wa_new_line-&amp;gt;* TO &amp;lt;wa_line&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Get the data from Dynamic Infostructure&lt;/P&gt;&lt;P&gt;  SELECT (gt_mseg_fields)&lt;/P&gt;&lt;P&gt;    FROM (p_itab)&lt;/P&gt;&lt;P&gt;    INTO TABLE &amp;lt;gt_table&amp;gt;&lt;/P&gt;&lt;P&gt;    WHERE  matnr IN s_matnr&lt;/P&gt;&lt;P&gt;    AND    werks IN s_werks&lt;/P&gt;&lt;P&gt;    AND    vrsio EQ p_vrsio&lt;/P&gt;&lt;P&gt;    AND  ( spmon IN s_fthrzn OR&lt;/P&gt;&lt;P&gt;           spwoc IN s_fthrzn ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Sailaja.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Nov 2010 06:10:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-for-info-structures/m-p/7393401#M1545804</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-11T06:10:05Z</dc:date>
    </item>
  </channel>
</rss>

