Hi Venkat
I am looking back on my program now, its been a whild since I finished it, and I am using it to merge two pdf fields into one pdf spool.
i am using the global directory I will attach the updated code for you.
you can also check out the code in this method. CL_SALV_WD_C_TABLE_V_TABLE->ON_PDF_SEND_TO_PRINTER
<p>
return.
l_wa_old_spool-rqident = 30096.
APPEND l_wa_old_spool
TO l_i_old_spools.
l_wa_old_spool-rqident = 30094.
APPEND l_wa_old_spool
TO l_i_old_spools.
BREAK-POINT.
DATA:
l_handle TYPE sy-tabix,
l_spoolid TYPE tsp01-rqident, "#EC NEEDED
l_partname TYPE adspart, "#EC NEEDED
l_new_partname TYPE adspart, "#EC NEEDED
l_filename(128) TYPE c.
data: lv_append type char1.
l_v_partname = 'darrenTest1'.
* Create a new spool order for the PDF'S
CALL FUNCTION 'ADS_SR_OPEN'
EXPORTING
dest = l_v_prdest
immediate_print = abap_false
* append = ' ' "append
doctype = l_c_doctype
titleline = 'Darren Merge Test'
IMPORTING
handle = l_v_handle
spoolid = l_v_spoolid
partname = l_v_partname
EXCEPTIONS
device_missing = 1
no_such_device = 2
operation_failed = 3
wrong_doctype = 4
wrong_devicetype = 5
OTHERS = 6.
CALL FUNCTION 'ADS_GET_PATH'
IMPORTING
ads_path = l_v_globaldir.
BREAK-POINT.
PERFORM get_statements.
READ TABLE gt_return INTO ls_doc INDEX 1.
CLEAR l_filename.
*CONCATENATE l_v_globaldir l_v
*l_v_partname = 'darrenTest1'.
*l_filename = |{ l_v_globaldir }/{ l_v_partname }.pdf |.
l_filename = |{ l_v_partname }.pdf |.
LOOP AT gt_return INTO ls_doc.
if sy-tabix > 1.
lv_append = 'X'.
else.
clear lv_append.
endif.
CALL FUNCTION 'ADS_WRITE_TO_FILE'
EXPORTING
filename = l_filename
buffer = ls_doc-bindoc
append = lv_append
useglobaldir = 'X'
EXCEPTIONS
cannot_open_file = 1
open_dataset_no_authority = 2
open_dataset_internal_error = 3
open_dataset_too_many_files = 4
dataset_cant_close = 5
close_dataset_internal_error = 6
cannot_close_file = 7
cannot_transfer_data = 8
transfer_internal_error = 9
dataset_write_error = 10
OTHERS = 11.
ENDLOOP.
CALL FUNCTION 'ADS_SR_CONFIRM'
EXPORTING
handle = l_v_handle
partname = l_v_partname
size = 0
pages = 0
* NO_PDF = ' '
IMPORTING
new_partname = l_new_partname
EXCEPTIONS
handle_not_valid = 1
operation_failed = 2
OTHERS = 3.
CALL FUNCTION 'ADS_SR_CLOSE'
EXPORTING
handle = l_v_handle
final = abap_true
EXCEPTIONS
handle_not_valid = 1
operation_failed = 2
OTHERS = 3.