<?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: Looping problem against tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem-against-tables/m-p/3295364#M788576</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jack,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you explain a bot more about placing the code you gave.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Balu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Jan 2008 16:48:03 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-01-16T16:48:03Z</dc:date>
    <item>
      <title>Looping problem against tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem-against-tables/m-p/3295362#M788574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Gurus,&lt;/P&gt;&lt;P&gt;I wrote the following code.  The program is working fine.&lt;/P&gt;&lt;P&gt;When executed, a selection screen appears with material and customer number.&lt;/P&gt;&lt;P&gt;When only material is given, it displays the material - sales org- dchannel - material status - description.&lt;/P&gt;&lt;P&gt;When clicked on any line, it takes to CO09 tcode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When both material and customer are given, it displays the common sales org where both material and customer exists:&lt;/P&gt;&lt;P&gt;material - sales org- dchannel - material status - description.&lt;/P&gt;&lt;P&gt;if the customer and material does not have no common sales area data, it will display the &lt;/P&gt;&lt;P&gt;material - sales org- dchannel - material status - description, where material exists.&lt;/P&gt;&lt;P&gt;When a line is selected, it will take to CO09 tcode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Everything is working fine until now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to make a change now. The program should function as it is when a customer is given, when the partner function is 'SP' or 'AG'. Else it should display a messahe - given customer is not a sold-to-party.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Balu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT  YP_10 MESSAGE-ID YPMSG                          .&lt;/P&gt;&lt;P&gt;TABLES    : MVKE, TVMST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES     : BEGIN OF T_MVKE,&lt;/P&gt;&lt;P&gt;            MATNR TYPE MVKE-MATNR,&lt;/P&gt;&lt;P&gt;            VKORG TYPE MVKE-VKORG,&lt;/P&gt;&lt;P&gt;            VTWEG TYPE MVKE-VTWEG,&lt;/P&gt;&lt;P&gt;            VMSTA TYPE MVKE-VMSTA,&lt;/P&gt;&lt;P&gt;            VMSTB TYPE TVMST-VMSTB,&lt;/P&gt;&lt;P&gt;            END OF T_MVKE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA      : LT_MVKE TYPE STANDARD TABLE OF T_MVKE WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;            LS_MVKE TYPE T_MVKE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA      : LT1_MVKE TYPE STANDARD TABLE OF T_MVKE WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;            LS1_MVKE TYPE T_MVKE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA      : LT2_MVKE TYPE STANDARD TABLE OF T_MVKE WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;            LS2_MVKE TYPE T_MVKE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES     : BEGIN OF T_KNVP,&lt;/P&gt;&lt;P&gt;            KUNNR TYPE KNVP-KUNNR,&lt;/P&gt;&lt;P&gt;            VKORG TYPE KNVP-VKORG,&lt;/P&gt;&lt;P&gt;            VTWEG TYPE KNVP-VTWEG,&lt;/P&gt;&lt;P&gt;            PARVW TYPE KNVP-PARVW,&lt;/P&gt;&lt;P&gt;            END OF T_KNVP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA      : LT_KNVP TYPE STANDARD TABLE OF T_KNVP WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;            LS_KNVP TYPE T_KNVP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT-OPTIONS S_MATNR FOR MVKE-MATNR OBLIGATORY.&lt;/P&gt;&lt;P&gt;PARAMETER  : P_KUNNR TYPE KNVP-KUNNR .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;SELECT MATNR VKORG VTWEG VMSTA FROM MVKE INTO TABLE LT_MVKE WHERE MATNR IN S_MATNR .&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;APPEND LT_MVKE.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT KUNNR VKORG VTWEG PARVW FROM KNVP INTO TABLE LT_KNVP WHERE KUNNR = P_KUNNR.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;APPEND LT_KNVP.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT LT_MVKE.&lt;/P&gt;&lt;P&gt;LT1_MVKE-MATNR = LT_MVKE-MATNR.&lt;/P&gt;&lt;P&gt;LT1_MVKE-VKORG = LT_MVKE-VKORG.&lt;/P&gt;&lt;P&gt;LT1_MVKE-VTWEG = LT_MVKE-VTWEG.&lt;/P&gt;&lt;P&gt;LT1_MVKE-VMSTA = LT_MVKE-VMSTA.&lt;/P&gt;&lt;P&gt;SELECT SINGLE VMSTB FROM TVMST INTO LT1_MVKE-VMSTB WHERE VMSTA = LT_MVKE-VMSTA AND SPRAS = SYST-LANGU.&lt;/P&gt;&lt;P&gt;APPEND LT1_MVKE.&lt;/P&gt;&lt;P&gt;CLEAR LT1_MVKE.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF NOT LT_KNVP[] is INITIAL.&lt;/P&gt;&lt;P&gt;   LOOP AT LT1_MVKE.&lt;/P&gt;&lt;P&gt;   READ TABLE LT_KNVP WITH KEY VKORG = LT1_MVKE-VKORG VTWEG = LT1_MVKE-VTWEG BINARY SEARCH TRANSPORTING NO FIELDS.&lt;/P&gt;&lt;P&gt;      IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;       APPEND LT1_MVKE TO LT2_MVKE.&lt;/P&gt;&lt;P&gt;       CLEAR LT1_MVKE.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;   ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   IF LT2_MVKE[] IS INITIAL.&lt;/P&gt;&lt;P&gt;     MESSAGE I003 DISPLAY LIKE 'E'.&lt;/P&gt;&lt;P&gt;     MESSAGE S003.&lt;/P&gt;&lt;P&gt;      LT2_MVKE[] = LT1_MVKE[].&lt;/P&gt;&lt;P&gt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lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; MESSAGE I002 DISPLAY LIKE 'E'.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET PARAMETER ID 'MAT' FIELD LT2_MVKE-MATNR.&lt;/P&gt;&lt;P&gt;CLEAR LT2_MVKE-MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA WERKS(4) TYPE C VALUE '1200'.&lt;/P&gt;&lt;P&gt;SET PARAMETER ID 'WRK' FIELD WERKS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA RULE(2) TYPE C VALUE 'ZB'.&lt;/P&gt;&lt;P&gt;SET PARAMETER ID 'PRR' FIELD RULE.&lt;/P&gt;&lt;P&gt;CALL TRANSACTION 'CO09'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jan 2008 15:51:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem-against-tables/m-p/3295362#M788574</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-16T15:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem against tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem-against-tables/m-p/3295363#M788575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Balu &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at seleciton-screen input/output.&lt;/P&gt;&lt;P&gt;select single kunnr from VBPA&lt;/P&gt;&lt;P&gt;  into lv_test&lt;/P&gt;&lt;P&gt;  where kunnr = P_KUNNR and &lt;/P&gt;&lt;P&gt;           partner function = 'AG'. &amp;lt;&amp;lt;&amp;lt; or 'SP' as saved in DB&lt;/P&gt;&lt;P&gt;if sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;message '''given customer is not a sold-to-party''.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Award points if helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jan 2008 16:34:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem-against-tables/m-p/3295363#M788575</guid>
      <dc:creator>former_member156446</dc:creator>
      <dc:date>2008-01-16T16:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem against tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem-against-tables/m-p/3295364#M788576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jack,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you explain a bot more about placing the code you gave.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Balu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jan 2008 16:48:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem-against-tables/m-p/3295364#M788576</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-16T16:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem against tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem-against-tables/m-p/3295365#M788577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;I need to make a change now. The program should function as it is &amp;gt;when a customer is given, when the partner function is 'SP' or 'AG'. &amp;gt;Else it should display a messahe - given customer is not a &amp;gt;sold-to-party.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at seleciton-screen input/output. &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;event name I guess &lt;STRONG&gt;input&lt;/STRONG&gt; is right&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*in the select you check if the kunnr is a sold to or ship to&lt;/P&gt;&lt;P&gt;if the Kunnr is saved as AG/ SP then it will proceed, if its not AG/SP then it will go inside the if statement and raise the message as you wanted*&lt;/P&gt;&lt;P&gt;select single kunnr from VBPA&lt;/P&gt;&lt;P&gt;into lv_test&lt;/P&gt;&lt;P&gt;where kunnr = P_KUNNR and&lt;/P&gt;&lt;P&gt;partner function = 'AG'. &amp;lt;&amp;lt;&amp;lt; or 'SP' as saved in DB&lt;/P&gt;&lt;P&gt;if sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;message '''given customer is not a sold-to-party''.  &amp;lt;&amp;lt;&amp;lt; message&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jan 2008 16:54:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem-against-tables/m-p/3295365#M788577</guid>
      <dc:creator>former_member156446</dc:creator>
      <dc:date>2008-01-16T16:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem against tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem-against-tables/m-p/3295366#M788578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jack.&lt;/P&gt;&lt;P&gt;I assigned points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Balu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jan 2008 17:44:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-problem-against-tables/m-p/3295366#M788578</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-16T17:44:26Z</dc:date>
    </item>
  </channel>
</rss>

