Execution of report in background and foreground
Hi all,
I have a report in which i have two radio buttons on selection screen.
1, Foreground
2. background
could you please tell how to do foreground and background execution of report depends on user selection.if you could send some sample code its really helpful.
thanks
If the Background radio button is selected the you need to use the SUBMIT command to submit your program in background.
Example
Scheduling a submitable program as a background task with the number number in a background request name. After scheduling, the background task is completed by function module JOB_CLOSE and released immediately providing the user has the relevant authorization.
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.
Cheers
VJ
Message was edited by:
Vijayendra Rao
Similar Messages
-
Running the alv report in background and sending it thro email
hi,
i have to run the alv report in background and send the output through emailHi
Many a times there is a requirement to display ALV Grid (not ALV List) in the background Job. I have checked the SDN Forum for the same and it has been mentioned that ALV Grid cannot be displayed in Background, but the list output of ALV is possible. So user wont have the actual Grid interface but the List interface.
There is a workaround to display ALV Grid in Background Job. The only restriction is you cant schedule the job through SM36. You need to execute the transaction of the report program, fill in the selection screen data and hit Execute.
The job would be executed in background. User will be able to see the Job Log and Job Status after executing the program. User doesnt have to go to SM37 to view the job status/log. Once the Job Status is changed to COMPLETED, user can click on DISPLAY SPOOL to view the ALV Grid.
Limitations:
Cant schedulea background job
The session should be active until the background job is completed. If the session is closed, then user wont be able to check the output in ALV Grid. User would be able to check the output through spool or SM37
Advantages:
If the spool width is greater than 255 characters, then the entire width could be seen in the output because the output is directed to an ALV Grid and not to spool
Interface of ALV Grid is available instead of ALV List even though its a background job.
Program wont give the TIME OUT error
Steps Required:
1. Once you execute the program, the following screen would be displayed
2. Click Display Job Status to check the Status of the Background Job
3. Click on Display the Job Log to check the Log
4. Click on Display Job Status to check the Job Status
5. Click on DISPLAY SPOOL to check the spool content once the Job Status is changed to COMPLETED. Output is displayed in ALV Grid
Programs:
1. Two different programs needs to be created
ZPROGRAM_ONE: This is the 1st program, where the selection screen and all the data validations would be done. Error handling for invalid data should be done in this program.
Once the data validation is done, this program would call the 2nd program ZPROGEAM_TWO. Build the logic to display ALV Grid in this program. The logic will only display ALV in foreground and it wont be reflected in the spool.
ZPROGRAM_TWO: This program would fetch all the data and do all the processing. If you want the spool output along with ALV Grid output, then build the logic in this program to display ALV Grid.
*& Report ZPROGRAM_ONE *
REPORT zprogram_one .
PRASHANT PATIL
TABLES : mara,
tsp01.
type-pools:slis.
TYPES : BEGIN OF t_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
laeda TYPE mara-laeda,
END OF t_mara.
DATA : i_mara TYPE STANDARD TABLE OF t_mara,
wa_mara TYPE t_mara,
wa_index TYPE indx, " For Index details
wa_index_key TYPE indx-srtfd VALUE 'PRG_ONE',
i_jobsteplist TYPE STANDARD TABLE OF tbtcstep, " For spool number
wa_params TYPE pri_params, " To Get Print Parameters
wa_jobhead TYPE tbtcjob, " To know the status of job
wa_jobsteplist TYPE tbtcstep, " To know the spool
w_jobname TYPE tbtco-jobname, " Job name for bckgrnd job
w_jobcount TYPE tbtco-jobcount, " Unique id for bckgrd job
w_path TYPE string, " Upload path
w_lsind TYPE sy-lsind, " Index
wa_seltab TYPE rsparams,
i_seltab TYPE STANDARD TABLE OF rsparams,
wa_index1 TYPE indx, " For Index details
wa_index_key1 TYPE indx-srtfd VALUE 'PRG_TWO',
i_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF i_fieldcat.
CONSTANTS DECLARATION *
CONSTANTS :
c_a(1) TYPE c VALUE 'A',
c_m(1) TYPE c VALUE 'M',
c_l(1) TYPE c VALUE 'L',
c_c(1) TYPE c VALUE 'C',
c_zfdr(4) TYPE c VALUE 'ZFDR',
c_x(1) TYPE c VALUE 'X',
c_locl(4) TYPE c VALUE 'LOCL', " Destination is LOCAL
c_f(1) TYPE c VALUE 'F', " Job Status - Failed
c_s(1) TYPE c VALUE 'S',
c_p(1) TYPE c VALUE 'P'.
SELECTION SCREEN PARAMETERS
SELECT-OPTIONS : s_matnr FOR mara-matnr.
START-OF-SELECTION.
Before the export, fill the data fields before CLUSTR
wa_index-aedat = sy-datum.
wa_index-usera = sy-uname.
EXPORT s_matnr
TO DATABASE indx(st) FROM wa_index ID wa_index_key.
To Open the Job for background processing
PERFORM open_job.
To get the print parameters
PERFORM get_print_parameters.
Submit the job in background
PERFORM job_submit.
Close the background job
PERFORM job_close.
This is the output screen with the buttons ********
Create 3 buttons DISPLAY SPOOL, STATUS, JOBLOG
SET PF-STATUS 'ZS001'.
WRITE: / 'The program is submitted in Background'.
WRITE: / 'Press DISPLAY SPOOL to see the spool'.
WRITE: / 'Press STATUS to see the status of the background'.
AT USER-COMMAND.
If user presses the 'BACK' button
IF sy-ucomm = 'BAK'.
IF wa_jobhead-status = c_f OR
wa_jobhead-status = c_a.
LEAVE TO SCREEN 0.
ENDIF.
ENDIF.
If the user presses the 'DISPLAY SPOOL' Button
IF sy-ucomm = 'DISPLAY'.
PERFORM display_spool.
ENDIF.
If the user presses the 'JOB STATUS' Button
IF sy-ucomm = 'STATUS'.
PERFORM display_status.
ENDIF.
If the user presses the 'JOB LOG' Button
IF sy-ucomm = 'JOBLOG'.
PERFORM display_job_log.
ENDIF.
*& Form open_job
text
--> p1 text
<-- p2 text
FORM open_job .
This is to Create a new job which is to be submitted in background to
process sales order/delivery/invoice
Here we would get a unique id ( Jobcount ) which identifies our job
along with the job name which we have assigned to our job
CONCATENATE sy-uname
sy-datum
sy-uzeit
INTO w_jobname . " Assign unique jobname
CALL FUNCTION 'JOB_OPEN'
EXPORTING
DELANFREP = ' '
JOBGROUP = ' '
jobname = w_jobname
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
JOBCLASS =
IMPORTING
jobcount = w_jobcount
CHANGING
RET =
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " open_job
*& Form get_print_parameters
text
--> p1 text
<-- p2 text
FORM get_print_parameters .
DATA : l_valid TYPE c.
This is to get the Print Parameters for the job which is to be
submitted in background to process sales order/delivery/invoice
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
ARCHIVE_ID = C_CHAR_UNKNOWN
ARCHIVE_INFO = C_CHAR_UNKNOWN
ARCHIVE_MODE = C_CHAR_UNKNOWN
ARCHIVE_TEXT = C_CHAR_UNKNOWN
AR_OBJECT = C_CHAR_UNKNOWN
ARCHIVE_REPORT = C_CHAR_UNKNOWN
AUTHORITY = C_CHAR_UNKNOWN
COPIES = C_NUM3_UNKNOWN
COVER_PAGE = C_CHAR_UNKNOWN
DATA_SET = C_CHAR_UNKNOWN
DEPARTMENT = C_CHAR_UNKNOWN
destination = c_locl " LOCL
EXPIRATION = C_NUM1_UNKNOWN
immediately = space
IN_ARCHIVE_PARAMETERS = ' '
IN_PARAMETERS = ' '
LAYOUT = C_CHAR_UNKNOWN
LINE_COUNT = C_INT_UNKNOWN
LINE_SIZE = C_INT_UNKNOWN
LIST_NAME = C_CHAR_UNKNOWN
LIST_TEXT = C_CHAR_UNKNOWN
MODE = ' '
new_list_id = c_x
PROTECT_LIST = C_CHAR_UNKNOWN
no_dialog = c_x
RECEIVER = C_CHAR_UNKNOWN
RELEASE = C_CHAR_UNKNOWN
REPORT = C_CHAR_UNKNOWN
SAP_COVER_PAGE = C_CHAR_UNKNOWN
HOST_COVER_PAGE = C_CHAR_UNKNOWN
PRIORITY = C_NUM1_UNKNOWN
SAP_OBJECT = C_CHAR_UNKNOWN
TYPE = C_CHAR_UNKNOWN
user = sy-uname
USE_OLD_LAYOUT = ' '
UC_DISPLAY_MODE = C_CHAR_UNKNOWN
DRAFT = C_CHAR_UNKNOWN
ABAP_LIST = ' '
USE_ARCHIVENAME_DEF = ' '
DEFAULT_SPOOL_SIZE = C_CHAR_UNKNOWN
PO_FAX_STORE = ' '
NO_FRAMES = C_CHAR_UNKNOWN
IMPORTING
OUT_ARCHIVE_PARAMETERS =
out_parameters = wa_params
valid = l_valid
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " get_print_parameters
*& Form job_submit
text
--> p1 text
<-- p2 text
FORM job_submit .
The job which we have created & the unique id ( jobcount ) which we
have got identifies our job. Hence those parameters are passed along
with the name of the background program "ZPROGRAM_TWO"
The job is submitted in background.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
ARCPARAMS =
authcknam = sy-uname
COMMANDNAME = ' '
OPERATINGSYSTEM = ' '
EXTPGM_NAME = ' '
EXTPGM_PARAM = ' '
EXTPGM_SET_TRACE_ON = ' '
EXTPGM_STDERR_IN_JOBLOG = 'X'
EXTPGM_STDOUT_IN_JOBLOG = 'X'
EXTPGM_SYSTEM = ' '
EXTPGM_RFCDEST = ' '
EXTPGM_WAIT_FOR_TERMINATION = 'X'
jobcount = w_jobcount
jobname = w_jobname
LANGUAGE = SY-LANGU
priparams = wa_params
report = 'ZPROGRAM_TWO'
VARIANT = ' '
IMPORTING
STEP_NUMBER =
EXCEPTIONS
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
OTHERS = 10
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " job_submit
*& Form job_close
text
--> p1 text
<-- p2 text
FORM job_close .
Once the job is submitted in background then the job is closed
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
AT_OPMODE = ' '
AT_OPMODE_PERIODIC = ' '
CALENDAR_ID = ' '
EVENT_ID = ' '
EVENT_PARAM = ' '
EVENT_PERIODIC = ' '
jobcount = w_jobcount
jobname = w_jobname
LASTSTRTDT = NO_DATE
LASTSTRTTM = NO_TIME
PRDDAYS = 0
PRDHOURS = 0
PRDMINS = 0
PRDMONTHS = 0
PRDWEEKS = 0
PREDJOB_CHECKSTAT = ' '
PRED_JOBCOUNT = ' '
PRED_JOBNAME = ' '
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS
strtimmed = c_x
TARGETSYSTEM = ' '
START_ON_WORKDAY_NOT_BEFORE = SY-DATUM
START_ON_WORKDAY_NR = 0
WORKDAY_COUNT_DIRECTION = 0
RECIPIENT_OBJ =
TARGETSERVER = ' '
DONT_RELEASE = ' '
TARGETGROUP = ' '
DIRECT_START =
IMPORTING
JOB_WAS_RELEASED =
CHANGING
RET =
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
invalid_target = 8
OTHERS = 9
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " job_close
*& Form display_spool
text
--> p1 text
<-- p2 text
FORM display_spool .
To Read the Job to get the spool details
DATA : l_rqident TYPE tsp01-rqident, " Spool Number
l_spoolno TYPE tsp01_sp0r-rqid_char.
CLEAR : l_rqident,
w_lsind,
wa_jobsteplist.
REFRESH : i_jobsteplist.
SET PF-STATUS 'ZAR02'.
Get the Spool Number
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = w_jobname
job_read_opcode = '20'
JOB_STEP_NUMBER =
IMPORTING
job_read_jobhead = wa_jobhead
TABLES
job_read_steplist = i_jobsteplist
CHANGING
RET =
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Read the Job Step list to get the spool number
READ TABLE i_jobsteplist INTO wa_jobsteplist INDEX 1.
CHECK wa_jobsteplist-listident <> space.
Spool Number
l_rqident = wa_jobsteplist-listident.
MOVE l_rqident TO l_spoolno.
Check the spool in TSP01
SELECT SINGLE * FROM tsp01 WHERE rqident = l_rqident.
IF sy-subrc = 0.
LEAVE TO LIST-PROCESSING.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = l_spoolno
IMPORTING
RC =
STATUS =
PERFORM show_alv.
ENDIF.
w_lsind = sy-lsind.
IF sy-lsind GE 19.
sy-lsind = 1.
ENDIF.
ENDFORM. " display_spool
*& Form show_alv
text
--> p1 text
<-- p2 text
FORM show_alv .
Before the import, fill the data fields before CLUSTR.
wa_index1-aedat = sy-datum.
wa_index1-usera = sy-uname.
To Import the selection screen data from Calling Program
IMPORT i_mara
FROM DATABASE indx(st) ID wa_index_key1 TO wa_index1.
FREE MEMORY ID wa_index_key1.
This prepares the field-catalog for ALV.
PERFORM prepare_fieldcatalog.
This displays the output in ALV format .
PERFORM display_alv.
ENDFORM. " show_alv
*& Form display_status
text
--> p1 text
<-- p2 text
FORM display_status .
To Display the STATUS of the JOB which is exectued in background
CLEAR : wa_jobsteplist.
REFRESH : i_jobsteplist.
WRITE:/ 'DISPLAYING JOB STATUS'.
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = w_jobname
job_read_opcode = '20'
JOB_STEP_NUMBER =
IMPORTING
job_read_jobhead = wa_jobhead
TABLES
job_read_steplist = i_jobsteplist
CHANGING
RET =
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
To Display the status text as per the status type
CASE wa_jobhead-status.
WHEN 'S'. WRITE: / 'Scheduled'.
WHEN 'R'. WRITE: / 'Released'.
WHEN 'F'. WRITE: / 'Completed'.
WHEN 'A'. WRITE: / 'Cancelled'.
WHEN OTHERS.
ENDCASE.
IF sy-lsind GE 19.
sy-lsind = 1.
ENDIF.
ENDFORM. " display_status
*& Form display_job_log
text
--> p1 text
<-- p2 text
FORM display_job_log .
To display the log of the background program
LEAVE TO LIST-PROCESSING.
CALL FUNCTION 'BP_JOBLOG_SHOW_SM37B'
EXPORTING
client = sy-mandt
jobcount = w_jobcount
joblogid = ' '
jobname = w_jobname
EXCEPTIONS
error_reading_jobdata = 1
error_reading_joblog_data = 2
jobcount_missing = 3
joblog_does_not_exist = 4
joblog_is_empty = 5
joblog_show_canceled = 6
jobname_missing = 7
job_does_not_exist = 8
no_joblog_there_yet = 9
no_show_privilege_given = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " display_job_log
*& Form prepare_fieldcatalog
text
--> p1 text
<-- p2 text
FORM prepare_fieldcatalog .
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-reptext_ddic = 'Material no.'.
wa_fieldcat-outputlen = '18'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ERSDA'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-reptext_ddic = 'Creation date'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ERNAM'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-reptext_ddic = 'Name of Person'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LAEDA'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-reptext_ddic = ' Last Change'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO i_fieldcat.
ENDFORM. " prepare_fieldcatalog
*& Form display_alv
text
--> p1 text
<-- p2 text
FORM display_alv .
Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = i_fieldcat
tables
t_outtab = i_mara.
ENDFORM. " display_alv
ZPROGRAM_TWO: This is the 2nd program which would be called from program ZPROGRAM_ONE.
*& Report ZPROGRAM_TWO *
REPORT zprogram_two .
PRASHANT PATIL
TABLES : mara.
TYPE-POOLS:slis.
TYPES : BEGIN OF t_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
laeda TYPE mara-laeda,
END OF t_mara.
DATA : i_mara TYPE STANDARD TABLE OF t_mara,
wa_mara TYPE t_mara,
wa_index TYPE indx, " For Index details
wa_index_key TYPE indx-srtfd VALUE 'PRG_ONE',
wa_index1 TYPE indx, " For Index details
wa_index_key1 TYPE indx-srtfd VALUE 'PRG_TWO',
i_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF i_fieldcat.
SELECT-OPTIONS : s_matnr FOR mara-matnr.
Before the import, fill the data fields before CLUSTR.
wa_index-aedat = sy-datum.
wa_index-usera = sy-uname.
To Import the selection screen data from Calling Program
IMPORT s_matnr
FROM DATABASE indx(st) ID wa_index_key TO wa_index.
FREE MEMORY ID wa_index_key.
SELECT matnr
ersda
ernam
laeda
FROM mara
INTO TABLE i_mara
WHERE matnr IN s_matnr.
PERFORM prepare_fieldcatalog.
PERFORM display_alv.
Before the export, fill the data fields before CLUSTR
wa_index1-aedat = sy-datum.
wa_index1-usera = sy-uname.
EXPORT i_mara
TO DATABASE indx(st) FROM wa_index1 ID wa_index_key1.
*& Form prepare_fieldcatalog
text
--> p1 text
<-- p2 text
FORM prepare_fieldcatalog .
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-outputlen = '18'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ERSDA'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ERNAM'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LAEDA'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO i_fieldcat.
ENDFORM. " prepare_fieldcatalog
*& Form display_alv
text
--> p1 text
<-- p2 text
FORM display_alv .
Call ABAP List Viewer (ALV)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = i_fieldcat
TABLES
t_outtab = i_mara.
ENDFORM. " display_alv
its possible to display ALV Grid using OO ALV. Following code can be used instead of FM.
In the PBO, add following code
SET PF-STATUS 'ZSTAT'.
If program is executed in background
CALL METHOD cl_gui_alv_grid=>offline
RECEIVING
e_offline = off.
IF off IS INITIAL.
IF container1 IS INITIAL.
CREATE OBJECT container1
EXPORTING
container_name = 'CC_ALV1' .
ENDIF.
ENDIF.
CREATE OBJECT g_grid1
EXPORTING
i_parent = container1.
CALL METHOD g_grid1->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
i_save = 'A'
i_default = ' '
is_layout =
is_print =
IT_SPECIAL_GROUPS =
it_toolbar_excluding =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
it_outtab = i_output
it_fieldcatalog = i_fieldcatalog
IT_SORT =
IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Reward points if useful
Regards
Anji -
Regarding running a report in background and generate spool
Hi,
I am developing a report [<b>REPORT1</b>].
It is taking long to execute if data is more.
Now i want to schedule this report in background and generate spool along with.
So once i execute REPORT1 it should run in background & generate spool?
Can anybody give inputs for the same!
Thanks,
Deep.Hi,
to generate spool, use below code
FORM create_spool .
CONSTANTS : l_c_device(4) VALUE 'LOCL'.
Create Spool Request
NEW-PAGE PRINT ON
LINE-SIZE 120
DESTINATION l_c_device
IMMEDIATELY ' '
KEEP IN SPOOL 'X'
NEW LIST IDENTIFICATION 'X'
NO DIALOG.
ENDFORM. " create_spool
And after createing spool to get the spool number use below code,
FORM obtain_spool_id .
TYPES : BEGIN OF t_tsp01,
rqident TYPE tsp01-rqident,
rqowner TYPE tsp01-rqowner,
END OF t_tsp01.
DATA : it_tsp01 TYPE STANDARD TABLE OF t_tsp01,
wa_tsp01 LIKE LINE OF it_tsp01.
SELECT rqident
rqowner
FROM tsp01
INTO TABLE it_tsp01
WHERE rqowner = sy-uname.
SORT it_tsp01 BY rqident DESCENDING.
READ TABLE it_tsp01 INTO wa_tsp01 INDEX 1.
IF sy-subrc = 0 .
v_spool_nr = wa_tsp01-rqident.
ENDIF.
Capture the immediate spool created for this report
v_spool_nr = sy-spono.
ENDFORM. " obtain_spool_id
<b>Reward points</b>
Regards -
Location Heuristics-diff of results in background and foreground
Hi,
We have this weekly bacth job of location heu.. just one program. nothing preceding and succeeding it.
I find the results in background and foreground different. This is partcularly wrt the receipts being created before the lead time of the loc-product. In the foreground when i delete the same receipts..and re-run the location heuristics, the receipts are correctly created . i.e obeying the lead time.
Questions:
- Why does this happen. I am doing this without anytime gap.
-Are there some settings that are called only in background (e.g from SNP global profile) but not in foreground.
Let me know if you need to know my SNP global profile settings.
The imporant ones are
HEU: Init short qty = Bakward scheduling
HEU: Order Update =Complete mode
In the location product master- NO horizons and time fences are maintained for SNP and PPDS.
Regards,
LoknathHi Loknath,
I will try to explain in with simple example.
Consider there is product xyz which exist at two different locations A & Location B.
Procurement type:
at A is Inhouse production
at B is external procurement from location A.
Both the location have some forcast/ Demand for the Product suppose 100qty each.
1. First Sequence: Now first the Heuristics needs to run at Location B so that there are Destribution receipts planned created at Location B, In other words, the Demand of Product XYZ will get transferred to Location A in form of Distributed demand Planned.
Now if you take run on Location A,
The Total demand at Location A will be 100 qty (forecast)+ 100qty( Distri.Demand from B)= 200qty and the Heuristics run will plan for the total requirement 200 qty and create the planned orders for it.
2. Second sequence: if you take heuristics at Location A first & than location B.
The planned orders generated will be only for Demand at A i.e 100 as Location A is not yet aware of the Distributed Demand which needs to be satisfied for Location B. as you have not taken the run on location B yet hence the demand is not yet transferred to Location A.
now if you take run at location B, the Distri. demand are generated to Location A but not planned or not satisfied.
Overall you see the wrong results of heuristic if you adapt second sequence.
So, it become neccesary to determine the right sequence in which the heuristic is taken for different product at different location. to determine this system use SNP low level codes.
I guess you are aware of low level code in BOM, As without exploding the Parent Material demand you cannot plan exact demand on Child material. similar principle works over here just it applies to Location Products.
Hope this helps
Regards
Kumar -
Background and foreground colors can be interchanged using which command
hi
background and foreground colors can be interchanged using which command<b>Background and foreground colors can be interchanged using the command Format Inverse.</b>
-
BDC issue background and foreground
Hiii
i have already write bdc code using batch input. The data is taken from an excel file .
How the program work now is it create a session in SM35 and i can decide to execute the session either in background or foreground.
The reson why i did batch input and not call transaction is because i am told that with call transaction you can't execute batch input program in background since the excel file will be loaded from the user desktop. With call transaction and background execution the file need to be loaded on server first and then take the file from the server to BDC tcode.
My problem is I need my program to execute automatically without passing though the SM35. I also need to give the option to user to either execute is in foreground or background.
BDC code look this:
Call function "OPEN_BDC"
group = "ztest" I use constant
keep = "X'
perform dynpro
perform fillfield
call fuction "CLOSE_BDC"
1) I am told to use the FM file_open / file_submit / file_close but I dont really know hat parameter to pass in those FM the file_submit is giving me exception error.
2) I tried to use submit program RSBDCSUB . it create a session in sm35 and have status background job but the session havent executed
3) All the No1 and No2 is to execute the BDC in background then what about the solution if user what to execute in foreground.
Please i need precise answer??Job_submit is not functioning plzzz ess sample code below because of invalid_jobdata = 3
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobgroup = Ztest //Session name in SM35
jobname = v_jobname
IMPORTING
jobcount = v_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4
IF sy-subrc <> 0.
ENDIF.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
authcknam = sy-uname
jobcount = v_jobcount
jobname = v_jobname
language = sy-langu
report = sy-repid
VARIANT = ' '
IMPORTING
STEP_NUMBER =
EXCEPTIONS
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
OTHERS = 10
IF sy-subrc <> 0.
ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = v_jobcount
jobname = v_jobname
sdlstrtdt = sy-uzeit
sdlstrttm = sy-datum
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
invalid_target = 8
OTHERS = 9
IF sy-subrc <> 0.
ENDIF. -
Scheduling a report in background and passing data for processing
Hi all,
Using code (in a report1) ...i want to execute a report (report2) in background.....but at the same time i want to pass data (an internal table and a variable) to that report2.
is it possible to pass data like internal table to a executable report and at the same time pass the data to that report.
Thanks in advance.
Thanks and Regards,
Sushil.hi
regarding Scheduling a report in background check the below thread
SCHEDULE THE ZREPORT IN BACKGROUND DYNAMICALLY
regards
chandra -
Run report on background and save to file
Hi all,
I have a development suite 10g.
I have created simple paper report with one parameter.
And I want to run this report on background from forms and get it
saved to file (PDF or RTF). The parameter for report should be passed from
my form.
Thanks for any suggestions.
Brano.Hi,
I use the following progam unit to generate a pdf file:
if RUN_PRODUCT does not work on 10g check out the built-in RUN_REPORT_OBJECT.
PROCEDURE create_pdf_report IS
l_pl_id ParamList;
v_report_from_date date;
v_report_to_date date;
/* PDF file name */
v_file_name varchar2(150);
/* network location where to save the pdf file*/
v_output_path varchar2(100):= :control.report_dir;
begin
v_report_from_date := :control.from_date;
v_report_to_date := :control.to_date;
v_file_name := v_output_path||'\your_pdf_filename.pdf';
L_pl_id := Get_Parameter_List ('REPORT_PARAMS');
If Not ID_NULL (l_pl_id) then
Destroy_Parameter_List (l_pl_id);
End if;
L_pl_Id := Create_Parameter_List ('REPORT_PARAMS');
/* Parameters to send output to pdf file*/
Add_Parameter(L_pl_id, 'DESTYPE' ,TEXT_PARAMETER, 'FILE');
Add_Parameter(L_pl_id, 'DESFORMAT' ,TEXT_PARAMETER, 'PDF');
Add_Parameter(L_pl_id, 'DESNAME' ,TEXT_PARAMETER, v_file_name);
Add_Parameter(L_pl_id, 'PARAMFORM' ,TEXT_PARAMETER, 'NO');
Add_Parameter(L_pl_id, 'BACKGROUND' ,TEXT_PARAMETER, 'YES');
/* Addtional data parameters */
Add_Parameter(L_pl_id, 'P_other_param' ,TEXT_PARAMETER, :CONTROL.MY_ITEM);
Add_Parameter(L_pl_id, 'P_FROM_DATE' ,TEXT_PARAMETER, to_char(v_report_from_date,'DD-MON-YYYY') );
Add_Parameter(L_pl_id, 'P_TO_DATE' ,TEXT_PARAMETER, to_char(v_report_to_date,'DD-MON-YYYY') );
-- call the report synchronously
Run_Product(REPORTS
,'YOUR_REPORT_NAME'
,SYNCHRONOUS
,RUNTIME
,FILESYSTEM
,L_pl_id
,NULL
exception
when others then
message('Error running report. '||sqlerrm, acknowledge);
end;
Regards,
Hugo -
BDC processing for background and foreground execution
Hi,
I've come accross a situation where in a BDC for sales order creation, creates one sales order and at the same time creates another sales order with a blank sales order number(but the data of both the sales order is identical), meaning it creates 2 sales orders. This only occurs when the BDC is processed in mode 'N' but it works fine when the BDC runs in mode 'A' and 'E'. Any idea as to why this could be happening?
Any help will be appreciated.
Thanks,
ALAM.Hi Alam,
No, sorry, I don't know why this is happening.
What update-mode are you using? Asynchronous or Synchronous?
Test both options, maybe it helps.
Why are you not using BAPI_SALESORDER_CREATEFROMDAT2?
Regards, Miranda -
Periodically auto generation of Report in background and send result to user mail ID in Excel Format
Hi Experts, I want to get the warehouse inventory report to be receive by email in excel format every month end. also i have 4-5 transaction for that I need the report by email in excel format in specific frequency.
Can some one help me on this?
Regards,
RushikeshHi Rushikesh,
You can create batch Jobs (Trx. SM36) for executing the transactions in background at specified times and in the spool recipient option mention the email IDs of the recipients.
Regards,
Namita -
Scheduling report in background and passing the necessary parameters
Hi all,
Using code (in a report1) ...i want to execute a report (report2) in background.....but at the same time i want to pass data (an internal table and a variable) to that report2.
is it possible to pass data like internal table to a executable report and at the same time pass the data to that report.
Thanks in advance.
Thanks and Regards,
Sushil.Jonathan,
you mean to say that ..... report1 will place the file on application server with all the data that is required for report2...
and after scheduling report2 in background ,...... the report 2 must read the file and then delete it,,,,,
the data is extensive,,, i want to pass on 1,00,000 records to that report ,... so passing it via a dataset,,,wont hamper performance..??
Is there any other direct way to do it,,,,,,,??
Thanks ,
Best Regards,
Sushil. -
Submit report in background and get result into calling program
Hi,
I want to call the standard SAP program from Zprogram to create invoice using Submit. here the code
SUBMIT RV60SBT1 TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO
VIA JOB name NUMBER number
WITH VKOR1 eq TVKO-VKORG
with X_VBELN eq gv_vbeln_so
with ALLEA eq 'X'
with ALLEL eq ''
AND RETURN.
the standard SAP program creates invoice (billing document number). I want to get the billing document number which created using the above statement into the calling program. ......could anyone pls tell me how to do this? ie how to read the billing document number in the calling program.
Regrds
shan
Edited by: Shankar Raju Devadoss on Mar 21, 2011 9:00 AMHi Shankar,
You can try it in both ways.
1. By using the parameter ID VF. (GET PARAMETE ID)
2. Select the invoice numbers from the table VBRK for the current date (SY-DATUM) and
sort it by time and get the latest invoice.
Regards
Hareesh Menon -
Report running fine in foreground but not in background
Dear Friends-
I have created few varaients to run my report in background and foreground .
and inside report am using OOPS ALV and call screen .
issue is when i run prog using varaient in foreground it work fine and show me the correct one record
but when i run the report with same varaient in background it shows me huge records which are not relevant with given input also ...............How to solve this pls guide me
Regards
MeetaHi
In my report am passing the input via varaients and submit another report inside the prog and in that second report it call screen with ALV stuff.
Is that is the reason ?
user command am not sure because at end of the job it not give any error job looks finish and shows so many records.
Regards
Meeta -
ALV report - run in background and output to screen
I wish to run a report in background and then output the report to screen as a standard ALV report with all the associated functionality. Can anyone tell me how to do this?
Thanks.Hi,
In background i dont think so its possible.
Regards,
Prashant -
Executing Report in Background
Dear All,
I have a report with more than 400 characters in width. If it is executed in foreground the report is properly displayed but if the report is executed in background, the generated spool only displays upto 255 characters.
Is there a way to execute the report in background and make sure that the spool is generated with required width?
Regards,
AnoshHi Sharabh,
I have tried printing it after unchecking the "spool request max 255 characters width" option. Still the generated report does not show the report upto 400 characters.
Can you please suggest some other solution or maybe provide a way to define our own printing format?
Regards,
Anosh
Maybe you are looking for
-
How do I use multiple classes to print out different results
I tried the below, but it only printed the print line from the class that contains the "main" method, but I want the second one (Demo2) to print to check some logic : class StaticDemo { int x; static int y; class Demo { public static void main(String
-
Exchange server 2013 send and received issue
Hi Support, I have install Exchange Server 2013 with server 2012 ( my domain not resisted but mail send & received in local for practice then live ) but few days back some changes in dns and ecp and mail stop sending and receiving. how to verify my e
-
Hello ! I would like to use Daqmx functions in a VB6 program I am currently writing. In order to gain ideas about how to do it, I ran an example code DigPulseTrain-Cont.vbp included in Labview 8.2 intsallation. It works OK when ran on a Window 2000 P
-
Now playing button doesn't work
Hello, I'm using a Verizon iPhone 4 w/ iOS 5.0. When I'm listening to music and searching through my music library the now playing button the top right hand corner stops working. When I hit the "now playing" button nothing happens so the only way to
-
How To Launch Servlet from Desktop App
Hello Everyone, I recently started my programing in JavaEE. First lesson was Servlets. My servlet takes the name and a number from a user using a html form and returns a wellcoming message to the user and calculates PI with "number" decimals. Well it