<?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: Complex ABAP Query Understanding in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-abap-query-understanding/m-p/766813#M37702</link>
    <description>&lt;P&gt;It'd be a lot easier to read and help if you use the "code" button in the editor and pasted your nicely formatted code - using right-click "paste as plain text".&lt;/P&gt;</description>
    <pubDate>Fri, 25 Jan 2019 08:03:24 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2019-01-25T08:03:24Z</dc:date>
    <item>
      <title>Complex ABAP Query Understanding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-abap-query-understanding/m-p/766812#M37701</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
  &lt;P&gt;I need to fix a specific bug in a select query in ABAP. &lt;/P&gt;
  &lt;P&gt;But i am unable to understand the logic written. I so would really appreciate if anyone could help me decode the logic in a simple manner.&lt;/P&gt;
  &lt;P&gt;ABAP Query:&lt;/P&gt;
  &lt;P&gt;CONSTANTS c_zero TYPE bseg-dmbtr VALUE '0.00'.&lt;/P&gt;
  &lt;P&gt;SELECT a~bukrs, a~belnr, a~gjahr,a~buzei AS buzei, a~dmbtr,a~menge,&lt;BR /&gt; a~meins,a~koart,&lt;BR /&gt; a~sgtxt, a~txgrp, a~bupla, a~gst_part, a~plc_sup, a~hsn_sac,&lt;BR /&gt; a~kunnr, a~werks, a~wrbtr, a~hkont, a~taxps, a~mwskz, a~shkzg,&lt;BR /&gt; a~umskz, a~ktosl, a~zuonr,a~ebeln, a~ebelp, a~qbshb,a~qsshb,&lt;BR /&gt; a~xref1, a~xref2,&lt;BR /&gt; a~rebzg, a~rebzj, a~matnr,a~prctr, a~kostl,&lt;BR /&gt; CASE a~koart&lt;BR /&gt; WHEN 'K' THEN a~lifnr WHEN 'D' THEN a~kunnr END AS lifnr,&lt;BR /&gt; ( CASE a~shkzg WHEN 'H' THEN a~dmbtr ELSE @c_zero END ) AS&lt;BR /&gt; lc_cr,&lt;BR /&gt; ( CASE a~shkzg WHEN 'S' THEN a~dmbtr ELSE @c_zero END ) AS&lt;BR /&gt; lc_db,&lt;BR /&gt; ( CASE a~shkzg WHEN 'H' THEN a~wrbtr ELSE @c_zero END ) AS&lt;BR /&gt; dc_cr,&lt;BR /&gt; ( CASE a~shkzg WHEN 'S' THEN a~wrbtr ELSE @c_zero END ) AS&lt;BR /&gt; dc_db,&lt;BR /&gt; ( CASE a~menge WHEN @c_zero THEN a~menge ELSE division(&lt;BR /&gt; a~dmbtr, a~menge, 2 ) END ) AS kbetr,&lt;BR /&gt; concat( a~hkont,&lt;BR /&gt; concat( '-', ( CASE a~koart&lt;BR /&gt; WHEN 'K' THEN a~lifnr WHEN 'D' THEN a~kunnr END ) ) ) AS&lt;BR /&gt; account,&lt;BR /&gt; a~zfbdt, a~zbd1t, a~zbd2t, a~zbd3t,&lt;BR /&gt; b~txt50,&lt;BR /&gt; c~maktx,&lt;BR /&gt;&lt;BR /&gt; CASE a~koart&lt;BR /&gt; WHEN 'K' THEN&lt;BR /&gt; ( concat_with_space( b~txt50,&lt;BR /&gt; ( concat_with_space( '-', d~name1 ,1 ) ),&lt;BR /&gt; 1 ) )&lt;BR /&gt;&lt;BR /&gt; WHEN 'D' THEN&lt;BR /&gt; ( concat_with_space( b~txt50,&lt;BR /&gt; ( concat_with_space( '-', e~name1 ,1 ) ),&lt;BR /&gt; 1 ) )&lt;BR /&gt; ELSE b~txt50&lt;BR /&gt; END AS name1,&lt;BR /&gt; d~ktokk,&lt;BR /&gt; ( concat_with_space( v1~name1, v1~name2 ,1 ) ) AS v1_name&lt;BR /&gt; FROM bseg AS a&lt;BR /&gt; INNER JOIN skat AS b&lt;BR /&gt; ON b~spras = @sy-langu&lt;BR /&gt; AND b~ktopl = '1000'&lt;BR /&gt; AND b~saknr = a~hkont&lt;BR /&gt; LEFT OUTER JOIN makt AS c&lt;BR /&gt; ON a~matnr = c~matnr&lt;BR /&gt; AND c~spras = @sy-langu&lt;BR /&gt; LEFT OUTER JOIN lfa1 AS d&lt;BR /&gt; ON a~lifnr = d~lifnr&lt;BR /&gt; LEFT OUTER JOIN kna1 AS e&lt;BR /&gt; ON a~kunnr = e~kunnr&lt;BR /&gt; LEFT OUTER JOIN bsec AS v1&lt;BR /&gt; ON a~bukrs = v1~bukrs&lt;BR /&gt; AND a~belnr = v1~belnr&lt;BR /&gt; AND a~gjahr = v1~gjahr&lt;BR /&gt; AND a~buzei = v1~buzei&lt;BR /&gt; WHERE a~bukrs = @im_bkpf-bukrs&lt;BR /&gt; AND a~belnr = @im_bkpf-belnr&lt;BR /&gt; AND a~gjahr = @im_bkpf-gjahr&lt;BR /&gt; ORDER BY buzei&lt;BR /&gt; INTO CORRESPONDING FIELDS OF&lt;BR /&gt; TABLE @gt_bseg.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 06:32:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-abap-query-understanding/m-p/766812#M37701</guid>
      <dc:creator>former_member574488</dc:creator>
      <dc:date>2019-01-25T06:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Complex ABAP Query Understanding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-abap-query-understanding/m-p/766813#M37702</link>
      <description>&lt;P&gt;It'd be a lot easier to read and help if you use the "code" button in the editor and pasted your nicely formatted code - using right-click "paste as plain text".&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 08:03:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-abap-query-understanding/m-p/766813#M37702</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-01-25T08:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Complex ABAP Query Understanding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-abap-query-understanding/m-p/766814#M37703</link>
      <description>&lt;P&gt;In which table field(data) you are getting the issue?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 08:47:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-abap-query-understanding/m-p/766814#M37703</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-01-25T08:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Complex ABAP Query Understanding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-abap-query-understanding/m-p/766815#M37704</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can take your time understanding big queries like these with extra replacement logic in it.&lt;/P&gt;&lt;P&gt;Just abstract them. First start with the inner and left outer joins and press f1 when you're having trouble understanding those terms.&lt;/P&gt;&lt;P&gt;Also understand the database tables from a functional perspective and their relationships.&lt;/P&gt;&lt;P&gt;Kind regards, Rob Dielemans&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 13:20:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-abap-query-understanding/m-p/766815#M37704</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-01-25T13:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Complex ABAP Query Understanding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-abap-query-understanding/m-p/766816#M37705</link>
      <description>&lt;P&gt;I could say this query is selecting information of partner ( could be customer or vendor or one-time partner thats why there are inner join with those master ). The CASE conditions just to separate into debit or credit column, get the partner name (maybe) etc...nothing special. Your query is specific with your logic so maybe you should ask about your issue instead.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 03:55:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-abap-query-understanding/m-p/766816#M37705</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-01-28T03:55:06Z</dc:date>
    </item>
  </channel>
</rss>

