03-19-2013 2:26 PM
Hi Experts,
I want to create the Zprogram which will downlaod the spool request in pdf and store it on the application server (AL11).
Once the file store on application server I need to create Zprogram which will run every night that will pick that file from application server and store the pdf on the share point server.
Currently functionality is we are directly storing the spool request pdf to share point server.
Thanks
Parag
03-19-2013 3:47 PM
Where is your Exact problem, replacing interface (duet ?) to sharepoint with dataset statements ?
Are you sure to have posted in the good forum/space, Switching, Enhancing, and Adapting Standard Programs, or can you reformulate your requirement for that ?
Regards,
Raymond
03-20-2013 8:19 AM
Please do find the code to put the spool in Application server. You can run this program in Background mode by scheduling it.
____________________________________________________________________________________
REPORT zotcopdf LINE-SIZE 255.
* This is for Billing document - create a spool using VF02.
*&---------------------------------------------------------------------*
*& Table declaration
*&---------------------------------------------------------------------*
TABLES : tsp01 , nast , vbrk, ztval1.
*&---------------------------------------------------------------------*
*& Ranges
*&---------------------------------------------------------------------*
RANGES: r_kschl FOR tnati-kschl.
*&---------------------------------------------------------------------*
*& Internal Tables
*&---------------------------------------------------------------------*
DATA : BEGIN OF t_tsp01 OCCURS 0.
INCLUDE STRUCTURE tsp01.
DATA : END OF t_tsp01.
DATA : BEGIN OF t_buffer OCCURS 0.
INCLUDE STRUCTURE soli.
DATA : END OF t_buffer.
DATA : BEGIN OF t_tnati OCCURS 0.
INCLUDE STRUCTURE tnati.
DATA : END OF t_tnati.
DATA : BEGIN OF t_errorlog OCCURS 0,
spool LIKE tsp01-rqident,
desc(100) TYPE c,
END OF t_errorlog.
DATA : BEGIN OF t_success OCCURS 0,
spool LIKE tsp01-rqident,
vbeln LIKE vbrk-vbeln,
END OF t_success.
*&---------------------------------------------------------------------*
*& Variable declaration
*&---------------------------------------------------------------------*
DATA : w_fkschl TYPE c.
DATA : w_char(14) TYPE c VALUE 'Invoice Number'.
DATA : w_tabix LIKE sy-tabix.
DATA: mtab_pdf LIKE tline OCCURS 0 WITH HEADER LINE,
mc_filename TYPE string.
DATA: mstr_print_parms LIKE pri_params,
mc_valid(1) TYPE c,
mi_bytecount TYPE i.
*&---------------------------------------------------------------------*
*& Start of Selection
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* Select the spool number for the latest print by the user.
DATA : w_date LIKE tsp01-rqcretime.
PERFORM get_spools.
PERFORM print_errors.
*&---------------------------------------------------------------------*
*& Form test
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_spools.
CONCATENATE sy-datum '00000000' INTO w_date.
* Select Output types for billing application
SELECT * FROM tnati INTO TABLE t_tnati
WHERE spras EQ 'EN'
AND kappl EQ 'V3'.
* Select spools
SELECT * FROM tsp01 INTO TABLE t_tsp01
WHERE rqclient EQ sy-mandt
AND rq0name EQ 'SMART'
* AND rqowner EQ sy-uname
AND rqarchtype EQ '1'
AND rqcretime GE w_date.
IF sy-subrc NE 0 .
CONCATENATE text-004 ' TIME : ' sy-uzeit ' & DATE :'
sy-datum INTO t_errorlog-desc.
APPEND t_errorlog.
CLEAR t_errorlog.
ENDIF.
SORT t_tsp01 BY rqcretime DESCENDING.
* This program will validate if the output type is ZD00
r_kschl-sign = 'I'.
r_kschl-option = 'EQ'.
r_kschl-low = 'ZD00'.
APPEND r_kschl.
CLEAR r_kschl.
LOOP AT t_tsp01.
REFRESH mtab_pdf.
CONCATENATE 'C:\' 'P_PDFILE' '.PDF' INTO mc_filename.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
copies = '1'
cover_page = space
destination = space
expiration = '1'
immediately = space
layout = space
mode = space
new_list_id = 'X'
no_dialog = 'X'
user = sy-uname
IMPORTING
out_parameters = mstr_print_parms
valid = mc_valid
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
IF sy-subrc EQ 0.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = t_tsp01-rqident
no_dialog = space
dst_device = mstr_print_parms-pdest
IMPORTING
pdf_bytecount = mi_bytecount
TABLES
pdf = mtab_pdf
EXCEPTIONS
err_no_otf_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_dstdevice = 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.
t_errorlog-spool = t_tsp01-rqident.
t_errorlog-desc = text-001.
APPEND t_errorlog.
CLEAR t_errorlog.
CONTINUE.
ELSE.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = t_tsp01-rqident
TABLES
buffer = t_buffer
* EXCEPTIONS
* NO_SUCH_JOB = 1
* JOB_CONTAINS_NO_DATA = 2
* SELECTION_EMPTY = 3
* NO_PERMISSION = 4
* CAN_NOT_ACCESS = 5
* READ_ERROR = 6
* TYPE_NO_MATCH = 7
* OTHERS = 8
.
IF sy-subrc <> 0.
t_errorlog-spool = t_tsp01-rqident.
t_errorlog-desc = text-003.
APPEND t_errorlog.
CLEAR t_errorlog.
CONTINUE.
ENDIF.
SEARCH t_buffer FOR w_char.
w_tabix = sy-tabix.
w_tabix = w_tabix + 2.
READ TABLE t_buffer INDEX w_tabix. "To read the Billing Doc No.
DATA : w_invno LIKE vbrk-vbeln.
w_invno = t_buffer-line+9.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_invno
IMPORTING
output = w_invno.
SELECT SINGLE * FROM vbrk WHERE vbeln EQ w_invno.
IF sy-subrc NE 0.
* t_errorlog-spool = t_tsp01-rqident.
* t_errorlog-desc = text-002.
* APPEND t_errorlog.
* CLEAR t_errorlog.
* CONTINUE.
ELSE.
DATA : file LIKE authb-filename.
DATA : w_time(50) TYPE c.
CONCATENATE sy-datum sy-uzeit INTO w_time.
CONDENSE w_time.
*&----------------------------------------------------------------&
*& To select the Patrner Id to send .pdf file &
*To validate the valid Partner ID in the NAST against the
* Invoice number.
*&----------------------------------------------------------------&
DATA : w_datum TYPE sy-datum.
MOVE sy-datum TO w_datum.
DATA : BEGIN OF t_vbrk OCCURS 0,
vbeln LIKE vbrk-vbeln,
kunag LIKE vbrk-kunag,
END OF t_vbrk.
DATA : BEGIN OF t_nast OCCURS 0,
kschl LIKE nast-kschl,
parnr LIKE nast-parnr,
END OF t_nast.
SELECT vbeln kunag FROM vbrk
INTO TABLE t_vbrk
WHERE vbeln EQ w_invno.
DATA : w_parnr LIKE nast-parnr.
LOOP AT t_vbrk.
SELECT SINGLE parnr FROM nast
INTO CORRESPONDING FIELDS OF t_nast
WHERE kschl EQ 'ZD00'
AND parnr EQ t_vbrk-kunag.
MOVE t_nast-parnr TO w_parnr.
*&------- Passing RAW info of PDF to Application server---------- &.
*To select the directory path dynamically *
* To save the pdf file in a specified directory.
* Fiel Format will be :
*PartnerID_INvoice N0_YYYYMMDDHHmmss
*It will be stored in DR1/INTERFACES/Elemica/ in this program.
*You can change it to any folder in application server, if you want to test this program
*&----------------------------------------------------------------&
DATA : w_sysid TYPE sysid.
MOVE sy-sysid TO w_sysid.
CONCATENATE '/' w_sysid '/interfaces' '/' 'Elemica' '/' w_parnr '' w_invno '' w_time '.pdf' INTO file.
CLEAR w_parnr.
CLEAR w_invno.
*&-----------------------------------------------------------------&
*end of changes
*&-----------------------------------------------------------------&
REFRESH t_buffer.
OPEN DATASET file FOR OUTPUT IN BINARY MODE.
IF sy-subrc NE 0.
t_errorlog-spool = t_tsp01-rqident.
t_errorlog-desc = text-002.
APPEND t_errorlog.
CLEAR t_errorlog.
CONTINUE.
ELSE.
LOOP AT mtab_pdf.
TRANSFER mtab_pdf TO file.
ENDLOOP.
t_success-spool = t_tsp01-rqident.
t_success-vbeln = vbrk-vbeln.
APPEND t_success.
CLEAR t_success.
CLOSE DATASET file.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " test
*&---------------------------------------------------------------------*
*& Form print_errors
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM print_errors.
CALL FUNCTION 'Z_ZS01_REPORT_HEADER'
EXPORTING
ip_confidential = ''
ip_pagewidth = 100
ip_title = text-005.
IF NOT t_errorlog[] IS INITIAL.
WRITE : / text-006.
WRITE : / text-008 , 30 text-010.
ENDIF.
LOOP AT t_errorlog.
WRITE : / t_errorlog-spool , 30 t_errorlog-desc.
ENDLOOP.
IF NOT t_success[] IS INITIAL.
WRITE : / text-007.
WRITE : / text-008 , 30 text-009.
ENDIF.
LOOP AT t_success.
WRITE : / t_success-spool , 30 t_success-vbeln.
ENDLOOP.
ENDFORM. " print_errors
12-28-2021 4:05 PM
CALL FUNCTION 'RSPO_GET_ATTRIBUTES_SPOOLJOB'
EXPORTINGENDIF.
DATA : lv_filename TYPE char50 VALUE '\\10.230.3.33\EDItest\PackingLists'.i had gone with this....but in pdf format internal table return
then i use open dataset
loop at it_pdf .
trasfer it_pdf to lv_dest.
endloop.
close dataset.
then file is created with junk value.
12-28-2021 4:06 PM