Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SQ01 ABAP runtime error due to a returned null value in a local calculated field

Former Member
0 Kudos
557

I've created an SQ01 query with the intention of returning order schedule lines that have an open quantity based off of the Delivered Quantity (MENGE - GLMNG), this has been configured in a local calculated field. SAP calculates this field in Table MEPO1320, field name OBMNG, and can be seen in the Delivery Schedule tab in ME23N, however OBMNG calculates open quantity from the GR quantity, which doesn't meet the requirements of what this query is intended for.

I have named my calculated field ZOBMNG, I am using this field as one of the selection criteria, returning all values not equal to 0 (all open schedule lines).

My issue is, if there is no quantity delivered, SAP leaves the GLMNG field as a null value, and I am finding it difficult with the basic logic available within the 'complex calculation' area to avoid a runtime error.

It is important to note that I need to know where there is a null value, as the null value represents a 0 delivered quantity.

I broke it down into two steps, the first looks if the delivered quantity is greater than 0, if so, subtract GLMNG (delivered quantity) from MENGE (schedule quantity):

Condition: GLMNG > 0 Formula: MENGE - GLMNG

I have run this independently and it does return partially delivered schedule lines. I havent been successful through various methods to return 0 otherwise.

What I've tried, all have ended up as runtime errors:

Condition: GLMNG = 0 Formula: MENGE (Looking to just return the schedule line qty if there is 0 delivered)

No second condition or formula, just MENGE in the otherwise section

Multiplying & dividing GLMNG by 0 & 1 and using DIV/MOD both together and separately - all to try return 0.

creating a second calculated field to define GLMNG as a text or numerical value of 0 and calling up this second calculated field in the first calculated field.

Is it possible to achieve what I need? Please also note I am not authorised to write code within the applicable section in SQ02.

3 REPLIES 3

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos
127

The only senseful way of handling Null Value in Open SQL is the condition IS [NOT] NULL.

Dealing with a numerical 0 does not help.

In modern Open SQL also expressions can return Null Values, e.g. a CASE expression where no condition is met. I wonder if your query would accept that, but I guess not (because the generated Open SQL most probably uses old syntax).

Sandra_Rossi
Active Contributor
127

It would be interesting to know the full content of your short dump (runtime error) : I think your issue is not about NULL values (your question is misleading), but about value 0 because you try to divide by zero.

If you have difficulties with using the classic SAP query interface, and you know ABAP well, then you may write your own ABAP code to select the data in your infoset, cf SAP Library: infoset - using an external program to read data.

127

+1 to Sandra, please post short dump text. Also MEPO1320 is a structure. It'd be beneficial if you posted the specific table names and your JOIN details in the infoset. I rather doubt that there is NULL value (which is different from 0) in the quantity field.