XML aus PDF extrahieren mit Testprogramm FP PDF TEST 03
Aus SAP-Wiki
Zur Navigation springenZur Suche springen
SAP hat ein Programm FP_PDF_TEST_03 geschrieben, mit der Funktionalität
- Hochladen eines PDF vom Frontend
- Extraktion des XML aus dem PDF
- Speichern XML auf dem Frontend
report fp_pdf_test_03. * extract data INCLUDE fp_utilities. parameters: p_pdf TYPE localfile obligatory, p_xml TYPE localfile obligatory, p_dest type rfcdest obligatory. DATA: l_fp TYPE REF TO if_fp, l_pdfobj TYPE REF TO if_fp_pdf_object, l_pdf TYPE xstring, l_data TYPE xstring, l_fpex TYPE REF TO cx_fp_runtime. INITIALIZATION. MOVE cl_fp=>get_ads_connection( ) TO p_dest. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_pdf. PERFORM value_help_for_file USING 'PDF' CHANGING p_pdf. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_xml. PERFORM value_help_for_output_file USING 'XML' CHANGING p_xml. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dest. PERFORM value_help_for_destination USING 'P_DEST'. START-OF-SELECTION.
1. PDF-Datei laden
PERFORM load_file USING p_pdf CHANGING l_pdf.
2. XML extrahieren aus PDF
* get FP reference l_fp = cl_fp=>get_reference( ). try. * create PDF Object l_pdfobj = l_fp->create_pdf_object( connection = p_dest ). * set document l_pdfobj->set_document( pdfdata = l_pdf ). * tell PDF object to extract data call method l_pdfobj->set_task_extractdata( ). * execute, call ADS call method l_pdfobj->execute( ). call method l_pdfobj->get_data importing formdata = l_data. CATCH cx_fp_runtime_internal cx_fp_runtime_system cx_fp_runtime_usage INTO l_fpex. PERFORM error USING l_fpex. endtry.
3. Speichern XML auf Frontend
* download data PERFORM download_file USING l_data p_xml.