Hi ,
how could I upload data from PDF into R/3
I am using below logic ,
But getting error at lo_pdfobj->execute( ).,could you please let me know
is there any ways ?
"**************************************************************************
PERFORM get_pdf_data.
PERFORM get_pdf_instantiate.
PERFORM extract_data.
&----
*& Form F4_HELP_FOR_FILE
&----
FORM f4_help_for_file . CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = lt_file_table
rc = lv_rc
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 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.
READ TABLE lt_file_table
INTO lv_filename
INDEX 1.
READ TABLE lt_file_table
INTO p_file
INDEX 1.
IF sy-subrc EQ 0.
lv_filename = p_file.
ENDIF.
ENDFORM. " F4_HELP_FOR_FILE
&----
*& Form GET_PDF_DATA
&----
form GET_PDF_DATA .
cl_gui_frontend_services=>gui_upload(
EXPORTING
filename = lv_filename
filetype = 'BIN' "Binary
IMPORTING
filelength = lv_filelength
CHANGING
data_tab = lt_rawtab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19 ).
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lv_filelength
FIRST_LINE = 0
LAST_LINE = 0
IMPORTING
BUFFER = w_pdf_data
tables
binary_tab = lt_rawtab
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. " GET_PDF_DATA
&----
*& Form GET_PDF_INSTANTIATE
&----
form GET_PDF_INSTANTIATE .
Get FP reference
DATA: lo_fp TYPE REF TO if_fp VALUE IS INITIAL.
lo_fp = cl_fp=>get_reference( ).
For handling exceptions
DATA: lo_fpex TYPE REF TO cx_fp_runtime VALUE IS INITIAL.
TRY.
lo_pdfobj = lo_fp->create_pdf_object( connection = 'ADS' ).
Set document
lo_pdfobj->set_document(
EXPORTING
pdfdata = w_pdf_data ).
Tell PDF object to extract data
lo_pdfobj->set_extractdata( ).
Execute the call to ADS
lo_pdfobj->execute( ).
CATCH cx_fp_runtime_system INTO exc.
xslt_message = exc->get_text( ).
ENDTRY.
endform. " GET_PDF_INSTANTIATE
&----
*& Form EXTRACT_DATA
&----
form EXTRACT_DATA .
DATA: xml_data TYPE xstring,
t_return type standard table of bapiret2,
t_per_info type standard table of smum_xmltb,
lfs_per_info type smum_xmltb.
lo_pdfobj->get_data(
IMPORTING
formdata = xml_data ).
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = xml_data
tables
xml_table = t_per_info
return = t_return
.
endform. " EXTRACT_DATA
Regards,
Siddivinesh.
hi,
check the below link for the same
Add a comment