cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BADI being called random times

Former Member
0 Likes
868

we have a requirement in our GTS system - while saving the customs duty calculation document, a warning message has to be displayed based on some values. As I haven't found any customer/user exits, I searched for BADI's and found a badi used for output determination, which has all the parameters I require. So, I have implemented my code there.

But the problem here is, that badi is being called random number of times - more than 1 time in 90% of cases, and that warning message is also being displayed random number of times.

I tried using ABAP memory for this - by setting a flag using EXPORT/IMPORT, but this approach is not working.

Any ideas how to implement this?? Any help would be appreciated.

Accepted Solutions (0)

Answers (3)

Answers (3)

mouaz_benredjeb
Contributor
0 Likes

Hi Ramya,

Indeed, BADI /SAPSLL/PRN_DET could be called by the standard multiple times...

Have you explored the possibility of instead using the BADI /SAPSLL/IF_EX_CUS_ECC with method MODIFY_CONSISTENCY_CHECK?

This BADI is usually the BADI used to check the content of the declaration before to set the declaration as complete.

When implementing this BADI, you would do the following:

- Add your own logic to identify the issue for which an error or warning message should be issued

- Set parameter CV_CONSISTENT to blank (so the declaration is inconsistent)

- (Important) Add a message in the consistency/incompleteness log - This can be easily done by issuing a message from within the BADI.

The user will then see this error/warning message in the incompletion log. If it is a warning message, he can then proceed with the declaration (e.g. send it to customs authorities). If it is an error message, he/she won't be able to process the message to customs.

Hope this helps.

Mouaz

RaymondGiuseppi
Active Contributor
0 Likes

Define some field or internal table in your BAdI implementation's instance attributes, set its value when warning is raised (or add a record when raised for an item) and don't raise the warning again if already done.

Former Member
0 Likes

I'm new to ABAP and i didn't know much, but whenever a second call is made, I think all the previously instantiated attributes gets recycled along with that object. Please correct me if I'm wrong. However, I haven't tried the approach yet, I'll try it today. Thanks.

RaymondGiuseppi
Active Contributor
0 Likes

So did you try to either

  • Find a BAdI only called once (a 'check' or 'prepare save' type of BAdI)
  • Save your flag in a shared area with a lifetime related to your main transaction
mouaz_benredjeb
Contributor
0 Likes

Hi Ramya,

In order to help, could you please share the name of the BADI definition you are using?

Thanks.

Mouaz

Former Member
0 Likes

Hi Mouaz,

The BADI is /SAPSLL/PRN_DET. I'm using it's implementation to write my "warning message" logic while saving customs duty regulation document.

Thanks

Ramya