‎2007 Dec 27 7:12 PM
I have a requirement to generate a Spool from a Custom BAPI. The BAPI gets its input from a broker like XI. Then it generates a report and has to send out the spool number.
Pl advise.
Thanks,
Ven
‎2007 Dec 27 7:27 PM
‎2007 Dec 27 8:49 PM
Solved myself using the follwoing code:
DATA : BEGIN OF T_MARA OCCURS 0.
INCLUDE STRUCTURE MARA.
DATA END OF T_MARA.
data v_spoolid like soos-sndspo.
data: v_textdata like LVC_S_1022 occurs 0 with header line.
SELECT * FROM MARA INTO TABLE T_MARA.
loop at t_mara.
v_textdata-line(18) = t_mara-matnr..
append v_textdata.
clear v_textdata.
endloop.
data: t_lines type i,
t_file type i.
describe table v_textdata lines t_lines.
t_file = t_lines * 1022.
CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'
EXPORTING
I_FILE_LENGTH = t_file
IMPORTING
E_SPOOLID = v_spoolid
TABLES
IT_TEXTDATA = v_textdata
EXCEPTIONS
SPOOL_ERROR = 1
PARAMETERS_INVALID = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Alterantely the following code is a better option:
FORM send_output_to_spool TABLES P_attach STRUCTURE solisti1.
data: IT_TEXTDATA type standard table of LVC_S_1022 ,
t_textdata type LVC_S_1022.
*----
data l_length type i.
*----
data: l_layout like tsp01-rqpaper,
l_doctype like tsp01-rqdoctype.
data l_pri_params type pri_params.
data l_valid type c.
data lt_spool type standard table of w3html.
data l_spool_handle type sy-tabix.
data ls_spool type w3html.
l_doctype = 'BIN'.
l_layout = 'X_POSTSCRIPT'.
data l_name type tsp01-rq0name.
l_name = l_pri_params-plist.
data: I_FILE_LENGTH TYPE INT4.
loop at p_attach.
ls_spool-line = p_attach-line.
append ls_spool to lt_spool.
endloop.
call function 'RSPO_SR_OPEN'
exporting
dest = 'LP01' " l_pri_params-pdest
LDEST =
layout = l_layout
name = l_name
SUFFIX1 =
SUFFIX2 =
COPIES =
PRIO =
immediate_print = ' ' " l_pri_params-primm
AUTO_DELETE =
titleline = 'this'
receiver = l_pri_params-prrec "
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 = e_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.
*----
l_length = i_file_length.
data l_line_length type i.
data t_spool(255) type c.
loop at lt_spool into t_spool.
l_line_length = 255.
call function 'RSPO_SR_WRITE'
EXPORTING
handle = l_spool_handle
text = t_spool
length = l_line_length.
endloop.
*----
call function 'RSPO_SR_CLOSE'
EXPORTING
handle = l_spool_handle.
message i159(0K) with text-m01 e_spoolid.