Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to print multiple instances of a Smartform ?

0 Kudos

Hello, before all thanks for entry.

Well, at the begining. I have two internal tables 1st have the information of the order (customer information) and in the 2nd i have the different positions of the order like which items he bought.

I need different instances of the smarform for each customer, but my code bring me only one instance. Here is my code. pls help.

At the begining of the code i look for the orders and the order details and i sent this like parameters to the smartform in a loop for each order. the code only print the last order .

  "variables de logica
DATA: periodo_vigente TYPE zsd_t_periodoven-cod_peventas,
vl_kunnr TYPE zsd_t_peventa-kunnr,
vl_nombre TYPE kna1-name1.

"variables de smartform
DATA: lv_fname TYPE rs38l_fnam.
DATA: ls_control_parameters TYPE ssfctrlop.
DATA: ls_composer_param TYPE ssfcompop.
DATA: ls_job_output_info TYPE ssfcrescl.
DATA: lt_lines_pdf TYPE TABLE OF tline.

ls_control_parameters-getotf = 'X'.
ls_control_parameters-no_dialog = 'X'.
ls_composer_param-tdcopies = '002'.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSD_SF_REMITOPEDIDO_FUNSAD'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
fm_name = lv_fname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

SELECT SINGLE cod_peventas
FROM zsd_t_periodoven
INTO periodo_vigente
WHERE fecha_inicio <= sy-datum
AND fecha_cierre >= sy-datum.

SELECT num_pedido
INTO TABLE it_num_pedido
FROM zsd_t_peventa
WHERE cod_peventas = periodo_vigente.


LOOP AT it_num_pedido.

it_detalle_cliente-num_pedido = it_num_pedido-num_pedido.

SELECT SINGLE kunnr
FROM zsd_t_peventa
INTO it_detalle_cliente-kunnr
WHERE num_pedido = it_num_pedido-num_pedido.

vl_kunnr = it_detalle_cliente-kunnr.
CLEAR it_detalle_cliente-nombre.

SELECT SINGLE name2
FROM kna1
INTO it_detalle_cliente-nombre
WHERE kunnr = vl_kunnr.
vl_nombre = it_detalle_cliente-nombre.

IF vl_nombre IS INITIAL.
SELECT SINGLE name1
FROM kna1
INTO it_detalle_cliente-nombre
WHERE kunnr = vl_kunnr.
ENDIF.

SELECT SINGLE ort01
FROM kna1
INTO it_detalle_cliente-reparto
WHERE kunnr = vl_kunnr.

SELECT SINGLE pstlz
FROM kna1
INTO it_detalle_cliente-cod_postal
WHERE kunnr = vl_kunnr.

SELECT SINGLE fecha_hora_pedido
FROM zsd_t_peventa
INTO it_detalle_cliente-fecha
WHERE num_pedido = it_num_pedido-num_pedido.

REFRESH it_detalles.

SELECT num_renglon_de cod_producto
INTO TABLE it_detalles
FROM zsd_t_peventa_de
WHERE num_pedido = it_num_pedido-num_pedido.

APPEND it_detalle_cliente.

LOOP AT it_detalles.

DATA vl_numero_renglon TYPE zsd_t_remito_det-num_renglon.
DATA vl_numero_renglon_max TYPE zsd_t_remito_det-num_renglon.
DATA incrementador TYPE i VALUE 1.

it_detalle_pedido-num_pedido = it_num_pedido-num_pedido.

it_detalle_pedido-num_renglon = it_detalles-num_renglon.

SELECT SINGLE cantidad
FROM zsd_t_peventa_de
INTO it_detalle_pedido-cantidad
WHERE num_pedido = it_num_pedido-num_pedido
AND num_renglon_de = it_detalles-num_renglon.

SELECT SINGLE desc_producto
FROM zsd_t_prodfunsad
INTO it_detalle_pedido-desc_producto
WHERE cod_producto = it_detalles-cod_producto.

SELECT SINGLE observacion
FROM zsd_t_peventa_de
INTO it_detalle_pedido-observacion
WHERE num_pedido = it_num_pedido-num_pedido
AND num_renglon_de = it_detalles-num_renglon.

APPEND it_detalle_pedido.

ENDLOOP.

CALL FUNCTION lv_fname
EXPORTING
* archive_index =
* archive_index_tab =
* archive_parameters =
control_parameters = ls_control_parameters
* mail_appl_obj =
* mail_recipient =
* mail_sender =
output_options = ls_composer_param
user_settings = 'X'
IMPORTING
* document_output_info =
job_output_info = ls_job_output_info
* job_output_options =
TABLES
it_cabecera = it_detalle_cliente
it_posiciones = it_detalle_pedido
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
REFRESH it_detalle_cliente.
REFRESH it_detalle_pedido.

ENDLOOP.

CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
* PDF_USERNAME = ' '
* PDF_PREVIEW = ' '
* USE_CASCADING = ' '
* MODIFIED_PARAM_TABLE =
* IMPORTING
* BIN_FILESIZE =
* BIN_FILE =
TABLES
otf = ls_job_output_info-otfdata
lines = lt_lines_pdf
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = 'C:\Users\jdominguez\Desktop\REMITOS.PDF'
filetype = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
* SHOW_TRANSFER_STATUS = ABAP_TRUE
* VIRUS_SCAN_PROFILE = '/SCET/GUI_DOWNLOAD'
* IMPORTING
* FILELENGTH =
TABLES
data_tab = lt_lines_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.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.

0 REPLIES 0