Application Development and Automation 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: 
Read only

Problem with Badi while inserting a record in a Z table

Former Member
0 Likes
1,521

Hi to all,

i have a problem with a Badi in version 4.6c. The badi is CTS_EXPORT_FEEDBACK. This badi is used when a request is released. At this time i need to insert the date and time of realeased in a Z table. I have done all the steps to succed, but the record is not being inserted in the table.

This badi run in a background job by the program RDDFDBCK, so i have to check SM37 for the log. The user that run the program in background is DDIC.

My code looks like this:


DATA: w_ot_valide TYPE zot_valide.
  w_ot_valide-trkorr = request.
  w_ot_valide-date_release = sy-datum.
  w_ot_valide-time = sy-uzeit.
  w_ot_valide-zuser =  sy-uname.

  INSERT INTO zot_valide VALUES w_ot_valide.
  if sy-subrc ne 0.
     MESSAGE ID 'ZMSJ' TYPE 'E' NUMBER '001'.
  endif.

I tried to force a COMMIT WORK, when sy-subrc eq 0 but still doesn't work. I know that a COMMIT WORK Badi is not the best, but I wanted to test whether it was working.

notes:

1.- The Badi is correctly implemented.

2.- The Badi is activated.

3.- The Badi is called because when i look in sm37 the job ended OK and if i put a message, the message is displayed in sm37.

4.- If i move the same code of the badi to a report program, that works correctly and inserted into the table.

Anyone have any idea why the record is not inserted into the table?

I appreciate any feedback on my problem.

best regards.

Andrew83.

Hi to all,

i have a problem with a Badi in version 4.6c. The badi is CTS_EXPORT_FEEDBACK. This badi is used when a request is released. At this time i need to insert the date and time of realeased in a Z table. I have done all the steps to succed, but the record is not being inserted in the table.

This badi run in a background job by the program RDDFDBCK, so i have to check SM37 for the log. The user that run the program in background is DDIC.

My code looks like this:


DATA: w_ot_valide TYPE zot_valide.
  w_ot_valide-trkorr = request.
  w_ot_valide-date_release = sy-datum.
  w_ot_valide-time = sy-uzeit.
  w_ot_valide-zuser =  sy-uname.

  INSERT INTO zot_valide VALUES w_ot_valide.
  if sy-subrc ne 0.
     MESSAGE ID 'ZMSJ' TYPE 'E' NUMBER '001'.
  endif.

I tried to force a COMMIT WORK, when sy-subrc eq 0 but still doesn't work. I know that a COMMIT WORK Badi is not the best, but I wanted to test whether it was working.

notes:

1.- The Badi is correctly implemented.

2.- The Badi is activated.

3.- The Badi is called because when i look in sm37 the job ended OK and if i put a message, the message is displayed in sm37.

4.- If i move the same code of the badi to a report program, that works correctly and inserted into the table.

Anyone have any idea why the record is not inserted into the table?

I appreciate any feedback on my problem.

best regards.

Andrew83.

8 REPLIES 8
Read only

former_member194669
Active Contributor
0 Likes
1,273

Your code looks okay,

May be try with MODIFY instead of INSERT or put your code in function module and call fm in badi.

Read only

0 Likes
1,273

hi a®s,

yes i have already tried with MODIFY instead of Insert and it doesn't work. i have thought the suggestion of the function module too, but first i wanted to know why a simple insert it doesn't working.

If I have no choice, I'm going to try it.

Thank you very much for your answer.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,273

Hi,

In SM37, select the job and put JDBG in the command bar and then debug the executed program to find the exact issue.

Read only

0 Likes
1,273

Hi Jayanthi Jayaraman,

i have tried debugging by the sm37, but i cant because a dump occurred raising the condition "NO_RUNTIME_INFO", also, I am sure that the sy-subrc eq 0, because I tried printing messages and it was fine. The problem i think is that the commit is not triggering in background job of the method.

Thanks you very much for your answer! any other idea?

Andrew83.

Read only

0 Likes
1,273

Yesterday I posted how to debug background jobs. You can check it in

Read only

Former Member
0 Likes
1,273

As suggested, debug to check that your variables contain the appropiate data.

Read only

Former Member
0 Likes
1,273

Hi to all. Now i am posting the answer to my problem. I thought it was unnecessary to use debugger because my sy-subrc was 0. It turned out that my problem was not the commit. The problem was that the background program running by user DDIC, was being processed in mandant '000', so my insert sentence, inserted records in mandant '000'.

The solution was write the code like this:


DATA: w_ot_valide TYPE zot_valide.
  w_ot_valide-mandt ='200'.
  w_ot_valide-trkorr = request.
  w_ot_valide-date_release = sy-datum.
  w_ot_valide-time = sy-uzeit.
  w_ot_valide-zuser =  sy-uname.
 
INSERT INTO zot_valide CLIENT SPECIFIED VALUES w_ot_valide.

thanks to all,

best regards.

Andrew83.

Read only

0 Likes
1,273

sometimes small glitch take lot of time to trace. Thanks for posting the solution