Background job processing - SM36
Hi All,
I need to schedule a job in the background(using SM36) . The report should run in the night from the last day of the month to the first day of the next month. What are the stepts to be followed in SM36 to achieve this?
Thanks ,
Vasuki
Hi,
>Go to transaction SM36, give job name and select job class.
> select start condition tab present at the left top corner. now select date and time tab. give start datae and time also end date and time. next select periodic values and select the period. check and save the
> select Step tab present at the left corner, give ABAP program name and variant for that program. check and save .
> fiinally Save the job.
Regards,
Lokeswari.
Similar Messages
-
After writing a report, I used this Function Module LIST_TO_ASCI to copy my report to an internal table (DOWNTAB) because Ill use that internal table to download a text file on the server using dataset.
Here is my code:
FORM DL_REP_SERVER.
DATA: ABAP_LIST LIKE ABAPLIST OCCURS 1,
MV_FILE2 LIKE RLGRAP-FILENAME.
DATA: BEGIN OF DOWNTAB OCCURS 1,
LINE(150),
END OF DOWNTAB.
CLEAR: MV_FILE2.
MV_FILE2 = J:/Downloads/Report.txt.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
LIST_INDEX = SY-LSIND
TABLES
LISTASCI = DOWNTAB
LISTOBJECT = ABAP_LIST
EXCEPTIONS
LIST_INDEX_INVALID = 1
OTHERS = 2.
OPEN DATASET MV_FILE2 FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC <> 0.
IF SY-SUBRC = 8.
MESSAGE E037 WITH 'File could not be opened'.
ELSE.
MESSAGE E037 WITH 'Error occurs in downloading the file'.
ENDIF.
ENDIF.
LOOP AT DOWNTAB.
TRANSFER DOWNTAB TO MV_FILE2.
ENDLOOP.
CLOSE DATASET MV_FILE2.
ENDFORM. " DL_REP_SERVER
My big problem is this, when Im running my program ordinarily (not as background job), Im getting all the pages downloaded correctly but when I run it as background job (using SM36), Im only getting the last page of my report being downloaded. Definitely, I cant debug it because its in background. I cant figure out why. Hope that I stated my problem clearly. Any help would be greatly appreciated. Thanks.You can debug batch jobs by going to 'SM37', type in 'JDBG' in the
command line ( no '/' ), put the cursor on the job and press enter - will
take you to the job in debug mode.
You can do this only after the job has finished execution. This will simulate the exact background scenario with the same selection screen values as used in the job also sy-batch will set to 'X'.
So type in the transaction code 'JDBG' and place your cursor on the job after It has finished. It will take you to a SAP program in debug mode. Step through this program which is about 10 lines, after this your program will be executed in the debug mode.
Steps
1. Create variant called BACKGROUND for program to be debugged.
2. Execute ZDEBUGBG (pgm code below) in background for immediate processing.
3. Execute transaction SM50.
4. Select process that runs ZDEBUGBG.
5. Goto 'Program/Session' 'Program' 'Debugging'.
A se80 debug session will open.
6. Change variable W_EXIT to 'E'.
7. Step thru (F6) until ZWBTEST comes up.
1. Go to Transaction SM66 and find your work porocess.
Select the line work process is on and click on the Debugging button.
If this is a custom program, you can put a wait statement in the code to buy yourself sometime.
2. Go to Transaction SM50. From the tool bar "Program/session"->Program->Debugging.
goto SM37 and from Program menu(not sure.. try other menu's)
-->Catchjob . it will goto the active job in debugging mode. -
Background Job Processing Spool Retention period
Hi ,
In my program i am calling another ABAP program and sumitting the same as a background job(using Job_Submit,Close etc.)
In this case i can view the Spool generated by the called program(using sm37).
But this spool exists for a very less period in the system.Is it possible to specify a retention period,as 90 days in my case.?
Pls Help !!!
Answers will be rewarded.
Regards,
Rohanhi Roahn,
You must set print parameters before the printing process starts.
When printing lists after creating them, the system uses the print format specified in the print parameters to split the completed list and fit it onto the print pages, truncating it if necessary.
When printing lists while creating them, the system uses the print format to actually format the list in the program.
Print parameters are set either interactively by the user or from within the program.
For each print process, the spool system needs a complete and consistent set of print parameters. In ABAP, the structure PRI_PARAMS (ABAP Dictionary) represent a set of print parameters.
When passing the print parameters interactively, the system displays a dialog box after starting the report, on which the user has to enter the most important print parameters.
It's shown below which input field of the Print List Output dialog window conform to which PRI_PARAMS component.
Input field----
Retention period
Component-------PEXPI
Meaning----
Number of days for which the system holds the spool request before deleting it. (Default value: 8). -
Error in Background Job Processing.
Dear All,
I am using a background job for processing the outbound delivery.
In the user exit in delivery program I am checking for the combination of
ship to party, Material & Batch of outbound delivery in a ztable. If the combination exists in
Ztable I do not want to save & ignore this delivery creation and continue with the next
delivery order creation thru the batch job.
However I need to give an error / warning message for the delivery orders
which are not created so I am giving the error message as success message
in the below format :-
IF L_RETURN-TYPE = 'E'.
MESSAGE S000(Z64_I) WITH L_RETURN-MESSAGE_V1
L_RETURN-MESSAGE_V2
L_RETURN-MESSAGE_V3
L_RETURN-MESSAGE_V4
DISPLAY LIKE 'E'.
PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).
FCODE = 'ENT1'.
SET SCREEN SYST-DYNNR.
LEAVE SCREEN.
ENDIF.
But my job is finished as soon as the above message is encountered and the
rest of the outbound deliveries are not created.
However if I execute the progarm in foreground the execution is working fine.
Could you please let me know what do I need to code / do corrections to make
the program run successfully in background.
Thanks & Regards
Jitendra GujarathiHello,
Check system log and also check work process trace, to know the error.
I feel that it could be Authorization issue, you don't have sufficient authorization to do.
Hope this helps.
Regards
venkata
Edited by: venkata emandi on Sep 12, 2011 8:13 AM -
Continue background job processing.
Hi All,
How to handle the system error
MESSAGE E328 WITH MATNR RAISING CONVERSION_NOT_FOUND thrown by FM MATERIAL_UNIT_CONVERSION so that the background job continue processing.
Thanks and Regards,
Ashik K.Hi,
I just now checked with this FM and worked with these two options:
1. Runtime error type 'E' will stop the program if we COMMENT the EXCEPTIONS while calling FM
* EXCEPTIONS
* CONVERSION_NOT_FOUND = 1
* INPUT_INVALID = 2
* MATERIAL_NOT_FOUND = 3
* MEINH_NOT_FOUND = 4
* MEINS_MISSING = 5
* NO_MEINH = 6
* OUTPUT_INVALID = 7
* OVERFLOW = 8
* OTHERS = 9
2. Runtime error type 'E' (which stops the program) will not come in this case
EXCEPTIONS
CONVERSION_NOT_FOUND = 1
INPUT_INVALID = 2
MATERIAL_NOT_FOUND = 3
MEINH_NOT_FOUND = 4
MEINS_MISSING = 5
NO_MEINH = 6
OUTPUT_INVALID = 7
OVERFLOW = 8
OTHERS = 9
Hope this helps.
Regards,
Amit Mittal. -
Background Jobs - Process Chains
Hello,
I want to schedule a background job for a process chain so that it triggers the process type and start executing...
Can anyone please let me know how i can do it?HI,
The background control options are available to directly schedule the start process. You can start the process chain immediately (when activating the process chain), at a specified time, or after a particular event. When you activate the process chain the start process is scheduled in the background, as defined in your selections.
If there are not sufficient options available, you can trigger the start of the process chain using API. You can use the SAP NetWeaver Scheduling Framework to start the chain and to have more extensive scheduling options.
You can also trigger the start of a process chain using a metachain. A metachain is a process chain, for which you determine this start condition, that is fixed to another process chain. The process chain is started directly by this metachain.
Tarak -
RSCRMBW_REPORT Background Jobs & Process Chain
Hello Everyone,
I have a program in a process chain that runs a query through rscrmbw_report. The program is the first step in the chain, followed by a DTP. When we have previously ran this program in our production box, we found that the we did not get all of the data from the query. We believe the fault is with the DTP running asynchronous to the background jobs of RSCRMBW_REPORT- In SM37, we believe we have found jobs from the report positioned before and after the DTP job.
I've made some slight changes and on a small volume of data (~1000), the chain works with no issue. However, I am concerned with dealing with a large number of records (~1,000,000+). As of now, I'm not sure I believe the analysis of the background jobs because there are still jobs that appear before and after the DTP, but the data is consistant between the destination of the DTP and the query.
Any advice on how to ensure those jobs run before my DTP? I've tried using commit work and wait, which I believe works because the DB should be open while the query jobs are running and I believe that the statement will wait for those jobs to finish before proceeding out of the code and to the DTP.
Thanks & Regards,
ChristianHI,
The background control options are available to directly schedule the start process. You can start the process chain immediately (when activating the process chain), at a specified time, or after a particular event. When you activate the process chain the start process is scheduled in the background, as defined in your selections.
If there are not sufficient options available, you can trigger the start of the process chain using API. You can use the SAP NetWeaver Scheduling Framework to start the chain and to have more extensive scheduling options.
You can also trigger the start of a process chain using a metachain. A metachain is a process chain, for which you determine this start condition, that is fixed to another process chain. The process chain is started directly by this metachain.
Tarak -
How to cancel the background job processing in ABAP programming?
Hi,
I have a requirement where i need to cancel the job depending on some constraint. My code is something like this:
Select some data from the table.
if sy-subrc = 0.
Do nothing.
Else
Cancel the job
call function 'BP_JOB_ABORT'
exporting
jobcount = number
jobname = name
EXCEPTIONS
CHECKING_OF_JOB_HAS_FAILED = 1
JOB_ABORT_HAS_FAILED = 2
JOB_DOES_NOT_EXIST = 3
JOB_IS_NOT_ACTIVE = 4
NO_ABORT_PRIVILEGE_GIVEN = 5
OTHERS = 6
The above code is cancelling the job but it is throwing an exception called CX_SY_DYN_CALL_PARAM_MISSING because i dint pass job count. How can we find the job count of next job that is going to run? Or How to handle the exception which it is throwing. Even if i try to handle that exception something like this:
TRY
call function 'BP_JOB_ABORT'
exporting
jobcount = number
jobname = name
EXCEPTIONS
CHECKING_OF_JOB_HAS_FAILED = 1
JOB_ABORT_HAS_FAILED = 2
JOB_DOES_NOT_EXIST = 3
JOB_IS_NOT_ACTIVE = 4
NO_ABORT_PRIVILEGE_GIVEN = 5
OTHERS = 6
RAISE EXCEPTION TYPE CX_SY_DYN_CALL_PARAM_MISSING.
CATCH
CX_SY_DYN_CALL_PARAM_MISSING.
ENDTRY.
It avoids the exception but it doesnt cancel the job. I even tried with function modules like JOB_OPEN
JOB_SUBMIT,BP_JOB_SELECT,BP_JOB_ABORT and tried to build some logic using status overview table (TBTCO) and TBTCP (Jobstep overview table).
Can someone suggest me the right way to write this program ?
Thanks in advance.
RashmiHi,
Problem is solved.
Create an background job with 2 steps. The first step in the background job calls the program ZBACKJOB_STEP1. In the variant we have a wrong material number
If the material number is not found in Mara, the next step in the job should not get executed and the job should get cancelled..
In the above posts i had asked how do I get the job count of the job that is currently triggering the program at the runtimeu2026..If u see the below code uu2019ll get to know.. We have to use the standard structure TBTCM which captures the properties/characteristics of the job.
REPORT ZBACKJOB_STEP1.
TABLES: MARA,TBTCM.
PARAMETERS : MATNR TYPE MATNR.
START-OF-SELECTION.
SELECT SINGLE * FROM MARA WHERE MATNR = MATNR.
IF SY-SUBRC IS INITIAL.
WRITE / : 'This is the material selected on the selection-screen' , MARA-MATNR.
ELSE.
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
EVENTID = TBTCM-EVENTID
EVENTPARM = TBTCM-EVENTPARM
EXTERNAL_PROGRAM_ACTIVE = TBTCM-XPGACTIVE
JOBCOUNT = TBTCM-JOBCOUNT
JOBNAME = TBTCM-JOBNAME
STEPCOUNT = TBTCM-STEPCOUNT
EXCEPTIONS
NO_RUNTIME_INFO = 1
OTHERS = 2.
IF SY-SUBRC = 0.
CALL FUNCTION 'BP_JOB_ABORT'
EXPORTING
JOBCOUNT = TBTCM-JOBCOUNT
JOBNAME = TBTCM-JOBNAME
EXCEPTIONS
CHECKING_OF_JOB_HAS_FAILED = 1
JOB_ABORT_HAS_FAILED = 2
JOB_DOES_NOT_EXIST = 3
JOB_IS_NOT_ACTIVE = 4
NO_ABORT_PRIVILEGE_GIVEN = 5
OTHERS = 6.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
ENDIF.
Regards,
Rashmi -
Background Job Processing/Spool List Recipient
When setting up a report to run as a background job and setting it up to e-mail the results via the Spool List Recipient button, it always sends the results in htm format. Is there a way it can be e-mailed in Excel?
hi swapna.
in scot it is not configured as excel how to do it.to get an attachment in excel format
thanks in advance -
JOB_CLOSE and Background Job Process a FM
HI Guys,
I have my code like this:
data: jobname like tbtcjob-jobname value
'TESTJOB'.
data: jobcount like tbtcjob-jobcount,
host like msxxlist-host.
data: begin of starttime.
include structure tbtcstrt.
data: end of starttime.
data: starttimeimmediate like btch0000-char1.
Job open
call function 'JOB_OPEN'
exporting
delanfrep = ' '
jobgroup = ' '
jobname = jobname
sdlstrtdt = sy-datum
sdlstrttm = sy-uzeit
importing
jobcount = jobcount
exceptions
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03.
if sy-subrc ne 0.
"error processing
endif.
data: lv_weekday type WEEK_DAY.
CALL FUNCTION 'DATE_TO_DAY'
EXPORTING
DATE = sy-datum
IMPORTING
WEEKDAY = lv_weekday.
Close job
starttime-sdlstrtdt = sy-datum.
starttime-sdlstrttm = SY-UZEIT.
call function 'JOB_CLOSE'
exporting
event_id = starttime-eventid
event_param = starttime-eventparm
event_periodic = starttime-periodic
jobcount = jobcount
jobname = jobname
laststrtdt = starttime-laststrtdt
laststrttm = starttime-laststrttm
prddays = 1
prdhours = 0
prdmins = 0
prdmonths = 0
prdweeks = 0
sdlstrtdt = starttime-sdlstrtdt
sdlstrttm = starttime-sdlstrttm
strtimmed = 'X' "starttimeimmediate
targetsystem = host
exceptions
cant_start_immediate = 01
invalid_startdate = 02
jobname_missing = 03
job_close_failed = 04
job_nosteps = 05
job_notex = 06
lock_failed = 07
others = 99.
if sy-subrc eq 0.
"error processing
endif.
This is the Program I want the Batch Job to Execute a BAPI Function Module in the Place of DATE_TO_DAY function module. Is it Possible ??????
And also I get an error at the JOB_CLOSE Function Module with SY-SUBRC = 5.
Can anyone know why this is happening and what should be done to overcome this.
Thanks & Regards,
YJR.Hi Ravi,
The below code which has an EXPORT and IMPORT commands
The IMPORT does'nt work in Background.
Do I need to do anything else.
REPORT ZTEST_LM22.
DATA: LV_NAME(10) TYPE C.
LV_NAME = 'HELLO'.
export lv_name to memory id 'ZNAM'.
submit ztest_lm22_a.
REPORT ZTEST_LM22_A.
DATA: GV_JOBNAME TYPE BTCJOB VALUE 'TEST_UNPACK',
GV_JOBCOUNT TYPE BTCJOBCNT.
data: lv_date type SYDATUM,
lv_time type SYUZEIT.
lv_date = SY-datum.
lv_time = sy-uzeit.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = GV_JOBNAME
SDLSTRTDT = lv_date
SDLSTRTTM = lv_time
IMPORTING
JOBCOUNT = GV_JOBCOUNT
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.
SUBMIT ztest_lm22_b AND RETURN
VIA JOB GV_JOBNAME
NUMBER GV_JOBCOUNT.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = GV_JOBCOUNT
JOBNAME = GV_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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REPORT ZTEST_LM22_B.
DATA: LV_NAME(10) TYPE C,
GV_NAME(10) TYPE C.
IMPORT LV_NAME = GV_NAME FROM MEMORY ID 'ZNAM'.
WRITE: GV_NAME.
If you see in SM37 the Spool does'nt have this value.
Could you just run a quick test and see what else should be done...
Thanks & Regards,
YJR. -
Hot to add a Background Job to process Chain
Hi Guys,
I have created a background job via Sm36, but I wanted to include all this jobs to Process Chain, is it possible?
thanks.Hi,
Welcome to SDN.
Please try this ( a quick and dirty solution)
1.Create a batch event in SM62 (e.g. Z_EVENT1D)
2.Allocate this event as start event of batch job in SE36
3.Create a report to trigger this event
REPORT Z_RAISE_EVENT.
Call Function 'BP_EVENT_RAISE'
EXPORTING
EVENTID = 'Z_EVENT1D'
4.Add a process type abap program calling this report to PC
Of course, you can add a parameter to report and save different variants to make it more flexible, if required.
Regards
Joe -
Failed to Run OLE Excel program in background JOB (SM36)
Please help.
I have write a program to use OLE to create a Excel file.
The program can run successful in front end workstation. However, when I run the program in background job by SM36.
The statement "CREATE OBJECT EXCEL 'EXCEL.APPLICATION'" return with error "SY-SUBRC = 2".
How can I solve it ?
Can OLE Excel be run on background job ?
Thanks so much,
MarkHi Mark:
Your need is a very common one. I also was asked to generate an Excel in Background.
It is not possible to work with OLE in background mode.
The reason is: In background mode there is no presentation server. OLE is executed in presentation server.
Below I paste the code I wrote to solve my problem.
This class sends a mail with an excel attached. The Excel content will be the internal table you pass to the class. But the Excel is not binary, it is a plain text file, separated by tabulators. Anyway, when you open it with Excel, the columns are properly shown.
Sorry. Comments are in spanish, I don't have time to translate it.
I kindly ask to everybody which want to use it to keep my name in the code.
* Autor: Jordi Escoda, 30/10/2008.
* Descripción: Esta clase genera un correo electrónico destinado a
* una persona, adjuntando el contenido de una tabla interna como
* Excel (campos separados por tabuladores).
* La virtud de esta clase es su sencillez de utilización. Para lanzar
* el mail con el excel adjunto basta con declarar la tabla interna,
* llenarla, colocar el asunto del mensaje, el destinatario, el nombre
* del excel adjunto, y pasar la tabla interna.
* Ejemplo de utilización:
* DATA: lc_mail TYPE REF TO cl_mail_builder_xls_attach.
* DATA: lt_anla TYPE STANDARD TABLE OF anla.
* SELECT * INTO TABLE lt_anla FROM anla.
* CREATE OBJECT lc_mail.
* CALL METHOD lc_mail->set_subject( 'Excel adjunto' ).
* CALL METHOD lc_mail->set_recipient( 'XXX@XXXDOTCOM' ).
* CALL METHOD lc_mail->set_attach_filename( 'ANLA' ).
* APPEND 'Cuerpo del mensaje' TO lt_body.
* APPEND 'Saludos cordiales' TO lt_body.
* CALL METHOD lc_mail->set_bodytext( lt_body ).
* CALL METHOD lc_mail->set_attach_table( lt_anla ).
* CALL METHOD lc_mail->send( ).
* CLASS cl_mail_builder_xls_attach DEFINITION
CLASS cl_mail_builder_xls_attach DEFINITION.
PUBLIC SECTION.
METHODS: set_subject
IMPORTING im_subject TYPE so_obj_des,
set_bodytext
IMPORTING im_body TYPE bcsy_text,
set_recipient
IMPORTING im_recipient TYPE ad_smtpadr,
set_attach_table
IMPORTING im_table TYPE ANY TABLE,
set_attach_filename
IMPORTING im_attach_name TYPE sood-objdes,
send.
PRIVATE SECTION.
CONSTANTS:
c_tab TYPE c VALUE cl_bcs_convert=>gc_tab,
c_crlf TYPE c VALUE cl_bcs_convert=>gc_crlf,
c_singlequote TYPE c VALUE '.
DATA: l_recipient_addr TYPE ad_smtpadr.
DATA: send_request TYPE REF TO cl_bcs,
document TYPE REF TO cl_document_bcs,
recipient TYPE REF TO if_recipient_bcs,
bcs_exception TYPE REF TO cx_bcs.
DATA: binary_content TYPE solix_tab,
size TYPE so_obj_len.
DATA: l_string TYPE string,
l_body_text TYPE bcsy_text,
l_subject TYPE so_obj_des,
l_attach_name TYPE sood-objdes.
METHODS: create_binary_content,
get_dataelement_medium_text
IMPORTING im_table_name TYPE tabname
im_field_name TYPE fieldname
EXPORTING ex_medium_text TYPE scrtext_m.
ENDCLASS. "cl_mail_builder_xls_attach DEFINITION
* CLASS cl_mail_builder_xls_attach IMPLEMENTATION
CLASS cl_mail_builder_xls_attach IMPLEMENTATION.
METHOD set_bodytext.
l_body_text[] = im_body[].
ENDMETHOD. "add_bodytext
METHOD set_subject.
l_subject = im_subject.
ENDMETHOD. "add_subject
METHOD set_attach_filename.
l_attach_name = im_attach_name.
ENDMETHOD. "add_subject
METHOD set_recipient.
l_recipient_addr = im_recipient.
ENDMETHOD. "add_subject
METHOD set_attach_table.
* Rellena en un string el contenido de la tabla interna recibida
DATA: ref_to_struct TYPE REF TO cl_abap_structdescr.
DATA: my_like TYPE fieldname,
nombretabla TYPE tabname,
nombrecampo TYPE fieldname,
texto_mediano TYPE scrtext_m.
DATA: l_idx TYPE i,
l_valorcampo(16) TYPE c,
l_long TYPE i.
FIELD-SYMBOLS: <fs_linea> TYPE ANY,
<fs_campo> TYPE ANY.
FIELD-SYMBOLS: <comp_descr> TYPE abap_compdescr.
CHECK NOT im_table[] IS INITIAL.
* Línea con los nombres de las columnas.
CLEAR l_string.
LOOP AT im_table ASSIGNING <fs_linea>.
* Toma los atributos del componente
ref_to_struct =
cl_abap_structdescr=>describe_by_data( <fs_linea> ).
LOOP AT ref_to_struct->components ASSIGNING <comp_descr>.
ASSIGN COMPONENT <comp_descr>-name
OF STRUCTURE <fs_linea> TO <fs_campo>.
* Obtenemos el origen de donde proviene (like). Ej:BKPF-BUDAT
DESCRIBE FIELD <fs_campo> HELP-ID my_like.
SPLIT my_like AT '-' INTO nombretabla nombrecampo.
CALL METHOD get_dataelement_medium_text
EXPORTING
im_table_name = nombretabla
im_field_name = nombrecampo
IMPORTING
ex_medium_text = texto_mediano.
IF texto_mediano IS INITIAL.
CONCATENATE l_string <comp_descr>-name INTO l_string.
ELSE.
CONCATENATE l_string texto_mediano INTO l_string.
ENDIF.
AT LAST.
CONCATENATE l_string c_crlf INTO l_string.
EXIT.
ENDAT.
CONCATENATE l_string c_tab INTO l_string.
ENDLOOP.
EXIT.
ENDLOOP.
* Contenido de la tabla
LOOP AT im_table ASSIGNING <fs_linea>.
* Toma los atributos del componente
ref_to_struct =
cl_abap_structdescr=>describe_by_data( <fs_linea> ).
LOOP AT ref_to_struct->components ASSIGNING <comp_descr>.
* Asignamos el componente ue tratamos, para obtener
* el valor del mismo
ASSIGN COMPONENT <comp_descr>-name OF STRUCTURE <fs_linea>
TO <fs_campo>.
CASE <comp_descr>-type_kind.
WHEN 'P'. "Packed Number
* Convierte a caracter
WRITE <fs_campo> TO l_valorcampo.
CONCATENATE l_string l_valorcampo INTO l_string.
WHEN OTHERS.
l_long = STRLEN( <fs_campo> ).
IF l_long > 11 AND <fs_campo> CO ' 0123456789'.
* El Excel muestra un número tal como 190000000006
* en formato 1,9E+11.
* Para eviarlo, los números de más de 11 dígitos los
* concatenamos con comillas simples.
CONCATENATE l_string c_singlequote
<fs_campo> c_singlequote INTO l_string.
ELSE.
CONCATENATE l_string <fs_campo> INTO l_string.
ENDIF.
ENDCASE.
AT LAST.
* Añade CRLF
CONCATENATE l_string c_crlf INTO l_string.
EXIT.
ENDAT.
* Añade tabulador
CONCATENATE l_string c_tab INTO l_string.
ENDLOOP.
ENDLOOP.
create_binary_content( ).
ENDMETHOD. "set_attach_table
METHOD create_binary_content.
DATA: l_size TYPE so_obj_len.
* convert the text string into UTF-16LE binary data including
* byte-order-mark. Mircosoft Excel prefers these settings
* all this is done by new class cl_bcs_convert (see note 1151257)
TRY.
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = l_string
iv_codepage = '4103' "suitable for MS Excel, leave empty
iv_add_bom = 'X' "for other doc types
IMPORTING
et_solix = binary_content
ev_size = size ).
CATCH cx_bcs.
MESSAGE e445(so).
ENDTRY.
ENDMETHOD. "create_binary_content
METHOD send.
DATA: l_sent_to_all TYPE os_boolean.
TRY.
* create persistent send request
send_request = cl_bcs=>create_persistent( ).
* create and set document with attachment
* create document object
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = l_body_text
i_subject = l_subject ).
* add the spread sheet as attachment to document object
document->add_attachment(
i_attachment_type = 'xls'
i_attachment_subject = l_attach_name
i_attachment_size = size
i_att_content_hex = binary_content ).
* add document object to send request
send_request->set_document( document ).
* add recipient (e-mail address)
recipient =
cl_cam_address_bcs=>create_internet_address(
l_recipient_addr ).
* add recipient object to send request
send_request->add_recipient( recipient ).
* send document
l_sent_to_all = send_request->send(
i_with_error_screen = 'X' ).
COMMIT WORK.
IF l_sent_to_all IS INITIAL.
MESSAGE i500(sbcoms) WITH l_recipient_addr.
ELSE.
MESSAGE s022(so).
ENDIF.
CATCH cx_bcs INTO bcs_exception.
MESSAGE i865(so) WITH bcs_exception->error_type.
ENDTRY.
ENDMETHOD. "lcl_mail_xls_attachment
METHOD get_dataelement_medium_text.
DATA: lt_fld_info TYPE STANDARD TABLE OF dfies,
wa_fld_info TYPE dfies.
* Busca en el diccionario los datos del campo
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = im_table_name
fieldname = im_field_name
langu = sy-langu
TABLES
dfies_tab = lt_fld_info
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
CLEAR ex_medium_text.
IF sy-subrc = 0.
READ TABLE lt_fld_info INDEX 1 INTO wa_fld_info.
* Si lo ha podido tomar del diccionario...
IF NOT wa_fld_info-scrtext_m IS INITIAL.
* Toma el nombre del nombre de campo del diccionario
ex_medium_text = wa_fld_info-scrtext_m.
ENDIF.
ENDIF.
ENDMETHOD. "get_dataelement_medium_text
ENDCLASS. "cl_mail_builder_xls_attach IMPLEMENTATION -
How to Create event, background Job & Assing event to backgroud job to trig
Hi Experts,
I want to trigger events in Backgroud for data scheduling purpose to automate.
I can able to create event in SM62. then i want to create background job in SM36 then how to assign to event in Background to trigger.
can anybody give some suggestion on this.
Best Regards
SiriHi,
There are two cases
1) to raise an event after the completion of a job
This can be done by using ABAP coding, trigger the event using a program by the 'RAISE' statement. The job can be scheduled to run in the background daily or weekly(or anything as per the requirements)
2) to run a job after an event
in the start condition of the job, give the event name which should trigger that job in the after event field.
or if you want to run multiple jobs after one event completes, give that event in the start condition of all the jobs.. or model a process chain which will run this jobs..
I hope this clrifies your doubt...
Regards
Shilpa -
Create background job triggered by another job
Hi experts,
I want to run FCHU in background everytime I finished run F110.
I'm thinking to use background job creation SM36 - triggered by job. But the problem is, job created from F110 the job name is not fixed.
Please anyone can give better idea ??
Thanks,
MelissaHi melissa,
The suggestion given by Prem is perfectly Ok.
I would suggest you to create an event by sm62 and then create an event triggered background job which will run the FCHU in Back ground.
So you need to get an enhancement point in F110 and put the code of triggering the event .
If there is no enhancement then you can create a program which will call the Transaction F110 by using CALL TRANSACTION statement and after F110 processing the control will get back to your program and you can write a code for triggering the event by using the FM SWE_EVENT_CREATE.
I hope this will help you -
Hi Gurus,
We want to have certain pruchase reqs automatically converted to POs via ME59N and we want to set it up as a background job. I will have filled certain fields on ME59N. How can this be acheived?
Thanks
AnushaCreate and schedule a background job in SM36 for program RM06BB30 (ME59N) with a variant of ME59N that selects the requisitions you wish to convert to orders. You can schedule this job to run once or periodically depending on your requirements.
Regards.
Maybe you are looking for
-
ICal, Mail, and Address Book won't open
When I open Mail, iCal, or Address Book, the application bounces a couple times in the dock and then immediately closes. Any idea what might be causing this and how I can fix it? I've repaired file permissions and that didn't work. I also tried (as s
-
Hello, I encounter a problem in an interface when I try to load the data which is in a Flat File. After looking to this file we've seen that there is at the end a carriage return symbol, and when we remove it all seems better. So I would like to know
-
I subscribed to HBONow yesterday on my iPad and received an email stating "Welcome to HBONow". HOWEVER, the HBONow app wouldn't accept my password. It gave an error message "there was a problem, please try again". I then tried logging in multiple t
-
Hi, I have some images in my Oracle Database. Now i would like to send this pictures to my clientele in web format. Can JSP be used to retrieve the images from the database, create the proper XML from a template and publish it? Is the process OK? Ram
-
When I e-mail a photo, my iPhone asks me if I want to reduce the size before sending. I assumed that IOS would be sensible, like Windows, and send a reduced copy. No! It reduces the size of the photo on the iPhone and the original hi-res picture is l