REPORT zpdfsendtoftp.
DATA : BEGIN OF t_vbak OCCURS 0,
vbeln TYPE vbrk-vbeln,
vkorg TYPE vbak-vkorg,
vkbur TYPE vbak-vkbur,
END OF t_vbak.
DATA: fm_name TYPE rs38l_fnam,
p_form TYPE tdsfname VALUE 'ZTEST1'. "smartforms name
DATA: carr_id TYPE sbook-carrid,
cparam TYPE ssfctrlop,
outop TYPE ssfcompop,
tab_otf_data TYPE ssfcrescl,
pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
file_size TYPE i,
bin_filesize TYPE i,
file_name TYPE string,
file_path TYPE string,
full_path TYPE string.
PARAMETERS : vbeln TYPE vbak-vbeln. " input parameter
SELECT vbeln vkorg vkbur FROM vbak INTO TABLE t_vbak WHERE vbeln = vbeln.
outop-tddest = 'LP01'.
cparam-no_dialog = 'X'.
cparam-preview = space.
cparam-getotf = 'X'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_form
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
CALL FUNCTION fm_name
EXPORTING
control_parameters = cparam
output_options = outop
user_settings = space
vbeln = vbeln
IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = tab_otf_data
TABLES
t_vbak = t_vbak.
tab_otf_final[] = tab_otf_data-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = bin_filesize
TABLES
otf = tab_otf_final
lines = pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 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.
"""""""""""" send pdf file to server """""""""""
DATA : i_tab_converted_data TYPE STANDARD TABLE OF char200 WITH HEADER LINE.
TYPES:
BEGIN OF ty_ftp,
zcountry TYPE zftpi-zcountry,
zuser TYPE zftpi-zuser,
zpasswd TYPE zftpi-zpasswd,
zhost TYPE zftpi-zhost,
zrfc_dest TYPE zftpi-zrfc_dest,
zapp TYPE zftpi-zapp,
zftp TYPE zftpi-zftp,
END OF ty_ftp,
BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
DATA: lt_xml_table TYPE TABLE OF xml_line,
l_xml_size TYPE i,
l_rc TYPE i,
lv_success TYPE i VALUE 1,
l_element_package TYPE REF TO if_ixml_element,
l_element_details TYPE REF TO if_ixml_element,
l_value TYPE string.
DATA: result TYPE TABLE OF text WITH HEADER LINE,
commands TYPE TABLE OF text WITH HEADER LINE.
DATA: c TYPE likp-ablad.
DATA: country TYPE char2.
DATA :rec TYPE xml_line."Adjust as per requirement/OS limits
DATA filepath(128) TYPE c.
DATA: w_hdl TYPE i,
c_key TYPE i VALUE 26101957,
l_slen TYPE i,
command_index TYPE i.
DATA : l_interface_key TYPE char30,
l_filename TYPE char200,
l_content_type TYPE char10,
lv_command(200) TYPE c.
DATA: t_time TYPE sy-uzeit,
lv_move TYPE c,
lv_pick TYPE c,
lv_pack TYPE c.
DATA: l_user(30) TYPE c VALUE 'ftptest123', "user name of ftp server
l_pwd(30) TYPE c VALUE 'pass123', "password of ftp server
l_host(64) TYPE c VALUE 'enter host', "ip address of FTP server
l_dest LIKE rfcdes-rfcdest VALUE 'SAPFTPA'. "Background RFC destination
filepath = '/home'.
OPEN DATASET filepath FOR OUTPUT IN BINARY MODE.
IF sy-subrc = 0.
LOOP AT lt_xml_table INTO rec.
TRANSFER rec TO filepath.
ENDLOOP.
ENDIF.
CLOSE DATASET filepath.
CONCATENATE '/' 'test' '.pdf' INTO l_filename. " file name
CONCATENATE 'put' filepath l_filename INTO lv_command SEPARATED BY space.
*HTTP_SCRAMBLE: used to scramble the password provided in a format recognized by SAP.
SET EXTENDED CHECK OFF.
l_slen = strlen( l_pwd ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
source = l_pwd
sourcelen = l_slen
key = c_key
IMPORTING
destination = l_pwd.
* To Connect to the Server using FTP
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = l_user
password = l_pwd
host = l_host
rfc_destination = l_dest
IMPORTING
handle = w_hdl
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
lv_success = 0.
EXIT.
ENDIF.
REFRESH commands.
* ***connecting to the ftp server
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = w_hdl
fname = l_filename
blob_length = bin_filesize
TABLES
blob = pdf_tab
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
* To disconnect the FTP
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = w_hdl.
*RFC_CONNECTION_CLOSE:This is used to disconnect the RFC connection between SAP and other system.
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = l_dest
EXCEPTIONS
OTHERS = 1.
WRITE: 'pdf file send successfully'.
DATA : BEGIN OF t_vbak OCCURS 0,
vbeln TYPE vbrk-vbeln,
vkorg TYPE vbak-vkorg,
vkbur TYPE vbak-vkbur,
END OF t_vbak.
DATA: fm_name TYPE rs38l_fnam,
p_form TYPE tdsfname VALUE 'ZTEST1'. "smartforms name
DATA: carr_id TYPE sbook-carrid,
cparam TYPE ssfctrlop,
outop TYPE ssfcompop,
tab_otf_data TYPE ssfcrescl,
pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
file_size TYPE i,
bin_filesize TYPE i,
file_name TYPE string,
file_path TYPE string,
full_path TYPE string.
PARAMETERS : vbeln TYPE vbak-vbeln. " input parameter
SELECT vbeln vkorg vkbur FROM vbak INTO TABLE t_vbak WHERE vbeln = vbeln.
outop-tddest = 'LP01'.
cparam-no_dialog = 'X'.
cparam-preview = space.
cparam-getotf = 'X'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_form
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
CALL FUNCTION fm_name
EXPORTING
control_parameters = cparam
output_options = outop
user_settings = space
vbeln = vbeln
IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = tab_otf_data
TABLES
t_vbak = t_vbak.
tab_otf_final[] = tab_otf_data-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = bin_filesize
TABLES
otf = tab_otf_final
lines = pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 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.
"""""""""""" send pdf file to server """""""""""
DATA : i_tab_converted_data TYPE STANDARD TABLE OF char200 WITH HEADER LINE.
TYPES:
BEGIN OF ty_ftp,
zcountry TYPE zftpi-zcountry,
zuser TYPE zftpi-zuser,
zpasswd TYPE zftpi-zpasswd,
zhost TYPE zftpi-zhost,
zrfc_dest TYPE zftpi-zrfc_dest,
zapp TYPE zftpi-zapp,
zftp TYPE zftpi-zftp,
END OF ty_ftp,
BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
DATA: lt_xml_table TYPE TABLE OF xml_line,
l_xml_size TYPE i,
l_rc TYPE i,
lv_success TYPE i VALUE 1,
l_element_package TYPE REF TO if_ixml_element,
l_element_details TYPE REF TO if_ixml_element,
l_value TYPE string.
DATA: result TYPE TABLE OF text WITH HEADER LINE,
commands TYPE TABLE OF text WITH HEADER LINE.
DATA: c TYPE likp-ablad.
DATA: country TYPE char2.
DATA :rec TYPE xml_line."Adjust as per requirement/OS limits
DATA filepath(128) TYPE c.
DATA: w_hdl TYPE i,
c_key TYPE i VALUE 26101957,
l_slen TYPE i,
command_index TYPE i.
DATA : l_interface_key TYPE char30,
l_filename TYPE char200,
l_content_type TYPE char10,
lv_command(200) TYPE c.
DATA: t_time TYPE sy-uzeit,
lv_move TYPE c,
lv_pick TYPE c,
lv_pack TYPE c.
DATA: l_user(30) TYPE c VALUE 'ftptest123', "user name of ftp server
l_pwd(30) TYPE c VALUE 'pass123', "password of ftp server
l_host(64) TYPE c VALUE 'enter host', "ip address of FTP server
l_dest LIKE rfcdes-rfcdest VALUE 'SAPFTPA'. "Background RFC destination
filepath = '/home'.
OPEN DATASET filepath FOR OUTPUT IN BINARY MODE.
IF sy-subrc = 0.
LOOP AT lt_xml_table INTO rec.
TRANSFER rec TO filepath.
ENDLOOP.
ENDIF.
CLOSE DATASET filepath.
CONCATENATE '/' 'test' '.pdf' INTO l_filename. " file name
CONCATENATE 'put' filepath l_filename INTO lv_command SEPARATED BY space.
*HTTP_SCRAMBLE: used to scramble the password provided in a format recognized by SAP.
SET EXTENDED CHECK OFF.
l_slen = strlen( l_pwd ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
source = l_pwd
sourcelen = l_slen
key = c_key
IMPORTING
destination = l_pwd.
* To Connect to the Server using FTP
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = l_user
password = l_pwd
host = l_host
rfc_destination = l_dest
IMPORTING
handle = w_hdl
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
lv_success = 0.
EXIT.
ENDIF.
REFRESH commands.
* ***connecting to the ftp server
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = w_hdl
fname = l_filename
blob_length = bin_filesize
TABLES
blob = pdf_tab
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
* To disconnect the FTP
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = w_hdl.
*RFC_CONNECTION_CLOSE:This is used to disconnect the RFC connection between SAP and other system.
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = l_dest
EXCEPTIONS
OTHERS = 1.
WRITE: 'pdf file send successfully'.
Thanks for your comments..
ReplyDeleteThanks for your comments..
ReplyDeleteThank you. It is such a wonderful post. it has great information it is very useful for sap videos.
ReplyDeleteI get a lot of great information from this blog on sap video tutorials
ReplyDeleteThank you it is really such a wonderful blogpost on sap training videos Please Share More Information.
ReplyDeleteI am planning to join sap abap with them after reading your blog.
ReplyDeleteHope the best will turn out.
Call them at 8122241286 in chennai.
www.thecreatingexperts.com
We provide sap abap technical course, call us to know more about us and join with us.
ReplyDeleteCall them at 8122241286 in chennai.
www.thecreatingexperts.com
Thank you for your post on sap video tutorials.
ReplyDelete
ReplyDeleteIt was so nice article Thank you for valuable information sap video tutorials
It was so nice article.I was really satisified by seeing this article. It has great information on.. sap video tutorials
ReplyDeleteThank you.This article is really contains lot more information about This Topic on sap video tutorials
ReplyDeleteGreat post! I am actually getting ready to across this information, It's very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
ReplyDeleteHadoop Training in Chennai
Dotnet Training in Chennai
Thank you sir.Thank you for giving this best information. It’s a very nice topicsap video
ReplyDeleteThanks for the great information in your blog on It was so nice article sap video tutorials
ReplyDeleteThank you sir.Thanks for Nice and Informative Post on sap video
ReplyDeleteThank you sir.It was so nice article Thank you for valuable information sap video
ReplyDeleteWell it Was Very Good Information. Thanks for sharing this Information. sap video tutorials
ReplyDeleteThanks for the great information in your blog on It was so nice article Thank you for valuable informationsap video tutorials
ReplyDeleteThank you for giving this best information. It’s a very nice topic on sap video tutorials
ReplyDeleteThankyou for information excellent blog have a great possible sap video tutorials
ReplyDeleteI like your post, its very informative and we learn something new from it...
ReplyDeleteSAP FICO Online Training
Simple Finance Online Training
SAP FSCM Online Training
Thank you. sir, Really I like your post on sap videos.
ReplyDeleteI have been a blogger too but you post much technical details. Thank you for sharing your knowledge. The creating experts was my first trainer in SAP ABAP got in depth learning from them
ReplyDeletehttp://thecreatingexperts.com/sap-abap-training-in-chennai/
contact +91-08122241286
SAP ABAP training is provided in CHENNAI.
ReplyDeleteTHE CREATING EXPERTS is one of the leading trainer in SAP who provides real time training
http://thecreatingexperts.com/sap-abap-training-in-chennai/
contact 8122241286
Thank you. It is such a wonderful post. it has great information it is very useful Post. sap video tutorials
ReplyDeleteThank you for Wonderful information.
ReplyDeleteSAP ABAP training in CHENNAI BY THE CREATING EXPERTS
http://thecreatingexperts.com/sap-abap-training-in-chennai/
CONTACT 8122241286
Thank you for Wonderful information.
ReplyDeleteSAP ABAP training in CHENNAI BY THE CREATING EXPERTS
http://thecreatingexperts.com/sap-abap-training-in-chennai/
CONTACT 8122241286
ReplyDeleteThis article is really contains lot more information sap video tutorials
ReplyDeleteThanks for sharing this informative blog..Your blog is really useful for me. sap video tutorials
ReplyDeleteThank you for giving this best information. It’s a very nice topic..sap video tutorials
Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video
ReplyDelete
ReplyDeleteWell it Was Very Good Information. Thanks for sharing this Information. sap video
Thank you for giving this best information. It’s a very nice topic.sap videos tutorials
ReplyDeleteFabulous..!!! The information you Provided is much useful.sap video
ReplyDeleteThis article is really contains lot more information.sap video tutorials
ReplyDelete
ReplyDeleteFabulous..!!! The information you Provided is much useful. sap videos tutorials
ReplyDeleteThanks for the great information in your blog on It was so nice article. sap video
This article is really contains lot more information. sap video tutorials
ReplyDeleteThanks for Sharing this Information.You are providing very valuable information. sap video
ReplyDelete
ReplyDeleteI get a lot of great information from this blog on sap video
Thank you for Sharing Great Information. It is Very Helpful Information onsap video tutorials
ReplyDeleteThank you. sir, Really I like your post on sap videos tutorials
ReplyDeleteHi, thanks, but this dont work for me....
ReplyDeletecan help?
I get a lot of great information from this blog. sap video tutorials
ReplyDelete
ReplyDeleteThe information you have given here is truly helpful to me. sap video tutorials
ReplyDeleteThank you for Sharing Great Information. It is Very Helpful Information on.sap video tutorials
ReplyDeleteThe information you have given here is truly helpful to me. sap video
Thank you for giving this best information. It’s a very nice topic. sap video tutorials
ReplyDeleteI am very grateful to you that you share very informative post with ussap video tutorials
ReplyDeleteThanks for sharing this informative blog..Your blog is really useful for me. sap video tutorials
ReplyDeleteIt was so nice article Thank you for valuable information. sap training videos
ReplyDeleteThanks for Nice and Informative Post on. sap video tutorials
ReplyDelete
ReplyDeleteThis article is really contains lot more information sap videos tutorials
Good blog post.I want to thank you for interesting and helpful information and my website some Information Hire This is one program that's effective in helping other interested data entry operators to do the job. Such billing uses optical character technology that recognizes and reads data on medical bills, instantly, electronically and automatically..If you want to know more.I will suggest you check out this link pdf data entry services
ReplyDelete{ Otherwise, {you can|you are able to|it is possible to|you'll be able to} directly ask Pay - Pal {or other|or any other|or another|and other} {methods to|techniques to|solutions to|ways to} {help you|assist you to|enable you to|allow you to} on phone or through remote desktop software| Some things {to look|to appear|to check|to take a look} out for {are the|would be the|will be the|include the} {availability of|accessibility to|option of|use of} direct {phone numbers|telephone numbers|cell phone numbers|numbers}, instant messaging support, and direct emails| You will never {know exactly|know precisely|understand specifically|specifically} that {what type of|which kind of|what sort of|which} client {you are|you're|you might be|you happen to be} handling {and you have|and you've got|plus you've got|along with} to be prepared {and have|and also have|and possess|and still have} some {bunch of|couple of|few|lot of} {ideas to|suggestions to|tips to|tricks to} {make out|write out|find out|figure out} the solutionspdf data entry services
ReplyDeletehi , tried your steps, it's not working for me
ReplyDeleteGetting command_error 3
ReplyDelete