cancel
Showing results for 
Search instead for 
Did you mean: 

calculation in final internal table in amdp class

winona86
Explorer
275

Hi ,

I have a AMDP class where the final itab is a join of several itabs.

I wrote this code initially as normal abap report and since the execution time was much longer I am approaching it as AMDP class.

 

winona86_0-1718656149046.png

How can I write this in my amdp select 

winona86_1-1718656286008.png

 

View Entire Topic
Romanos
Explorer

Hello,

You can include CASE statements in your select query. You can also do this with openSQL if your abap version allows it and still have improved performance from the code pushdown. For example :

  SELECT
  CASE WHEN kwmeng = 0
      THEN division( kzwi4 , kwmeng , 2 )
      ELSE CAST( 0 AS DEC )
  END AS
  summary,
  CASE WHEN kalsm IN ( @LC_usf , @LC_ysf )
      THEN coalesce( division( kzwi2 , kwmeng , 2 ) , 0 )
      ELSE coalesce( division( ( kzwi1 - kszwi4 ) , kwmeng , 2 ) , 0 )
  END AS
  order_net_subtotal,
  CASE WHEN kalsm IN ( @LC_usf , @LC_ysf )
      THEN kzwi2
      ELSE ( kzwi1 - kzwi4 )
  END AS
  order_net_subval

 

winona86
Explorer

Update , I was able to solve many of the issues. Division statement was throwing error so replaced with

winona86_0-1718976796823.png

I have to join stxh and stxl to pull the comment , since we cannot use read_text. 

 

winona86
Explorer
0 Kudos

@Romanos

Since we cannot use read_text in the amdp class, I am fetching data from stxh and stxl. However , I am facing issues while decompressing the raw data to text.

I tried BINTOHEX and BINTOSTR , but no luck.

Anyway I can get this done?

text_stxh.JPGtext_raw.JPG