09-01-2007 7:10 AM
Hi all,
I have a report program which calls another report program using SUBMIT statement.The second report program will generate some messages.
I want to catch that in first report program .
I will have write statement in the first program to print that message.
When i schedule the first program in background i want that message to be available in spool
If anyone knows how to solve the scenario please help.......a sample code will be more helpful.
points will be rewarded.....
09-01-2007 7:21 AM
Hi,
In your second program, that you are calling in SUBMIT, export the messages to memory
w_message = message text.
EXPORT w_message TO MEMORY-ID 'MESSAGE'.
In your first program, import it..
IMORT FROM MEMORY-ID 'MESSAGE' FIELD w_message.
Thanks and Regards,
Vikas Bittera.
09-01-2007 7:53 AM
Hi Vikas
Thanks for that quick reply.What i have posted before were only part of my requirement.
Let me explain my whole scenario.If you could also help on solving this scenario,it would be really helpful.
I will explain the scenario with some sort of pseudocode.
<b>First Program .</b>
costing run = 'XXXX'
costing date = 'yyyy/mm/dd'
jobname = 'yyyyy'
call function Job_open and pass the jobname to get the job count.
submit second_program with crun = costing run
with cdate = costing date
with jnam = jobname
with jcnt = jobcount.
and return.
call function job_close .
<b>Second program.</b>
selection screen.
parameters : crun type kalaid,
cdate type kaladat,
jnam type tbtcjob-jobanme,
jcnt type tbtcjob-jobcount.
end of selction screen.
//comment : to get a cfromdate by passing cdate as input to the function module
call funtion determine_period
import : cdate
export : cfromdate
if sysubrc <>0
w_message //<b>it will have the error message which i want to pass to first program with export as you said.</b>
else.
submit saprck23 with crun
with cdate
with cfromdate
via jnam and jcnt.
and return.
endif.
In the above pseudocode i have said like if the function module in second program fails , then the error message should be exxproted to first program and that shoud be availbale in the spool when the first program is exceuted in the background.else if the function module executes successfully ,in the spool the output of the saprck23 program should be avialble.
Help me in solving the problem because since i didnt know to work with jobs i am confused.when i tried it is giving me some dump erroe which i am not able to understand also
09-01-2007 8:01 AM
Hi Hema,
The first solution i provided will work for your first case, means if the FM fails.. And for the second case regarding the spool of the called program, you will need to code something like this.:
SUBMIT rm07idif WITH SELECTION-TABLE li_selection
EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = li_listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
CHECK sy-subrc = 0.
CALL FUNCTION 'WRITE_LIST'
TABLES
listobject = li_listobject
EXCEPTIONS
empty_list = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
Thanks and Best Regards,
Vikas Bittera.
09-01-2007 7:56 AM
Hi,
Just to add to the above comments..after the import..use the FREE memory statement
Reason : If the second report doesnot have any messages and memory is not freed...chances are that the report will show messages of a condition which was previously run...pls always use FREE command if the use of that memory id is restricted to one report
w_message = message text. "OK
EXPORT w_message TO MEMORY-ID 'MESSAGE'. "OK
In your first program, import it.. "OK
IMORT FROM MEMORY-ID 'MESSAGE' FIELD w_message. "OK
<b>FREE MEMORY ID 'MESSAGE'.</b> "use free here
Also please use a unique or different name for memory..u need to be careful not to step on someone elses toe
something like <b>'MESSAGEPROGNAME'</b>
for correct syntax please refer ABAP documentation
Hope it proved useful
Reward all helpful answers
Regards
Byju