<?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: problem in code in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750719#M1303147</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;

loop at itab.
          if itab-lgort eq 'W1WP'.
          write: / itab-matnr,itab-lgort.
          else.
          write: / itab-matnr,itab-lgort.
          endif.
        ENDLOOP.
 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is no point using If condition here.instead you can use the&lt;/P&gt;&lt;P&gt;condition directly in loop for getting only 'W1WP' values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

Loop at itab where lgort EQ 'W1WP'.

    write: / itab-matnr,itab-lgort.
   
ENDLOOP.
 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Jun 2009 04:00:06 GMT</pubDate>
    <dc:creator>GauthamV</dc:creator>
    <dc:date>2009-06-05T04:00:06Z</dc:date>
    <item>
      <title>problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750715#M1303143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had developed the code and i want to display the data according to the given condition. it is displaying the storage location of a material but when i specify a condition that only this should be displayed it is not working properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here's the code:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

tables: mard.
data: begin of itab occurs 0,
      matnr like mard-matnr,
      werks like mard-werks,
      lgort like mard-lgort,
      end of itab.

PARAMETERS: item like mard-MATNR,
            plant like mard-werks.

      select matnr werks lgort FROM mard
        into table itab where matnr eq item and werks eq plant." and ( lgort eq 'w1wp' or lgort eq 'w1wp' ).

        sort itab by matnr lgort.

        loop at itab.
          if itab-lgort eq 'w1wp'.
          write: / itab-matnr,itab-lgort.
          else.
          write: / itab-matnr,itab-lgort.
          endif.
        ENDLOOP.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 03:49:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750715#M1303143</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-05T03:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750716#M1303144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All the constant values in quotes ' ' should always be in capital letters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

tables: mard.
data: begin of itab occurs 0,
      matnr like mard-matnr,
      werks like mard-werks,
      lgort like mard-lgort,
      end of itab.
 
     PARAMETERS: item like mard-MATNR,
            plant like mard-werks.
 
      select matnr werks lgort FROM mard
        into table itab where matnr eq item and werks eq plant." and ( lgort eq 'W1WP' or lgort   eq 'W1WP' ).
 
        sort itab by matnr lgort.
 
        loop at itab.
          if itab-lgort eq 'W1WP'.
          write: / itab-matnr,itab-lgort.
          else.
          write: / itab-matnr,itab-lgort.
          endif.
        ENDLOOP.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 03:54:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750716#M1303144</guid>
      <dc:creator>GauthamV</dc:creator>
      <dc:date>2009-06-05T03:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750717#M1303145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;chk whether the data is getting populated in the internal table properly or not. Debug the program and check the values for storage location in internal table. use IN statement instead of EQ while fetching data from select query and while checking pls chk the data in CAPS letter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anil N.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 03:55:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750717#M1303145</guid>
      <dc:creator>former_member438956</dc:creator>
      <dc:date>2009-06-05T03:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750718#M1303146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree wit h you but i had tried it is still not displaying the right data. It is not satisfying the if condition as i checked in the debugged mode.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 03:56:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750718#M1303146</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-05T03:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750719#M1303147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;

loop at itab.
          if itab-lgort eq 'W1WP'.
          write: / itab-matnr,itab-lgort.
          else.
          write: / itab-matnr,itab-lgort.
          endif.
        ENDLOOP.
 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is no point using If condition here.instead you can use the&lt;/P&gt;&lt;P&gt;condition directly in loop for getting only 'W1WP' values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

Loop at itab where lgort EQ 'W1WP'.

    write: / itab-matnr,itab-lgort.
   
ENDLOOP.
 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 04:00:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750719#M1303147</guid>
      <dc:creator>GauthamV</dc:creator>
      <dc:date>2009-06-05T04:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750720#M1303148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can u tell why u r using same storage location condition twice in select statement? &lt;/P&gt;&lt;P&gt;( lgort eq 'w1wp' or lgort eq 'w1wp')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if in select statement, lgort is picking only 'w1wp' , then no need to write else condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Lalit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 04:02:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750720#M1303148</guid>
      <dc:creator>former_member506713</dc:creator>
      <dc:date>2009-06-05T04:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750721#M1303149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually this is a dummy code which i am trying right now ,the problem is with my code in which i have to display that if a storage location matches then it should make qty field to 0 ,but it is not displaying it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

