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: 

BADI to work in background job too

rangerlet_mesee
Participant
0 Kudos
347

Hi

I am using a BADI to manipulate price of a purchase req. I have put condition as sy-tocde as ME51N,52N,53N for the logic written.

But now they want the BADI to do its work when creating the PR in background too...

Is the check sy-batch EQ 'X' enough along with sy-tcode check ?

Pls suggest

5 REPLIES 5

former_member667434
Active Participant
0 Kudos
157

Hi rangerlet.mesee

That will definitely be a start and mostly should do the trick for you.

-Ashutosh

Sandra_Rossi
Active Contributor
0 Kudos
157

you say "in background", I guess you mean BAPI or Web Service, in that case they are right sy-tcode will not contain ME51N, 52N, 53N. What BAdI is it? What method?

How to know whether adding a condition on sy-batch is sufficient? (we don't know your code/your rules).

"They" have to provide a test case so that you can make sure your code works in all possible test cases.

Gourab_Dey
Contributor
0 Kudos
157

You condition should work for background mode too. Have you tried debugging the job to find out whether your existing condition(sy-tocde as ME51N,52N,53N)is working or not.

If you are new to debugging a job, you can do it in a following way.

  • Put a infinite loop in your BADI before your condition. The loop will be something like
while 'x' eq 'x'.
endwhile.
  • Then you can schedule your job
  • Then go to SM50 and debug the job. Your existing condition should work. Not sure tough. You can try our.

Let me know if you need any more information.

Thanks,
Gourab

raymond_giuseppi
Active Contributor
0 Kudos
157

Which BAdI did you use? Without this information, it will be hard to guess your exact problem. Why did you rely on sy-tocde, is this BAdI common with many transactions

(e.g. Changing price if transaction is ME53N so in display mode is surprising in itself)

raymond_giuseppi
Active Contributor
0 Kudos
157

If you use a pure Purchase Requesition BAdI such as ME_PROCESS_REQ_CUST. Then don't check sy-tcode but use attribute TRTYP of the current transaction (check domain value) you can get this value in OPEN method as an imported parameter (save it as an instance attibute of your class implementing the BAdI as in following sample)

" Initialize attribute at start
METHOD if_ex_me_process_req_cust~open .
  me->trtyp = im_trtyp.
ENDMETHOD.                    "IF_EX_ME_PROCESS_REQ_CUST~OPEN

" Sample on one method
METHOD if_ex_me_process_req_cust~process_item .
  INCLUDE mm_messages_mac.
  CHECK me->trtyp NE 'A'. " A = 'Anzeigen' = 'Display'
  " ....
ENDMETHOD.                    "IF_EX_ME_PROCESS_REQ_CUST~PROCESS_ITEM