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: 

How to put a report which contains code for BDC in background

Former Member
0 Kudos

Hello Experts ,

Please provide your valuable opinions on following issue,

My BDC execution is taking longer time and it gives time out error. To avoid this problem i have created a separate report which l contains the BDC code (Call transaction ) and i have put this report for background execution. But upon doing this My BDC code is not performing the transaction call which it was performing when it was executed individually. In sm37 it shown the job that i am creating but nothing is actually happening as a result of transaction call.

The code that i have written is :

RFC code

SUBMIT ZREPORT AND RETURN.

RFC end

Z_REPORT .

PERFORM open_job.

PERFORM get_print_parameters.

PERFORM job_submit. here in Submit i have specified the another report name(zbdcreport) which contains the actual logic for bdc

PERFORM job_close.

Report END.

zbdcreport

The call transaction is as follows :

( CALL TRANSACTION TCODE USING BDCDATA

MODE 'N' "CTUMODE "N

UPDATE 'S' "CUPDATE "S

MESSAGES INTO MESSTAB .)

end zbdcreport

Can anybody provide the reason for the error .

Regards,

Uma

18 REPLIES 18

Former Member
0 Kudos

Hi

For BDC are you using any external file,If you are using the external file, then the file should be application server when your process the proram in backgroud.

regards,

Raghu

0 Kudos

Hi ,

Thanks ,

The file being used is placed at particular location and it is accessible when we execute the bdc individually , so the expectation is that it will also be accessible when bdc is executed in the report which is put in background execution.

0 Kudos

>

> The file being used is placed at particular location and it is accessible when we execute the bdc individually , so the expectation is that it will also be accessible when bdc is executed in the report which is put in background execution.

Am afraid your expectation is wrong and wont work in this scenario. I assume you are meaning that the BDC is run in foreground when you say 'The file being used is placed at particular location and it is accessible when we execute the bdc individually ' . The same wont work when you are trying run the BDC in background as SAP system is completely independent in background mode and wont have any access to any file on the presentation server. Thats the reason why you are suggested to put the file on the application server.

Regards,

Vik

0 Kudos

Hi ,

It is somewhat difficult to understand as it is complex , please see the explanation below and let me know has your query resolved and can you please provide any solution :

My BDC execution is taking longer time and it gives time out error. To avoid this problem i have created a separate report which l contains the BDC code (Call transaction in background mode N ) and i have put this report for background execution using open , close , submitt job statements. But upon doing this My BDC code is not performing the transaction call which it was performing when it was executed individually(put in background mode there too by specifying mode as N ). In sm37 it shown the job that i am creating but nothing is actually happening as a result of transaction call.

The code that i have written is :

RFC code

SUBMIT ZREPORT AND RETURN.

RFC end

Z_REPORT .

PERFORM open_job.

PERFORM get_print_parameters.

PERFORM job_submit. here in Submit i have specified the another report name(zbdcreport) which contains the actual logic for bdc

PERFORM job_close.

Report END.

zbdcreport

The call transaction is as follows :

( CALL TRANSACTION TCODE USING BDCDATA

MODE 'N' "CTUMODE "N

UPDATE 'S' "CUPDATE "S

MESSAGES INTO MESSTAB .)

end zbdcreport

Can anybody provide the reason for the error .

0 Kudos

Hi Uma,

There is lot of difference between putting background mode as N and background job using open job,close job etc... I hope and I want you to understand this difference...

in background mode,ur executing the program and then only the call transaction process of updating records is run in background mode...that is you dont see screens,but in background job the whole program is put in background....in such cases files present on desktop or presentation server or personal system...will not work.

Hope you get it now!!!

Vishwa.

Former Member
0 Kudos

Hi

Check the code using this...

DATA: number TYPE tbtcjob-jobcount,

name TYPE tbtcjob-jobname VALUE 'JOB_TEST',

print_parameters TYPE pri_params.

...

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = name

IMPORTING

jobcount = number

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4.

IF sy-subrc = 0.

SUBMIT submitable TO SAP-SPOOL

SPOOL PARAMETERS print_parameters

WITHOUT SPOOL DYNPRO

VIA JOB name NUMBER number

AND RETURN.

IF sy-subrc = 0.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = number

jobname = name

strtimmed = 'X'

EXCEPTIONS

cant_start_immediate = 1

invalid_startdate = 2

jobname_missing = 3

job_close_failed = 4

job_nosteps = 5

job_notex = 6

lock_failed = 7

OTHERS = 8.

