<?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>Question Re: GETTING AN ERROR WHILE RE-USING PARTAILLY CREATED COL... in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618752#M4819724</link>
    <description>&lt;P&gt;You cannot reuse previous fields, you must indicate again the same formulas:&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;select
(select case MSEG.SHKZG when 'S' then MSEG.MENGE else 0.0 end) as Receipt,
(select case MSEG.SHKZG WHEN 'S' THEN ( MSEG.MENGE + MSEG.MENGE ) else 0.0 end) as BalQuantity,
...&lt;/LI-CODE&gt;&lt;P&gt;NB: I didn't fix the other numerous errors of your query (like defining BalQuantity twice)&lt;/P&gt;&lt;P&gt;NB 2: you'd better do one simple query first, test it, then add complexity, test it again, etc.&lt;/P&gt;</description>
    <pubDate>Mon, 26 Feb 2024 07:23:59 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2024-02-26T07:23:59Z</dc:date>
    <item>
      <title>GETTING AN ERROR WHILE RE-USING PARTAILLY CREATED COLUMN IN SQL</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaq-p/13618260</link>
      <description>&lt;P&gt;Hi There!&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;The below query i wrote for a requirement. The thing is 2 columns RECEIPT(C) &amp;amp; ISSUE (D) were not there in my DB so i'hv created those using 2 columns named DEBIT/CREDIT (A) &amp;amp; BALANCE QUANTITY(B)&amp;nbsp;MSEG.MENGE , Like if D/C is 'S' then the bal.quantity value should be stored in 'receipt' field and if D/C is 'H' then the bal.quantity value should store in 'Issue' field. Now i got the receipt and issue field values correctly but balance quantity field values are not correct becoz there are some calculations involved in that. In that calculation i have to reuse the receipt field but when i'm using RECEIPT field while creating the balance quantity field i'm getting an error ( INVALID COLUMN) can anybody give me a suggestion? Error is at 3rd and 4th case statements.&lt;BR /&gt;&lt;STRONG&gt;NOTE : RECEIPT AND ISSUE FIELDS I HAVE POPULATED USING THE ABOVE LOGIC&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;select  distinct T001L.LGORT as sloc,MKPF.BUDAT as Year,MKPF.XBLNR as ReferenceDoc,MKPF.XABLN as GRGISlip,
MSEG.BWART as MovementType,MSEG.SHKZG as DC,
 
(select case MSEG.SHKZG when 'S' then MSEG.MENGE else 0.0 end) as Receipt,
 
(select case MSEG.SHKZG when 'H' then MSEG.MENGE else 0.0 end) as Issue,
 
MSEG.DMBTR as Amount,MSEG.MENGE as BalQuantity,
(select case MSEG.SHKZG WHEN 'S' THEN SUM(BalQuantity+Receipt)else 0.0 end)as BalQuantity,
 
(select case MSEG.SHKZG WHEN 'H' THEN MSEG.MENGE,Issue(MSEG.MENGE-Issue)else 0.0 end)as BalQuantity
MBEW.VERPR as PricePerUnit, MBEW.SALK3 as BalanceAmount,
t156t.BTEXT as Comment 
  from mara
 
INNER join mseg  on mara.MATNR=mseg.MATNR AND mara.MEINS=mseg.MEINS AND mara.BSTME=mseg.BSTME
 AND mara.KUNNR=mseg.KUNNR

INNER  join t001l on t001l.LGORT=mseg.LGORT AND t001l.WERKS=mseg.WERKS
 AND t001l.LIFNR=mseg.LIFNR AND t001l.KUNNR=mseg.KUNNR

INNER  join mkpf on mkpf.MBLNR=mseg.MBLNR AND  mkpf.MJAHR=mseg.MJAHR

INNER join mbew on mbew.MATNR=MARA.MATNR AND MBEW.LVORM=MARA.LVORM

INNER  join mard on mard.MATNR=MSEG.MATNR 
--AND mard.PSTAT=mbew.PSTAT 
AND mard.LVORM=mbew.LVORM
AND mard.LFGJA=mbew.LFGJA AND mard.LFMON=mbew.LFMON

