on 2006 Nov 07 10:09 PM
I am trying to build a sample offline form scenario using the code published in the SDN document "Offline Interactive Forms Using ABAP" written by Vani Krishnamoorthy. Everything works perfectly up to the point where we instantiate the PDF Object to extract the data from the form. Then there seems to be some code missing just before we call the method SET_DOCUMENT. We are supposed to export the parameter pdfdata = pdf_data , but I cannot find where pdf_data variable is declared or assigned. Also, an ENDTRY statement seems to be missing.
Has anyone had success with Vani's offline scenario, and if so, do you know what code is missing, if any?
Thanks in advance for any help you can offer.
Thanks again Ramakrishna,
I am still not able to solve the problem. I believe it's to do with the definition of the table LT_RAWTAB which contains the PDF file uploaded from the PC (I defined it as type SOLIX_TAB, which may be incorrect -- declaration is missing from the sample code so I can't tell). I realize this has nothing to do with Adobe Forms specifically, but it sure would be nice to be able to replicate the forms scenario published in the SDN document.
Thanks again for your help, it has given me some ideas,
but I will have to keep trying.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found the missing code in sample program FP_PDF_TEST_06. Everything works well now.
The PDF file that was uploaded from the PC first needs to be converted from binary to XSTRING before you can create the PDF object:
data: lt_rawtab type standard table of raw255,
g_pdfdata type xstring,
l_len type i.
call method cl_gui_frontend_services=>gui_upload
exporting
filename = l_filename
filetype = 'BIN'
importing
filelength = l_len
changing
data_tab = lt_rawtab "PDF file (binary)
exceptions
file_open_error = 1
file_read_error = 2
etc. etc.
Convert binary tab to Xstring
call function 'SCMS_BINARY_TO_XSTRING'
exporting
input_length = l_len
importing
buffer = g_pdfdata "converted to Xstring
tables
binary_tab = lt_rawtab
exceptions
failed = 1
others = 2.
if sy-subrc is not initial.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Instantiate PDF object..
data: l_fp type ref to if_fp value is initial,
l_pdfobj type ref to if_fp_pdf_object value is initial,
l_fpex type ref to cx_fp_runtime,
l_type type string,
l_errmsg type string.
Get FP reference
l_fp = cl_fp=>get_reference( ).
Handle exceptions with Try..Endtry
try.
Create PDF Object using destination 'ADS' (<--this is how it is
defined in SM59)
l_pdfobj = l_fp->create_pdf_object( connection = 'ADS' ).
Set document
l_pdfobj->set_document( exporting pdfdata = g_pdfdata ).
Tell PDF object to extract data
l_pdfobj->set_extractdata( ).
Execute the call to ADS
l_pdfobj->execute( ).
catch cx_fp_runtime_internal
cx_fp_runtime_system
cx_fp_runtime_usage into l_fpex.
case cl_abap_classdescr=>get_class_name( l_fpex ).
when '\CLASS=CX_FP_RUNTIME_INTERNAL'.
l_type = 'INTERNAL ERROR'.
when '\CLASS=CX_FP_RUNTIME_SYSTEM'.
l_type = 'SYSTEM ERROR'.
when '\CLASS=CX_FP_RUNTIME_USAGE'.
l_type = 'USAGE ERROR'.
endcase.
l_errmsg = l_fpex->get_short( ).
message e010(ad) with l_type ':' l_errmsg.
endtry.
Hi,
Check the program BCS_EXAMPLE_6. It has similar logic.
Check the below sample code.
DATA send_request TYPE REF TO cl_bcs.
DATA pdf_content TYPE solix_tab.
DATA lp_pdf_size TYPE so_obj_len.
Now call the generated function module
CALL FUNCTION fm_name
EXPORTING
/1bcdwb/docparams = fp_docparams
customer = customer
bookings = bookings
connections = connections
IMPORTING
/1bcdwb/formoutput = ls_formoutput
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
send_request = cl_bcs=>create_persistent( ).
---------- add document ----------------------------------------
get PDF xstring and convert it to BCS format
lp_pdf_size = XSTRLEN( ls_formoutput-pdf ).
pdf_content = cl_document_bcs=>xstring_to_solix(
ip_xstring = ls_formoutput-pdf ).
document = cl_document_bcs=>create_document(
i_type = 'PDF'
i_hex = pdf_content
i_length = lp_pdf_size
i_subject = 'test created by BCS_EXAMPLE_6' ). "#EC NOTEXT
.....
Message was edited by: Ramakrishna Prasad Ramisetti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the feedback. However the code sample you provided is related to the sending of the form via email. This part of the scenario works fine for me. My problem is when we want to read the filled PDF form back into our application and extract the data from the form (Step "Instantiate the PDF Object"). Specifically, here's the sample code that appears to be incomplete in Vani's document:
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_fpec type ref to cx_fp_runtime value is initial.
TRY.
Create PDF Object using destination 'ADS' (<--this
is how it is defined in SM59)
DATA: lo_pdfobj type ref to if_fp_pdf_object value is initial.
lo_pdfobj = lo_fp->create_pdf_object( connection = 'ADS' ).
Set document
lo_pdfobj->set_document(
exporting
pdfdata = pdf_data ). <<== where did this come from?
.
.etc
Hi Sharon,
You are correct. The code is missing for pdf_data.
But you can still use the progran BCS_EXAMPLE_6 to create the required code.
pdf_data object need to be created using internal table lt_rawtab (cl_gui_frontend_services=>gui_upload).
So I think you can write logic like similar to below.
Please check with the bwlo code.
get PDF xstring and convert it to BCS format
DATA pdf_data TYPE solix_tab.
DATA lp_pdf_size TYPE so_obj_len.
lp_pdf_size = XSTRLEN( lt_rawtab ).
pdf_data = cl_document_bcs=>xstring_to_solix(
ip_xstring = lt_rawtab ).
document = cl_document_bcs=>create_document(
i_type = 'PDF'
i_hex = pdf_data
i_length = lp_pdf_size
i_subject = 'Vendor Master' ). "#EC NOTEXT
Thanks
Ramakrishna
User | Count |
---|---|
67 | |
11 | |
10 | |
10 | |
9 | |
9 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.