<?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: Need Help with selection in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-selection/m-p/7848728#M1591744</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Duplicate post. Thread locked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 May 2011 05:51:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-05-18T05:51:52Z</dc:date>
    <item>
      <title>Need Help with selection</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-selection/m-p/7848727#M1591743</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;In the below code i want to add  material group wise selection and remove plant wise selection.&lt;/P&gt;&lt;P&gt;Can any one please help me out.  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECTION-SCREEN BEGIN OF BLOCK b1    WITH FRAME TITLE text-001.
PARAMETERS : p_bklas like mbewh-bklas OBLIGATORY,
             p_bukrs LIKE mseg-bukrs OBLIGATORY.
SELECT-OPTIONS :  s_werks FOR t001k-bwkey,              " Plant
                                s_budat FOR mkpf-budat OBLIGATORY NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK b1.
SELECT bukrs bwkey  FROM t001k INTO TABLE it_werks
                  WHERE bukrs = p_bukrs
                  AND bwkey IN s_werks.
  if sy-subrc = 0.
    select ms~mblnr ms~mjahr mk~blart mk~budat ms~zeile ms~bwart
           ms~xauto ms~matnr ms~werks ms~charg ms~shkzg ms~dmbtr ms~menge
           ms~meins ms~bualt "ma~matkl
           from mkpf as mk
           inner join mseg as ms on
           mk~mandt = ms~mandt
           and mk~mblnr = ms~mblnr
           and mk~mjahr = ms~mjahr
           into corresponding fields of table it_mkpf3
           for all entries in it_werks
           where mk~budat in s_budat
             and ms~mjahr = v_myear
             and bukrs    = it_werks-bukrs
             and ms~werks = it_werks-bwkey.
    select matnr matkl from mara into table it_mara
           for all entries in it_mkpf3
           where matnr = it_mkpf3-matnr.
    loop at it_mkpf3 .
      read table it_mara with key matnr = it_mkpf3-matnr.
      it_mkpf-mblnr = it_mkpf3-mblnr.
      it_mkpf-mjahr = it_mkpf3-mjahr.
      it_mkpf-blart = it_mkpf3-blart.
      it_mkpf-budat = it_mkpf3-budat.
      it_mkpf-zeile = it_mkpf3-zeile.
      it_mkpf-bwart = it_mkpf3-bwart.
      it_mkpf-xauto = it_mkpf3-xauto.
      it_mkpf-matnr = it_mkpf3-matnr.
      it_mkpf-werks = it_mkpf3-werks.
      it_mkpf-charg = it_mkpf3-charg.
      it_mkpf-shkzg = it_mkpf3-shkzg.
      it_mkpf-dmbtr = it_mkpf3-dmbtr.
      it_mkpf-menge = it_mkpf3-menge.
      it_mkpf-meins = it_mkpf3-meins.
      it_mkpf-bualt = it_mkpf3-bualt.
      it_mkpf-matkl = it_mara-matkl.
      append it_mkpf.
    endloop.
    select matnr bwkey lbkum salk3 bklas lfgja lfmon
           from mbew
           into table it_mbew
           for all entries in it_werks
           where bwkey = it_werks-bwkey
           and   bklas = p_bklas.
    select  matnr bwkey lfgja lfmon  lbkum salk3  bklas
           from mbewh
           into table it_mbewh
           for all entries in it_mbew
           where  matnr = it_mbew-matnr
           and   bwkey = it_mbew-bwkey
           and   lfgja eq v_year
           and   lfmon ge v_period.
    sort  it_mbewh BY lfgja ASCENDING lfmon ASCENDING.
    select matnr matkl from mara into table it_mara1
           for all entries in it_mbew
           where matnr = it_mbew-matnr.
    if sy-subrc = 0.
      loop at it_mbew.
        read table it_mara1 with key matnr  = it_mbew-matnr.
        it_mardh-matnr = it_mbew-matnr.
        it_mardh-werks = it_mbew-bwkey.
        it_mardh-lfgja = it_mbew-lfgja.
        it_mardh-lfmon = it_mbew-lfmon.
        read table it_mbewh with key matnr = it_mbew-matnr
                                     bwkey = it_mbew-bwkey.
        if sy-subrc = 0 .
          it_mardh-bklas = it_mbewh-bklas.
          it_mardh-salk3 = it_mbewh-salk3.
          it_mardh-lbkum = it_mbewh-lbkum.
        else.
          it_mardh-bklas = it_mbew-bklas.
          it_mardh-salk3 = it_mbew-salk3.
          it_mardh-lbkum = it_mbew-lbkum.
        endif.
        it_mardh-matkl = it_mara1-matkl.
        append it_mardh.
        clear it_mardh.
        clear it_mbewh.
        clear it_mara1.
        clear it_mbew.
      endloop.
    endif.
    sort it_mardh by werks matnr.
    select bukrs belnr gjahr blart budat into table it_bkpf9
           from bkpf
           where bukrs = p_bukrs
           and   blart = 'RE'
           and   budat in s_budat
           or    bukrs = p_bukrs
           and   blart = 'PR'
           and   budat in s_budat.
    if sy-subrc = 0.
      select bukrs belnr gjahr buzei buzid shkzg dmbtr matnr werks
             from bseg
             into table it_bseg9
             for all entries in it_bkpf9
             where bukrs = it_bkpf9-bukrs
             and   belnr = it_bkpf9-belnr
             and   gjahr = it_bkpf9-gjahr
             and   werks in s_werks
             and   buzid = 'M'.
    endif.

  endif.
* END-OF-SELECTION.
END-OF-SELECTION.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2011 05:41:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-selection/m-p/7848727#M1591743</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-18T05:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with selection</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-selection/m-p/7848728#M1591744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Duplicate post. Thread locked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2011 05:51:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-selection/m-p/7848728#M1591744</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-18T05:51:52Z</dc:date>
    </item>
  </channel>
</rss>

