Print binary as background job
Hi experts,
Is there a way to send binary(xstring) to a printer, eg. jpg/doc/pdf, as a background job with abap.
Mvh,
Alex
Alexander,
check these threads:
Printing binary data in PDF format
Solution! (Hopefully) :Print label image in GIF format
Save print output as PDF file in front end system using PDF printer output device
Similar Messages
-
Sending output to a printer in a background job
I did a quick search on this issue and found a few suggestions. One suggestion was to use something like this:
SUBMIT RSFLFIND ... TO SAP-SPOOL DESTINATION 'LT50'.
I looked at the SAP help for SUBMIT and it was quite helpful however it raised a few questions. The program that am writing will be run in the background. I want to create a simple report that will print at several different printers when it is done. Looking at the help section (specifically this part):
"The SUBMIT statement accesses an executable program rep. The executable program is executed as described under Calling Executable Reports.
The program name rep can either be specified directly or as the content of a character-like data object name. The data object name must contain the name of the program to be accessed in block capitals. If the program specified in name is not found, an irretrievable exception is generated.
The selscreen_options additions can be used to determine the selection screen for the program accessed and to supply it with values.
The list_options additions allow you to influence the output medium and the page size in the basic list for the program accessed.
You can schedule the program for background processing by specifying job_options. "
It seems like I would create a simple program like this:
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 DESTINATION 'LT50'.
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.
That will then call the background job and the output will go to the print spool. I have a few reservations about this. The print spool will not be determined until the background job. The background job creates sales orders and the material group, in the sales order, determines the printer that the final report will go to. Also, if this is the way to do it, do I just do simple write statements in the background job?Hi,
Please try this ... perhaps it may help.
SUBMIT submitable TO SAP-SPOOL
SPOOL DESTINATION 'LT50'.
IMMEDIATELY 'X' "Add here
VIA JOB name NUMBER number
AND RETURN.
OR
SUBMIT submitable TO SAP-SPOOL
SPOOL DESTINATION 'LT50'.
IMMEDIATELY 'X' "Add here
WITHOUT SPOOL DYNPRO "Add here
VIA JOB name NUMBER number
AND RETURN.
Regards,
Ferry Lianto -
Printing Invoices in Background Jobs
Hello,
We have an o/p type that is processed each time a billing document is created. The o/p type prints the billing document as soon as it is saved. When we have a billing due list program run in background the printouts are waiting in the Spool and are not printed. Is there any way we can print the documents when the billing due list program runs in background.
Any help would be appreciated.
Thanks,
Alam.Hello Alam,
If your question was answered, please close this thread and assign the points to the person that give you the answer.
Regards,
Eric -
Background job- getting printed automatically
In my BDC Program i have submitted Session for Background Processing using
Submit RSBDCSUB..........
my code is also given below..The problem is after the user executes the program, background job is automatically going to his Local printer and getting printed. HOw to avoid this?
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = gf_jobname
IMPORTING
jobcount = gf_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
*-Submit the selected sales orders for changes.
SUBMIT rsbdcsub AND RETURN
WITH mappe = v_sess
WITH von = sy-datum
WITH bis = sy-datum
WITH z_verarb = 'X'
WITH fehler = space
WITH batchsys = space
WITH logall = space
USER sy-uname VIA JOB gf_jobname NUMBER gf_jobcount.
IF sy-subrc NE 0.
MESSAGE i999 WITH text-013.
EXIT.
ENDIF.
*-Close job and start immediately.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = gf_jobcount
jobname = gf_jobname
strtimmed = 'X'
IMPORTING
job_was_released = gf_release
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.On SUBMIT use
SUBMIT zxxxxxx TO SAP-SPOOL
WITHOUT SPOOL DYNPRO
IMMEDIATELY ' '
KEEP IN SPOOL 'X'
DESTINATION printer
NUMBER number
AND RETURN -
Background Job not Printing TOs immediately
Hello experts,
I am having an issue with printing Transfer Orders created by background job, the output requests are sent to the output controller with status '-' . It works when I manually create the TOs or if I run the RLAUTA10 program with my userID in SE38 .
I have set the background job user default print parameters in SU3 to print immediately.
Also in the Job step, I have set up the print parameters to 'print immediately'
I have assigned printer for sorce storage type & set the indicator to use the source sto type in OMLV, The printer seems to be determined correctly, I've checked the Spool request name & printer in the spool controller, only issue seems to be the print not being triggered immediately.
Not sure, if there is some other setting that I have to make to be able to print the TOs created by the background job immediately.
Any help would be appreciated.
Thanks
Kris Twhether the printer which you assigned is configured in SAP (network printer)? or LOCL?
printing may not happen if LOCL(background job)
Thanks -
Background job step - Printer - Output device table
Hi,
When creating background job, printer- output device also specified for every step. Which table to check for job name and output device combination ?
Thanks.Hi Raj check table TBTCP
-
How to print result of transaction processing in background job?
Hi experts,
Could you give me advice how to resolve following task:
I need to print a list of sales orders (transaction VA05) in background job.
Are exist standard techniques for this? Or should I create new program (report) and create the job with printing of parameters?
Thanks for advanceHi,
Define a background job with the program name & variant.
Pass the print specifications as well.
Best regards,
Prashant -
How to stop background job to print papers
Hi all,
I have background job of forms running every day and its printing papers. My requirement is to stop the printing of papers in the background job.
How to do this .
i am using CALL FUNCTION 'GET_PRINT_PARAMETERS and NEW-PAGE PRINT ON PARAMETERS v_params NO DIALOG.
NEW-PAGE PRINT OFF.
Thanks
KrupaliHi,
<li>Set the below before you call NEW-PAGE PRINT ON
lw_pripar-prrel = space.
lw_pripar-primm = space.
<li>Call NEW-PAGE PRINT ON like below
NEW-PAGE PRINT ON
NEW-SECTION
PARAMETERS lw_pripar
ARCHIVE PARAMETERS lw_arcpar
NO DIALOG.
Thanks
Venkat.O -
Background job should not print
Hi guys,
We have a background job, but we dont want it to print. Is that possible?
Thanks!Hi,
Of course it is. Going into the print parameters for the job step and take off the print immediately setting.
Regards,
Nick -
Print spool requests by background job
Hi,
we want to print spool requests by a background job. Do you know any abap program to do this.? I search at the programs RSPO... , but i can't find anyone to do this.
Can anybody help me.
Regards OliverHi,
i found a report for this issue. You can use the report RSPO0015 -
Printing from background jobs ....
Hi, I have ECC 6.0 , I have a job that generate an invoice with printer inmmediality, when job run, invoice is not printed.
I define my printer as F at SPAD transaction, I check SP01 and show me my invoice, but I need that it go to the printer directly.
I read 128105 note and say that I can not print with Frontend printing (F) from a job, I try with I, S and U but does not work.
Regards.Hi, I change to L in my printer (SPAD transaction) and when I try to print from SAP, showme following message:
SAP spool error log
=====================
Print request processing log
The host spool is reporting errors
Message from host spool:
Unable to initialize device
192.168.0.85\EP
End of message
Command used: print /d:
192.168.0.85\EP G:\usr\sap\DEV\DVEBMGS00\data\000000968700001.DEV
Errors occurred processing this print request
Error during print request output. l_rc = 1
There may be no printout
Most important attributes of spool request
Request number 9687
Request name LIST1S DM RFITEMAP_OAL
Client 350
Owner OALTUVE
Request attributes
Time created 2007102421205500
Remaining life +00008000000
Dispo 1 (Go/Hold) G
Dispo 2 (Keep/Delete) K
Dispo 3 (Indirect/Direct) D
Default output device DM
Default no. copies 1
Format X_65_255
Main print request characteristics
Spool request number 9687
Print request number 1
Print request attributes
Time created 2007102421205500
Output device DM
Format X_65_255
Character converter active when first problem occurred
No information available.
If I change to F, I can print from SAP but no from my job.
Any comments?....
Regards. -
Print smartform from background
Dear Experts,
I have requirement to create delivery then create bill automatically so i open background job from program (A) and submit the creating program for bill (B) via this job what happened is the delivery creating is ok, the delivery printing is ok and the billing creation is ok but the billing printing program (C) is not ok where the spool is creating with status waiting so can any body help how to print from background job??
program (A) (Create backgroundjob and submit program via it)
FORM USEREXIT_SAVE_DOCUMENT.
DATA: jobcount TYPE tbtcjob-jobcount,
new_time type TBTCJOB-SDLSTRTTM.
data : p_vbeln TYPE likp-vbeln.
DATA : v_JOB_WAS_RELEASED LIKE BTCH0000-CHAR1.
break rurik.
if T180-TRTYP = 'H'
and ( likp-lfart = 'ZDCF'
or likp-lfart = 'ZDCI'
or likp-lfart = 'ZDCO'
or likp-lfart = 'ZDCP'
or likp-lfart = 'ZDCR'
or likp-lfart = 'ZDOB'
or likp-lfart = 'ZDOT'
or likp-lfart = 'ZDQT'
or likp-lfart = 'ZDRE' - Ian
or likp-lfart = 'ZDSO').
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = 'SD_AUTOMATION'
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
JOBCLASS =
IMPORTING
JOBCOUNT = jobcount
CHANGING
RET =
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
SUBMIT zsd_create_billing_document
with vbeln EQ LIKP-VBELN
AND RETURN
VIA JOB 'SD_AUTOMATION'
NUMBER jobcount.
new_time = sy-uzeit + 10. "short delay
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = jobcount
jobname = 'SD_AUTOMATION'
STRTIMMED = 'X'
SDLSTRTDT = sy-datum
SDLSTRTTM = new_time
IMPORTING
JOB_WAS_RELEASED = v_JOB_WAS_RELEASED
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
ENDIF.
ENDFORM.
Program B (Creat bill)
REPORT zsd_create_billing_document
NO STANDARD PAGE HEADING LINE-SIZE 255.
TABLES: vbup, vbak, vbuk.
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA done(1).
PARAMETERS vbeln TYPE likp-vbeln.
DATA sal_vbeln TYPE vbeln..
DATA messtab LIKE TABLE OF bdcmsgcoll WITH HEADER LINE.
DATA billing_doc TYPE vbeln.
DATA messagetext(200).
MESSAGE s002(zsd).
WRITE: / vbeln.
DATA : v_print TYPE i.
CALL FUNCTION 'ENQUEUE_EVVBLKE'
EXPORTING
MODE_LIKP = 'E'
MANDT = SY-MANDT
vbeln = vbeln
X_VBELN = ' '
_SCOPE = '2'
_wait = 'X'
" _wait = space
_COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3
MESSAGE s005(zsd).
*In case ZSOT automatic billing once we create delivery and post goods issue manual.
SELECT SINGLE vbelv
FROM vbfa
INTO sal_vbeln
WHERE vbeln = vbeln
AND vbtyp_v = 'C'.
SELECT SINGLE *
FROM vbak
WHERE vbeln = sal_vbeln.
import v_print to v_print FROM MEMORY id 'PRINTFLAG'.
IF vbak-auart EQ 'ZSOT'.
IF v_print eq '1'.
PERFORM create_document USING vbeln
CHANGING sy-subrc.
ENDIF.
ELSE.
*Other than ZSOT Post Goods issue from ZPGI2 and from there automatic billing.
ENDIF.
*& Form CREATE_DOCUMENT
text
-->P_VBELN text
FORM create_document USING p_vbeln
CHANGING sysubrc.
PERFORM bdc_dynpro USING 'SAPMV60A' '0102'.
PERFORM bdc_field USING 'BDC_CURSOR'
'KOMFK-VBELN(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'KOMFK-VBELN(01)'
p_vbeln."'1130010202'.
PERFORM bdc_dynpro USING 'SAPMV60A' '0104'.
PERFORM bdc_field USING 'BDC_CURSOR'
'VBRK-FKART'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SICH'.
CALL FUNCTION 'DEQUEUE_EVVBLKE'
EXPORTING
MODE_LIKP = 'E'
MANDT = SY-MANDT
vbeln = vbeln
X_VBELN = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' '
CALL TRANSACTION 'VF01' USING bdcdata
MODE 'N'
UPDATE 'S'
MESSAGES INTO messtab.
READ TABLE messtab WITH KEY msgtyp = 'E'.
IF sy-subrc EQ 0.
sysubrc = 4.
ELSE.
sysubrc = 0.
ENDIF.
LOOP AT messtab.
sy-msgty = messtab-msgtyp.
sy-msgid = messtab-msgid.
sy-msgno = messtab-msgnr.
sy-msgv1 = messtab-msgv1.
sy-msgv2 = messtab-msgv2.
sy-msgv3 = messtab-msgv3.
sy-msgv4 = messtab-msgv4.
CALL FUNCTION '/SAPTRX/GET_MESSAGE_TEXT'
EXPORTING
msgid = sy-msgid
msgno = sy-msgno
msgv1 = sy-msgv1
msgv2 = sy-msgv2
msgv3 = sy-msgv3
msgv4 = sy-msgv4
IMPORTING
messagetext = messagetext
EXCEPTIONS
no_message_retrieved = 1
OTHERS = 2.
WRITE: / messagetext.
CLEAR messagetext.
ENDLOOP.
*... refresh tables
REFRESH: messtab, bdcdata.
ENDFORM. "CREATE_DOCUMENT
*& Form BDC_DYNPRO
text
-->PROGRAM text
-->DYNPRO text
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "BDC_DYNPRO
Insert field *
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM. "BDC_FIELD
*& Form change_status
text
--> p1 text
<-- p2 text
FORM change_status .
*Change status if delivery and the billing document has been created
SELECT *
FROM vbup
WHERE vbeln = vbeln
AND fksta NE 'C'.
vbup-fksta = 'C'.
vbup-gbsta = 'C'.
MODIFY vbup.
ENDSELECT.
UPDATE vbuk
SET fkstk = 'C'
gbstk = 'C'
WHERE vbeln = vbeln.
ENDFORM. " change_status
Program C (Print Bill)
REPORT z_sdps_invoice.
*& <Module>: SD Smart Forms.
*& Type : Executable
*& Request No.:
*& Author/Co. : Ahmed Al Eryani
*& Created On : 26.02.2007
*& Finished : 24.2007
*& Description:
*& MODIFICATION LOG
*& Modified by :
*& Request No. :
*& Dev. Class :
*& Date Modified:
*& Description :
TABLES: vbrk, kna1, vbrp, makt, konv, vbkd.
SELECTION-SCREEN BEGIN OF BLOCK a.
PARAMETER: p_vbeln LIKE vbrp-vbeln OBLIGATORY MATCHCODE OBJECT vmcf. "Billing document No
"SELECT-OPTIONS s_bukrs FOR bkpf-bukrs. "Company Code
SELECTION-SCREEN END OF BLOCK a.
*itab is object of our smart form structre
DATA: itab TYPE zsd_invoice OCCURS 0 WITH HEADER LINE.
DATA: wa_footer TYPE zsd_invv1.
DATA: t_items TYPE zsd_inv WITH HEADER LINE,
w_items TYPE LINE OF zsd_inv,
it_footer TYPE zsd_inv1,
w_footer TYPE LINE OF zsd_inv1.
DATA: amountspell LIKE spell.
DATA: g_fm_name TYPE rs38l_fnam.
DATA: mnumvflag(10) TYPE c.
DATA: coun TYPE i,
totalforitems TYPE kwert,
lasttotal(8) TYPE p DECIMALS 2,
lasttotalc(11) TYPE c,
firstpart(11) TYPE c,
secondpart(2) TYPE c.
DATA: currency TYPE waerk.
DATA: currtxet(50) TYPE c.
*Header internal table
DATA: BEGIN OF t_header OCCURS 0,
vbeln LIKE vbrk-vbeln,"Document no
name1 LIKE kna1-name1,"Customer Name
adrnr LIKE kna1-adrnr,"Customer Address
bstkd LIKE vbkd-bstkd,"
kunnr LIKE kna1-kunnr,"Customer Account no
waerk LIKE vbrk-waerk, "currency key
aubel LIKE vbrp-aubel,
kunrg LIKE vbrk-kunrg,
street LIKE adrc-street,
fkart LIKE vbrk-fkart,
lgort LIKE lips-lgort,"Stord bin
lgobe LIKE t001l-lgobe,
ktokd LIKE kna1-ktokd,
PSTYV LIKE vbrp-PSTYV,
orgbil LIKE vbfa-vbelv,
END OF t_header.
*detail internal table
DATA: BEGIN OF t_items1 OCCURS 0,
matnr LIKE vbrp-matnr,"Material Number
posnr LIKE vbrp-posnr,
vgpos LIKE vbrp-vgpos,
maktx LIKE makt-maktx,"Material Description
lgort LIKE vbrp-lgort,"Storage location
fkimg LIKE vbrp-fkimg,"
knumv LIKE vbrk-knumv,"
unitprice LIKE konv-kawrt,
total LIKE konv-kawrt,
waers LIKE konv-waers,
kkurs LIKE konv-kkurs,
vgbel LIKE vbrp-vgbel,
lgpbe LIKE lips-lgpbe,
vgtyp LIKE vbrp-vgtyp,
END OF t_items1.
DATA: v_belnr TYPE belnr_d.
*Unit price internal table
DATA: BEGIN OF t_untprice OCCURS 0,
kschl LIKE konv-kschl,"condition type
kawrt LIKE konv-kawrt,"unit price
END OF t_untprice.
*Condition(spcial deduction)
DATA: BEGIN OF t_spcialcnd OCCURS 0,
kschl LIKE konv-kschl,"condition type
kwert LIKE konv-kwert,"Deduction value
END OF t_spcialcnd.
DATA: t_tax LIKE TABLE OF t_spcialcnd WITH HEADER LINE,
v_tax LIKE konv-kwert.
DATA: BEGIN OF t_curtxt OCCURS 0,
ltext LIKE tcurt-ltext,
END OF t_curtxt.
DATA :return_code TYPE i," VALUE 999,
us_screen TYPE c. "VALUE 'X'.
declaration of data
INCLUDE rlb_invoice_data_declare.
definition of forms
INCLUDE rlb_invoice_form01.
INCLUDE rlb_print_forms.
START-OF-SELECTION.
"IF p_vbeln IS NOT INITIAL.
PERFORM entry USING return_code us_screen.
"ENDIF.
FORM ENTRY
FORM entry USING return_code us_screen.
DATA: lf_retcode TYPE sy-subrc.
CLEAR retcode.
xscreen = us_screen.
perform processing using us_screen
changing lf_retcode.
if lf_retcode ne 0.
return_code = 1.
else.
return_code = 0.
endif.
IF p_vbeln IS INITIAL.
p_vbeln = nast-objky.
ENDIF.
"get header data
SELECT SINGLE vbrk~vbeln vbrk~waerk vbrp~aubel vbrk~kunrg vbrk~fkart vbrp~lgort vbrp~PSTYV
INTO (t_header-vbeln, t_header-waerk, t_header-aubel, t_header-kunrg, t_header-fkart,
t_header-lgort, t_header-PSTYV)
FROM vbrk JOIN vbrp ON vbrp~vbeln = vbrk~vbeln
JOIN kna1 ON vbrk~kunrg = kna1~kunnr
WHERE vbrk~vbeln = p_vbeln.
IF t_header-PSTYV = 'ZREN'.
SELECT SINGLE VBELV
INTO t_header-orgbil
FROM vbfa
WHERE vbeln = p_vbeln
and VBTYP_V = 'M'.
ENDIF.
SELECT SINGLE t001l~lgobe
INTO t_header-lgobe
FROM t001l
WHERE t001l~lgort = t_header-lgort.
SELECT SINGLE kna1~name1 kna1~adrnr kna1~kunnr kna1~ktokd
INTO (t_header-name1, t_header-adrnr, t_header-kunnr, t_header-ktokd)
FROM kna1 "ON vbrk~kunrg = kna1~kunnr
WHERE kna1~kunnr = t_header-kunrg
AND spras = 'AR'.
IF t_header-name1 IS INITIAL.
SELECT SINGLE kna1~name1 kna1~adrnr kna1~kunnr kna1~ktokd
INTO (t_header-name1, t_header-adrnr, t_header-kunnr, t_header-ktokd)
FROM kna1 "ON vbrk~kunrg = kna1~kunnr
WHERE kna1~kunnr = t_header-kunrg
AND spras = 'EN'.
ENDIF.
IF t_header-ktokd = 'ZONE'.
SELECT SINGLE belnr
INTO v_belnr
FROM bkpf
WHERE xblnr = p_vbeln.
SELECT SINGLE name1
INTO t_header-name1
FROM bsec
WHERE belnr = v_belnr.
ENDIF.
SELECT SINGLE adrc~street
INTO t_header-street
FROM adrc
WHERE addrnumber = t_header-adrnr
AND langu = 'AR'.
IF t_header-street IS INITIAL.
SELECT SINGLE adrc~street
INTO t_header-street
FROM adrc
WHERE addrnumber = t_header-adrnr
AND langu = 'EN'.
ENDIF.
"get details data
SELECT vbrp~matnr vbrp~posnr vbrp~vgpos vbrp~fkimg
vbrk~knumv vbrp~matnr vbrp~vgbel vbrp~vgtyp"makt~maktx
INTO CORRESPONDING FIELDS OF TABLE t_items1
FROM vbrp "JOIN makt ON vbrp~matnr = makt~matnr
JOIN vbrk ON vbrp~vbeln = vbrk~vbeln
"join konv on vbrk~knumv = konv~knumv
WHERE vbrp~vbeln = p_vbeln
AND vbrp~fkimg NE '0.000'.
"AND makt~spras = 'E'.
break arasmy.
LOOP AT t_items1.
SELECT SINGLE lips~lgpbe
INTO t_items1-lgpbe
FROM lips
WHERE vbeln = t_items1-vgbel
AND posnr = t_items1-vgpos.
SELECT SINGLE makt~maktx
INTO t_items1-maktx
FROM makt
WHERE matnr = t_items1-matnr
AND makt~spras = 'EN'.
SELECT SINGLE konv~kbetr konv~kwert konv~waers konv~kkurs
INTO (t_items1-unitprice, t_items1-total, t_items1-waers,
t_items1-kkurs)
FROM konv
WHERE konv~kschl = 'NETW'"'ZSPC' "'ZSP1'
AND konv~knumv = t_items1-knumv
AND kposn = t_items1-posnr.
t_items1-unitprice = ( t_items1-total / t_items1-fkimg ) * t_items1-kkurs.
MODIFY t_items1.
mnumvflag = t_items1-knumv."Number of the document condition
ENDLOOP.
*get the deduction value for the document condiotion no
SELECT konvkschl konvkwert
INTO CORRESPONDING FIELDS OF TABLE t_spcialcnd
FROM konv
WHERE konv~kschl IN ('ZSSD', 'ZSCD', 'ZSDD', 'ZSPD', 'ZSWD', 'ZMW1', 'ZSGS', 'ZMW2')
AND konv~knumv = mnumvflag.
Get tax 10%
SELECT konvkschl konvkwert
APPENDING CORRESPONDING FIELDS OF TABLE t_tax
FROM konv
WHERE konv~kschl = 'MWST'
AND konv~knumv = mnumvflag.
itab-invn = t_header-vbeln.
itab-orgbil = t_header-orgbil.
itab-cusna = t_header-name1.
itab-addr = t_header-street.
itab-custn = t_header-kunrg.
itab-sord = t_header-aubel.
itab-fkart = t_header-fkart.
itab-lgort = t_header-lgort.
itab-lgobe = t_header-lgobe.
itab-PSTYV = t_header-PSTYV.
currency = t_header-waerk.
LOOP AT t_items1.
w_items-matn = t_items1-matnr.
w_items-matdes = t_items1-maktx.
w_items-stloc = t_items1-lgpbe."lgort.
w_items-qunt = t_items1-fkimg.
w_items-total = t_items1-total.
totalforitems = totalforitems + w_items-total.
COLLECT w_items INTO t_items.
endloop.
LOOP AT t_items1.
LOOP AT t_items WHERE matn = t_items1-matnr.
t_items-prc = t_items1-unitprice.
MODIFY t_items.
ENDLOOP.
ENDLOOP.
LOOP AT t_items.
coun = coun + 1.
t_items-itmn = coun.
MODIFY t_items.
ENDLOOP.
w_footer-totalforitems = totalforitems.
LOOP AT t_spcialcnd.
CASE t_spcialcnd-kschl.
WHEN 'ZSSD'.
w_footer-spdisc = w_footer-spdisc + t_spcialcnd-kwert.
WHEN 'ZSCD'.
w_footer-comdisc = w_footer-comdisc + t_spcialcnd-kwert.
WHEN 'ZSDD'.
w_footer-DIFMAT = w_footer-DIFMAT + t_spcialcnd-kwert.
when 'ZSPD'.
w_footer-trgtdisc = w_footer-trgtdisc + t_spcialcnd-kwert.
WHEN 'ZMW2'.
w_footer-comindisc = w_footer-comindisc + t_spcialcnd-kwert.
WHEN 'ZSWD'.
w_footer-cshdisc = w_footer-cshdisc + t_spcialcnd-kwert.
WHEN 'ZSGS'.
w_footer-stampsdisc = w_footer-stampsdisc + t_spcialcnd-kwert.
ENDCASE.
w_footer-ttldisc = w_footer-spdisc + w_footer-comdisc + w_footer-trgtdisc
+ w_footer-cshdisc + w_footer-DIFMAT + w_footer-stampsdisc.
ENDLOOP.
w_footer-aftrdiscnts = w_footer-totalforitems + w_footer-ttldisc.
LOOP AT t_tax WHERE kwert NE '0.00'.
w_footer-saltax = w_footer-saltax + t_tax-kwert.
ENDLOOP.
w_footer-totalaftrtax = w_footer-aftrdiscnts + w_footer-saltax.
w_footer-total = w_footer-totalaftrtax + w_footer-comindisc.
lasttotal = w_footer-total.
APPEND w_footer TO it_footer.
SELECT tcurt~ltext
INTO CORRESPONDING FIELDS OF TABLE t_curtxt
FROM tcurt
WHERE tcurt~spras = 'AR'
AND tcurt~waers = currency.
LOOP AT t_curtxt.
currtxet = t_curtxt-ltext.
ENDLOOP.
itab[] = t_header[].
lasttotalc = lasttotal.
SPLIT lasttotalc AT '.' INTO firstpart secondpart.
lasttotal = firstpart / 100.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
amount = lasttotal
currency = ''"CURRENCY
filler = space
language = 'A'
IMPORTING
in_words = amountspell
EXCEPTIONS
not_found = 1
too_large = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
--split amount--
BREAK radha.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_INVOICE_PARTS2'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = g_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DATA : control_parameters TYPE ssfctrlop,
print_options TYPE ssfcompop.
DATA : document_output_info TYPE ssfcrespd,
job_output_info TYPE ssfcrescl,
job_output_options TYPE ssfcresop.
DATA : count TYPE i.
control_parameters-langu = 'AR'.
control_parameters-no_dialog = 'X'."Don't show Dialog
print_options-tdarmod = '1'.
print_options-tdcopies = '001'.
print_options-tddest = 'LP02'.
print_options-tdprinter = 'ZARSWIN'.
print_options-tdimmed = 'X'.
print_options-tddelete = 'X'.
print_options-tdlifetime = '8'.
print_options-tddest = 'LP03'."nast-ldest.
"print_options-tddest = nast-ldest.
"print_options-tdcopies = pv_copies.
print_options-tddelete = 'X'.
print_options-tdfinal = 'X'.
print_options-tdnewid = 'X'.
WHILE count ne 1.
IF job_output_info-outputdone ne 'X'.
CALL FUNCTION g_fm_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
control_parameters = control_parameters
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
output_options = print_options
user_settings = space
header = itab
amountspell = amountspell
currtxt = currtxet
secondpart = secondpart
wa_footer = w_footer
IMPORTING
DOCUMENT_OUTPUT_INFO = document_output_info
JOB_OUTPUT_INFO = job_output_info
JOB_OUTPUT_OPTIONS = job_output_options
TABLES
it_items = t_items
it_footer = it_footer
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
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. "ENTRYHi,
lw_control_param-device = 'PRINTER'.
lw_control_param-getotf = c_x.
lw_control_param-no_dialog = c_x.
lw_composer_param-tdnoprev = c_x.
<b>*lw_composer_param-tddest = 'LONSC0P310'.</b>
<b>lw_composer_param-tddest = 'XXXX'.</b> <b>"Four digits</b>
<i>lw_composer_param-tdnewid = c_x.
lw_composer_param-tdfinal = c_x.</i> --> Not required
In place of 'XXXX', replace it by a 4 digit value. It would be available in transaction SPAD->Output Devices->Double click your output device. On the right hand side there would be a field Short Name. Replace 'XXXX' with that value.
Best regards,
Prashant -
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 -
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). -
Background Job is not creating the List ID
Hello Experts,
I am scheduling a program as a Background Job. When I go and check the tables TBTCP & TBTCO, I see the List ID field (TBTCP-LISTIDENT or TBTCO-LISTIDENT) value as 0 .
Hence I am not able to get the Spool ID for this List.
Can anybody please let me know what is the problem?
Thanks a lot.Hi,
See, if this piece of code can help you.
data: sdate type sy-datum,
stime type sy-uzeit,
l_valid,
ls_params like pri_params,
l_jobcount like tbtcjob-jobcount,
l_jobname like tbtcjob-jobname.
start-of-selection.
Get Print Parameters
call function 'GET_PRINT_PARAMETERS'
exporting
no_dialog = 'X'
importing
valid = l_valid
out_parameters = ls_params.
Open Job
l_jobname = 'THIS_JOB'.
call function 'JOB_OPEN'
exporting
jobname = l_jobname
importing
jobcount = l_jobcount.
Submit report to job
submit <your_program_name
via job l_jobname
number l_jobcount
to sap-spool without spool dynpro
spool parameters ls_params
and return.
Kick job off 10 seconds from now.
sdate = sy-datum.
stime = sy-uzeit + 10.
Schedule and close job.
call function 'JOB_CLOSE'
exporting
jobcount = l_jobcount
jobname = l_jobname
sdlstrtdt = sdate
sdlstrttm = stime.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Mar 3, 2008 11:09 AM
Maybe you are looking for
-
Audio needs to be rendered every time
I did a project this week which required me to change my sequence settings to PAL, 44.1KHz audio. I since changed back the sequence settings to easy setup DV NTSC, so I shouldn't have any problem with new sequences. Even so, any time I drop a QT movi
-
Preview will not work. Have to force quit it. Will not work on Jpg or pdf
I tried sending the preview.plist to the trash and restarting the computer. It worked for a short time, now is back not working again. Could not find the file except in the trash. Any ideas how to fix? This has happened once before and it just starte
-
Email notification not received
We have a incident that user and admin is not received the email notification to lotus notes id.other users receiving the notifications from the same application.Same user and admin receiving mails from other applications SWI1 no error but in SOST th
-
WebAS 640 DO_INIT always called
Hi Guys, I got a little problem with an MVC-BSP application. The application consists of one maincontroller and several subcontrollers. When being started Do_Init is being called on all of them, which is fine so far. When I now click a link, or press
-
Relation type 'is purchaser of'
Dear SAP experts, I'm interested to see that it is possible in SRM to make assignment to organization to be more flexible as in this link http://help.sap.com/saphelp_srm50/helpdata/en/2c/867d3ca2156c6ae10000000a114084/content.htm We think that we can