cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

calculation in final internal table in amdp class

winona8689
Participant
1,792

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

 

Accepted Solutions (0)

Answers (4)

Answers (4)

Romanos
Product and Topic Expert
Product and Topic Expert

@winona8689 

If you consume the procedures from ABAP, use the read text there.
If you consume it in a fiori app you can also use a custom entity so you can fill an element with read_text.

Otherwise for the long text to be available on hanadb:
A. You can use an enhancement to store the text in a readable format, in a custom table.
B. Use SLT to transform the text. 

For me, the easiest option is the first, if possible.

winona8689
Participant
0 Likes

@RomanosSo again, I tried your first method, but It is throwing some error.

winona86_0-1719424111112.png

 

Romanos
Product and Topic Expert
Product and Topic Expert

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

 

winona8689
Participant

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. 

 

winona8689
Participant
0 Likes

@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

ravishgarg
Participant

Hi @winona8689 

Curious to ask you but from the code snippet shared, it can be done in a CDS easily, without needing to do an AMDP class.

Regards

RG

winona8689
Participant
0 Likes
Hi , I have several other validations hence had to resort to use a class and call in my report.
winona8689
Participant
0 Likes

@Romanos  Thanks, That helped a lot. However I am unable to apply filter. I have below code in my report

winona86_0-1718734192874.png

winona86_1-1718734716430.png

 

This is my class below , Should I mention FKDAT in my where Clause?

winona86_2-1718734757578.png

 

winona8689
Participant
0 Likes
So , basically I am unable to select by fkdat date ranges.