Skip to Content
Former Member
Jul 22, 2017 at 04:59 AM

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

261 Views Last edit Jul 21, 2017 at 11:21 AM 2 rev

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.