‎2009 Feb 10 9:21 AM
If i call a Function Module in Background will i be able to Export values to Database ?
like:
CALL FUNCTION 'func_name' IN BACKGROUND TASK TABLES table = table1.
and in FM:
EXPORT <one> FROM <two> TO DATABASE indx(some) ID 'some1'.
I am only able to export if i dont use the background processing.
thanks
Edited by: shalaxy s on Feb 10, 2009 3:18 PM
‎2009 Feb 10 9:51 AM
Hi,
You should update Database directly, since it may violate the integrity policy of the tables. You need to write a BDC program for this and you can execute it to create a session, which in turn you can execute in background.
Regards,
Shiny
‎2009 Feb 10 10:12 AM
hi,
thing is i am executing an FM in background because i dont want to see its output. i just need the result itab from this FM.
for fetching values from this itab , i am exporting it using reff. in INDX table (which is used for the purpose)
i dont want BDC, just want to retrieve the itab value from a FM.
‎2009 Feb 10 9:59 AM
Hi:
It depends on the situations, for maximum databases, either function module or class are available in SAP but in the case of exception, its better to go with BDC.
Regards
Shashi
‎2009 Feb 10 10:21 AM
Hi,
Please post your question clearly.
As per my understand you can directly update data base through LSMW or BDC programs and this yuo can in foreground also.
Regards
Md.MahaboobKhan
‎2009 Feb 10 10:36 AM
ok, here it goes .. ..
my problem is not related to BDC or any DB update
its simple ... there's an FM that executes and displays an output alv report.
I dont want to see the output , just need the itab that has data (which is finally displayed as output)
I can export (and then import) this itab if i execute the FM in foreground
BUT, since i dont want to see the FM output i am executing this FM in background.
BUT when i execute it in background, values dont get exported.
I am using EXPORT ......... TO .......... DATABASE for this.
‎2009 Feb 10 11:53 AM
Hi Shalaxy,
Calling Function Module in Background/Update Task is normally used for bundling techniques where your requirement is to execute all the database updates in single database LUW (Logical Unit of Work) in order to maintain data integrity. All your database updates gets successfull or none of them.
If you call FM in Background Task, it is not executed immediatly, it is registered with all its values and executed only when COMMIT WORK statement is executed.
I think there is no explicit COMMIT WORK statement in your code and that is why you are not able to see effect of EXPORT TO DATABASE statement as LUW is not at all initiated.
I feel, as your requirement is only to suppress the ALV output, you should handle it through some other alternative e.g. using parameter or something like that and If function module you are talking about is Z and you are willing to change it.
Regards,
Vishal
‎2009 Feb 10 3:09 PM
thanks Vishal,
i am using a Commit statement right after i export the <itab>
the FM is a standard one , so i cant change it either , and this one calls the ALV at the end !!
But what i wud really like to know if its possible that in background processing we cannot export anything ? Am i doing something else wrong ?
‎2009 Feb 11 10:13 AM
Hi Shalaxy,
I think commit statement should be in the calling program not inside FM itself.
Please refer below link from sap help if it helps.
http://help.sap.com/saphelp_nw04/helpdata/EN/9f/dbae4135c111d1829f0000e829fbfe/frameset.htm
Regards,
Vishal
‎2009 Feb 11 1:09 PM
hi Vishal,
yes , the commit is inside calling prog.
once i have the internal table with values, i call commit.
also, when i call FM in foreground , it commits but the prob comes only when i execute it in background .......
‎2009 Feb 11 1:42 PM
Hi Shalaxy,
Try using the statement commit work and wait.
Hope this might be the reason,
if you just use commit work it updates database asynchronously which means the database gets updated, and simulataneously your program proceeds further,
if you use commit work and wait then until the database is not updated the program waits.
Hope this helps you,
Regards,
Siddarth
‎2009 Feb 12 3:39 AM
Hi Shalaxy,
What I feel is, You try Siddharth's suggetion of synchronous update first.
If it aslo fails then as a last option you create a function module for testing purpose with normal open sql statement i.e. insert/update and your export to database statement and see if both the statements fails or only export statement.
If both are failing then something is wrong with the function call.
If open sql works and export fails then we may conclude that export to database can not be used in this scenario.
If you tried it, do let us know the result.
Regards,
Vishal
‎2009 Feb 12 4:18 PM
tried
BAPI_TRANSACTION_COMMIT
COMMIT WORK AND WAIT .
WAIT UNTIL sy-subrc = 0.
nothing's working. When i call this FM in background, it doesnt wait .
Infact i executed the code and checked after a couple of hours if table gets data. But it doesnt.
maybe export ... to.. database doesnt work in background processing.??
How do we retrieve the values of an internal table that gets populated in background processing?
‎2009 Feb 12 4:52 PM
You can either debug the job after it is completed or enter into debug via SM50 and see if your itab is populated or not.
~Suresh
‎2009 Feb 13 2:46 AM
when i debug, and i come out of the FM call ( FM which populates the itab i require) , it doesnt recognize the internal table and following statement doesnt assign anything:
assign ('(report)<itab>[]') to <itemp>
‎2009 Feb 14 4:51 AM
Hi,
Could you please paste the code so that i can help you out......
Regards,
Siddarth..