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: 

report in background

Former Member
0 Kudos

Hi,

My requirement is to create report and in that iam calling BDC to upload my transaction,now the end user want to execute the report in back ground with selection screen parameters.

how can i do that.

Thanks,

Donald

5 REPLIES 5

Former Member
0 Kudos

Hi,

Define a Variant for the Report with the Selection-Screen paramters/Values.

Then Schedule the Job as Background .

Sample program:

REPORT yb<pprf> MESSAGE-ID yb.

TABLES: ybstprot,rfcdes.

  • Internal Tables

DATA: it_profl LIKE ybstprot OCCURS 0 WITH HEADER LINE,

it_uname LIKE ybstnamt OCCURS 0 WITH HEADER LINE,

it_auth LIKE ybstaval OCCURS 0 WITH HEADER LINE,

it_subprofl LIKE ybstsprf OCCURS 0 WITH HEADER LINE.

  • Variables

DATA: p_target LIKE rfcdes-rfcdest,

v_jobname LIKE tbtcjob-jobname,

v_jobnumber LIKE tbtcjob-jobcount,

v_valid TYPE c,

user_arc_params LIKE arc_params,

user_print_params LIKE pri_params.

  • Selection Screen

SELECTION-SCREEN BEGIN OF BLOCK b1.

PARAMETERS: p_sysid LIKE ybstprot-sysid,

p_job TYPE c DEFAULT 'X' NO-DISPLAY.

SELECTION-SCREEN END OF BLOCK b1.

  • Help Value

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_sysid.

PERFORM destination_read USING p_sysid

p_target.

PERFORM help_sysid USING p_sysid.

  • Start-of-selection

START-OF-SELECTION.

IF p_job = ' '.

DELETE FROM ybstprot WHERE sysid = p_sysid.

DELETE FROM ybstnamt WHERE sysid = p_sysid.

DELETE FROM ybstaval WHERE sysid = p_sysid.

DELETE FROM ybstsprf WHERE sysid = p_sysid.

CALL FUNCTION 'YBFPPROF'

DESTINATION p_target

TABLES

it_profile = it_profl

it_auth = it_auth

it_uname = it_uname

it_subprof = it_subprofl

EXCEPTIONS

OTHERS = 1.

IF sy-subrc = 0.

MODIFY ybstprot FROM TABLE it_profl.

MODIFY ybstaval FROM TABLE it_auth.

MODIFY ybstnamt FROM TABLE it_uname.

MODIFY ybstsprf FROM TABLE it_subprofl.

COMMIT WORK.

ENDIF.

endif.

  • End of Selection

END-OF-SELECTION.

IF p_job = 'X'.

CONCATENATE sy-cprog sy-datum sy-uzeit

INTO v_jobname SEPARATED BY '_'.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = v_jobname

IMPORTING

jobcount = v_jobnumber

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

  • EXPORTING

  • mode = 'BATCH'

  • no_dialog = 'X'

  • report = 'YBSPCODE'

IMPORTING

out_archive_parameters = user_arc_params

out_parameters = user_print_params

valid = v_valid

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

SUBMIT yb<pprf> "VIA SELECTION-SCREEN

WITH p_job = ' '

WITH p_sysid = p_sysid

AND RETURN

USER sy-uname

VIA JOB v_jobname NUMBER v_jobnumber

TO SAP-SPOOL

SPOOL PARAMETERS user_print_params

ARCHIVE PARAMETERS user_arc_params

WITHOUT SPOOL DYNPRO.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = v_jobnumber

jobname = v_jobname

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

invalid_target = 8

OTHERS = 9.

IF sy-subrc <> 0.

Write: /5 'Job ',v_jobname,

' could not be created for back ground processing'.

else.

Write: /5 'Job ',v_jobname,

' has been created for back ground processing'.

ENDIF.

ENDIF.

&----


*& Form destination_read

&----


  • Read the Destination

----


FORM destination_read USING p_sysid LIKE p_sysid

p_trg LIKE p_target.

IF NOT p_sysid IS INITIAL.

SELECT SINGLE desid FROM ybstmain INTO p_trg

WHERE sysid = p_sysid.

IF NOT p_trg IS INITIAL.

SELECT SINGLE rfcdest FROM rfcdes INTO rfcdes-rfcdest

WHERE rfcdest = p_trg.

IF sy-subrc <> 0.

MESSAGE e000 WITH 'PLEASE SPECIFY A VALID DESTINATION'.

ENDIF.

ENDIF.

ELSE.

p_sysid = sy-sysid.

ENDIF.

ENDFORM. " destination_read

&----


*& Form help_sysid

&----


  • text

----


  • -->P_P_SYSID text

----


FORM help_sysid USING p_sysid LIKE p_sysid.

DATA : lt_main LIKE ybstmain OCCURS 0 WITH HEADER LINE.

  • Internal table to store the field names.

DATA: lt_field LIKE help_value OCCURS 0 WITH HEADER LINE.

  • Internal table to store the field values

DATA: BEGIN OF lt_value OCCURS 0,

sysid LIKE ybstmain-sysid,

desid LIKE ybstmain-desid,

END OF lt_value.

  • Fetch Possible Destinations

SELECT * FROM ybstmain

INTO TABLE lt_main.

  • Populate field data

lt_field-tabname = 'YBSTMAIN'.

lt_field-fieldname = 'SYSID'.

lt_field-selectflag = 'X'.

APPEND lt_field.

CLEAR lt_field.

  • Populate the field values.

LOOP AT lt_main.

lt_value-sysid = lt_main-sysid.

lt_value-desid = lt_main-desid.

APPEND lt_value.

CLEAR lt_value.

ENDLOOP.

CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE'

IMPORTING

select_value = p_sysid

TABLES

fields = lt_field

valuetab = lt_value

EXCEPTIONS

field_not_in_ddic = 1

more_then_one_selectfield = 2

no_selectfield = 3

OTHERS = 4.

ENDFORM. " help_sysid

Regards,

Anji

Message was edited by:

Anji Reddy Vangala

Former Member
0 Kudos

You hae to schedule the job in background.

Goto SM35 and specify the program name adn shcedule it when ever u need with the variant.

Else u can specifythe variant in SE38 instead of pressing F8 press F9 a window will appear u can shceudule the job in bg there.

Former Member
0 Kudos

Hi,

Just fill in the selection screen parameters, press F9 , in that click immediate. the program will now be sent for background execution

thanks,

Former Member
0 Kudos

Hi donald,

Schedule a background job in trnx SM36.

<a href="= http://help.sap.com/saphelp_47x200/helpdata/en/c4/3a7f46505211d189550000e829fbbd/frameset.htm">Backg... Job scheduling</a>

Rgds,

Jothi.P

**reward if useful.

Former Member
0 Kudos

Hi,

If you want to run the Program in the Background, create a Variant with the selection screen parameters. and create a background job in SM36 and give the Program name and the Variant.

or, from the Program, when the selection screen comes, in the menu option you have ann option like execute in background(F9) and select the time and date or select immediate to run the program in the background.

or, you can write the Program using the JOB_OPEN, JOB_SUBMIT and JOB_CLOSE function module to run the Report in background ..

but make sure, you have a BDC, if the program contains in WS_UPLOAD or GUI_UPLOAD then the Program won't run in the Background ..

Regards

Sudheer