Creating a Step for Background Job from within ABAP Program
Step-1: I have a Report in ECC, which is scheduled as Background Job, which writes the file to the Application Server(UNIX)
Step-2: Trigger a Unix Command to ftp the file to other server.
Both Step-1 & Step-2 can be done from SM36.
Another Scenario:
Users can run the report in background from SE38 or using the transaction code for the report, In this case we want to call the external command.
Instead of calling the External Command as below in the report, I want to create a Step from within the program when it is scheduled in background mode.
CALL 'SYSTEM' ID 'COMMAND' FIELD lc_unixcom. [ Here lc_unixcom has the External Command ].
Any ideas??? Appreciate help.
Hi,
For submitting a report step, you may use either SUBMIT ... VIA JOB ... or JOB_SUBMIT function module.
For external commands, this should be done only by calling JOB_SUBMIT function module.
Sandra
Similar Messages
-
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 -
Passing data to se16 from within abap program
Hi,
I have an internal table itab defined as three fields (e.g., fld1(10) type c) and would like to pass the data from fld1 row 3 to the se16 textbox and then have se16 process to find the table.
I used "call transaction 'SE16'." to initiate, but I do not know how to pass the field value to the textbox and then have it process the field value to find the table. Can anyone advise?
thanks!I believe that this is what you want.
report zrich_0004.
data: bdcdata like bdcdata occurs 0 with header line.
start-of-selection.
perform bdc_dynpro using 'SAPLSETB' '0230'.
perform bdc_field using 'BDC_CURSOR'
'DATABROWSE-TABLENAME'.
perform bdc_field using 'BDC_OKCODE'
'=ANZE'.
perform bdc_field using 'DATABROWSE-TABLENAME'
'MARA'.
call transaction 'SE16' using bdcdata
mode 'E'.
* Start new screen *
form bdc_dynpro using program dynpro.
clear bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
append bdcdata.
endform.
* Insert field *
form bdc_field using fnam fval.
clear bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
append bdcdata.
endform.
Regards,
Rich Heilman -
Regarding Variants for Background jobs
Hi Folks
Can you please let me know the procedure how we can create the variants for Background jobs.
Points are assured for correct answers.
Regards,
kumarHi Sree Ram,
Check this info.
If you have any selection screen parameters for your program you need to enter the values for those fields in runtime. So, if you schedule your program in background to execute then there is no one to do this job. Here comes the concept of Variant.
With variant you define what are the selection field values in the runtime. During runtime the program picks this values and runs the program.
When you execute your program which has selection fields, you enter the values and then you click on 'GO TO ' tab and 'SAVE AS VARIANT'.
When you schedule your program in background, give this variant also. Then it will run automatically.
Hope this resolves your query.
Reward all the helpful answers.
Regards -
You need to schedule and automate batch jobs in an organisation. There will be multiple variants and multiple steps within same batch jobs. The variants are date dependent and needs to change every day. You need to automatically change the variants every day and schedule the jobs. Also check for the failures in the jobs. Apart from that Once the jobs in one server example : R/3 server ends the jobs in BW servers should be triggered automatically. Explain all steps with proper T codes and also provide a dry run example. Also provide all the table used for the variants purpose.
Please help on this,thanks
NarendraHi Narendra,
The background jobs are scheduled depending on the requirement with specific variants which are both date specific and even specific sometimes. These variants are created for the programs or reports which are run in the background job ,These variants are stored in VARID table for client specific variants and
VARID_CI for client independent. For most of the times all these jobs are maintained in some job scheduling tools so that they automatically inform about job failures and processes can be automated.In our organisation we use UC4 for background job schedulign and it controls the process as you are looking for.
Please award points accordingly
With Regards,
Junaid
Message was edited by:
muhammed junaid -
Kicking off Background Job from Another SAP system
Hi,
Does anybody know how to kick off a background job from a separate SAP system??
i.e I have a job on our CRM system that is dependant on a Job finishing from our ECC6 system first.
Does anyone know how to do this? I know I might be able to use events, is there anything else I should be making use of??
Many ThanksHi Daniel,
Guess there is one more solution. In system A write a report (let us name it X) that would trigger a job in system B through an RFC call.
Now in System A create a job with 2 steps. First step would be normal one, the second one for report X. Only when step 1 is over would step 2 start. So indirectly end of the existing Job A would trigger the required Job B.
Regards.
Ruchit. -
Date and time for background job
Hi,
I am creating a program with out selection screen . This program runs based on date and time . so I need to create a table
with date and time fileds.
Program runs based on FROM DATE FROM TIME TO DATE TO TIME....... FROM DATE and FROM TIME will get it from ztable and TO DATE & TO TIME values as SY-DATUM & SY-UZEIT. In the end I will update sy-datum and sy-uzeit values in the custom table to get the values ( Use it for from date from time ) for next run of the program.
This program is mainly used for background job so how do we get the values of from date and from time for the first run of the program ? how do we update the latest date and time details by deleting old date and time details.
Thanks ,
Vinay.
Edited by: Vinay parakala on Apr 22, 2010 9:18 AMFirst of all, I'll suggest to maintain TVARVC instead of doing it in custom table unless you need a complete log.
As per my understanding, you are trying to fetch some records based on the time period(Delta loads).
So, you will do an initial run to load the complete data then you will run it for time periods. For example,
1st Load- 01/01/1991(earliest date possible) - today's date say 03/22/2010
2nd load- 03/22/2010 - today's date
so on............
You have to move the to date values to from date values and to date value needs to be updated by the latest one for each load.
Do you have any dependency on background job? Please let me know if my understanding is correct or specify your requirement in detail. -
How to trigger a background job from BADI method.
hi friends,
i need to trigger a background job from the badi method CHANGE_AT_SAVE for the BADI BOM_UPDATE.
for this i think i need to create an event which i should give with parameters during job creation.
can you pls help me solve this issue.
thank u all.Hi Saravanan,
Here is an example of what you have to do.
Regards,
Eric
Reward any helpful sugestion.
*& Form generar_job
FORM generar_job .
Generar Variante
PERFORM generar_variante.
w_fecha = sy-datum + 3.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = w_fecha
IMPORTING
day = w_weekday.
Si la fecha cae en sabado o domingo se debe continuar el lunes.
CASE w_weekday.
when '1'.
ADD 2 TO w_fecha.
WHEN '6'.
ADD 2 TO w_fecha.
WHEN '7'.
ADD 1 TO w_fecha.
ENDCASE.
w_jobname = 'ZQM_CIERRE_LOTE_INSPECCION'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobgroup = 'QUEUE'
jobname = w_jobname
IMPORTING
jobcount = w_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc EQ 0.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
authcknam = sy-uname
jobcount = w_jobcount
jobname = w_jobname
report = 'ZQM_CIERRE_LOTE_INSPECCION'
variant = w_var
IMPORTING
step_number = w_stepnum
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 EQ 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = w_jobcount
jobname = w_jobname
sdlstrtdt = w_fecha
sdlstrttm = w_hora
IMPORTING
job_was_released = w_rel
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 EQ 0.
IF w_rel EQ 'X'.
WRITE:/ w_jobname, 'FUE LIBERADO. VER SM37.'.
Guardamos los destinatarios
PERFORM destinatarios_job.
Guardamos la información a utilizar al ejecutar el job
PERFORM guardar_datos_job.
ELSE.
WRITE:/ w_jobname, 'NO FUE LIBERADO'.
ENDIF.
ELSE.
WRITE:/ w_jobname, 'NO FUE CERRADO'.
ENDIF.
ELSE.
WRITE:/ w_jobname, 'NO FUE ENVIADO'.
ENDIF.
ELSE.
WRITE:/ w_jobname, 'NO FUE CREADO'.
ENDIF.
ENDFORM. " generar_job -
Handle submit program for background jobs in RFC FM to send email in ITS
Hi all
I am facing a problem in ITS, i.e. I have called a RFC Function Module on the page load event of one of the HTML template. In that FM I have used <b>submit program</b>. This RFC FM is working fine in background i.e. it is sending pdf as email to a particular email address
but in the frontend it is not responding.
I wanted to ask whether we can handle submit <program-name> in background job from ITS
<b>If you are unable to understand the problem i can share with you my code as well.</b>
Thanks
Ekta TuliHi Tobias
The Function Module <b>ZV_FUNC_CCK_EMAIL_PDF</b> is used to generate the email with pdf as attachement. it is generating email at backend but not in frontend.
thanks
ekta
please find the code below for the FM
FUNCTION zv_func_cck_email_pdf.
*"*"Local interface:
*" IMPORTING
*" VALUE(CONTRACT) LIKE VBAP-VBELN
*" VALUE(EMAIL) LIKE ADR6-SMTP_ADDR
*" EXPORTING
*" VALUE(RETURN) TYPE CHAR4
data: i_vbak like vbak .
DATA: v_cont(10) TYPE c.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = contract
IMPORTING
output = v_cont.
DATA: z_element(30) TYPE c.
DATA: gv_fb_addr_get_selection LIKE addr1_sel.
DATA: BEGIN OF mtab_contract OCCURS 0, "sap field
ordno(10), "vbeln (10)
terr(6),
vkorg LIKE vbak-vkorg,
vkgrp LIKE knvv-vkgrp,
repname(35),
repmailbox(10),
gueen(10), "expires dated -same as valid to
kunnr(10),
name1(35), "name1(35)
stras(35), "stras(35)
pstlz(10), "pstlz(10)
ort01(35), "ort01(35) city
regio(3), "regio(3)
kunnr2(10),
name2(35), "NUM?(35)
stras2(35), "stras(35)
pstlz2(10), "pstlz(10)
ort012(35), "ort01(35) city
regio2(3), "regio(3)
kit1 LIKE vbap-matnr, " currently 41315
kit1-qty(6), " like vbap-zmeng,
kit2 LIKE vbap-matnr, " currently 41316
kit2-qty(6), " like vbap-zmeng,
kit3 LIKE vbap-matnr, " currently 41317
kit3-qty(6), " like vbap-zmeng,
kit4 LIKE vbap-matnr, " currently 91869US
kit4-qty(6), " like vbap-zmeng,
med1 LIKE vbap-matnr, " currently 7408cp
med1-qty(6), " like vbap-zmeng,
med2 LIKE vbap-matnr, " currently 0211CP
med2-qty(6), " like vbap-zmeng,
med3 LIKE vbap-matnr, " currently 0578CP
med3-qty(6), " like vbap-zmeng,
med4 LIKE vbap-matnr, " currently 0068CP
med4-qty(6), " like vbap-zmeng,
med5 LIKE vbap-matnr, " currently 0069CP
med5-qty(6), " like vbap-zmeng,
med6 LIKE vbap-matnr, " currently other
dis6 LIKE makt-maktx, " currently other
med6-qty(6), " like vbap-zmeng,
med7 LIKE vbap-matnr, " currently other
dis7 LIKE makt-maktx, " currently other
med7-qty(6), " like vbap-zmeng,
med8 LIKE vbap-matnr, " currently other
dis8 LIKE makt-maktx, " currently other
med8-qty(6), " like vbap-zmeng,
med9 LIKE vbap-matnr, " currently other
dis9 LIKE makt-maktx, " currently other
med9-qty(6), " like vbap-zmeng,
med10 LIKE vbap-matnr, " currently other
dis10 LIKE makt-maktx, " currently other
med10-qty(6), " like vbap-zmeng,
END OF mtab_contract.
DATA: BEGIN OF mtab_material OCCURS 0,
ordno(10),
matnr LIKE vbap-matnr,
qty LIKE vbap-zmeng,
END OF mtab_material.
DATA: w-mm(4) VALUE ' MM '.
*SELECT-OPTIONS: s_vkorg FOR vbak-vkorg,
* s_vkgrp FOR knvv-vkgrp, "Sales Group
* s_terr FOR knvp-kunn2. "Territory Code
*PARAMETERS: p_parvw LIKE vbpa-parvw MEMORY ID par OBLIGATORY, "Partner ID
** DEFAULT 'Z1'.
* p_vbeln LIKE vbak-vbeln MEMORY ID aun,
* p_email LIKE adr6-smtp_addr MEMORY ID email. "Sales Document #
*SELECT-OPTIONS: "s_vbeln FOR vbak-vbeln MEMORY ID aun, "Sales Document #
* s_guebg FOR vbak-guebg, "Valid-From Date
* s_gueen FOR vbak-gueen, "Valid-To Date
* s_ship FOR vbpa-kunnr, "Ship-to customer
* s_bstzd FOR vbak-bstzd MEMORY ID bst ."DEFAULT 'CCK'. "P.O. # Supplement
DATA: i_otf TYPE STANDARD TABLE OF itcoo,
i_content_txt TYPE table of solisti1, "Content
i_content_bin TYPE solix_tab, "Content
i_content_bin1 TYPE solix_tab, "Content
i_objhead TYPE soli_tab,
w_pdf TYPE solisti1, "For PDF
w_res TYPE itcpp, "SAPscript output
w_otf TYPE itcoo, "For OTF
w_transfer_bin TYPE sx_boolean, "Content
prog(60).
data : t_obj_bin type standard table of solisti1.
DATA: w_arc_params LIKE arc_params,
w_pri_params LIKE pri_params.
*DATA: lcl_cls TYPE REF TO cl_gui_frontend_services.
CONSTANTS : c_x TYPE c VALUE 'X', "X
c_locl(4) TYPE c VALUE 'LOCL', "Local Printer
c_otf TYPE sx_format VALUE 'OTF', "OTF
c_pdf TYPE sx_format VALUE 'PDF', "PDF
c_printer TYPE sx_devtype VALUE 'PRINTER', "PRINTER
c_bin TYPE char10 VALUE 'BIN'. "BIN
DATA: v_name TYPE string ."Downloading File Name
DATA: v_len_in TYPE so_obj_len,
v_tempdir(50) TYPE c,
v_size TYPE i.
DATA : x_pdf_bag_tline TYPE rcl_bag_tline,
v_pdf_fsize TYPE i,
objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE,
doc_chng LIKE sodocchgi1,
tab_lines LIKE sy-tabix.
DATA : v_pnum LIKE usr21-persnumber,
v_anum LIKE usr21-addrnumber,
smtp_addr LIKE adr6-smtp_addr.
DATA: v_path TYPE string,
v_code TYPE i.
DATA : wa_obj_txt TYPE solisti1.
DATA : t_obj_txt TYPE STANDARD TABLE OF solisti1.
DATA : t_rec_list TYPE STANDARD TABLE OF somlreci1.
DATA : t_obj_pack TYPE STANDARD TABLE OF sopcklsti1.
DATA : wa_document_data TYPE sodocchgi1. "Mail data
DATA : wa_rec_list TYPE somlreci1.
DATA: reciever TYPE sadrud. "Email address of the receiver
DATA : wa_obj_pack TYPE sopcklsti1.
DATA: v_lines(10) TYPE n.
DATA: binfilesize TYPE i.
DATA : wa_obj_header TYPE solisti1.
DATA : t_obj_header TYPE STANDARD TABLE OF solisti1.
DATA : obj_id TYPE sofolenti1-object_id. "To send a file as attatchment
data: pdftab type table of tline with header line.
data : flag_sent_to_all type sonv-flag.
*START-OF-SELECTION.
* IF lcl_cls IS INITIAL.
* CREATE OBJECT lcl_cls.
* ENDIF.
CLEAR i_vbak.
SELECT * FROM vbak into i_vbak
WHERE
* guebg IN s_guebg AND "Valid-From Date
* gueen IN s_gueen AND "Valid-To Date
* vkorg IN s_vkorg AND
vbeln = v_cont AND
* AUART = 'LP ' AND "Converts to 'CO ' Scheduling A
auart = 'KM ' AND "Converts to 'CQ ' Qty contract
* VBTYP = 'E' AND "sales doc cat? JM
vbtyp = 'G' ."AND "sales doc cat "JM
* bstzd IN s_bstzd.
mtab_contract-kunnr = i_vbak-kunnr.
mtab_contract-ordno = i_vbak-vbeln.
mtab_contract-vkorg = i_vbak-vkorg.
WRITE i_vbak-gueen TO mtab_contract-gueen. "CHG014419
APPEND mtab_contract.
ENDSELECT.
LOOP AT mtab_contract.
* PERFORM get_contract. "CO sales orders line items
******Get Contract*********
* SELECT SINGLE kunnr "partner
* INTO vbpa-kunnr
* FROM vbpa
* WHERE vbeln EQ mtab_contract-ordno
* AND posnr EQ '000000'
* AND parvw EQ 'WE' "Ship-To's
* AND kunnr IN s_ship. "Ship-To ID added 04/01/99
* IF sy-subrc EQ 0 .
* MOVE vbpa-kunnr TO mtab_contract-kunnr2.
* MODIFY mtab_contract.
* ELSE.
* EXIT.
* ENDIF.
CLEAR knvp.
SELECT SINGLE kunn2 "territory
INTO knvp-kunn2
FROM knvp
WHERE kunnr EQ mtab_contract-kunnr2
AND vkorg EQ mtab_contract-vkorg
AND parvw EQ 'Z6'.
* AND kunn2 IN s_terr .
IF sy-subrc EQ 0 .
MOVE knvp-kunn2 TO mtab_contract-terr.
MODIFY mtab_contract.
ELSE.
EXIT.
ENDIF.
CLEAR kna1. "get rep name and mail box
SELECT SINGLE name2 FROM kna1 INTO (kna1-name2)
WHERE kunnr = knvp-kunn2.
IF sy-subrc EQ 0 .
SPLIT kna1-name2 AT w-mm INTO mtab_contract-repname
mtab_contract-repmailbox.
mtab_contract-repmailbox+3 = mtab_contract-repmailbox.
mtab_contract-repmailbox(3) = 'MM'.
MODIFY mtab_contract.
ENDIF.
CLEAR knvv.
SELECT SINGLE vkgrp
INTO knvv-vkgrp
FROM knvv
WHERE kunnr EQ knvp-kunn2
AND vkorg EQ mtab_contract-vkorg.
* AND vkgrp IN s_vkgrp.
IF sy-subrc EQ 0 .
MOVE knvv-vkgrp TO mtab_contract-vkgrp.
MODIFY mtab_contract.
ELSE.
EXIT.
ENDIF.
mtab_contract-med1-qty = '_______'.
mtab_contract-med2-qty = '_______'.
mtab_contract-med3-qty = '_______'.
mtab_contract-med4-qty = '_______'.
mtab_contract-med5-qty = '_______'.
mtab_contract-med6-qty = '_______'.
mtab_contract-med7-qty = '_______'.
mtab_contract-med8-qty = '_______'.
mtab_contract-med9-qty = '_______'.
mtab_contract-med10-qty = '_______'. "JM
mtab_contract-kit1-qty = '____'.
mtab_contract-kit2-qty = '____'.
mtab_contract-kit3-qty = '____'.
mtab_contract-kit4-qty = '____'.
mtab_contract-dis6 = 'OTHER _____________________'. "JM
mtab_contract-dis7 = 'OTHER _____________________'. "JM
mtab_contract-dis8 = 'OTHER _____________________'. "JM
mtab_contract-dis9 = 'OTHER _____________________'. "JM
mtab_contract-dis10 = 'OTHER _____________________'. "JM
* SELECT * FROM VBAP WHERE VBELN = MTAB_CONTRACT-ORDNO.
* IF VBAP-MATNR = '7408CP'.
* MTAB_CONTRACT-MED1 = VBAP-MATNR.
* ELSEIF VBAP-MATNR = '0211CP'.
* MTAB_CONTRACT-MED2 = VBAP-MATNR.
* ELSEIF VBAP-MATNR = '91865US'.
* MTAB_CONTRACT-MED3 = VBAP-MATNR.
* ELSEIF VBAP-MATNR = '0578CP'.
* MTAB_CONTRACT-MED4 = VBAP-MATNR.
* ELSEIF VBAP-MATNR = '0068CP'.
* MTAB_CONTRACT-MED5 = VBAP-MATNR.
* ELSEIF VBAP-MATNR = '0069CP'.
* MTAB_CONTRACT-MED6 = VBAP-MATNR.
* ELSEIF VBAP-MATNR = '92055CP'. "JM
* MTAB_CONTRACT-MED7 = VBAP-MATNR. "JM
* ELSEIF VBAP-MATNR = '90799CP'. "JM
* MTAB_CONTRACT-MED8 = VBAP-MATNR. "JM
* ELSEIF VBAP-MATNR = '41315'.
* MTAB_CONTRACT-KIT1 = VBAP-MATNR.
* ELSEIF VBAP-MATNR = '41316'.
* MTAB_CONTRACT-KIT2 = VBAP-MATNR.
* ELSEIF VBAP-MATNR = '41317'.
* MTAB_CONTRACT-KIT3 = VBAP-MATNR.
* ELSEIF VBAP-MATNR = '91869US'.
* MTAB_CONTRACT-KIT4 = VBAP-MATNR.
* ELSE.
* SELECT SINGLE MAKTX INTO MAKT-MAKTX
* FROM MAKT WHERE MATNR = VBAP-MATNR.
* ENDIF.
* MODIFY MTAB_CONTRACT.
* ENDSELECT.
MODIFY mtab_contract.
* IF.
** mtab_contract-terr IN s_terr AND
** mtab_contract-kunnr2 IN s_ship AND
** mtab_contract-vkgrp IN s_vkgrp.
** PERFORM get_address.
* ELSE.
* DELETE mtab_contract INDEX sy-tabix.
* ENDIF.
ENDLOOP.
SORT mtab_contract BY terr.
* PERFORM set_print_option.
* Print defaults should be immed and delete after print...
itcpo-tdimmed = ' '.
itcpo-tddelete = 'X'.
itcpo-tdnewid = 'X'.
itcpo-tdcopies = 1.
itcpo-tdnoprev = 'X'.
itcpo-tdgetotf = 'X'.
itcpo-tddest = 'LOCL'.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = 'LOCL'
no_dialog = 'X'
IMPORTING
out_archive_parameters = w_arc_params
out_parameters = w_pri_params.
*exit if cancel chosen*
IF sy-subrc NE 0.
EXIT.
ENDIF.
sadr-regio = 'CA'.
sadr-pstlz = '92620'.
LOOP AT mtab_contract.
* PERFORM check-for-values.
IF mtab_contract-ordno = space.
mtab_contract-ordno = '___________'.
ENDIF.
IF mtab_contract-terr = space.
mtab_contract-terr = '______'.
ENDIF.
IF mtab_contract-repname = space.
mtab_contract-repname = '___________________________________'.
ENDIF.
IF mtab_contract-repmailbox = space.
mtab_contract-repmailbox = '__________'.
ENDIF.
IF mtab_contract-kunnr = space.
mtab_contract-kunnr = '__________'.
ENDIF.
IF mtab_contract-name1 = space.
mtab_contract-name1 = '___________________________________'.
ENDIF.
IF mtab_contract-stras = space.
mtab_contract-stras = '___________________________________'.
ENDIF.
IF mtab_contract-pstlz = space.
mtab_contract-pstlz = '__________'.
ENDIF.
IF mtab_contract-ort01 = space.
mtab_contract-ort01 = '___________________________________'.
ENDIF.
IF mtab_contract-regio = space.
mtab_contract-regio = '___'.
ENDIF.
IF mtab_contract-kunnr2 = space.
mtab_contract-kunnr2 = '__________'.
ENDIF.
IF mtab_contract-name2 = space.
mtab_contract-name2 = '___________________________________'.
ENDIF.
IF mtab_contract-stras2 = space.
mtab_contract-stras2 = '___________________________________'.
ENDIF.
IF mtab_contract-pstlz2 = space.
mtab_contract-pstlz2 = '__________'.
ENDIF.
IF mtab_contract-ort012 = space.
mtab_contract-ort012 = '___________________________________'.
ENDIF.
IF mtab_contract-regio2 = space.
mtab_contract-regio2 = '___'.
ENDIF.
* PERFORM open_form.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
dialog = ' '
form = 'ZREV_CCK_AGREMT'
language = sy-langu
OPTIONS = itcpo
EXCEPTIONS
canceled = 1
device = 2
form = 3
OPTIONS = 4
unclosed = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE e000(zz) WITH 'Open Form Error. ' sy-subrc.
ENDIF.
z_element = 'MAIN'.
* PERFORM write_form.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = z_element
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
* PERFORM close_form.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = w_res
TABLES
otfdata = i_otf
EXCEPTIONS
unopened = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e000(zz) WITH 'Close Form Error. ' sy-subrc.
ENDIF.
*&---Convert OTF data to PDF data.
call function 'CONVERT_OTF'
exporting
format = 'PDF'
importing
bin_filesize = binfilesize
tables
otf = i_otf
lines = pdftab[].
data : name LIKE RLGRAP-FILENAME.
CONCATENATE 'C:Temp' mtab_contract-ordno '.pdf' INTO v_name.
*CALL FUNCTION 'DOWNLOAD'
* EXPORTING
* bin_filesize = v_size
* filename = name
* filetype = 'BIN'
* TABLES
* data_tab = pdftab[].
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = v_name
FILETYPE = 'BIN'
tables
data_tab = pdftab[].
* Downloading the PDF File
* CALL METHOD lcl_cls->gui_download
* EXPORTING
* bin_filesize = v_size
* filename = v_name
* filetype = c_bin
* CHANGING
* data_tab = pdftab[].
CALL METHOD cl_gui_cfw=>flush.
**Send PDF as Email.
* wa_obj_txt-line = 'CCK Contract Agreement'.
APPEND wa_obj_txt TO t_obj_txt.
CLEAR wa_obj_txt.
wa_obj_txt-line = 'Please find attatched PDF document for Contract'.
APPEND wa_obj_txt TO t_obj_txt.
CLEAR wa_obj_txt.
DESCRIBE TABLE t_obj_txt LINES tab_lines.
**Prepare document data
wa_document_data-obj_name = 'CCK Contract Agreement'.
wa_document_data-obj_descr = 'CCK Contract Agreement'.
wa_document_data-obj_langu = sy-langu.
wa_document_data-proc_type = 'R'.
wa_document_data-proc_name = 'CCK'.
wa_document_data-priority = c_x.
wa_document_data-obj_prio = c_x.
**Receiving list
wa_rec_list-receiver = sy-uname.
wa_rec_list-rec_type = 'B'.
wa_rec_list-com_type = 'INT'.
wa_rec_list-notif_del = c_x.
APPEND wa_rec_list TO t_rec_list.
CLEAR wa_rec_list.
wa_rec_list-receiver = '[email protected]'."p_email.
reciever = wa_rec_list-receiver.
wa_rec_list-rec_type = 'U'.
wa_rec_list-com_type = 'INT'.
wa_rec_list-notif_del = c_x.
APPEND wa_rec_list TO t_rec_list.
CLEAR wa_rec_list.
*Object packet
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src = 134
line_width_dst = 255
TABLES
content_in = pdftab[]
content_out = t_obj_bin
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4
IF sy-subrc <> 0.
ENDIF.
DESCRIBE TABLE t_obj_bin LINES v_lines.
CLEAR wa_obj_pack-transf_bin .
wa_obj_pack-head_start = 1.
wa_obj_pack-head_num = 0.
wa_obj_pack-body_start = 1.
wa_obj_pack-body_num = tab_lines.
wa_obj_pack-doc_type = 'RAW'.
wa_obj_pack-doc_size = tab_lines * 255.
APPEND wa_obj_pack TO t_obj_pack.
CLEAR wa_obj_pack.
wa_obj_pack-transf_bin = 'X'.
wa_obj_pack-head_start = 1.
wa_obj_pack-head_num = 0.
wa_obj_pack-body_start = 1.
wa_obj_pack-body_num = v_lines.
wa_obj_pack-doc_type = 'PDF'.
wa_obj_pack-obj_name = 'ATTATCHMENT'.
wa_obj_pack-obj_descr = mtab_contract-ordno.
wa_obj_pack-doc_size = binfilesize.
APPEND wa_obj_pack TO t_obj_pack .
CLEAR wa_obj_pack.
**Object header
wa_obj_header-line = 'PDF'.
APPEND wa_obj_header TO t_obj_header.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_document_data
put_in_outbox = c_x
commit_work = c_x
IMPORTING
sent_to_all = flag_sent_to_all
new_object_id = obj_id
TABLES
packing_list = t_obj_pack
object_header = t_obj_header
contents_bin = t_obj_bin
contents_txt = t_obj_txt
receivers = t_rec_list
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
else.
return = 'true'.
ENDIF.
ENDFUNCTION.
<b> Flow Editor</b>
<flow>
<state name="Start">
<module name="<b>ZV_FUNC_CCK_EMAIL_PDF</b>" type="RFC" stateful="1">
<inputmapping source="Contract" target="CONTRACT"/>
<inputmapping source="email" target="EMAIL"/>
</module>
<module name="ZV_FUNC_CCK_VALIDATE_SHIPTO" type="RFC" stateful="1">
<inputmapping source="SHIP_TO" target="KUNNR"/>
<inputmapping source="USERNAME" target="USER"/>
<outputmapping source="CITY" target="CITY"/>
<outputmapping source="NAME" target="NAME"/>
<outputmapping source="POSTAL" target="POSTAL"/>
<outputmapping source="REGION" target="REGION"/>
<outputmapping source="RETURN" target="RETURN"/>
<outputmapping source="SD_CITY" target="SD_CITY"/>
<outputmapping source="SD_NAME" target="SD_NAME"/>
<outputmapping source="SD_POSTAL" target="SD_POSTAL"/>
<outputmapping source="SD_REGION" target="SD_REGION"/>
<outputmapping source="SD_STREET" target="SD_STREET"/>
<outputmapping source="SOLDTO" target="SOLDTO"/>
<outputmapping source="STREET" target="STREET"/>
</module>
</state>
<event name="onLoad" next_state="Start"/>
<event name="Check2" next_template="ZV_CCO_CONFIRMED_ORDER"/>
</flow> -
RE: Report for Background jobs
Hi SAP Guru's,
I need to create a report on Background Job status , please tell me is there any standard reports ? or How to create a report on Background Jobs Status?
Thanks in Advance,
Krishna.Dear Raja,
In std report this is not possible, talk to ur ABAPer to fetch the feild PLNUM from AFPO table with respect to the AUFNR field. This can be added to the std report itself. use this logic it will work
sree -
Job failure ( report RFFDKU00 scheduled for background job)
Hi Experts,
When iam scheduling the report RFFDKU00 for background job. Job is getting cancelled with status "ABAP/4 processor: DBIF_RSQL_SQL_ERROR" . when iam obesrving this job it is going to dump at this select query
" select ausbk belnr gjahr bzkey buzei
033370 from vbsegs into table t_vbsegsfields
033380 where bukrs in r_bukrs
033390 and not ( fdlev = space
033400 and fdgrp = space
033410 and fdtag = init_date
033420 and fdwbt = 0 )
033430 and not saknr in r_cm_sk "
Can anyone helpme to deal with this issues ,
thanks in advance,
Kranthinote 167301 might help.
-
Function module for background jobs email
hi abaper's
i hace to create a function module for background jobs this function module have to send an email automatically when a background job is assigned or processed in background.
thnks n regards
pardeep kumarhi dear
open this site
https://weblogs.sdn.sap.com/pub/wlg/781. [original link is broken] [original link is broken] [original link is broken]
<removed by moderator>
Edited by: Mike Pokraka on Aug 8, 2008 12:48 PM -
Creation of background job from SE38
hello all...
In the selection screen of my report program, there are two radiobuttons - read mode or update mode.
In read mode, the program reads an excel file and gives the output in teh form of errors, if at all, after some chekcs on this excel file.
In update mode, the program should check the excel file, get an internal table with errors from the excel file as well as run BDC for the correct records in excel file. So the output here has two blocks, first one - errors in excel file, second one - errors in BDC update.
But this update mode should run in background.
HOW TO CALL THE BACKGROUND JOB FROM THIS REPORT PROGRAMME when the update mode is selected??
Advance Thanks
omkarHi Vishal,
1. How are u running the BDC ?
2. If u are using call transaction syntax,
then there is an extension to it.
MODE mode
(See help F1 on call transaction)
The processing mode can take the following values:
'A' Display screen
'E' Display only if an error occurs
'N' Do not display
'P' Do not display; debugging possible
3. We can use N
4. N means, it won't display any screens
of that BDC transaction.
5. It does not exactly mean the BACKGROUND JOB
generated thru sm36.
Regards,
Amit M.
Message was edited by: Amit Mittal -
How to Create Linux-Cron Job from a Java Program
Hello,
Can anybody help me to CREATE/EDIT/DELETE Linux Cron job from Java Program. Its Very Urgent.Thanks in advance..
from
ChakriI decided this didn't sound too tough so I played around with it a little. Basically because I'd never tried executing external processes out of java before, so I wanted to see how it was done.
Just change whatever you like in the jobs ArrayList and call writeJobs.
If you call writeJobs without putting anything in the list first you'll wipe out all of your crontab entries.
import java.lang.*;
import java.io.*;
import java.util.*;
public class cron {
ArrayList jobs;
Runtime rt;
cron() {
rt = Runtime.getRuntime();
jobs = new ArrayList();
void readCron() {
String[] list = { "crontab", "-l" };
jobs = new ArrayList();
try {
// Stick a job into crontab
Process child = rt.exec(list);
BufferedReader cronout = new BufferedReader(new InputStreamReader(child.getInputStream()));
String cronjob = cronout.readLine();
while (cronjob != null) {
jobs.add(cronjob);
cronjob = cronout.readLine();
child.waitFor();
catch(IOException e) {
System.err.println("IOException starting process!");
catch(InterruptedException e) {
System.err.println("Interrupted waiting for process!");
void listJobs() {
Iterator iter = jobs.iterator();
while (iter.hasNext()) {
System.out.println((String)iter.next());
void writeJobs() {
String[] edit = { "crontab"};
try {
// Stick a job into crontab
Process child = rt.exec(edit);
PrintWriter cronIn = new PrintWriter(child.getOutputStream());
Iterator iter = jobs.iterator();
while (iter.hasNext()) {
cronIn.println((String)iter.next());
cronIn.close();
child.waitFor();
catch(IOException e) {
System.err.println("IOException starting process!");
catch(InterruptedException e) {
System.err.println("Interrupted waiting for process!");
void doStuff() {
readCron();
listJobs();
jobs.add("* * * * 4 cronjob");
writeJobs();
readCron();
listJobs();
public static void main(String[] args) {
cron c = new cron();
c.doStuff();
} -
Userexit or BADI for program *RMMRP000* for background job
Hi,
We are scheduling background job for MRP through SM36 using program RMMRP000 or Through Transaction MDBT (MDBT is calling program RMMRP000) which creates PR (through background job).
I want to default one field in PR (PO Price field in valuation tab in PR default to gross) using any userexit or BADI.
Can any body suggest me userexit or BADI for program RMMRP000 for background job
Regards.Hi,
1. The below are the List of Userexit for this MDBT t.CODE.
2. But i dont see any one helping to resolve your issue.
3. May be you should lookg at the Userexit for me21n or relevant Purhcase requisition creation transaction.
reg
dsk
Maybe you are looking for
-
Audio transmit problem under redhat linux 9
Hi !! I have already compiled J2sdk1.4.2 and JMF2.1.1e performance pack for linux and they both work alright under Redhat linux 9. JMStudio works fine to playback audio files. The problem I'm having is when I try to transmit and receive audio files t
-
I've taken the schema for SOAP and can create an envelope, a header and a body with no data content. But now I can't add content; I can't create put anything in the body. It appears you can only set a Body with a Body object, but I want to put my XML
-
RAID performance is poor on the K8N NEO NF4 SLi mobo...why?
I reccently downloaded and purchased pcmark05 to keep tabs on my system performance, I have 2 wd800jb/se ide in raid'0', isn't there supposed to be a performance gain with using raid?, is it a hardware or software version of raid that is used with my
-
Nvidia installation hanged, had to cancel... pacman errors after that
fresh Arch install (64bit), had just installed X then went on to nvidia & nvidia-utils but it hanged so I had to cold boot... after that this is what I get for whatever I try to install with pacman, I've tried removing both nvidia & X and re-installi
-
I am trying to make a paintbrush kind of application in JAVA - wherein i have taken 2 canvases - one on a 1:1 scale and the other on a 6:1 scale. to draw on the canvases, i am using a 2-dimensional array of ints. i make changes to this array for draw