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: 

Not initial values check in CDS

bharath_padmanabhan
Participant
0 Kudos
2,470

Experts,

I have to fetch records from MSDM_E_MSEG in CDS table function. I need records for which Storage location (LGORT) is not blank and has some value. In regular ABAP, we go with LGORT is not initial or LGORT NE ''.

My code is as below:

I see that we can't use is not initial in table function. I tried LGORT <> '' and LGORT is not NULL. In both cases, I am getting records with empty LGORT. Can you please suggest how can we check for blank values inside table function?

Thanks

Bharath

1 ACCEPTED SOLUTION

bharath_padmanabhan
Participant
0 Kudos
2,024

Jun Wu and Sandra,

Thank you so much for your valuable replies.

@Jun Wu - I tried LGORT <> '' and LGORT is not NULL. This is working and I am not getting blank records anymore.

@Sandra:

1) I have data in only 1 client. In my table func, I have MANDT as one of the fields to be returned. But when I do a select query on that table func and see the columns in debugger, I see MATNR, WERKS and LGORT. First column MANDT is not shown. I am guessing that debugger for some reason is not showing the MANDT column.

2) Hex value for LGORT with blank values shows as '2000200020002000'

3) LGORT is not initial or LGORT NE '' " but LGORT is CHAR 4 so both subexpressions are equivalent in ABAP. Just keep one.

Agreed. I meant to say, we will be using one of these expressions to achieve the validation.

4) it's NSDM_E_MSEG - Apologies. Typo.

Thanks

Bharath

6 REPLIES 6

junwu
Active Contributor
2,024

did u try using both of them?

LGORT <> '' and LGORT is not NULL

Sandra_Rossi
Active Contributor
2,024

The explanation could be related to the client selection, are you sure that you are querying only the current client? (in case your system contains data in 2 or more clients)

Another possibility is that you got for unknown reason some space-looking characters (like tab, control characters) in LGORT of the database table. Could you check in ABAP debugger - display LGORT values in hex mode?

Otherwise, check SAP notes or contact SAP support.

NB: you have said "In regular ABAP, we go with LGORT is not initial or LGORT NE '' " but LGORT is CHAR 4 so both subexpressions are equivalent in ABAP. Just keep one.

NB: it's NSDM_E_MSEG, not MSDM_E_MSEG.

bharath_padmanabhan
Participant
0 Kudos
2,025

Jun Wu and Sandra,

Thank you so much for your valuable replies.

@Jun Wu - I tried LGORT <> '' and LGORT is not NULL. This is working and I am not getting blank records anymore.

@Sandra:

1) I have data in only 1 client. In my table func, I have MANDT as one of the fields to be returned. But when I do a select query on that table func and see the columns in debugger, I see MATNR, WERKS and LGORT. First column MANDT is not shown. I am guessing that debugger for some reason is not showing the MANDT column.

2) Hex value for LGORT with blank values shows as '2000200020002000'

3) LGORT is not initial or LGORT NE '' " but LGORT is CHAR 4 so both subexpressions are equivalent in ABAP. Just keep one.

Agreed. I meant to say, we will be using one of these expressions to achieve the validation.

4) it's NSDM_E_MSEG - Apologies. Typo.

Thanks

Bharath

bharath_padmanabhan
Participant
0 Kudos
2,024

Jun Wu - I don't see an option to convert your reply to answer. I remember seeing this usually when someone helps me with a resolution. Not sure what I am missing. So I ended up converting my reply to you as the answer so that anyone referring this thread in the future can know what worked.

Sandra_Rossi
Active Contributor
0 Kudos
2,024

bharath.padmanabhan Only the author of a comment can convert his comment to an answer (Actions > Convert to Answer). You may also post the answer yourself (with credits to the comment author) and at last resort ask an administrator if the author isn't willing to do it.

bharath_padmanabhan
Participant
0 Kudos
2,024

Thank you so much for patiently explaining me this feature, Sandra. I believe the easiest thing to do is to give credits to the author as you said and convert it as correct answer. This way, the person who helped me need not do 1 more extra step of visiting the thread to convert his reply as correct answer.

Its because of people like you, Jun Wu and other experts - We are able to handle clients and deliver projects. So I am always grateful to you and others for guiding me every single time.