<?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: SAP Query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065731#M1176941</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Lijo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If u want to incorporate ur requirement in report program,, the following piece works:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES: vbak, vbap, zvbak_t.

DATA: BEGIN OF ITAB OCCURS 0,
        VBELN LIKE VBAK-VBELN,
        POSNR LIKE VBAP-POSNR,
      END OF ITAB.

DATA: BEGIN OF ztab occurs 0.
        INCLUDE STRUCTURE zvbak_t.
DATA: END of ztab.

SELECT-OPTIONS: s_vbeln for VBAK-VBELN.

SELECT   a~vbeln
         b~posnr
    INTO  CORRESPONDING FIELDS OF TABLE itab
    FROM  ( VBAK  AS a INNER JOIN VBAP AS b
      ON    a~vbeln = b~vbeln )
   WHERE  a~vbeln IN s_vbeln.

select * from zvbak_t into table ztab for all entries in itab where vbeln = itab-vbeln.

*loop at ztab.
*write:/ ztab-vbeln.
*endloop.
*
write:/ sy-dbcnt.

if sy-subrc = 0.
delete zvbak_t from table ztab.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks\&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Feb 2009 05:23:50 GMT</pubDate>
    <dc:creator>former_member222860</dc:creator>
    <dc:date>2009-02-03T05:23:50Z</dc:date>
    <item>
      <title>SAP Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065726#M1176936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;     I have to add some extra validations in an existing SAP Query.&lt;/P&gt;&lt;P&gt;Current Scenario :  Now the Query is fetching the details from the tables VBAK &amp;amp; VBAP. &lt;/P&gt;&lt;P&gt;Proposed : After fetching these details I need to check the following . Check whether the field (VBELN) is included in another table(Z-TABLE) or not. If it is there I have to remove that record.   &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How I will write the code?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Where can I write the code?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Please help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lijo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 04:43:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065726#M1176936</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-03T04:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065727#M1176937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lijo, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&amp;gt;  After fetching the values from the table, put a select query on the Z-Table comparing the value of VBELN, and check for the SY-SUBRC value, if the value of SY-SUBRC = 0, record exist, oderwise it doesnt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&amp;gt; to remove the record from the Z-Table, use DELETE ZTable where vbeln = vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will work fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Karan Arya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 04:54:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065727#M1176937</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-03T04:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065728#M1176938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Karan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Thanks for the reply. &lt;/P&gt;&lt;P&gt;   My requirement is - Where can I write the code &lt;/P&gt;&lt;P&gt;   In infoset(In which area)? SAP Query(In which area)? &lt;/P&gt;&lt;P&gt;   or in Report Program which has been automatically generated from the Query?&lt;/P&gt;&lt;P&gt;   Can you please let me know?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lijo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 05:00:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065728#M1176938</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-03T05:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065729#M1176939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lijo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Go to TCODE : SQ02. Give Infoset name. Under Data fields you will find technical names as VBAK , VBAP etc &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Right click on VBAK and select "&lt;STRONG&gt;Code for record processing&lt;/STRONG&gt;" . On the right the coding section will open up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 05:00:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065729#M1176939</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-03T05:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065730#M1176940</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;Write the above said logic in ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Goto Tcode SQ02, select the reuired infoset, then click Change button,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then Click on the required table and select the Code Button (Shift + F8) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There in the drop down list in code section,  select Record Processing,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then write your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you clear in the steps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 05:07:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065730#M1176940</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-03T05:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065731#M1176941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Lijo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If u want to incorporate ur requirement in report program,, the following piece works:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES: vbak, vbap, zvbak_t.

DATA: BEGIN OF ITAB OCCURS 0,
        VBELN LIKE VBAK-VBELN,
        POSNR LIKE VBAP-POSNR,
      END OF ITAB.

DATA: BEGIN OF ztab occurs 0.
        INCLUDE STRUCTURE zvbak_t.
DATA: END of ztab.

SELECT-OPTIONS: s_vbeln for VBAK-VBELN.

SELECT   a~vbeln
         b~posnr
    INTO  CORRESPONDING FIELDS OF TABLE itab
    FROM  ( VBAK  AS a INNER JOIN VBAP AS b
      ON    a~vbeln = b~vbeln )
   WHERE  a~vbeln IN s_vbeln.

select * from zvbak_t into table ztab for all entries in itab where vbeln = itab-vbeln.

*loop at ztab.
*write:/ ztab-vbeln.
*endloop.
*
write:/ sy-dbcnt.

if sy-subrc = 0.
delete zvbak_t from table ztab.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks\&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 05:23:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-query/m-p/5065731#M1176941</guid>
      <dc:creator>former_member222860</dc:creator>
      <dc:date>2009-02-03T05:23:50Z</dc:date>
    </item>
  </channel>
</rss>

