cancel
Showing results for 
Search instead for 
Did you mean: 

how to 'remember' a field value inside a BAdI?

Former Member
0 Kudos

Hi all,

We need to implement some code in a BAdI for Healthcare. The BAdI is active in the PBO of transaction NV2000. We need to read the value of one field and, if this field has a certain value, default another field with a certain value.

The problem is - this BAdI reads each time another structure which you can change, but the two fields in question are in two different structures. So it's like:

CASE i_structure_name.

...

WHEN 'RNBADI_ADM'.

MOVE c_data TO ls_rnbadi_adm.

*here I could read the value of my controle field which can be found in ls_rnbadi_adm

...

WHEN 'RNBADI_EXTDOC_ADM'.

MOVE c_data TO ls_rnbadi_extdoc_adm.

  • here I could change my other field which can be found in ls_rnbadi_extdoc_adm

  • give changed data back

c_data = ls_rnbadi_extdoc_adm.

...

The problem is, in the step where structure ls_rnbadi_extdoc_adm is filled, structure ls_rnbadi_adm is empty so the value of the control field is not accessible any more. The control field is also not an interface parameter so I don't really know its value at runtime... it can be changed so selecting it from the database is not a good idea...

I thought to declare a 'static' variable and give it the value of the control field in the step where ls_rnbadi_adm was filled, so the program would remember it in the step where ls_rnbadi_extdoc_adm was filled. But the ABAP Editor gives a syntax error 'you can't declare statics inside an instance method'.

So any idea how to 'remember' the value of that control field?

Thanks in advance,

Ioana

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi Ioana,

You can add your own variables in the implementation of your BADI. Go to the class interface of your implementation, hit the tab 'Attributes' and add the control field you need.

Regards,

John.

Former Member
0 Kudos

Hi John,

If I go to the class interface (via the menu

Go to->Interface) and hit the Attributes tab and then 'Change' the system asks me for a key because I'm trying to change a SAP Standard object ( R3TR INTF IF_EX_ISH_NV2000_PBO ).

Is it OK to do this, or will it give problems with the next upgrade? or am I hitting the wrong button?

Thanks,

Ioana

Former Member

Hi Ioana,

You should not change the standard SAP interface but your implementation of the interface (the BADI). Use transaction SE19, enter the name of your implementation, Hit change and go to the tab Interface. Then double click on the name of the implementing class and go to the tab Attributes.

Regards,

John.

Former Member
0 Kudos

Hi John,

Thanks a lot for the info.

I'm trying to do that now but there are still two things I don't know:

- declaration type: instance attribute or static attribute?

- visibility area: public or protected or private?

Thanks,

Ioana

Former Member

Hi Ioana,

It depends on your requirements, but normally you would use type instance attribute and visibility public.

Regards,

John.

Former Member
0 Kudos

Hi John,

Thanks a lot for the help. Problem solved.

Ioana

Former Member
0 Kudos

Hi Ioana,

If I solved your problem would you please be so kind to reward the points?

Thanx,

John.

Former Member
0 Kudos

Hi John,

How do I do that exactly? I thought it was enough to check the radiobutton 'yes, my question has been answered' under the message window... is there some other thing I should do?

Regards,

Ioana

Former Member
0 Kudos

Hi Ioana,

To do this simply Click on the Yellow Star icon in my reply and then a window will appear where you can give:

10 points (solves problem, marks question as answered)

6 points (very helpful)

2 points (helpful).

Kind regards,

John.

Former Member
0 Kudos

OK, it has happened now - I didn't know that.

Regards,

Ioana

Answers (0)