LOOP AT STIT WHERE QMNUM = STIT1-QMNUM.

    IF STIT-MGEIG GE 0.

        SELECT A~PRUEFLOS A~MATNR A~LOSMENGE B~MBLNR B~MJAHR C~ZEILE C~CHARG   
                     C~LGORT C~MENGE FROM QALS AS A
                     INNER JOIN QAMB AS B ON B~PRUEFLOS = A~PRUEFLOS
                     INNER JOIN MSEG AS C ON C~MBLNR = B~MBLNR AND C~MJAHR = B~MJAHR
                     INTO TABLE ITSC01 WHERE A~PRUEFLOS EQ STIT-PRUEFLOS AND A~MATNR 
                     EQ  STIT-MATNR." AND C~LGORT EQ 'SC01'.

    SORT ITSC01 BY PRUEFLOS.

      ITAB-MATNR = STIT-MATNR.
      ITAB-PRUEFLOS = STIT-PRUEFLOS.
      ITAB-PAENDTERM = STIT-PAENDTERM.
      ITAB-LOSMENGE = STIT-LOSMENGE.
      ITAB-CHARG = STIT-CHARG.
      ITAB-LGORTCHARG = STIT-LGORTCHARG.
      ITAB-MGEIN = STIT-MGEIN.

      IF ITSC01-LGORT EQ 'SC03'. "This Storage location should be satisfied.
      ITAB-MGEIG = 0.
      ELSE.
      ITAB-MGEIG = STIT-MGEIG.
      ENDIF.

      ITAB-NTGEW = STIT-NTGEW.

    ELSE.

      ITAB-MATNR = STIT-MATNR.
      ITAB-PRUEFLOS = STIT-PRUEFLOS.
      ITAB-PAENDTERM = STIT-PAENDTERM.
      ITAB-LOSMENGE = STIT-LOSMENGE.
      ITAB-CHARG = STIT-CHARG.
      ITAB-LGORTCHARG = STIT-LGORTCHARG.
      ITAB-MGEIN = STIT-MGEIN.
      ITAB-MGEIG = STIT-MGEIG.
      ITAB-NTGEW = STIT-NTGEW.

     ENDIF.

    ENDLOOP.
    APPEND ITAB.

  ENDLOOP.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 04:04:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750721#M1303149</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-05T04:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750722#M1303150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry my fault ,i will keeep a check.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 04:05:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750722#M1303150</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-05T04:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750723#M1303151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't  use select statements inside loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using loop condition for stit table then you have to use read&lt;/P&gt;&lt;P&gt;statement to get data into itsc01 table and then check the condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

LOOP AT t_ekpo .

    t_outtab-ebeln = t_ekpo-ebeln .
    t_outtab-ebelp = t_ekpo-ebelp .
    t_outtab-txz01 = t_ekpo-txz01 .
    t_outtab-netwr = t_ekpo-netwr .
    t_outtab-werks = t_ekpo-werks .

 READ TABLE t_eket WITH KEY ebeln = t_ekpo-ebeln
                               ebelp = t_ekpo-ebelp.

    IF sy-subrc = 0 .
      t_outtab-eindt = t_eket-eindt.
   endif.

    APPEND t_outtab .
    CLEAR t_outtab .
     clear :  t_eket.

Endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 04:10:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750723#M1303151</guid>
      <dc:creator>GauthamV</dc:creator>
      <dc:date>2009-06-05T04:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750724#M1303152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use read table option for ITSC01. and write the if condition after that. IF ITSC01-LGORT EQ 'SC03'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 04:21:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750724#M1303152</guid>
      <dc:creator>former_member506713</dc:creator>
      <dc:date>2009-06-05T04:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750725#M1303153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if i write the query of fetch data for ITSC01 outside the loop of STIT it is not fetching the data but when it is in the STIT it is picking the data but not satisfying the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please provide me guidlines to solve this problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 04:26:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750725#M1303153</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-05T04:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750726#M1303154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope using select inside loop is not recommended for performance reasons , so better &lt;STRONG&gt;use For all entries&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the next thing is you are fetching data into table ITSCO1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT A~PRUEFLOS A~MATNR A~LOSMENGE B~MBLNR B~MJAHR C~ZEILE C~CHARG   
                     C~LGORT C~MENGE FROM QALS AS A
                     INNER JOIN QAMB AS B ON B~PRUEFLOS = A~PRUEFLOS
                     INNER JOIN MSEG AS C ON C~MBLNR = B~MBLNR AND C~MJAHR = B~MJAHR
                     *INTO TABLE ITSC01* WHERE A~PRUEFLOS EQ STIT-PRUEFLOS AND A~MATNR 
                     EQ  STIT-MATNR." AND C~LGORT EQ 'SC01'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But after Sorting it you are just using the workarea not internal table so &lt;STRONG&gt;you should loop at ITSC01/READ it inot Workarea before checking&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF ITSC01-LGORT EQ 'SC03'. "This Storage location should be satisfied.
      ITAB-MGEIG = 0.
      ELSE.
      ITAB-MGEIG = STIT-MGEIG.
      ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is wrong and this happened because &lt;STRONG&gt;you should have declared ITSCO1 with header line&lt;/STRONG&gt;. Thats why its not recommended to use &lt;STRONG&gt;WITH HEADER LINE&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So change it, check and revert back&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Karthik D&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 04:28:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750726#M1303154</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-05T04:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: problem in code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750727#M1303155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IF ITSC01-LGORT EQ 'SC03'. "This Storage location should be satisfied.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before this u have to write as&lt;/P&gt;&lt;P&gt;READ TABLE ITSC01 with key prueflos = stat-prueflos &lt;/P&gt;&lt;P&gt;                                              matnr = stat-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Now the ITSC01 tables' 1 row will be at header line and u can check the condition&lt;/P&gt;&lt;P&gt;IF ITSC01-LGORT EQ 'SC03'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will work&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 04:37:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-code/m-p/5750727#M1303155</guid>
      <dc:creator>former_member506713</dc:creator>
      <dc:date>2009-06-05T04:37:14Z</dc:date>
    </item>
  </channel>
</rss>

