Es común que nos pidan hacer un resguardo de un formulario. Y probablemente tengamos que hacer el backup a PDF.
Con las siguientes pocas líneas vamos a poder hacerlo.
*Declaraciones
TABLES: itcpo.
DATA: otfdata LIKE itcoo OCCURS 0 WITH HEADER LINE,
intab TYPE soli_tab,
objbin TYPE solix_tab,
wa_intab TYPE LINE OF soli_tab,
wa_objbin TYPE LINE OF solix_tab,
objpack LIKE sopcklsti1 WITH HEADER LINE.
*Antes de la llamada a la función ‘OPEN_FORM’
itcpo-tdgetotf = ‘X’.
itcpo-tddest = ‘LP01’.
CALL FUNCTION ‘OPEN_FORM’
EXPORTING
form = ‘ZSAPSCRIPT’ “Nombre del formulario Sapscript
language = ‘S’
options = itcpo
device = ‘PRINTER’
dialog = ‘ ‘ “Vacío para que no muestre el pop-up de impresión
EXCEPTIONS
OTHERS = 1.
*En el ‘CLOSE_FORM’
CALL FUNCTION ‘CLOSE_FORM’
TABLES
otfdata = otfdata
EXCEPTIONS
OTHERS = 1.
*En la tabla otfdata nos queda guardado el formulario en formtao OTF
*Ahora sólo resta convertir el OTF en PDF
LOOP AT otfdata.
wa_intab = otfdata.
APPEND wa_intab TO intab.
CLEAR wa_intab.
ENDLOOP.
*Convertir el OTF en PDF
CALL FUNCTION ‘SX_OBJECT_CONVERT_OTF_PDF’
EXPORTING
format_src = ‘OTF’
format_dst = ‘PDF’
* ADDR_TYPE =
devtype = ‘LP01’
* FUNCPARA =
CHANGING
transfer_bin = objpack-transf_bin
content_txt = intab
content_bin = objbin
objhead = intab
len = objpack-doc_size
EXCEPTIONS
err_conv_failed = 1
OTHERS = 2.
*LISTO!!! En la tabla objbin nos queda guardado el PDF para salvarlo *en la PC con la función ‘GUI_DOWNLOAD’ o bien enviarlo por mail con *la función ‘SO_NEW_DOCUMENT_ATT_SEND_API1’
Comentarios Recientes: