Add statement to report output to CSV
We have just been told that we need to include a canned statement on all of our reports or documents that are generated from our database. We use APEX and a lot of our users love the download to CSV function that it offers because of the flexibility it provides them. Is there a way to add a header field to these types of reports so we can fill this request?
We have just been told that we need to include a canned statement on all of our reports or documents that are generated from our database. We use APEX and a lot of our users love the download to CSV function that it offers because of the flexibility it provides them. Is there a way to add a header field to these types of reports so we can fill this request?
Similar Messages
-
How to get Report Output in csv format
Hi,
How can i get report Output in csv format, can any one tell me the word used for output type to get output in csv format.
i have used XLS output type but it opens in excel format.
conc.addLayout(appCode,concReqCode,"en-US","US",XLS);
Thanks
BabuHi Babu,
Till now in xmlpublisher there is no method to create file in csv format ,you have to create Excel file and then save it in .csv format.Unless and until ur using BI Publisher in which some work around are possible.
Thanks -
Intrastat - Add fields in report output - VE01
Hi Friends,
I do not see import output fields like mode of transport, COO, material No, etc in VE01 intrasta report output. Is there any configuration to add required output fileds. In the select laout also we do not have these fields except there in VEIAV table
early respinse appreciated
Thanks,Hi,
Your question is already answered here:
[VE01 - User exit and BADI ?;
This can be done through screen exit in SMOD/CMOD enhancement RVEXAKK1
BR,
Barna -
Add Journal Entries Report - Output to Request Set
Hi All,
I'm trying to create a Request Set for the receivable application
The request set should contains two Programs
1- AR: Journal Entries Report
2- Journal Entries Report - Output
I defined the request set and when i start adding the programs , i selected the first program AR: Journal Entries Report from the list and gave it sequence 10
when i tried to add the other Report "Journal Entries Report - output" i didn't find it in the list and i'm not able to add it
1-Do any one know why this program doesn't appeat in the list ?
2- If i created a copy of this program and gave it other name , this program in the definition doesn't have any parameters although a parameters must be passed to it from the first request AR : Journal Entries report. how to pass parameters from the first program to it
Best Regardsnuppara,
I need to add this report to the request set as it's a workaround to get the output of the AR: Journal Entries Report as Excel - I created a post asking this question also , u already replied to it.
My workaround is like this , the AR: journal Entries Report automatically sumbit the program "Journal Entries Report - Output" based on the parameters that the user select
Print Detail By Account , Print Detail By Category , Print Summary By Account , Print Summary By Category
if i want to to make this report to be an Excel output so i'll have to create 4 templates but won't be able to assign the correct template to it , as the main request AR: journal Entries report calls it automaticcaly, and may run it 4 times
so my workaround was like this
i'll create 4 request sets ,
the first RS will be for example AR: journal Entries Detail By Account, i'll add to it 2 programs the AR: journal Entries Report , and the Journal Entry Report - output -OR a program copied from it with the same design and i'll add parameters to it-
i'll force the parameters of the AR: Journal Entries in this request set to be Print Detail By Account = 'Y' and the other options = 'N' so the report will call Journal Entry Report - output with the parmeter layout= 'Print Detail By Account ' will be displayed as text ... when it finish the request set will run the Journal Entry Report - output -OR the copied program - that i'll assign the correct template and data definition for it, so it'll run and display the output as Excel .
I need to try this solution, but i was not able to add the journal Entries Report - Output to the request set :( and i'm not sure if i'll create a copy from it will be added or not,
and also i'm not sure if this workaround may work , as i know when the AR: Journal Entires report complete it delete the data from the temp table so the 2nd request may work on an empty table , or it'll have a request_id different from the request_id of the temp table so it won't select any row
all of this is just a brain storming to find the solution. :( i'm thinking by a loud voice here :-D
i know it may not work but at least to try it i need to add this report to the request set. -
How to generate report output in csv file and send it to user email inbox
Hi All,
We have requiremnt to generate the csv file from the report (Bex query)automatically and need to send that file automatically to user email address every week.
It should be done automatically and one more thing the file name should contain that particuar date
for example if we generate file automatically today the file name should be like below.
US_04_15_2009.CSV
Any one have any ideas?
Regards,
SirishaHi Arun Varadarajan.
Thanks for your reply.We are in BI 7.0.Can you tell me how to broadcast the query as CSV.Please let me know if there is any possiblity to display or change the file name dynamically based on system date.
Regards,
Sirisha
Edited by: sirisha Nekkanti on Apr 16, 2009 4:08 AM -
Can we add links to perform editing, modify properties in KM Report output?
Hello,
I have created KM report which provides list of XML forms which satisfy specific conditions. Now I want to add links on report output so that user can click on that link and can directly start editing documents if needed. Also I want to provide direct link which can open properties of document.
Also can we add images/ icons on a particular row like traffic lights icons: Green, Yellow, Red.
Thank you,
Nitesh ShelarI have another question related to following class may be that can put more light on my base requirement. I am creating Result item object based on details I found on various KM articles for KM reports. I wonder what is that List executedCommands, object.
public static ResultItem getInstance(RID rid,
Map properties,
List executedCommands,
boolean hadError,
String statusDescription)
Can any one tell me about this List executedCommands and what exactly I should pass there and how it is going to affect my output? -
Add CSV file as Scheduled Report Output Format
Is there any option in BOXI R2 and R3 - Add CSV file as Scheduled Report Output Format. If not, how do we achieve this?
Hai
http://www.christiansteven.com/products/crd/
http://webtrends.dbt.co.uk/wrc/help/webhelp/hlp_exrpt.htm
http://www.businessobjectstips.com/tips/infoview/business-objects-cannor-not-create-an-excel-file/ -
Report output Export to CSV issue
Hi Experts,
I have a Bex Query. After running the report when I export the report in CSV format using "Export to CSV" from the report output screen, the data
is being dumped in different columns And when i try to convert that particular CSV file to Excel as we can only select one single column for delimiting the values using a separator into different cells the data in the other column is being truncated.
Kindly suggest me how to resolve this.
Thanks in Advance,
SushmaHi,
(If anything else on the BW side doesn't help).
Not so long ago I had a similiar problem all data (originally taken from several columns) were in one column - solved it with the help of VB coding.
Sth like this could help you.
Regards, Leszek
Dim tekst As String
last_row = Selection.SpecialCells(xlCellTypeLastCell).Row
Range("A1:Z" & last_row).Select
Cells.Select
Selection.NumberFormat = "@"
For wiersz = 1 To last_row
Cells(wiersz, 1).Select
tekst = Selection.Value
Cells(wiersz, 1).Value = Left(tekst, 21)
Cells(wiersz, 2).Value = Right(Left(tekst, 27), 6)
Cells(wiersz, 3).Value = Right(Left(tekst, 37), 10)
Cells(wiersz, 4).Value = Right(Left(tekst, 50), 13)
Next wiersz -
How to send report output from SUBMIT statement
Hi,
I need to develop one report whcih can be use to send any report output in mail as attachment in txt of execl format. So i will be using SUBMIT statement to execute the report in my new report and i need to convert the reportout in txt or excel format and need to send as attachment in mail. This new report can be use to execute any report which may have ALV GRid, Normal outout screen. So what could be the best way to develop this kind of report.
Br,
Piyush>
piyush mathur wrote:
> Hi Suhas,
>
> LIST_TO_ASCI will give me data in lines. and its difficult to separate the columns in another internal table for attachment file. As this report is going to use to send any report output so i can not fixed the delimiter. So i am looking some function which can split the data in columns when I am reading from List.
> Br,
> Piyush
No need to seperate nothing additionally, this will come automatically in the attached file. Draft below
DATA list_tab TYPE TABLE OF abaplist.
SUBMIT your_report EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = list_tab
EXCEPTIONS
not_found = 1
OTHERS = 2.
DATA string_tab TYPE list_string_table.
"use table type appropriate for attchement
DATA ascii_tab TYPE soli_tab.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = ascii_tab
listobject = list_tab.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\test.txt'
filetype = 'ASC'
TABLES
data_tab = ascii_tab.
DATA go_email_doc TYPE REF TO cl_document_bcs.
go_email_doc = cl_document_bcs=>create_document(
i_type = 'TXT'
go_email_doc->add_attachment( i_attachment_type = 'TXT'
i_attachment_subject = 'My Attachment'
i_att_content_text = ascii_tab ).
Regards
Marcin -
Add new field in CMP9 transaction report output
Hi,
I want to add a new field in the CMP9 transaction report output. Is there any way ?
Thanks,
FractHi,
BADI: CYMP_MODIFY_DISPLAY Change of Work Distribution to Personnel Resource Output -
Hi Experts,
How to add additional field into output table VENDORS/WH TAX TYPES AND CODES in RFIDYYWT(Generic Withholding Tax Reporting).
I have no idea how to start with, please give some advice.
Thanks!
IceDear Ice,
Use Append structure, see given link:
https://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eb61446011d189700000e8322d00/content.htm
Regards,
Abbas. -
Saving a CSV report output as TXT file
Hi,
We are generating reports on the web using Intenet Explorer. The report is a CSV report, i.e. the data displayed is comma separated. After generating the report, we need to save it as TXT file.
If the length of a line is long (let us say more than 80 chars) while saving it as TXT file, it is saving as 2 lines. If the length of a line is less, then it is saving in a single line.
How can I avoid this 2 line problem?
I am not facing this problem if I generate report with Netscape browser and save as TXT file.
We are using Reports 6i.
Thanks in Advance,
SrinivasHello,
I had the same problem. And I think what I did to fix it is I made the mode=charcter, batch=yes, and background=yes. Hope this helps.
Martin -
ABAP Dump while Changing the Layout fields in Report output - RCOPCA02
Hi,
I Copied the Standard Program RCOPCA02 to ZRCOPCA02. I added two new fields(AUART, AUGRU) in the report output. It is executing correctly with default layout, While Changing the layout for displaying new fields it is dumping.
I am not understanding, What should i do...
Here is the Code.
report ZRCOPCA02 no standard page heading message-id km
line-count (2) line-size 81.
type-pools: slis, ecarc.
DDIC-Tabellen *******************************************************
tables: glpca, "Einzelposten / Ist
glu1, "Übergabestruktur FI-SL-Anzeige
t000,
tka01,
sscrfields,
vbak.
Variablen und int. Tabellen *****************************************
data: l_vbeln like vbak-vbeln,
l_auart like vbak-auart,
l_augru like vbak-augru.
data: afield type slis_fieldcat_alv,
sp_group type slis_sp_group_alv,
t_listheader type slis_t_listheader with header line,
t_layout type slis_layout_alv,
t_fieldcat type slis_t_fieldcat_alv,
t_spec_groups type slis_t_sp_group_alv,
event type slis_alv_event,
t_events type slis_t_event,
g_variant like disvariant,
gx_variant like disvariant,
g_exit(1) type c,
g_save(1) type c,
g_repid like sy-repid,
msgtyp like sy-msgty,
lt_dynpread like dynpread occurs 1 with header line,
ls_rpcak like rpcak, "note 0310592
packsize type i value 1000,
text1(60) type c,
text2(60) type c,
oldkokrs like glpca-kokrs,
oldracct like glpca-racct.
data: whr_size type i value 50,"Maximum of single values per MIC 46a
"charact. in the where-clause of the select-statement
lines type i, "number of lines of range table MIC 46a
cnt_rldnr type i, "Zähler Anzahl selektierter Ledger
cnt_kokrs type i, "Zähler Anzahl selektierter KoReKreise
cnt_poper type i, "Zähler Anzahl selektierter Perioden
cnt_ryear type i, "Zähler Anzahl selektierter GeschJahre
cnt_rvers type i, "Zähler Anzahl selektierter Versionen
cnt_bukrs type i, "Zähler Anzahl selektierter BuKreise
empge like dkobr-empge,
ksl_curr like tka01-pcacur,
hsl_curr like t001-waers,
a_rec like rstirec.
data: begin of dim_data.
include structure rgcdi. "data for dimensions
data: end of dim_data.
data: begin of tab_fields occurs 80,
name like dntab-fieldname, "fields in table i_glpca
end of tab_fields.
data: begin of i_glpca occurs 0.
include structure rpca2.
data: racct_ktext like rpcak-ktext,
psppp like prps-posid,
v_auart like vbak-auart,
v_augru like vbak-augru,
end of i_glpca.
data: rw_subrc like sy-subrc, "Flag: Report-Writer-Schnittstelle
re_subrc like sy-subrc, "Flag: Recherche-Schnittstelle
subrc like sy-subrc.
data: set_id like sethier-setid, "Set-ID "RDI_SETS_4.0
set_class like sethier-setclass, "Setklasse "RDI_SETS_4.0
set_sname like sethier-shortname."Setname (24) "RDI_SETS_4.0
data: authorised(1),
s_message(1),
auth_dbcount like sy-tabix,
Hex-Konstanten für Minimum/Maximum-Werte
begin of hex00,
x1(12) type c,
x2(12) type c,
end of hex00,
begin of hexff,
x1(12) type c,
x2(12) type c,
end of hexff.
ranges rclnt for glpca-rclnt.
field-symbols: type ecarc_glpca_curr.
Selektionsoptionen *************************************************
select-options:
rldnr for glpca-rldnr default '8A' no-display,
rassc for glpca-rassc no-display,
rrcty for glpca-rrcty default 0,
rrcty for glpca-rrcty,
rvers for glpca-rvers default '000',
kokrs for glpca-kokrs memory id cac,
bukrs for glpca-rbukrs memory id buk,
poper for glpca-poper default sy-datlo+4(2),
ryear for glpca-ryear default sy-datlo,
poper for glpca-poper,
ryear for glpca-ryear,
prctr for glpca-rprctr matchcode object prct,
pprctr for glpca-sprctr matchcode object prct,
RACCT FOR GLPCA-RACCT MATCHCODE OBJECT KART, "RD_P30K128304
racct for glpca-racct, "RD_P30K128304
drcrk for glpca-drcrk,
activ for glpca-activ,
rhoart for glpca-rhoart,
rfarea for glpca-rfarea,
stagr for glpca-stagr,
rtcur for glpca-rtcur,
runit for glpca-runit,
versa for glpca-versa no-display,
eprctr for glpca-eprctr no-display,
afabe for glpca-afabe no-display,
rmvct for glpca-rmvct no-display,
hrkft for glpca-hrkft no-display, "note 550972
sbukrs for glpca-sbukrs no-display, "note 550972
shoart for glpca-shoart no-display, "note 550972
sfarea for glpca-sfarea no-display, "note 550972
docct for glpca-docct,
docnr for glpca-docnr,
refdocct for glpca-refdocct,
refdocnr for glpca-refdocnr,
werks for glpca-werks,
repmatnr for glpca-rep_matnr matchcode object pca_shlp_rep_matnr,
rscope for glpca-rscope.
parameters: no_rrint no-display default ' '." skip "MICP40K066037
" report-report-interface
display variant ">>MICP40K039857
selection-screen begin of block 0 with frame title text-e01.
parameters: p_vari like disvariant-variant.
selection-screen comment 47(40) varname for field p_vari.
selection-screen end of block 0.
parameters log_grp(4) type c no-display default 'KE5Z'.
"<<MICP40K039857
ranges: v_racct for glpca-racct,
v_prctr for glpca-rprctr,
v_pprctr for glpca-sprctr.
Tabelle mit Werten aus den Berichts-Set vom Report-Writer *
data begin of val_tab occurs 50.
include structure rgciv.
data end of val_tab.
MICP30K166368
feldkatalog und interface für bb-schnittstelle rw MICP30K166368
MICP30K166368
"MICP30K166368
data begin of bbs_fieldtab occurs 20. "MICP30K166368
include structure rstifields. "MICP30K166368
data end of bbs_fieldtab. "MICP30K166368
archiv
type-pools: rsds.
types: begin of ty_archive_objects,
object like arch_obj-object,
end of ty_archive_objects,
ty_t_archive_objects type ty_archive_objects occurs 2.
constants: lc_set type c value 'X',
lc_report type progname value 'KE5Z',
lc_reporttype type reporttype value 'TR'.
tables: admi_files.
select-options lr_files for admi_files-archiv_key no-display.
parameter: read_db type c default 'X' no-display,
read_ar type c no-display,
arc_obj like arch_obj-object no-display,
read_as type c default 'X' no-display.
data : lt_arch_obj type ty_t_archive_objects with header line,
ls_selections type rsds_frange,
lt_selections type rsds_frange_t,
ls_selopt type rsdsselopt,
lt_glpca_archiv type ecarc_t_glpca_curr.
*********************************************************>>MICP40K039857
INITIALIZATION
initialization.
Diverse Initialisierungen
perform init_vars.
g_repid = sy-repid.
Set default values for record type
rrcty-sign = 'I'.
rrcty-option = 'EQ'.
rrcty-low = '0'.
append rrcty.
rrcty-low = '2'.
append rrcty.
Set default values for period and year (if kokrs or bukrs is known)
get parameter id 'BUK' field bukrs-low.
get parameter id 'CAC' field kokrs-low.
if kokrs-low is initial "get contr. area from company code
and not bukrs-low is initial.
call function 'KOKRS_GET_FROM_BUKRS'
exporting
i_bukrs = bukrs-low
importing
e_kokrs = kokrs-low
exceptions
no_kokrs_found = 1
others = 2.
if sy-subrc <> 0.
clear kokrs-low.
endif.
endif.
if not kokrs-low is initial.
call function 'K_KOKRS_READ' "get fiscal year variant
exporting
kokrs = kokrs-low
importing
e_tka01 = tka01
exceptions
not_found = 1
not_found_gjahr = 2
others = 3.
if sy-subrc = 0.
call function 'G_PERIOD_GET'
exporting
date = sy-datlo
variant = tka01-lmona
importing
period = poper-low
year = ryear-low
exceptions
ledger_not_assigned_to_company = 1
period_not_defined = 2
variant_not_defined = 3
others = 4.
if sy-subrc = 0.
poper-sign = 'I'.
poper-option = 'EQ'.
append poper.
ryear-sign = 'I'.
ryear-option = 'EQ'.
append ryear.
endif.
endif.
endif.
Settings for display variants
g_save = 'A'. "Schalter Varianten benutz./allg. speichern
clear g_variant.
g_variant-report = g_repid.
g_variant-log_group = log_grp.
g_variant-username = sy-uname.
Get default variant
gx_variant = g_variant.
call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
exporting
i_save = g_save
changing
cs_variant = gx_variant
exceptions
not_found = 2.
if sy-subrc = 0.
p_vari = gx_variant-variant.
endif.
Set variant
if p_vari is initial.
p_vari = '1SAP'.
move p_vari to gx_variant-variant.
call function 'REUSE_ALV_VARIANT_EXISTENCE'
exporting
i_save = g_save
changing
cs_variant = gx_variant
exceptions
not_found = 1.
if sy-subrc ne 0.
clear p_vari.
clear gx_variant-variant.
endif.
endif.
varname = gx_variant-text.
"<<MICP40K039857
archiv
call function 'KARL_DATA_INPUT_INIT'
exporting
i_report = lc_report
i_reporttype = lc_reporttype
importing
e_xusedb = read_db
e_xusear = read_ar
e_archobj = arc_obj
e_infosys = read_as
tables
t_arch_sel = lr_files.
data: lt_excluding like sy-ucomm occurs 0 with header line.
call function 'RS_SET_SELSCREEN_STATUS'
exporting
p_status = 'SELSCREEN'
p_program = 'RCOPCA02'
tables
p_exclude = lt_excluding.
Initialisieren der Bericht/Bericht-Schnittstellen *
data: ld_no_rrint type boole_d. "note 490484 begin
import rri = ld_no_rrint from memory id 'RCOPCA02_NO_RRI'.
if ld_no_rrint = 'X'.
free memory id 'RCOPCA02_NO_RRI'.
else. "note 490484 end
call function 'G_REPORT_INTERFACE_INIT' "Report-Writer?
exporting "MICP30K166368
table = 'GLPCT' "MICP30K166368
importing
subrc = rw_subrc "MICP30K166368
tables "MICP30K166368
it_fieldr = bbs_fieldtab. "MICP30K166368
call function 'RSTI_APPL_STACK_POP'"oder Recherche?
importing
i_rec = a_rec
exceptions
appl_stack_not_initialized = 1.
re_subrc = sy-subrc.
if re_subrc = 0.
check Receiver is this report
if not ( ( a_rec-rtool = 'RT' and a_rec-ronam = 'RCOPCA02' )
or ( a_rec-rtool = 'TR' and a_rec-ronam = 'KE5Z' ) ) .
re_subrc = 2.
endif.
endif.
endif.
AT SELCTION-SCREEN on value request**********************************
*at selection-screen on value-request for racct-low. "RD "4.6a
"RD "4.6a
call function 'K_RACCT_VALUE_REQUEST' "RD "4.6a
importing "RD "4.6a
e_racct = racct-low. "RD "4.6a
"RD "4.6a
"RD "4.6a
*at selection-screen on value-request for racct-high. "RD "4.6a
"RD "4.6a
call function 'K_RACCT_VALUE_REQUEST' "RD "4.6a
importing "RD "4.6a
e_racct = racct-high. "RD "4.6a
at selection-screen on value-request for p_vari. "MICP40K039857
perform f4_for_variant. "MICP40K039857
at selection-screen on value-request for poper-low. "RD "4.6a
begin of insertion note 522715
call function 'K_KOKRS_READ'
exporting
kokrs = kokrs-low
exceptions
not_found = 1
not_found_gjahr = 2
others = 3.
if sy-subrc = 0.
end of insertion note 522715
call function 'ECPCA_RPMAX_VALUE_REQUEST' "RD "4.6a
exporting "RD "4.6a
i_kokrs = kokrs-low "RD "4.6a
i_ryear = ryear-low "RD "4.6a
importing "RD "4.6a
e_rpmax = poper-low "RD "4.6a
begin of insertion note 522715
exceptions
table_empty = 1.
endif.
end of insertion note 522715
at selection-screen on value-request for poper-high. "RD "4.6a
begin of insertion note 522715
call function 'K_KOKRS_READ'
exporting
kokrs = kokrs-low
exceptions
not_found = 1
not_found_gjahr = 2
others = 3.
if sy-subrc = 0.
end of insertion note 522715
call function 'ECPCA_RPMAX_VALUE_REQUEST' "RD "4.6a
exporting "RD "4.6a
i_kokrs = kokrs-low "RD "4.6a
i_ryear = ryear-low "RD "4.6a
importing "RD "4.6a
e_rpmax = poper-high "RD "4.6a
begin of insertion note 522715
exceptions
table_empty = 1.
endif.
end of insertion note 522715
AT SELCTION-SCREEN ***************************************************
at selection-screen.
perform pai_of_selection_screen.
begin of insertion note 522715
if not kokrs-low is initial.
call function 'K_KOKRS_READ'
exporting
kokrs = kokrs-low
exceptions
not_found = 1
not_found_gjahr = 2
others = 3.
if sy-subrc <> 0.
message e101(ki) with kokrs-low.
endif.
endif.
end of insertion note 522715
archiv
if sy-ucomm = 'FC01' or sy-ucomm = 'UCDS'
or sy-ucomm = 'ONLI' and read_ar = 'X'
and read_as is initial and lr_files[] is initial.
if lt_arch_obj[] is initial.
lt_arch_obj-object = 'PCA_OBJECT'. append lt_arch_obj.
lt_arch_obj-object = 'EC_PCA_ITM'. append lt_arch_obj.
endif.
call function 'KARL_DATA_INPUT_SELECT'
exporting
i_db_and_arc = lc_set
i_infosys_possible = lc_set
i_object_fixed = 'V'
i_documentation = 'KARL_DATA_INPUT_SEL_KE5YZ'
i_report = lc_report
i_reporttype = lc_reporttype
tables
t_objects = lt_arch_obj
t_arch_sel = lr_files
changing
c_xusedb = read_db
c_xusear = read_ar
c_archobj = arc_obj
c_infosys = read_as.
endif.
START-OF-SELECTION **************************************************
start-of-selection.
Default-Werte löschen, falls Aufruf über Recherche
oder Report-Writer erfolgt ist
if no_rrint is initial and ld_no_rrint is initial. "note 490484
if rw_subrc eq 0 or re_subrc eq 0.
refresh: rldnr, rrcty, rvers, kokrs, bukrs, poper, ryear,
racct, prctr, pprctr, drcrk, activ, rhoart, rfarea,
versa, afabe, eprctr,
v_racct, v_prctr, v_pprctr.
clear: rldnr, rrcty, rvers, kokrs, bukrs, poper, ryear,
racct, prctr, pprctr, drcrk, activ, rhoart, rfarea,
versa, afabe, eprctr,
v_racct, v_prctr, v_pprctr.
endif.
Parameter einlesen über Report-Writer-Schnittstelle *
if rw_subrc eq 0.
perform rw_get_parameters.
oder Parameter einlesen über Recherche-Schnittstelle *
elseif re_subrc eq 0.
perform re_get_parameters.
endif.
endif.
if read_db = 'X'. " read from DB (archiv)
Bewegungsdaten einlesen und puffern...................................
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = 'Einzelposten selektieren'(p10).
Use dirty trick to mislead DB-optimizer
call function 'DB_DO_NOT_USE_CLIENT_INDEX'
exporting
value = sy-mandt
tables
mandttab = rclnt.
select (tab_fields) from glpca
client specified
package size packsize
APPENDING CORRESPONDING FIELDS OF TABLE i_glpcaO
into corresponding fields of table i_glpca
where rldnr in rldnr
and rrcty in rrcty
and rvers in rvers
and kokrs in kokrs
and rbukrs in bukrs
and ryear in ryear
and rassc in rassc
and hrkft in hrkft "note 550972
and sbukrs in sbukrs "note 550972
and shoart in shoart "note 550972
and sfarea in sfarea "note 550972
and racct in racct
and rprctr in prctr
and sprctr in pprctr
and poper in poper
and drcrk in drcrk
and activ in activ
and rhoart in rhoart
and rfarea in rfarea
and versa in versa
and eprctr in eprctr
and afabe in afabe
and rmvct in rmvct
and docct in docct
and docnr in docnr
and stagr in stagr
and rtcur in rtcur
and runit in runit
and refdocct in refdocct
and refdocnr in refdocnr
and werks in werks
and rep_matnr in repmatnr "RDIP40K020663
and rscope in rscope "RDIP40K020663
and rclnt in rclnt. "dirty trick to mislead DB-optimizer
if sy-dbcnt > 1.
text1 = sy-dbcnt.
condense text1.
concatenate text1 text-m01 into text2 separated by space.
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = text2. " ... Datensätze gelesen
endif.
endselect.
Entfernt nicht zugehörige Einträge....................................
loop at i_glpca where ( not rprctr in v_prctr )
or ( not sprctr in v_pprctr )
or ( not racct in v_racct ).
delete i_glpca.
endloop.
endif.
*archiv
if read_ar = 'X' and not
( read_as is initial and lr_files[] is initial ).
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = 'Lesen im Archiv'(p12).
define fill_lt_selections.
if not &2[] is initial.
clear ls_selections.
move &1 to ls_selections-fieldname.
loop at &2.
clear ls_selopt.
move-corresponding &2 to ls_selopt.
append ls_selopt to ls_selections-selopt_t.
endloop.
append ls_selections to lt_selections.
endif.
end-of-definition.
fill_lt_selections 'RLDNR' rldnr.
fill_lt_selections 'RRCTY' rrcty.
fill_lt_selections 'RVERS' rvers.
fill_lt_selections 'KOKRS' kokrs.
fill_lt_selections 'RBUKRS' bukrs.
fill_lt_selections 'POPER' poper.
fill_lt_selections 'RYEAR' ryear.
fill_lt_selections 'RPRCTR' prctr.
fill_lt_selections 'SPRCTR' pprctr.
fill_lt_selections 'RACCT' racct.
fill_lt_selections 'DRCRK' drcrk.
fill_lt_selections 'ACTIV' activ.
fill_lt_selections 'RHOART' rhoart.
fill_lt_selections 'RFAREA' rfarea. "note 401961
fill_lt_selections 'STAGR' stagr.
fill_lt_selections 'RTCUR' rtcur.
fill_lt_selections 'RUNIT' runit.
fill_lt_selections 'VERSA' versa.
fill_lt_selections 'EPRCTR' eprctr.
fill_lt_selections 'AFABE' afabe.
fill_lt_selections 'RMVCT' rmvct.
fill_lt_selections 'DOCCT' docct.
fill_lt_selections 'DOCNR' docnr.
fill_lt_selections 'REFDOCCT' refdocct.
fill_lt_selections 'REFDOCNR' refdocnr.
fill_lt_selections 'WERKS' werks.
fill_lt_selections 'REP_MATNR' repmatnr.
fill_lt_selections 'RSCOPE' rscope.
fill_lt_selections 'HRKFT' hrkft. "note 550972
fill_lt_selections 'SBUKRS' sbukrs. "note 550972
fill_lt_selections 'SHOART' shoart. "note 550972
fill_lt_selections 'SFAREA' sfarea. "note 550972
call function 'EC_PCA_SELECT_FROM_ARCHIVE'
exporting
i_selections = lt_selections[]
i_files_sequential_read = lr_files[]
importing
e_glpca = lt_glpca_archiv[]
exceptions
no_infostruc_found = 1.
if sy-subrc = 1.
message id sy-msgid type 'I' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
clear i_glpca.
loop at lt_glpca_archiv assigning to i_glpca.
append i_glpca.
endloop.
endif.
if i_glpca[] is initial. "Info,nichts gefunden
message s000.
exit.
endif.
get texts for accounts ...............................................
sort i_glpca by kokrs racct.
loop at i_glpca assigning -racct_ktext = ls_rpcak-ktext.
endloop.
Liste mit Einzelposten geeignet sortieren.............................
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = 'Einzelposten sortieren'(p30).
if show_ref is initial.
sort i_glpca by rldnr ryear rbukrs rrcty rvers
docct docnr docln.
else.
sort i_glpca by rldnr kokrs ryear rbukrs rrcty rvers poper
refdocct refdocnr refdocln.
endif.
Berechtigungsprüfung und gemerkte Belege aufbereiten .................
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = 'Berechtigungsprüfungen'(p40).
clear: cnt_rldnr, cnt_kokrs, cnt_ryear, cnt_rvers, cnt_bukrs.
loop at i_glpca assigning .
Berechtigungscheck
perform check_repo_authority changing authorised.
if authorised is initial.
delete i_glpca.
s_message = 'X'.
zählen der Sätze ohne Berechtigung
auth_dbcount = auth_dbcount + 1.
else. "Weitere Bearbeitung nur für berechtigte Belege...
Zusätzlich merken der Anzahl der Ausprägungen
bestimmter Dimensionen
on change of -rbukrs
ct = '10'
importing
currency = hsl_curr.
endon.
externe Immobilienbezeichnung "ww/kb
on change of i_glpca-imkey.
if ( not -dabrz
I_length = 20
importing
e_empge = -konty.
endif.
CONCATENATE I_GLPCA-KONTY I_GLPCA-EMPGE INTO I_GLPCA-IMBEZ.
endif.
endon.
on change of i_glpca-dabrz.
call function 'REMD_IMKEY_TO_EMPGE'
exporting
i_imkey = i_glpca-imkey
i_dabrz = i_glpca-dabrz
i_length = 20
importing
e_empge = i_glpca-empge
e_konty = i_glpca-konty.
CONCATENATE I_GLPCA-KONTY I_GLPCA-EMPGE INTO I_GLPCA-IMBEZ.
endon.
Konvertierungsproblem mit PSP-Nummer bereinigen
if not -psppp.
endif.
endif.
Währungen in Hilfsfeldern speichern
if -ksl_curr = ksl_curr.
endif.
modify i_glpca.
endif.
endloop.
Nachricht, wenn nicht alle Einzelposten angezeigt werden.
if not s_message is initial.
message s407(km) with auth_dbcount.
endif.
EP ausgeben...........................................................
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = 'Einzelposten ausgeben'(p50).
t_layout-detail_initial_lines = 'X'.
t_layout-detail_popup = 'X'.
t_layout-f2code = 'PIC1'. "MICP40K039857
t_layout-get_selinfos = 'X'.
t_layout-group_change_edit = 'X'. "note 576149
perform fill_listheader.
perform fieldcat_fill.
perform spec_groups_fill.
perform events_fill. "MICP40K039857
">>MICP40K039857
call function 'K_KKB_LIST_DISPLAY'
exporting
i_callback_program = 'RCOPCA02'
i_callback_user_command = 'USR_CMD'
i_callback_top_of_page = 'TOP_OF_PAGE'
I_CALLBACK_END_OF_PAGE =
I_CALLBACK_END_OF_LIST =
i_callback_pf_status_set = 'SET_PF_STATUS'
I_CALLBACK_LAYOUT_SAVE =
I_CALLBACK_FIELDCAT_SAVE =
i_tabname = 'I_GLPCA'
is_layout = t_layout
it_fieldcat = t_fieldcat
I_FCTYPE = 'R'
IT_EXCLUDING =
it_special_groups = t_spec_groups
IT_SORT =
IS_SEL_HIDE =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
tables
t_outtab = i_glpca
exceptions
others = 1.
loop at i_glpca.
select single vbeln auart augru
into (l_vbeln, l_auart, l_augru)
from vbak where vbeln = i_glpca-aubel.
if sy-subrc = 0.
move l_auart to i_glpca-v_auart.
move l_augru to i_glpca-v_augru.
modify i_glpca.
endif.
endloop.
call function 'REUSE_ALV_GRID_DISPLAY'
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
i_callback_program = 'ZRCOPCA02'
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USR_CMD'
i_structure_name = 'I_GLPCA'
is_layout = t_layout
it_fieldcat = t_fieldcat
IT_EXCLUDING =
it_special_groups = t_spec_groups
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'X'
i_save = g_save
is_variant = g_variant
it_events = t_events
IT_EVENT_EXIT =
IS_PRINT =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = i_glpca
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
"<<MICP40K039857
clear i_glpca.
*& Form CHECK_REPO_AUTHORITY
Check only new auth-object K_PCA *
--> p1 text
<-- p2 text
form check_repo_authority changing authorized like authorised.
fill structure for userexit in K_PCA_RESP_AUTHORITY_CHECK
data: auth like pca_i_auth. "46a MIC check K_PCA and G_GLTP
auth-bukrs = -rrcty.
clear authorized.
check PrCtr/account/activity
call function 'K_PCA_RESP_AUTHORITY_CHECK'
exporting
i_kokrs = -racct
i_vorgn = 'REPP'
i_actvt = '28'
i_auth = auth
i_no_dialog_message = 'X'
exceptions
no_authority = 1
data_missing = 2
others = 3.
if sy-subrc = 0. "ok
check ledger/version/record type
call function 'PCA_G_GLTP_AUTH_CHECK'
exporting
rldnr = -rrcty
exceptions
no_authorisation = 1
others = 2.
if sy-subrc = 0. "ok, User is authorized
authorized = 'X'.
endif.
endif.
endform. " CHECK_REPO_AUTHORITY
*& Form INIT_VARS
Initialisieren diverser Hilfsvariablen und -tabellen *
form init_vars.
data begin of nametab occurs 80. "Tabelle mit Feldern aus der RPCA2
include structure dntab.
data end of nametab.
select single * from t000
client specified
where mandt = sy-mandt.
refresh nametab.
call function 'NAMETAB_GET'
exporting
only = 'T'
tabname = 'RPCA2'
tables
nametab = nametab.
Übernehmen der Feldnamen, die auch in der GLPCA
vorkommen.
loop at nametab where fieldname ne 'KSL_CURR'
and fieldname ne 'HSL_CURR'
and fieldname ne 'EMPGE' "ww/kb
and fieldname ne 'KONTY'. "ww/kb
move nametab-fieldname to tab_fields-name.
append tab_fields.
endloop.
fill Fields of receiver for BBS "MIC46C
call function 'RSTI_REPORT_FIELDS_FIND'
exporting
e_repid = 'RCOPCA02'
e_type = 'R'
tables
it_fields = bbs_fieldtab.
correct fieldnames
read table bbs_fieldtab with key rfield = 'PRCTR'.
if sy-subrc = 0.
bbs_fieldtab-rfield = 'RPRCTR'.
modify bbs_fieldtab index sy-tabix.
endif.
read table bbs_fieldtab with key rfield = 'PPRCTR'.
if sy-subrc = 0.
bbs_fieldtab-rfield = 'SPRCTR'.
modify bbs_fieldtab index sy-tabix.
endif.
read table bbs_fieldtab with key rfield = 'BUKRS'.
if sy-subrc = 0.
bbs_fieldtab-rfield = 'RBUKRS'.
modify bbs_fieldtab index sy-tabix.
endif.
Unicode
class cl_abap_char_utilities definition load.
clear hex00 with cl_abap_char_utilities=>minchar.
clear hexff with cl_abap_char_utilities=>maxchar.
endform. " INIT_VARS
FORM FILL_LISTHEADER *
List-Header in Abhängigkeit der selektierten Daten *
form fill_listheader.
read table i_glpca index 1.
if sy-subrc ne 0.
exit.
endif.
t_listheader-typ = 'S'.
t_listheader-key = 'Ledger '(h01).
if cnt_rldnr <= 1.
t_listheader-info = i_glpca-rldnr.
else.
t_listheader-info = '*'.
endif.
append t_listheader.
t_listheader-typ = 'S'.
t_listheader-key = 'Kostenrechnungskreis'(h02).
if cnt_kokrs <= 1.
t_listheader-info = i_glpca-kokrs.
else.
t_listheader-info = '*'.
endif.
append t_listheader.
t_listheader-typ = 'S'.
t_listheader-key = 'Buchungskreis '(h03).
if cnt_bukrs <= 1.
t_listheader-info = i_glpca-rbukrs.
else.
t_listheader-info = '*'.
endif.
append t_listheader.
t_listheader-typ = 'S'.
t_listheader-key = 'Buchungsperiode '(h04).
if cnt_poper <= 1.
t_listheader-info = i_glpca-poper.
else.
t_listheader-info = '*'.
endif.
append t_listheader.
if cnt_ryear <= 1.
t_listheader-typ = 'S'.
t_listheader-key = 'Geschäftsjahr '(h05).
t_listheader-info = i_glpca-ryear.
append t_listheader.
endif.
t_listheader-typ = 'S'.
t_listheader-key = 'Version '(h06).
if cnt_rvers <= 1.
t_listheader-info = i_glpca-rvers.
else.
t_listheader-info = '*'.
endif.
append t_listheader.
endform. "fill_listheader
*& Form FIELDCAT_FILL
*& Aufbau des Feldkataloges für den K_KKB_LIST_DISPLAY, *
*& bzw REUSE_ALV_LIST_DISPLAY, *
*& weitere Infos enthält die FktBaustein-Doku *
form fieldcat_fill.
data: i type i value 0.
refresh t_fieldcat.
Ledger
if cnt_rldnr > 1.
add 1 to i.
clear afield.
afield-col_pos = i.
afield-fieldname = 'RLDNR'.
afield-no_sum = 'X'.
afield-no_out = 'X'.
afield-key = 'X'.
afield-ref_tabname = 'GLPCA'.
afield-sp_group = '1'.
append afield to t_fieldcat.
endif.
Satzart
add 1 to i.
clear afield.
afield-col_pos = i.
afield-fieldname = 'RRCTY'.
afield-no_sum = 'X'.
afield-ref_tabname = 'GLPCA'.
afield-no_out = 'X'.
afield-sp_group = '1'.
append afield to t_fieldcat.
Version
if cnt_rvers > 1.
add 1 to i.
clear afield.
afield-col_pos = i.
afield-fieldname = 'RVERS'.
afield-no_sum = 'X'.
afield-ref_tabname = 'GLPCA'.
afield-no_out = 'X'.
afield-sp_group = '1'.
append afield to t_fieldcat.
endif.
Periode
if cnt_poper > 1.
add 1 to i.
clear afield.
afield-col_pos = i.
afield-fieldname = 'POPER'.
afield-no_sum = 'X'.
afield-ref_tabname = 'GLPCA'.
afield-no_out = 'X'.
afield-sp_group = '1'.
append afield to t_fieldcat.
endif.
Geschäftsjahr
if cnt_ryear > 1.
add 1 to i.
clear afield.
afield-col_pos = i.
afield-fieldname = 'RYEAR'.
afield-no_sum = 'X'.
afield-ref_tabname = 'GLPCA'.
afield-no_out = 'X'.
afield-sp_group = '1'.
append afield to t_fieldcat.
endif.
Referenzbelegtyp
add 1 to i.
clear afield.
afield-col_pos = i.
afield-fieldname = 'REFDOCCT'.
afield-ref_tabname = 'GLPCA'.
afield-key_sel = 'X'.
afield-no_sum = 'X'.
afield-sp_group = '2'.
afield-seltext_s = 'Typ'(t01).
afield-seltext_m = 'Belegtyp'(t02).
afield-seltext_l = 'Ref.Belegtyp'(t03).
afield-outputlen = 3. "Platz für die Sterne der Zwischensummen
if not show_ref is initial.
afield-key = 'X'.
else.
afield-no_out = 'X'.
endif.
append afield to t_fieldcat.
Referenzbelegnummer
add 1 to i.
clear afield.
afield-col_pos = i.
afield-fieldname = 'REFDOCNR'.
afield-ref_tabname = 'GLPCA'.
afield-key_sel = 'X'.
afield-no_sum = 'X'.
afield-sp_group = '2'.
afield-seltext_s = 'Refbeleg'(t04).
afield-seltext_m = 'Refbelegnr'(t05).
afield-seltext_l = 'Ref.Belegnummer'(t06).
if not show_ref is initial.
afield-key = 'X'.
else.
afield-no_out = 'X'.
endif.
appendHi Prabhu,
You are right, problem is with Field Catalog...
When I use FM 'REUSE_ALV_GRID_DISPLAY' it is dumping...
When i tried with FM 'REUSE_ALV_LIST_DISPLAY' it is working perfectly....
how can i use FM 'REUSE_ALV_GRID_DISPLAY' without dumping????
do i need to pass any thing in FM????
Here is the dump:
Runtime Errors MESSAGE_TYPE_X
Occurred on 12/21/2006 at 01:03:24
The current application triggered a termination with a short dump.
What happened?
The current application program detected a situation which really
should not occur. Therefore, a termination with a short dump was
triggered on purpose by the key word MESSAGE (type X).
Error analysis
Short text of error message:
Technical information about the message:
Message classe...... "0K "
Number.............. 000
User, transaction...
Language key........ "E"
Transaction......... "SE38 "
Program............. "SAPLSLVC "
Screen.............. "SAPLSLVC_FULLSCREEN 0500"
Screen line......... 3
Information on where termination occurred
The termination occurred in the ABAP program "SAPLSLVC " in "LINE_OUT_NEW_2".
The main program was "ZRCOPCA02 ".
The termination occurred in line 918 of the source code of the (Include)
program "LSLVCF01 "
of the source code of program "LSLVCF01 " (when calling the editor 9180).
Source code extract
008880 gs_roid-row_id = rs_row-index * -1.
008890 endif.
008900 gs_roid-sub_row_id = rs_row-rowtype+7(10).
008910 gs_poid-row_id = gs_roid-row_id.
008920 gs_poid-sub_row_id = gs_roid-sub_row_id.
008930 gs_poid-rowtype = rs_row-rowtype.
008940 gs_poid-index = rs_row-index.
008950 insert gs_poid into table rt_poid.
008960 endif.
008970 append gs_roid to rt_roid.
008980
008990 loop at rt_fieldcat assigning <ls_fieldcat> where tech ne 'X' and
009000 no_out ne 'X'.
009010
009020 if gflg_invisible = 'X'.
009030 if <ls_fieldcat>-do_sum is initial.
009040 clear gflg_invisible.
009050 continue.
009060 else.
009070 clear g_col_counter.
009080 clear gflg_invisible.
009090 endif.
009100 endif.
009110
009120 clear gs_lvc_data.
009130 clear g_style.
009140
009150 assign component
009160 <ls_fieldcat>-fieldname of structure rt_data to <g_field>.
009170 if sy-subrc ne 0.
> message x000(0k).
009190 endif.
009200
009210 g_col_counter = g_col_counter + 1.
009220
009230 gs_lvc_data-row_pos = r_row_counter.
009240 gs_lvc_data-col_pos = g_col_counter.
009250 gs_lvc_data-row_id = gs_roid-row_id.
009260 gs_lvc_data-sub_row_id = gs_roid-sub_row_id.
009270
009280 * Endtotal and average
009290 if rs_row-rowtype(1) ca 'T' and <ls_fieldcat>-do_sum = 'C'.
009300 * save the actual grouplevel information
009310 gs_grouplevels = rs_grouplevels.
009320 clear g_lines.
009330
009340 * get number of lines of the collect table
009350 describe table rt_data lines g_lines.
009360 * if there is only one line or the field has no references so
009370 * that only the first line has to be considered
Thanks,
fractal
null -
Report output to convert to pdf and mail it to recepient
Hi
I'm using the below coding for converting the output of the program to pdf and then mail it to the recepient.The coding works for background processsing only can i do the same for online.In the write statement i'm using the sy-repid my program name and when i get the pdf mail i'm getting the name of the program but instead i need to get the output of my program.Can any one help me in correcting the coding to get the output in pdf format.I know where i'm going wrong but this is the first time i'm working with this so new to this....It would be better if i could run the program and get the convertions into pdf through mail instead of background processing.....Please change the coding below to get the same.....
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE sy-repid.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
Alternative way could be to submit another program and store spool
id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
Get spool id from program called above
IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool'
'request to be created.'.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Branch Revenue'.
gd_attachment_desc = 'Branch Revenue'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Branch Revenue,Profit and Commissions'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Branch Revenue'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
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.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
Thanks in advance.....Hi
Below is the code I was used to convert the sap script( Sales Order) to convert to PDf and send as an attachment.
Dev/UDD Id : EUR-770416 *
Author : M.Sreeram Kumar *
Date : 08-Apr-07 *
Request : DU1K933766
Description: Send an order confirmation to the multiple user in a *
PDF format via Email. *
Change Log *
Author : *
Date : *
Description : *
Request : *
Print of an order confirmation by SAPscript
REPORT zrep_email LINE-COUNT 100 MESSAGE-ID vn.
TABLES: komk, "Communicationarea for conditions
komp, "Communicationarea for conditions
komvd, "Communicationarea for conditions
vbco3, "Communicationarea for view
vbdka, "Headerview
vbdpa, "Itemview
vbdpau, "Subitemnumbers
conf_out, "Configuration data
sadr, "Addresses
tvag, "Reason for rejection
vedka, "Servicecontract head data
vedpa, "Servicecontract position data
vedkn, "Servicecontract head notice data
vedpn, "Servicecontract pos. notice data
vbpa, "Sales Document: Partner
kna1, "General Data in Customer Master
riserls, "Serialnumbers
komser, "Serialnumbers for print
tvbur, "Sales office
tvko, "Sales organisation
adrs, "Communicationarea for Address
fpltdr. "billing schedules
INCLUDE zrep_rvadtabl.
*INCLUDE yzrvadtabl.
*INCLUDE RVADTABL.
INCLUDE zrep_rvdirekt.
*INCLUDE yzrvdirekt.
*INCLUDE RVDIREKT.
INCLUDE zrep_vedadata.
*INCLUDE yzvedadata.
*INCLUDE VEDADATA.
DATA: retcode LIKE sy-subrc. "Returncode
DATA: repeat(1) TYPE c.
DATA: xscreen(1) TYPE c. "Output on printer or screen
DATA: BEGIN OF steu, "Controldata for output
vdkex(1) TYPE c,
vdpex(1) TYPE c,
kbkex(1) TYPE c,
kbpex(1) TYPE c,
END OF steu.
DATA: BEGIN OF tvbdpa OCCURS 0. "Internal table for items
INCLUDE STRUCTURE vbdpa.
DATA: END OF tvbdpa.
DATA: BEGIN OF tkomv OCCURS 50.
INCLUDE STRUCTURE komv.
DATA: END OF tkomv.
DATA: BEGIN OF tkomvd OCCURS 50.
INCLUDE STRUCTURE komvd.
DATA: END OF tkomvd.
DATA: BEGIN OF tvbdpau OCCURS 5.
INCLUDE STRUCTURE vbdpau.
DATA: END OF tvbdpau.
DATA: BEGIN OF tkomcon OCCURS 50.
INCLUDE STRUCTURE conf_out.
DATA: END OF tkomcon.
DATA: BEGIN OF tkomservh OCCURS 1.
INCLUDE STRUCTURE vedka.
DATA: END OF tkomservh.
DATA: BEGIN OF tkomservp OCCURS 5.
INCLUDE STRUCTURE vedpa.
DATA: END OF tkomservp.
DATA: BEGIN OF tkomservhn OCCURS 5.
INCLUDE STRUCTURE vedkn.
DATA: END OF tkomservhn.
DATA: BEGIN OF tkomservpn OCCURS 5.
INCLUDE STRUCTURE vedpn.
DATA: END OF tkomservpn.
DATA: BEGIN OF tkomser OCCURS 5.
INCLUDE STRUCTURE riserls.
DATA: END OF tkomser.
DATA: BEGIN OF tkomser_print OCCURS 5.
INCLUDE STRUCTURE komser.
DATA: END OF tkomser_print.
DATA: BEGIN OF tfpltdr OCCURS 5.
INCLUDE STRUCTURE fpltdr.
DATA: END OF tfpltdr.
DATA: pr_kappl(01) TYPE c VALUE 'V'. "Application for pricing
DATA: BEGIN OF char_val OCCURS 0,
atnam LIKE cabn-atnam,
atwrt LIKE ausp-atwrt,
END OF char_val.
FORM entry USING return_code us_screen.
CLEAR retcode.
xscreen = us_screen.
PERFORM processing.
IF retcode NE 0.
return_code = 1.
ELSE.
return_code = 0.
ENDIF.
ENDFORM. "ENTRY
FORM PROCESSING *
FORM processing.
PERFORM get_data.
CHECK retcode = 0.
PERFORM form_open USING xscreen vbdka-land1.
CHECK retcode = 0.
PERFORM logo_selection.
PERFORM form_title_print.
CHECK retcode = 0.
PERFORM write_header_info.
PERFORM validity_print.
CHECK retcode = 0.
PERFORM header_data_print.
CHECK retcode = 0.
PERFORM header_serv_print.
CHECK retcode = 0.
PERFORM header_notice_print.
CHECK retcode = 0.
PERFORM header_inter_print.
CHECK retcode = 0.
PERFORM header_text_print.
CHECK retcode = 0.
PERFORM item_print.
CHECK retcode = 0.
PERFORM end_print.
CHECK retcode = 0.
PERFORM form_close.
CHECK retcode = 0.
PERFORM zemail_process.
ENDFORM. "PROCESSING
S U B R O U T I N E S *
FORM ALTERNATIVE_ITEM *
A text is printed, if the item is an alternative item. *
FORM alternative_item.
CHECK vbdpa-grpos CN '0'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ALTERNATIVE_ITEM'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ALTERNATIVE_ITEM
FORM CHECK_REPEAT *
A text is printed, if it is a repeat print for the document. *
FORM check_repeat.
CLEAR repeat.
SELECT * INTO *nast FROM nast WHERE kappl = nast-kappl
AND objky = nast-objky
AND kschl = nast-kschl
AND spras = nast-spras
AND parnr = nast-parnr
AND parvw = nast-parvw
AND nacha BETWEEN '1' AND '4'.
CHECK *nast-vstat = '1'.
repeat = 'X'.
EXIT.
ENDSELECT.
ENDFORM. "CHECK_REPEAT
FORM DELIVERY_DATE *
If the delivery date in the item is different to the header *
date and there are no scheduled quantities, the delivery date *
is printed in the item block. *
FORM delivery_date.
IF vbdka-lfdat = space AND
vbdpa-lfdat NE space AND
vbdpa-etenr_da = space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_DELIVERY_DATE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "DELIVERY_DATE
FORM DIFFERENT_CONSIGNEE *
If the consignee in the item is different to the header con- *
signee, it is printed by this routine. *
FORM different_consignee.
CHECK vbdka-name1_we NE vbdpa-name1_we
OR vbdka-name2_we NE vbdpa-name2_we
OR vbdka-name3_we NE vbdpa-name3_we
OR vbdka-name4_we NE vbdpa-name4_we.
CHECK vbdpa-name1_we NE space
OR vbdpa-name2_we NE space
OR vbdpa-name3_we NE space
OR vbdpa-name4_we NE space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_CONSIGNEE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "DIFFERENT_CONSIGNEE
FORM DIFFERENT_REFERENCE_NO *
If the reference number in the item is different to the header*
reference number, it is printed by this routine. *
FORM different_reference_no.
CHECK vbdpa-vbeln_vang NE vbdka-vbeln_vang
OR vbdpa-vbtyp_vang NE vbdka-vbtyp_vang.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_REFERENCE_NO'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "DIFFERENT_REFERENCE_NO
FORM DIFFERENT_TERMS *
If the terms in the item are different to the header terms, *
they are printed by this routine. *
FORM different_terms.
DATA: us_vposn LIKE vedpa-vposn.
DATA: us_text(1) TYPE c. "Flag for Noticetext was printed
IF vbdpa-zterm NE vbdka-zterm AND
vbdpa-zterm NE space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_PAYMENT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
IF vbdpa-inco1 NE space.
IF vbdpa-inco1 NE vbdka-inco1 OR
vbdpa-inco2 NE vbdka-inco2.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_DELIVERY'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDIF.
Print different validity-data for the position
READ TABLE tkomservp WITH KEY vbdpa-posnr.
IF sy-subrc EQ 0.
vedpa = tkomservp.
IF vedpa-vbegdat NE space AND
vedpa-venddat NE space AND
NOT vedpa-vbegdat IS INITIAL AND
NOT vedpa-venddat IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_SERV1'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSEIF vedpa-vbegdat NE space AND
NOT vedpa-vbegdat IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_SERV2'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_SERV3'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDIF.
Notice-rules for the positions.
MOVE vbdpa-posnr TO us_vposn.
CLEAR us_text.
LOOP AT tkomservpn WHERE vposn = us_vposn.
vedpn = tkomservpn.
IF us_text IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_NOTTXT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
us_text = charx.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_NOTICE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDLOOP.
IF NOT us_text IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'EMPTY_LINE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "DIFFERENT_TERMS
FORM END_PRINT *
FORM end_print.
PERFORM get_header_prices.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'PROTECT'.
PERFORM header_price_print.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'END_VALUES'.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'ENDPROTECT'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'SUPPLEMENT_TEXT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "END_PRINT
FORM FORM_CLOSE *
End of printing the form *
FORM form_close.
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT =
RDI_RESULT =
TABLES
otfdata = t_otfdata
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF sy-subrc NE 0.
PERFORM protocol_update.
retcode = 1.
ENDIF.
SET COUNTRY space.
ENDFORM. "FORM_CLOSE
FORM FORM_OPEN *
Start of printing the form *
--> US_SCREEN Output on screen *
' ' = printer *
'X' = screen *
--> US_COUNTRY County for telecommunication and SET COUNTRY *
FORM form_open USING us_screen us_country.
INCLUDE zrep_rvadopfo.
INCLUDE yzrvadopfo.
INCLUDE RVADOPFO.
ENDFORM. "FORM_OPEN
FORM FORM_TITLE_PRINT *
Printing of the form title depending of the field VBTYP *
FORM form_title_print.
CASE vbdka-vbtyp.
WHEN 'A'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_A'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'B'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_B'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'C'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_C'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'E'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_E'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'F'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_F'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'G'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_F'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'H'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_H'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'K'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_K'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'L'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_L'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN OTHERS.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_OTHERS'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDCASE.
IF repeat NE space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'REPEAT'
window = 'REPEAT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "FORM_TITLE_PRINT
FORM GET_DATA *
General provision of data for the form *
FORM get_data.
DATA: us_veda_vbeln LIKE veda-vbeln.
DATA: us_veda_posnr_low LIKE veda-vposn.
CALL FUNCTION 'RV_PRICE_PRINT_REFRESH'
TABLES
tkomv = tkomv.
CLEAR komk.
CLEAR komp.
vbco3-mandt = sy-mandt.
vbco3-spras = nast-spras.
vbco3-vbeln = nast-objky.
vbco3-kunde = nast-parnr.
vbco3-parvw = nast-parvw.
CALL FUNCTION 'RV_DOCUMENT_PRINT_VIEW'
EXPORTING
comwa = vbco3
IMPORTING
kopf = vbdka
TABLES
pos = tvbdpa.
Fetch servicecontract-data and notice-data for head and position.
us_veda_vbeln = vbdka-vbeln.
us_veda_posnr_low = posnr_low.
CALL FUNCTION 'SD_VEDA_GET_PRINT_DATA'
EXPORTING
i_document_number = us_veda_vbeln
i_language = sy-langu
i_posnr_low = us_veda_posnr_low
TABLES
print_data_pos = tkomservp
print_data_head = tkomservh
print_notice_pos = tkomservpn
print_notice_head = tkomservhn.
PERFORM get_controll_data.
PERFORM sender.
PERFORM check_repeat.
PERFORM tvbdpau_create.
ENDFORM. "GET_DATA
FORM GET_ITEM_BILLING_SCHEDULES *
In this routine the billing schedules are fetched from the *
database. *
FORM get_item_billing_schedules.
REFRESH tfpltdr.
CHECK NOT vbdpa-fplnr IS INITIAL.
CALL FUNCTION 'BILLING_SCHED_PRINTVIEW_READ'
EXPORTING
i_fplnr = vbdpa-fplnr
i_language = nast-spras
TABLES
zfpltdr = tfpltdr.
ENDFORM. "GET_ITEM_BILLING_SCHEDULES
*& Form ITEM_BILLING_SCHEDULES_PRINT
This routine prints the billing shedules of a salesdocument *
position. *
FORM item_billing_schedules_print.
DATA: first_line(1) TYPE c.
first_line = charx.
LOOP AT tfpltdr.
fpltdr = tfpltdr.
Output of the following printlines
IF NOT fpltdr-perio IS INITIAL.
periodische Fakturen
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_PERIODIC'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
bei periodischen nur eine Zeile
EXIT.
ELSEIF fpltdr-fareg CA '14'.
prozentuale Teilfakturierung
IF NOT first_line IS INITIAL.
CLEAR first_line.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_PERCENT_HEADER'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_PERCENT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ELSEIF fpltdr-fareg CA '235'.
wertmäßige Teilfakturierung
IF NOT first_line IS INITIAL.
CLEAR first_line.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_VALUE_HEADER'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_VALUE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ELSEIF fpltdr-fareg CA '3'.
Schlußrechnung
ENDIF.
ENDLOOP.
ENDFORM. "ITEM_BILLING_SCHEDULES_PRINT
*eject
FORM GET_ITEM_CHARACTERISTICS *
In this routine the configuration data item is fetched from *
the database. *
FORM get_item_characteristics.
REFRESH tkomcon.
CHECK NOT vbdpa-cuobj IS INITIAL.
CALL FUNCTION 'CUD0_GET_CONFIGURATION' "#EC EXISTS
EXPORTING
instance = vbdpa-cuobj
language = nast-spras
TABLES
configuration = tkomcon
EXCEPTIONS
OTHERS = 4.
ENDFORM. "GET_ITEM_CHARACTERISTICS
FORM GET_ITEM_PRICES *
In this routine the price data for the item is fetched from *
the database. *
FORM get_item_prices.
CLEAR: komp,
tkomv.
IF komk-knumv NE vbdka-knumv.
CLEAR komk.
komk-mandt = sy-mandt.
komk-kalsm = vbdka-kalsm.
komk-kappl = pr_kappl.
komk-waerk = vbdka-waerk.
komk-knumv = vbdka-knumv.
komk-vbtyp = vbdka-vbtyp.
ENDIF.
komp-kposn = vbdpa-posnr.
CALL FUNCTION 'RV_PRICE_PRINT_ITEM'
EXPORTING
comm_head_i = komk
comm_item_i = komp
language = nast-spras
IMPORTING
comm_head_e = komk
comm_item_e = komp
TABLES
tkomv = tkomv
tkomvd = tkomvd.
ENDFORM. "GET_ITEM_PRICES
FORM GET_HEADER_PRICES *
In this routine the price data for the header is fetched from *
the database. *
FORM get_header_prices.
CALL FUNCTION 'RV_PRICE_PRINT_HEAD'
EXPORTING
comm_head_i = komk
language = nast-spras
IMPORTING
comm_head_e = komk
TABLES
tkomv = tkomv
tkomvd = tkomvd.
ENDFORM. "GET_HEADER_PRICES
*& Form HEADER_DATA_PRINT
Printing of header data like terms, weights .... *
FORM header_data_print.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_DATA'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. " HEADER_DATA_PRINT
FORM HEADER_PRICE_PRINT *
Printout of the header prices *
FORM header_price_print.
LOOP AT tkomvd.
AT FIRST.
IF komk-supos NE 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_SUM'.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'UNDER_LINE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDAT.
komvd = tkomvd.
IF komvd-koaid = 'D'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TAX_LINE'.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'SUM_LINE'.
ENDIF.
ENDLOOP.
DESCRIBE TABLE tkomvd LINES sy-tfill.
IF sy-tfill = 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'UNDER_LINE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "HEADER_PRICE_PRINT
FORM HEADER_TEXT_PRINT *
Printout of the headertexts *
FORM header_text_print.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_TEXT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "HEADER_TEXT_PRINT
FORM ITEM_CHARACERISTICS_PRINT *
Printout of the item characteristics -> configuration *
FORM item_characteristics_print.
LOOP AT tkomcon.
conf_out = tkomcon.
IF sy-tabix = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_CONFIGURATION_HEADER'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_CONFIGURATION'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. "ITEM_CHARACTERISTICS_PRINT
FORM ITEM_DELIVERY_CONFIRMATION *
If the delivery date is not confirmed, a text is printed *
FORM item_delivery_confirmation.
CHECK vbdpa-lfdat = space.
CHECK vbdpa-kwmeng NE 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_DELIVERY_CONFIRMATION'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ITEM_DELIVERY_CONFIRMATION
FORM ITEM_PRICE_PRINT *
Printout of the item prices *
FORM item_price_print.
LOOP AT tkomvd.
komvd = tkomvd.
IF sy-tabix = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_PRICE_QUANTITY'.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_PRICE_TEXT'.
ENDIF.
ENDLOOP.
ENDFORM. "ITEM_PRICE_PRINT
FORM ITEM_PRINT *
Printout of the items *
FORM item_print.
DATA: da_subrc LIKE sy-subrc,
da_dragr LIKE tvag-dragr.
CALL FUNCTION 'WRITE_FORM' "First header
EXPORTING element = 'ITEM_HEADER'
EXCEPTIONS OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
CALL FUNCTION 'WRITE_FORM' "Activate header
EXPORTING element = 'ITEM_HEADER'
type = 'TOP'
EXCEPTIONS OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
LOOP AT tvbdpa.
vbdpa = tvbdpa.
TVAG lesen um festzustellen ob abgesagte Positionen gedruckt werden
sollen
PERFORM tvag_select(sapmv45a) USING vbdpa-abgru
da_dragr
space
da_subrc.
IF da_dragr EQ space. "Print rejected item?
IF vbdpa-posnr_neu NE space. "Item
PERFORM get_item_serials.
PERFORM get_item_characteristics.
PERFORM get_item_billing_schedules.
PERFORM get_item_prices.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'ENDPROTECT'.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'PROTECT'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE'.
PERFORM item_rejected.
PERFORM item_price_print.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'ENDPROTECT'.
PERFORM item_text_print.
PERFORM item_serials_print.
PERFORM item_characteristics_print.
PERFORM alternative_item.
PERFORM delivery_date.
PERFORM item_delivery_confirmation.
PERFORM item_billing_schedules_print.
PERFORM different_reference_no.
PERFORM different_terms.
PERFORM different_consignee.
PERFORM schedule_header.
PERFORM main_item.
ELSE.
PERFORM schedule_print.
ENDIF.
ENDIF.
ENDLOOP.
CALL FUNCTION 'WRITE_FORM' "Deactivate Header
EXPORTING element = 'ITEM_HEADER'
function = 'DELETE'
type = 'TOP'
EXCEPTIONS OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ITEM_PRINT
FORM ITEM_REJECTED *
A text is printed, if the item is rejected *
FORM item_rejected.
CHECK NOT vbdpa-abgru IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_REJECTED'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ITEM_REJECTED
FORM MAIN_ITEM *
A text is printed, if the item is a main item * -
Problem in converting report output to pdf
Hi,
I'm managing to get the spool id and other requirements but could'nt get the output of the program converted to pdf format.When i'm trying to do this i'm getting the pdf format of the functional module which retrievs the header and item records and displays the numbers records in the header and item like for eg. header records 8 and item records 10 this its displaying in the format in which we get our funtional module output when we give some data into it.....
Can any one please tell me how to solve this for ur information i'm using hierarchail squential report with multiple reports in the same report.............
for instance i'm using the following coding please find the bug......
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
Alternative way could be to submit another program and store spool
id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
Get spool id from program called above
IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
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.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.Please go throught the code ... this is my salary sending program to all the employees as pdf attach file of his salary breakup ...... it was so clear how the data is converted in th pdf format .... and more understanding way the internal tables are declared ....
DATA W_OPTIONS LIKE ITCPO OCCURS 0 WITH HEADER LINE.
DATA : z_itcpp LIKE itcpp OCCURS 0 WITH HEADER LINE.
DATA : otfdt like ITCOO OCCURS 0 WITH HEADER LINE.
DATA : pdfdt like TLINE OCCURS 0 with header line.
DATA: NUMBYTES TYPE I.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
DATA: Begin of i_errors occurs 0,
type(1) type c,
descr(100) type c,
End of i_errors.
w_options-tdprinter = 'POSTSCPT'.
W_options-TDRDIDEV = 'XP45'.
W_options-TDGETOTF = 'X'.
APPEND W_options.
call function 'OPEN_FORM'
exporting
device = 'PRINTER'
dialog = ' '
form = 'ZHRPAYSLIP'
language = sy-langu
options = w_options
* IMPORTING
* LANGUAGE =
* NEW_ARCHIVE_PARAMS =
* RESULT =
exceptions
canceled = 1
device = 2
form = 3
options = 4
unclosed = 5
mail_options = 6
archive_error = 7
invalid_fax_number = 8
more_params_needed_in_batch = 9
others = 10 .
CALL FUNCTION 'CLOSE_FORM'
* IMPORTING
* RDI_RESULT =
TABLES
OTFDATA = otfdt
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
OTHERS = 4.
EXPORT otfdt TO MEMORY ID 'PDFT'.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = NUMBYTES
* BIN_FILE =
TABLES
otf = otfdt
lines = pdfdt
* EXCEPTIONS
* ERR_MAX_LINEWIDTH = 1
* ERR_FORMAT = 2
* ERR_CONV_NOT_POSSIBLE = 3
* ERR_BAD_OTF = 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 .
Refresh OBJTXT. clear OBJTXT.
Refresh OBJPACK. clear OBJPACK.
Refresh objbin. clear objbin.
Refresh OBJHEAD. clear OBJHEAD.
Refresh RECLIST. Clear RECLIST.
* Creation of the document to be sent
* File Name
DOC_CHNG-OBJ_NAME = 'PAYSLIP'.
* Mail Subject
DOC_CHNG-OBJ_DESCR = 'Payslip'.
* Mail Contents
OBJTXT = 'This e-mail was sent from an automated system...'.
APPEND OBJTXT.
OBJTXT = 'Do not reply to this message.'.
APPEND OBJTXT.
OBJTXT = 'Please open the attachment to view the Payslip'.
APPEND OBJTXT.
OBJTXT = ''.
APPEND OBJTXT.
if not msgtxt1 is initial.
OBJTXT = msgtxt1.
APPEND OBJTXT.
endif.
if not msgtxt2 is initial.
OBJTXT = msgtxt2.
APPEND OBJTXT.
endif.
if not msgtxt3 is initial.
OBJTXT = msgtxt3.
APPEND OBJTXT.
endif.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
* Creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
* Creation of the document attachment
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = pdfdt
t_target_tab = objbin
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
describe table objbin lines tab_lines.
OBJHEAD = 'Payslip.PDF'.
APPEND OBJHEAD.
** Creation of the entry for the compressed attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'PDF'.
OBJPACK-OBJ_NAME = 'Payslip'.
OBJPACK-OBJ_DESCR = 'Payslip'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
* Completing the recipient list
* Read table i_pa0105 with key pernr = pernr-pernr binary search.
loop at i_pa0105 where pernr = pernr-pernr and USRTY = '0010'.
endloop.
if sy-subrc = 0.
RECLIST-RECEIVER = i_pa0105-USRID_LONG.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
endif.
if RECLIST[] is initial.
loop at i_pa0105 where pernr = pernr-pernr and USRTY = 'MAIL'.
endloop.
if sy-subrc = 0.
RECLIST-RECEIVER = i_pa0105-USRID.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
endif.
endif.
if not RECLIST[] is initial.
* Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = ''
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
LOOP AT RECLIST.
* Concatenate pernr-pernr '-' RECLIST-RECEIVER(48)
into error1.
IF RECLIST-RETRN_CODE = 0.
* Concatenate error1 ': The document was sent' into
error1.
i_errors-descr = pernr-pernr.
i_errors-type = 'S'.
append i_errors.
ELSE.
Concatenate error1 ': The document could not be
sent' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
ENDIF.
ENDLOOP.
WHEN 1.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into
error1.
Concatenate error1 ': No authorization for sending to the
recipients' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
WHEN 2.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into
error1.
Concatenate error1 ': Document could not be sent to the
recipient' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
WHEN 4.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into
error1.
Concatenate error1 ': No send authorization' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
WHEN OTHERS.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into
error1.
Concatenate error1 ': Error occurred while sending' into
error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
ENDCASE.
else.
error1 = pernr-pernr.
* Concatenate error1 ': Maintain Infotype 0105.' into error1.
i_errors-descr = error1.
i_errors-type = 'M'.
append i_errors.
endif.
girish
Maybe you are looking for
-
Use Apple TV to Cut Cable Cord
My wife and I are frustrated by the arrogance and greed of our local cable monopoly and looking at the plusses and minuses of Apple TV using Hulu and various other streaming sources. Dish TV is not an option for a few reasons. Our only cable usage wo
-
IPod classic 120gb - can't download from itunes
I sync the ipod to my mac, open it and DON"T get a management screen that I've read about. It just opens in finder. What is shown to be on the ipod is not what actually is. My problem is, I'm trying to download music from itunes onto it. When I d
-
Defaulting PayScale Group and Level in IT0008.
The System is configured as that the Payscale Group and Level will get defaulted in IT0008 from the Planned Compensation maintained for the Job. This is working fine for all personnel areas except one. Can anyone pls explain what all tables/SPRO node
-
Wind.8bf file missing from trial version photoshop cs5?
I am trying to learn a specific text effect and the tutorial uses the "wind" filter in photoshop. I am currently using a trial version of PS cs5, and have been able to use all features so far... has the wind filter been ommitted from the trial vers
-
What is a hard boot and will it fix my grainy photos when I take flash photographs with my iPhone 5 in the deep dark? Someone said a hard boot fixed the problem above .....when I go outside in the dark and take a flash photograph the photograph is al