INNER JOIN t156t
 
     ON  t156t.bwart = mseg.bwart
 
     AND t156t.sobkz = mseg.sobkz
 
     AND t156t.kzbew = mseg.kzbew
 
     AND t156t.kzzug = mseg.kzzug
 
     AND t156t.kzvbr = mseg.kzvbr
 
where
 
MARA.MATNR='1L90MHVB10250A'
 
and (MKPF.budat between '20200101' and '20231231')
 
and MSEG.BUKRS='VN01' and MSEG.WERKS='VNSD' AND t001l.lgort='RM01'and t156t.SPRAS='E' ;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2024 16:37:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaq-p/13618260</guid>
      <dc:creator>Albatross</dc:creator>
      <dc:date>2024-02-25T16:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING AN ERROR WHILE RE-USING PARTAILLY CREATED COLUMN IN SQL</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618648#M4819712</link>
      <description>&lt;P&gt;As I said one week ago: "You can find by yourself why the query gives duplicate lines, by removing one table at a time till you get unique lines: it's the last table removed which makes the duplicate lines."&lt;/P&gt;&lt;P&gt;But I guess there's something you don't understand in my reply,&amp;nbsp;because you keep duplicating your question (3rd time now) without asking any precision on any part of my reply...&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 06:14:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618648#M4819712</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2024-02-26T06:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING AN ERROR WHILE RE-USING PARTAILLY CREATED COLUMN IN SQL</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618697#M4819713</link>
      <description>No &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/22232"&gt;@Sandra&lt;/a&gt; kindly read my question once again.....it's not at all about duplicates. Actually i'hv created a partial column and when i'm reusing it in the next case statement it is throwing error like 'INVALID COLUMN'. I need to spend some time to post and it's not a simple thing no? So if it's an duplicate issue then y am i again created a new post for the same issue.</description>
      <pubDate>Mon, 26 Feb 2024 06:40:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618697#M4819713</guid>
      <dc:creator>Albatross</dc:creator>
      <dc:date>2024-02-26T06:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING AN ERROR WHILE RE-USING PARTAILLY CREATED COLUMN IN SQL</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618741#M4819722</link>
      <description>LOL apologies!!! You have lots of issues with this query &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
      <pubDate>Mon, 26 Feb 2024 07:18:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618741#M4819722</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2024-02-26T07:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING AN ERROR WHILE RE-USING PARTAILLY CREATED COL...</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618752#M4819724</link>
      <description>&lt;P&gt;You cannot reuse previous fields, you must indicate again the same formulas:&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;select
(select case MSEG.SHKZG when 'S' then MSEG.MENGE else 0.0 end) as Receipt,
(select case MSEG.SHKZG WHEN 'S' THEN ( MSEG.MENGE + MSEG.MENGE ) else 0.0 end) as BalQuantity,
...&lt;/LI-CODE&gt;&lt;P&gt;NB: I didn't fix the other numerous errors of your query (like defining BalQuantity twice)&lt;/P&gt;&lt;P&gt;NB 2: you'd better do one simple query first, test it, then add complexity, test it again, etc.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 07:23:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618752#M4819724</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2024-02-26T07:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING AN ERROR WHILE RE-USING PARTAILLY CREATED COLUMN IN SQL</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618787#M4819732</link>
      <description>Don't apologize buddy &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/22232"&gt;@Sandra&lt;/a&gt;... As i have so much requirements to be satisfied in a single query exhausted little bit. And u r seeing the same query again u r thinking like i'm asking the same doubt again and again. I understood. Thanks alot for ur quick response. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 26 Feb 2024 07:58:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618787#M4819732</guid>
      <dc:creator>Albatross</dc:creator>
      <dc:date>2024-02-26T07:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING AN ERROR WHILE RE-USING PARTAILLY CREATED COL...</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618788#M4819733</link>
      <description>Thanks my dear &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/22232"&gt;@Sandra&lt;/a&gt; sure i'll try this method.</description>
      <pubDate>Mon, 26 Feb 2024 07:59:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-an-error-while-re-using-partailly-created-column-in-sql/qaa-p/13618788#M4819733</guid>
      <dc:creator>Albatross</dc:creator>
      <dc:date>2024-02-26T07:59:12Z</dc:date>
    </item>
  </channel>
</rss>

