Create Spool from Internal table & converrt the spool to PDF
Hi All,
My requirement is take data from a table and find amount specific to each Vendors . So I took all the data into ITAB and do all the calculation. Later after calculation I have to create a spool from this ITAB and this spool have to convert to PDF. Later this PDF have to seend via email.
To convert the internal table to Spool , I used
LOOP AT t_summ INTO wa_summ.
w-amount = wa_summ-remittanceamount.
CONCATENATE wa_summ-vendorcode
wa_summ-controlnum
w-amount INTO wa_textdata SEPARATED BY space.
APPEND wa_textdata TO t_textdata.
ENDLOOP.
DESCRIBE TABLE t_textdata .
w-file_length = syst-tfill * 1022.
l_doctype = 'LIST'.
l_layout = 'X_POSTSCRIPT'.
CONCATENATE ' Listbill Summary Report for' syst-datum INTO
l_title SEPARATED BY space.
l_receiver = syst-uname.
* Create Spool
CALL FUNCTION 'RSPO_SR_OPEN'
EXPORTING
dest = 'LOCL'
* LDEST =
layout = l_layout
name = 'SUMREP'
* SUFFIX1 =
* SUFFIX2 =
copies = '1'
* PRIO =
* immediate_print = ' '
* AUTO_DELETE =
titleline = l_title
receiver = syst-uname "
* division = l_pri_params-prabt " abteilung
* authority = l_pri_params-prber "
* POSNAME =
* ACTTIME =
* LIFETIME = '8'
* APPEND =
* COVERPAGE =
* CODEPAGE =
doctype = l_doctype
* ARCHMODE =
* ARCHPARAMS =
* TELELAND =
* TELENUM =
* TELENUME =
IMPORTING
handle = l_spool_handle
spoolid = w-spoolid
EXCEPTIONS
device_missing = 1
name_twice = 2
no_such_device = 3
operation_failed = 4
OTHERS = 5
. "#EC DOM_EQUAL
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'SLVC_C1022_TO_C255'
EXPORTING
i_file_length = w-file_length
TABLES
it_c1022 = t_textdata
et_c255 = lt_spool.
l_length = w-file_length.
LOOP AT lt_spool INTO ls_spool.
l_length = l_length - 255.
IF ( l_length > 0 ).
l_line_length = 255.
ELSE.
l_line_length = l_length + 255.
ENDIF.
* Write contents to spool
CALL FUNCTION 'RSPO_SR_WRITE'
EXPORTING
handle = l_spool_handle
text = ls_spool
length = l_line_length.
ENDLOOP.
* Close Spool
CALL FUNCTION 'RSPO_SR_CLOSE'
EXPORTING
handle = l_spool_handle
pages = 1
FINAL = 'X'
EXCEPTIONS
handle_not_valid = 1
operation_failed = 2
OTHERS = 3
By this I can see the spool with data in SP02.
Then to conver to PDF, I used
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = w-spoolid
no_dialog = 'X'
DST_DEVICE = 'LOCL'
* PDF_DESTINATION =
IMPORTING
* PDF_BYTECOUNT =
* PDF_SPOOLID =
list_pagecount = list_pagecount
* BTC_JOBNAME =
* BTC_JOBCOUNT =
TABLES
pdf = t_pdf
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
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = 'D:\t\t.pdf'
filetype = 'BIN'
TABLES
data_tab = t_pdf
* FIELDNAMES =
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22
But later when I go and open the PDF, I am getting an error saying'Page cannot be open because it dont have any pages'
Please help me
Regards,
Nikhil
Hi Nikhil,
<li>If you are still not able to find out the problem. You can an alternative way , which is used for the same purpose.
<li>Try this way. It creates spool and and same CONVERT_ABAPSPOOLJOB_2_PDF fm is used to convert spool to PDF. It works. Test this test program.
REPORT ztest_notepad.
DATA:g_val TYPE c,
w_pripar TYPE pri_params,
w_arcpar TYPE arc_params,
i_pdf TYPE TABLE OF tline,
spoolid LIKE tsp01-rqident,
l_no_of_bytes TYPE i,
l_pdf_spoolid LIKE tsp01-rqident,
l_jobname LIKE tbtcjob-jobname,
l_jobcount LIKE tbtcjob-jobcount.
DATA:it_t001 TYPE TABLE OF t001 WITH HEADER LINE.
START-OF-SELECTION.
SELECT * FROM t001 INTO TABLE it_t001.
"Read, determine, change spool print parameters and archive parameters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
in_archive_parameters = w_arcpar
in_parameters = w_pripar
layout = 'X_65_132'
line_count = 65
line_size = 132
no_dialog = 'X'
IMPORTING
out_archive_parameters = w_arcpar
out_parameters = w_pripar
valid = g_val.
IF g_val NE space AND sy-subrc = 0.
w_pripar-prrel = space.
w_pripar-primm = space.
NEW-PAGE PRINT ON NEW-SECTION PARAMETERS w_pripar ARCHIVE PARAMETERS w_arcpar NO DIALOG.
ENDIF.
LOOP AT it_t001.
WRITE:/ it_t001.
ENDLOOP.
NEW-PAGE PRINT OFF.
CALL FUNCTION 'ABAP4_COMMIT_WORK'.
spoolid = sy-spono.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spoolid
no_dialog = ' '
IMPORTING
pdf_bytecount = l_no_of_bytes
pdf_spoolid = l_pdf_spoolid
btc_jobname = l_jobname
btc_jobcount = l_jobcount
TABLES
pdf = i_pdf.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\temp\test.pdf'
filetype = 'BIN'
TABLES
data_tab = i_pdf.
Thanks
Venkat.
Similar Messages
-
How to send data from internal table to the shared folder in ABAP
Hi experts,
My requirement is to transfer data from a file to shared folder. i just did reading data from a file to a internal table. Now i want to send this internal table data into a shared folder which is "
xxx\y\z....".
I do not have any idea on how to send data from internal table to the shared folder path.
can anybody please help me out how to do this?
Thanks & Regards
Sireesha.Where that folder is located, its on presentation server i.e. desktop or application server.
If its on presentation server, use FM GUI_UPLOAD.
If its on application server, then use DATASET functions. Have a look at below link.
[File Handling in ABAP|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm]
I hope it helps.
Thanks,
Vibha
Please mark all the useful answers -
How to display data from internal table in the SELECTION-SCREEN
Hello Experts,
My requirement is to display the data's from an internal table in the selection screen. I tried using selection-screen comment. But it is working only for a single record. Can anyone please tell me how to do this?Hi Ritika,
we cant use write statement inside selection-screen.
see my coding.
SELECTION-SCREEN BEGIN OF SCREEN 123 AS WINDOW TITLE TEXT-456.
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-BL1
NO INTERVALS.
SELECT-OPTIONS SEL1 FOR SY-DATUM.
PARAMETERS PAR1(10).
<b>** I WANT ALL RECORDS FROM AN INTERNAL TABLE HERE ONLY</b>
SELECTION-SCREEN END OF BLOCK BL1.
SELECTION-SCREEN PUSHBUTTON 2(10) but1 USER-COMMAND cli1.
SELECTION-SCREEN PUSHBUTTON 20(10) but2 USER-COMMAND cli2.
SELECTION-SCREEN END OF SCREEN 123. -
How to create an dynamic internal table with the structure of a ddic table
Hi all,
I want to fill ddic-tables (which I already created) in my abap dictionary with data out of CSV-files (which are located on the CRM-Server). The ddic tables have different amount of fields.
I started with creating a table which contains the name of the tables and the path to the matching CSV-file.
At the beginning I'm filling an internal table with part of this data (the name of the ddic-tables) - after that I am looping at this internal table.
LOOP AT lt_struc ASSIGNING <lfs_struc>.
LOOP AT lv_itab1 INTO lv_wa1 WHERE ztab_name = <lfs_struc>.
lv_feld = lv_wa1-zdat_name.
ENDLOOP.
CONCATENATE 'C:\-tmp\Exportierte Tabellen\' lv_feld INTO lv_pfad.
Do.
OPEN DATASET lv_pfad FOR INPUT IN TEXT MODE ENCODING NON-UNICODE IGNORING CONVERSION ERRORS.
READ DATASET lv_pfad INTO lv_rec.
IF sy-subrc NE 0.
EXIT.
ENDIF.
enddo.
REPLACE ALL OCCURRENCES OF '"' IN lv_rec WITH ''.
SPLIT lv_rec AT ';' INTO TABLE lt_str_values.
INSERT into (<lfs_struc>) values lr_str_value.
CLOSE DATASET lv_pfad.
endloop.
This is not the whole code, but it's working until
SPLIT lv_rec AT ';' INTO TABLE lt_str_values.
I want to split all the data of lv_rec into an internal table which has the structure of the current ddic-table, but I didn't find out how to do give the internal table the structure of the ddic-table. In the code I used an internal tyble type string but I should be the structure of the matching tabel.
If I try to create an internal table by using a fiel symbol, I am told, that the data types are not matching.
Has anyone an idea?Hi Mayari,
though you were successfull with
METHOD cl_alv_table_create=>create_dynamic_table
I must warn you not to use it. The reason is that the number of tables created is limited, the method uses GENERATE SUBROUTINE statement and this triggers an unwanted database commit.
If you know the DDIC structure, it is (starting with ECC6.0) much easier:
field-symbols:
<table> type standard table.
data:
lr_data type ref to data.
Create data lr_data type table of (<DDIC structure>).
assign lr_data->* to <table>.
The split code can be simplified gaining speed loosing complexity not loosing functionality.
field-symbols:<fs_s> type any.
field-symbols:<fs_t> type any.
SPLIT lv_rec AT ';' INTO table it_string.
loop at it_string assigning <fs_s>.
assign component sy-tabix of wa_string to <fs_t>.
if sy-subrc = 0.
<fs_t> = <fs_s>.
endif.
at last.
append <fs_itwa3> to <ft_itab3>.
endat.
endloop.
Though it may work as Keshav.T suggested, there is no need to do that way.
Regards,
Clemens -
How to Read the internal table for the data download from the spool
HI all,
I have one issue regarding the spool ,we are getting the correct output as per requirement of user but when we send the same to the user in pdf format they did notget the same.
they are telling that the due date is missing from the pdf.
Please advice me how to track the internal table for the spool data converted intopdf in a readable format.
the FM used for the above task is :
call function 'CONVERT_OTFSPOOLJOB_2_PDF'
Please reply if any one worked on the same.
Thanks in advance.
Gaurav,Hi Wang,
Please let me know how you solved your question.
Points will be rewarded.
Thanks,
Arun. -
Table control from internal table giving problem.
HI ALL,
I am creating a table control using wizard from internal table in the program when i give work area it gives this error "The table work area G_TABC_WA does not exist or is not a structure"
I have declared internal table and work like this.
TYPES: BEGIN OF T_TABC,
OPTID LIKE ZHRPMT_TRNSAC-OPTID,
STGID LIKE ZHRPMT_TRNSAC-STGID,
TETID LIKE ZHRPMT_TRNSAC-TETID,
REQSR LIKE ZHRPMT_TRNSAC-REQSR,
MUNIT LIKE ZHRPMT_TRNSAC-MUNIT,
END OF T_TABC.
DATA: G_TABC_ITAB TYPE T_TABC OCCURS 0,
G_TABC_WA TYPE T_TABC. "work area
why it is giving this error and how to correct this.
thanks.Hay
Hello there is very small mistake
TYPES: BEGIN OF t_tabc,
optid TYPE zhrpmt_trnsac-optid,
stgid TYPE zhrpmt_trnsac-stgid,
tetid TYPE zhrpmt_trnsac-tetid,
reqsr TYPE zhrpmt_trnsac-reqsr,
munit TYPE zhrpmt_trnsac-munit,
END OF t_tabc.
DATA: g_tabc_itab TYPE TABLE OF t_tabc ,
g_tabc_wa LIKE t_tabc. "work area
**Please reward suitable points***
With Regards
Navin Khedikar -
Create dynmic deep internal table
Dear all,
is it possible to create a dynamic internal table which has a deep structure. The catch here is that component tables of the main internal table will determined dynamically.
thanks a lot!!!
NavjotHi Navjot,
Dyanmic internal table with deep structure is specially useful when we have to create an ALV with Colors or Style etc. Since we have CL_ABAP_TABLEDESCR class from RTTS, it is also possible to create a dynamic internal table with the deep structure. To create an internal table with deep structure, we need to first get the object definition of the table type. Than we have to add that as a component of our table definition and that's it.
Try this :
*& Report ZNP_DYNAMIC_DEEP_TABLE.
*& Shows how to create dynamic internal table with deep strcuture
*& which can be used in the ALV to have Sytle table, Color table
* 2.1 Creating the Deep strcuture field
DATA: lo_tab TYPE REF TO cl_abap_tabledescr.
lo_tab ?= cl_abap_typedescr=>describe_by_name( 'LVC_T_SCOL' ).
la_comp-name = 'COLOR_TAB'.
la_comp-type = lo_tab.
APPEND la_comp TO lt_tot_comp.
CLEAR: la_comp.
Regards
Abhinab Mishra -
Reading Data from Internal Table
Hi,
Can anyone please tell me how to read data from Internal Tables in the Event Handler without using the Select statement OnInitialization?
Thanks,
GauravHi Siddhartha,
Can you tell me the problem in my code. I tried to work on the way you suggested. Though I have not finished with the coding, I just wanted to know whether I am going in the direction or not.
I have declared the the structure in Type Defination as
TYPES: BEGIN OF TEST_STRUC,
BEGDA TYPE BEGDA,
ENDDA TYPE ENDDA,
END OF TEST_STRUC.
TYPES: TEST_TAB_TYPE TYPE TABLE OF TEST_STRUC.
In the Event Handler, I have added the following code on OnInputProcessing:
event handler for checking and processing user input and
for defining navigation
DATA TEST_INFO LIKE LINE OF TEST_TAB.
DATA: MYTAB6 TYPE TABLE OF PA0006,
MYTAB6_WA LIKE LINE OF MYTAB6.
REFRESH TEST_TAB.
CLEAR TEST_INFO.
MYTAB6_WA-BEGDA = REQUEST->GET_FORM_FIELD( STARTDATE ).
MYTAB6_WA-ENDDA = REQUEST->GET_FORM_FIELD( ENDDATE ).
IF EVENT->NAME EQ 'button'
AND EVENT->SERVER_EVENT EQ 'click'.
LOOP AT MYTAB6 INTO MYTAB6_WA.
TEST_INFO-BEGDA = MYTAB6_WA-BEGDA.
TEST_INFO-ENDDA = MYTAB6_WA-ENDDA.
ENDLOOP.
APPEND TEST_INFO TO TEST_TAB.
CLEAR TEST_INFO.
NAVIGATION->SET_PARAMETER( NAME = 'test_tab'
VALUE = 'begda' ).
NAVIGATION->SET_PARAMETER( NAME = 'test_tab'
VALUE = 'endda' ).
NAVIGATION->GOTO_PAGE( 'MyBSP2.htm').
ENDIF.
P.S. MyBSP2.htm is my next page.
Thanks,
Gaurav -
Read contents of changing fields from internal table
Hi Folks,
Please help me in my query below:
Consider there is a Z-table with two fields TABNAM and FIELD having values KNA1 and NAME1 respectively.
In my report I have fetched entries for customers from KNA1. Now based on the field from Z-table I want to populate a variable suppose V_FREE_VAR with the value from KNA1 table.
Here V_FREE_VAR is of CHAR200 so that it accomodate all types of values from KNA1.
The value of Z-table FIELD can change daily i.e next day the value may be PSTLZ.
So how can I read the particular field from internal table as the field to be read is dynamic.
Note: using case is not feasible.
Thanks in advance.
Regards,
Shardul@Hartmut P
As Rob said i want to get the value of the field from internal table. the code is something like this.
I_KNA1 contains records for customers.
Suppose values of Z-table are in internal table I_TEMP_TABLE.
Entries in I_TEMP_TABLE are as follows
TABNAME FIELDNAME
KNA1 NAME1
The value of FIELNAME in Z-table can be changed
Loop at I_TEMP_TABLE into WA_TEMP_TABLE.
Read I_KNA1 into WA_KNA1 with key KUNNR = '0001002234'.
IF SY-SUBRC EQ 0.
CASE WA_TEMP_TABLE-FIELDNAME.
WHEN 'NAME1'.
V_VAR = WA_KNA1-NAME1.
WHEN 'PSTLZ'
V_VAR = WA_KNA1-PSTLZ.
ENDIF.
But using case is not appropriate as KNA1 contains 176 fields. -
How to Send Internal table to SAP Spool using Function Modules or Methods?
Hi Experts,
How to Send Internal table to SAP Spool using Function Modules or Methods?
Thanks ,
KiranThis is my code.
I still get the no ABAP list data for the spool, even tho I can see it sp01?
REPORT Z_MAIL_PAYSLIP.
* Declaration Part *
tables: PERNR, PV000, T549Q, V_T514D, HRPY_RGDIR.
infotypes: 0000, 0001, 0105, 0655.
data: begin of ITAB occurs 0,
MTEXT(25) type C,
PERNR like PA0001-PERNR,
ABKRS like PA0001-ABKRS,
ENAME like PA0001-ENAME,
USRID_LONG like PA0105-USRID_LONG,
end of ITAB.
data: W_BEGDA like HRPY_RGDIR-FPBEG,
W_ENDDA like HRPY_RGDIR-FPEND.
data: RETURN like BAPIRETURN1 occurs 0 with header line.
data: P_INFO like PC407,
P_FORM like PC408 occurs 0 with header line.
data: P_IDX type I,
MY_MONTH type T549Q-PABRP,
STR_MY_MONTH(2) type C,
MY_YEAR type T549Q-PABRJ,
STR_MY_YEAR(4) type C,
CRLF(2) type x value '0D0A'.
data: W_CMONTH(10) type C.
data: TAB_LINES type I,
ATT_TYPE like SOODK-OBJTP.
data: begin of P_INDEX occurs 0,
INDEX type I,
end of P_INDEX.
constants: begin of F__LTYPE, "type of line
CMD like PC408-LTYPE value '/:', "command
TXT like PC408-LTYPE value 's', "textline
end of F__LTYPE.
constants: begin of F__CMD, "commands
NEWPAGE like PC408-LINDA value '',
end of F__CMD.
data: P_LIST like ABAPLIST occurs 1 with header line.
*data: OBJBIN like SOLISTI1 occurs 10 with header line,
data: OBJBIN like LVC_S_1022 occurs 10 with header line,
DOCDATA like SODOCCHGI1,
OBJTXT like SOLISTI1 occurs 10 with header line,
OBJPACK like SOPCKLSTI1 occurs 1 with header line,
RECLIST like SOMLRECI1 occurs 1 with header line,
OBJHEAD like SOLISTI1 occurs 1 with header line,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_buffer type string,
l_no_of_bytes TYPE i,
l_pdf_spoolid LIKE tsp01-rqident,
l_jobname LIKE tbtcjob-jobname.
data: file_length type int4,
spool_id type rspoid,
line_cnt type i.
*-------------------------------------------------------------------* * INITIALIZATION *
OBJBIN = ' | '.
append OBJBIN.
OBJPACK-HEAD_START = 1.
data: S_ABKRS like PV000-ABKRS.
data: S_PABRP like T549Q-PABRP.
data: S_PABRJ like T549Q-PABRJ.
* SELECTION SCREEN *
selection-screen begin of block BL1.
parameters: PAY_VAR like BAPI7004-PAYSLIP_VARIANT default 'ESS_PAYSLIPS' obligatory.
selection-screen end of block BL1.
START-OF-SELECTION.
s_ABKRS = PNPXABKR.
S_PABRP = PNPPABRP.
s_pabrj = PNPPABRJ.
w_begda = PN-BEGDA.
w_endda = PN-ENDDA.
get pernr.
* "Check active employees
rp-provide-from-last p0000 space pn-begda pn-endda.
CHECK P0000-STAT2 IN PNPSTAT2.
* "Check Payslip Mail flag
rp-provide-from-last p0655 space pn-begda pn-endda.
CHECK P0655-ESSONLY = 'X'.
rp-provide-from-last p0001 space pn-begda pn-endda.
* "Find email address
RP-PROVIDE-FROM-LAST P0105 '0030' PN-BEGDA PN-ENDDA.
if p0105-usrid_LONG ne ''.
ITAB-PERNR = P0001-PERNR.
ITAB-ABKRS = P0001-ABKRS.
ITAB-ENAME = P0001-ENAME.
ITAB-USRID_LONG = P0105-USRID_LONG.
append itab.
clear itab.
endif.
"SY-UCOMM ='ONLI'
END-OF-SELECTION.
*------------------------------------------------------------------* start-of-selection.
write : / 'Payroll Area : ', S_ABKRS.
write : / 'Payroll Period/Year : ',STR_MY_MONTH,'-',STR_MY_YEAR. write : / 'System Date : ', SY-DATUM.
write : / 'System Time : ', SY-UZEIT.
write : / 'User Name : ', SY-UNAME.
write : / SY-ULINE.
sort ITAB by PERNR.
loop at ITAB.
clear : P_INFO, P_FORM, P_INDEX, P_LIST, OBJBIN, DOCDATA, OBJTXT, OBJPACK, RECLIST, TAB_LINES.
refresh : P_FORM, P_INDEX, P_LIST, OBJBIN, OBJTXT, OBJPACK, RECLIST.
* Retrieve Payroll results sequence number for this run
select single * from HRPY_RGDIR where PERNR eq ITAB-PERNR
and FPBEG ge W_BEGDA
and FPEND le W_ENDDA
and SRTZA eq 'A'.
* Produce payslip for those payroll results
if SY-SUBRC = 0.
call function 'GET_PAYSLIP'
EXPORTING
EMPLOYEE_NUMBER = ITAB-PERNR
SEQUENCE_NUMBER = HRPY_RGDIR-SEQNR
PAYSLIP_VARIANT = PAY_VAR
IMPORTING
RETURN = RETURN
P_INFO = P_INFO
TABLES
P_FORM = P_FORM.
check RETURN is initial.
* remove linetype from generated payslip
loop at p_form.
objbin = p_form-linda.
append objbin.
line_cnt = line_cnt + 1.
endloop.
file_length = line_cnt * 1022.
* create spool file of paylsip
CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'
EXPORTING
i_file_length = file_length
IMPORTING
e_spoolid = spool_id
TABLES
it_textdata = objbin.
IF sy-subrc EQ 0.
WRITE spool_id.
ENDIF.
DESCRIBE table objbin.
DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = spool_id
NO_DIALOG = ' '
DST_DEVICE = 'MAIL'
* PDF_DESTINATION =
* IMPORTING
* PDF_BYTECOUNT = l_no_of_bytes
* PDF_SPOOLID = l_pdf_spoolid
* LIST_PAGECOUNT =
* BTC_JOBNAME =
* BTC_JOBCOUNT =
TABLES
PDF = pdf
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
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*Download PDF file C Drive
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\itab_to_pdf.pdf'
filetype = 'BIN'
TABLES
data_tab = pdf.
* Transfer the 132-long strings to 255-long strings
* LOOP AT pdf.
* TRANSLATE pdf USING ' ~'.
* CONCATENATE gd_buffer pdf 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.
OBJHEAD = 'Objhead'.
append OBJHEAD.
* preparing email subject
concatenate W_ENDDA(6)
' Payslip-'
ITAB-ENAME+0(28)
ITAB-PERNR+4(4) ')'
into DOCDATA-OBJ_DESCR.
DOCDATA-OBJ_NAME = 'Pay Slip'.
DOCDATA-OBJ_LANGU = SY-LANGU.
OBJTXT = 'Pay Slip.'.
append OBJTXT.
*prepare email lines
OBJTXT = DOCDATA-OBJ_DESCR.
append OBJTXT.
OBJTXT = 'Please find enclosed your current payslip.'.
append OBJTXT.
* Write Attachment(Main)
* 3 has been fixed because OBJTXT has fix three lines
read table OBJTXT index 3.
* DOCDATA-DOC_SIZE = ( 3 - 1 ) * 255 + strlen( OBJTXT ).
clear OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = 3.
OBJPACK-DOC_TYPE = 'RAW'.
append OBJPACK.
* Create Message Attachment
ATT_TYPE = 'PDF'.
describe table OBJBIN lines TAB_LINES.
read table OBJBIN index TAB_LINES.
* OBJPACK-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = ATT_TYPE.
OBJPACK-OBJ_NAME = 'ATTACHMENT'.
OBJPACK-OBJ_DESCR = 'Payslip'.
append OBJPACK.
* Create receiver list refresh RECLIST.
clear RECLIST.
RECLIST-RECEIVER = itab-USRID_long.
translate RECLIST-RECEIVER to lower case.
RECLIST-REC_TYPE = 'U'.
append RECLIST.
* Send the document
*SO_NEW_DOCUMENT_ATT_SEND_API1
call function 'SO_DOCUMENT_SEND_API1'
exporting
DOCUMENT_DATA = DOCDATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
tables
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = pdf
CONTENTS_TXT = OBJTXT
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
RECEIVERS = RECLIST
exceptions
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
others = 8.
if SY-SUBRC NE 0.
ITAB-MTEXT = 'Message Not Sent to : '.
else.
ITAB-MTEXT = 'Message Sent to : '.
endif.
* else.
* ITAB-MTEXT = 'Message Not Sent to : '.
* endif.
else.
"SY-SUBRC Not = 0
ITAB-MTEXT = 'Payroll data not found : '.
endif.
"end of SY-SUBRC = 0.
modify ITAB.
endloop. "end loop at ITAB
sort ITAB by MTEXT PERNR.
loop at ITAB.
at new MTEXT.
uline.
write : / ITAB-MTEXT color 4 intensified on.
write : / 'Emp. Code' color 2 intensified on,
12 'Emp. Name' color 2 intensified on,
54 'Email ID' color 2 intensified on.
endat.
write : / ITAB-PERNR, 12 ITAB-ENAME, 54 ITAB-USRID_LONG.
endloop. -
Create XML file on application server (unix directory) from internal table
Hallo everybody,
I have got the following problem:
I am working with <u><b>release 4.6C</b></u> and have got to create XML files from HR master data and organizational data respectively.
This takes place in 3 steps:
1. Collect the data in an internal table
2. Convert the data to XML format using the function module 'SAP_CONVERT_TO_XML_FORMAT'
3. Download the data
If I download the converted data, which are in an internal table, to the presentation server via the function module WS_DOWNLOAD and open it with the Internet Explorer, everything is ok.
If I download the converted data to the application server, i.e. into a unix directory via
open dataset, loop at internal table, transfer working area to file, close dataset
and then try to open it, this is not possible, because after the last tag some unreadable characters, e.g. a square, appear that arent supposed to be there. Thats what my colleagues told me, for I havent got access to the server.
I have no idea where these characters come from and how I can get rid of them. I guess that either I have to modify (how?) the table with the converted data before the download or I have to use another way to convert the data. For the second way I would probably have to work with an XML class or an XML interface. Unfortunately II am not an expert in working with classes so sample coding would have to be rather detailed.
Heres some more information about how I work with the conversion function module:
call function 'SAP_CONVERT_TO_XML_FORMAT'
exporting
i_field_seperator = lv_field_seperator
i_line_header = lv_line_header
i_filename = lv_xml_file
i_appl_keep = ' '
i_xml_doc_name = lv_xml_doc_name
importing
pe_bin_filesize = lv_result
tables
i_tab_sap_data = gt_data
changing
i_tab_converted_data = lt_tab_converted_data
exceptions
conversion_failed = 1
others = 2.
lv_field_seperator = X.
lv_xml_doc_name = Personalstammdaten Publikation
lv_result: type i
gt_data: fields: PERNR, PERSG, PERSK etc.
types:
begin of truxs_xml_line,
data(256) type x,
end of truxs_xml_line.
types:
truxs_xml_table type table of truxs_xml_line.
data:
lv_tab_converted_data type truxs_xml_line,
lt_tab_converted_data type truxs_xml_table
open dataset lv_xml_file for output in binary mode.
loop at lt_tab_converted_data into lv_tab_converted_data.
transfer lv_tab_converted_data to lv_xml_file.
endloop.
close dataset lv_xml_file
lv_xml_file: /usr/users/.../.../Personendaten_2004-11-02.xml
Hope the information is detailed enough! Otherwise let me know. Thank you in advance.
Message was edited by: Johannes SchwehmHi Raja,
tried the "TEXT" mode, but that didn't help.
There are still characters after the last tag, that are not supposed to be there including a date that is not
the creation date of the file.
Thank you for your help.
Regards
Johannes -
Create an internal table with the rows of another internal table.
Hi I want to know if posible to create an internal table structure with the rows of another internal table?
ex.
If in i_tab column A has this values: row 1 = first, row 2 = second, row 3 = third.
Now I want that the structure of my internal table be: first, second, thirdHi,
If you do this way then what will be the difference between the two table anyway?? First internal table has the same structure irrespective of which row you select. and you are going to store the data from each row to the rows of the second internal table. In that case, the structure of the internal table is the same as first table. and it would have same rows.
Am I missing something here? or you want to declare the internal table with each field being the structure of the first table? In this case you'd have to do a dynamic declaration of data as the first table can have any no of rows then the second table would have any no of fields in the structure.
Now if you know that your first internal table is going to have a fixed no of rows eg 3 rows then it becomes simple. Do the following then
Data: begin of second_table occurs 0,
first type <first_table type>,
second type <first_table type>,
third type <first_table type>,
end of second_table.
Regards
Prasenjit -
Eliminate the values from internal table
I have an internal table with fields..
begin of it occurs 0,
ebeln
matkl
werks
end of it.
its filled with values..
ebeln | matkl | werks |
12111 | A123 | LK
12111 | A123 | LK
12111 | A123 | LK
12111 | A123 | LK
12111 | A123 | LK
12111 | A123 | LN
12121 | A124 | LK
12121 | A124 | LK
12121 | A124 | LK
12122 | A125 | LK
12122 | A125 | LK
12122 | A125 | LK
12123 | A126 | LN
12123 | A126 | LN
Now I want to eliminate the values from the internal table where all ebeln and werks are different..for example..all 12111's should be eliminated from the internal table as the it has different werks assighned to one of the ebeln's..and I need only ebeln's with 12121 and 12123.
Any suggention would be helpful..
Thanks,
M/Hi,
DATA : v_ebeln LIKE table name-ebeln,
v_werks LIKE table name--werks.
SORT itab BY ebeln werks .
LOOP AT ITAB.
ON CHANGE OF itab-ebeln.
Move : itab-ebeln TO v_ebeln,
itab-werks TO v_werks.
ENDON.
IF ITAB-ebeln NE v_ebeln OR
ITAB-werks NE v_werks.
DELETE ITAB WHERE ebeln EQ ITAB-ebeln .
clear : v_ebeln , v_werks.
ENDIF.
ENDLOOP. -
Fetch the values from internal table inside an internal table (urgent!!)
data : BEGIN OF PITB2_ZLINFO occurs 0,
BEGDA LIKE SY-DATUM,
ENDDA LIKE SY-DATUM,
PABRJ(4) TYPE N, "Payroll Year
PABRP(2) TYPE N, "Pay. Period
ZL LIKE PC2BF OCCURS 0,
END OF PITB2_ZLINFO.
I have a internal table like this,
How to Fetch the values from internal table inside an internal table.
Kindly Help me on this..
Regards,
Ram.Hi,
Try this....
Loop at PITB2_ZLINF0.
Loop at PITB2_ZLINF0-ZL.
endloop.
Endloop.
Thanks...
Preetham S -
Hi All,
I am getting Error when i am viewing my salary slip in ESS.
The Error i am getting is :
Internal error in the spool system., error key: RFC_ERROR_SYSTEM_FAILURE
So can anybody help me out in this.
Regards,
Dhruv ShahSolved the Error by deleting the spool in the Backend.
Spool was overflow.
Regards,
Dhruv Shah
Maybe you are looking for
-
Return process from Depot with excise duties.
Hi All, I want to return the material from depot(rec. plant) to manufacturing plant (supl plant). When I gone thru forum I found different procedure by different experts. Can anyone guide me for the exact step by step procedure which if anybody is us
-
24" iMac mid 2007 does not read full 4GB Memory
I brought a used 24" iMac mid 2007 with 2GB (one stick of 2GB in one slot) so I brought another 2GB stick same specs as the other one and my mac show only 3GB? Does anyone know the problem? Im running Mountain Lion and all updates has been made to th
-
Unable to install soa suite 10.1.3.1.0 in windows XP
hello when i install SOA Suite10.1.3.1.0 in my windows XP, Configuration Assistant "Oracle Web Services Manager Configuration Assistant" failed, the following is the log: install.configApps.setUpLogging: [copy] Copying 1 file to D:\Oracle\10.1.3.1\Or
-
How to enable flash in windows 8
Adobe website says Firefox is installed. Works under Internet Explorer. But Firefox Options Plugins does not show either Flash or Shock. Trying an install bombs out with an error that it can't find entry point in a Windows system file. How do I get F
-
Hi all: I have a doubt in Query ... I have an infocube for GR quantities and other infocube for confimation quantities. In a multiprovider,i collect this two cubes.In query designer,if i given GR date as i/p, confirmation quantities doesnt display.IF