IF sy-subrc <> 0.

...

ENDIF.

ENDIF.

ENDIF.

Sandra_Rossi
Active Contributor
0 Kudos

unfortunately, it sometimes happen that sap programs test the runtime context and behave differently. What you may do is tracing the interactive and background executions (starting from the call transaction) via SE30 (use a variant without aggregation) and compare when the execution becomes different (in SE30 display the "call hierarchy")

0 Kudos

Hi thanks,

can you elaborate how would it help ?

0 Kudos

Hi

I think the file should be on Application Server and not on the Presentation system for BDC to work in background mode.

Vishwa.

0 Kudos

Hi ,

the file is on presentation server ,

and when we individually run the bdc in background mode with the same file it works fine, but when we put this code in the report which is put in background , then the bdc returns the successful message but does not do the the work.

0 Kudos

sorry but programs running in background CANNOT access files on presentation server (= Personal Computer). So, check again, and tell us.

0 Kudos

hi,

you can't run bdc in background for files on presentation server, you should access files from unix only.Otherwise you need to run it in foreground.

Thanks,

Ram.

0 Kudos

Please try to understand the scenario

The code that i have written is :

RFC xxx

SUBMIT ZREPORT AND RETURN.

RFC xxx end

Z_REPORT .

PERFORM open_job.

PERFORM get_print_parameters.

PERFORM job_submit. here in Submit i have specified the another report name(zbdcreport) which contains the actual logic for bdc

PERFORM job_close.

Report END.

zbdcreport

The call transaction is as follows :

( CALL TRANSACTION TCODE USING BDCDATA

MODE 'N' "CTUMODE "N

UPDATE 'S' "CUPDATE "S

MESSAGES INTO MESSTAB .)

end zbdcreport

first case : when i execute the report zbdcreport in foreground it works fine (here as well i have put the CALL transcation with Mode N that is background and the file is at the persentation server) .

second case : The file is at the same place . And when i execute the RFC xxx which intern makes call to the report Z_REPORT which intern makes call to the report zbdcreport in background using open job submitt and close job . The called report zbdcreport contain the bdc code to be executed in background . Here BDC does not work

0 Kudos

Hi,

You certainly seem to be in a wrong assumption that running the BDC with mode N is same as running the BDC as a background job. Both are different. The only problem why the BDC is not working as a background job is the location of the file which should not be in the presentation server while running as a background job.

Regards,

Vik

0 Kudos

sorry Uma but the way you explained it, you could be sure of the reaction of everybody !!

Could you run the job with "jdbg" okcode from SM37? (search forum for explanations) It will run the program with sy-batch = X, but with GUI attached. Just to see whether the sap pogram tests sy-batch or tests the GUI connection.

0 Kudos

Thanks ,

My file is neither on presentation server , nor on application server , it is on some file system , can you please tell me how do i get those files on application server

0 Kudos

I understand nothing. In the following, could you indicate where is the file logic ?

Moreover, does the RFC call originates from an SAP system, or something else? And did you make a test by calling Z_REPORT directly?

RFC xxx

SUBMIT ZREPORT AND RETURN.

RFC xxx end

Z_REPORT .

PERFORM open_job.

PERFORM get_print_parameters.

PERFORM job_submit. here in Submit i have specified the another report name(zbdcreport) which contains the actual logic for bdc

PERFORM job_close.

Report END.

zbdcreport

The call transaction is as follows :

( CALL TRANSACTION TCODE USING BDCDATA

MODE 'N' "CTUMODE "N

UPDATE 'S' "CUPDATE "S

MESSAGES INTO MESSTAB .)

end zbdcreport

0 Kudos

About using SE30 (see my answer above), it is usually used for performance measurement, but it can also be used to do a detailed trace of the execution of a transaction. To activate this functionality, you must create an SE30 variant and choose "no aggregation", and maybe increase the maximum size of the trace (2 MB by default). When you display the trace, you have additional buttons, one is to display the "call hierarchy".

It will allow you to see what is executed in the 2 cases (case 1 (interactive) which works, and case 2 (background) which doesn't work) and compare them. At the point where it becomes different (for example, procedure 1 is called in case 1, while procedure 2 is called in case 2), just "back debug" the case 2 from the point it is different, and you'll see the original reason and you'll be able to make a decision.

I often use SE30 call hierarchy (mostly in cases other than BDC by the way), when functional people tell me that there are 2 cases which are apparently the same, one which works and one which doesn't work. It often comes from a different customizing or transaction data, and I can answer them the reason why.