cancel
Showing results for 
Search instead for 
Did you mean: 

Handling an Empty Node

Former Member
0 Kudos

Hi all,

I'm having a problem with a RFC that I cannot see how to solve. I'm importing the BAPI_ADDRESSEMPGETDETAILEDLIST to see if the employee has a primary/secondary residence. I'm mapping it in the context, and applying a form template to have the output fields in the View. The schema is simple, if the user has a primary residence it's shown in the overview and he has a button to add a secondary residence (if he wants), the opposite is also true, and if he has one primary and one secondary residence both are shown in different overviews.

Well, the problem appears when he has none. He is supposed to have two buttons to add a primary and secondary Residence, and it's true, but when I try to set the values in the output node of the BAPI it calls an exception because it has no structure. The employee didn't have any residence so the output node is null...

Is there any way to inicialize the structure despite the fact of having no values? Do I have to map private var's to set them if the node built from the bapi is empty?

Thank you in advance for your answers,

Regards.

Ricardo Nascimento.

Accepted Solutions (0)

Answers (3)

Answers (3)

abhijeet_mukkawar
Active Contributor
0 Kudos

hi,

yeah you can initialise structure with default values through code. So this code will get executed if the user has no residence.

Or other way round , if you dont want to initialise with default values then you can execute it with wahtever values or no values and if it throws exeption you can catch that and show relevant message in catch block

hope it helps

regards,

former_member189631
Active Contributor
0 Kudos

Hi Ricardo,

You can acheive this by writting code to check null values.

Or While handling the Exception the control must come to the

catch block ,there you can display any warning messages

by using message manager or call any other methods.

Regards,

Ramganesan K.

Former Member
0 Kudos

Hi Ricardo

One way to avoid the problem that you are facing is to have a value node which has structure similar to that of model output node. After execution of model object, copy the output to this value node and then use this value node in your view.

I hope this helps you.

Regards

Kapil