cancel
Showing results for 
Search instead for 
Did you mean: 

How to capture the value of ADOBE Form field/Internal Table in abap program

Former Member
0 Kudos

Hi Gurus,

I need a way to capture the value of table inside an Adobe Inter-active form in my abap program. I would appreciate, if any body suggest me any solution.

Regards,

Srini

Accepted Solutions (0)

Answers (1)

Answers (1)

OttoGold
Active Contributor
0 Kudos
Former Member
0 Kudos

Hi Otto,

Thank you so much for your help. I am already trying this but not all the data from the pdf file is storing in my variable "xml_data".

When I debug, the variable values xml_data, and lv_xml_data_string they are incorrect. They only contain 2766 and 1381 characters. Is there any other way to get all my PDF Form data instead of partial data.

DATA: xml_data TYPE xstring,

lt_xml_data TYPE STANDARD TABLE OF xstring.

APPEND xml_data TO lt_xml_data.

l_pdfobj->get_data(

IMPORTING

formdata = xml_data ).

  • Convert XML data from XSTRING format to STRING format

DATA: lv_xml_data_string TYPE string.

CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'

EXPORTING

im_xstring = xml_data

IMPORTING

ex_string = lv_xml_data_string.

  • Remove NEW-LINE character from XML data in STRING format

CLASS cl_abap_char_utilities DEFINITION LOAD.

REPLACE ALL OCCURENCES OF cl_abap_char_utilities=>newline IN lv_xml_data_string WITH ''.

  • Make the XML envelope compliant with identity transform

REPLACE '<?xml version="1.0" encoding="UTF-8"?><data>' IN lv_xml_data_string WITH '<?xml version="1.0" encoding="iso-8859-1"?><asx:abap xmlns :asx="http://www.sap.com/abapxml" version="1.0"><asx:values>'.

REPLACE '</data>' IN lv_xml_data_string WITH '</asx:values></asx:abap>'.

OttoGold
Active Contributor
0 Kudos

Hello,

I don´t understand what data do you miss? You should receive all the data saved in the PDF in the XML file. Please elaborate what do you miss and we could try to fiure out what is the problem.

Next: Your coding and the coding from the tutorial are different. Is it on purpose? If you complain about what I recommended, why didn´t you follow the tutorial?

At the end: I am using this tutorial for all my interactive forms data extraction and except some weird characters here and there, everything works fine. SO I don´t understand the problem, sorry.

Otto

Former Member
0 Kudos

Hi Otto,

I have used the code from the same . I have problem in the "Extract the Data" section of the document you have forwarded.Above portion is working fine and displaying only few fields data. My form infact having so many fields and so much data.But the code part I have given is not displaying all the data .

Regards,

Srini

Edited by: Srinivasp on Aug 25, 2010 12:42 PM

OttoGold
Active Contributor
0 Kudos

Reasons why you could get less data than you expect:

- XML file extracted from the PDF file gets truncated. Please check if there is some reasonable end of the XML string or not. I believe there is, because this is a theoretical error.

- some of your fields are not included into the interface. What does not come through the interface, cannot come from the SAP system to the form or vice versa. Check if all the fields you want to get back are present in your interface. If you do not see the XML tags for some data items at all, it is this case.

- fields are not bound correctly (wrong binding string) or not bound at all (no string defined). If you can see the XML tags but there are no values present, it is most probably this case.

- both looks good, but the interface structure was changed some time ago, but the binding string were not corrected

- data are not saved in the form (what is not saved cannot be extracted, obviously).

is that enough for you to find the error?

regards Otto

Former Member
0 Kudos

Hi Otto,

Thanks for your response. For testing I have created test form and used all the fileds only from the interface. But still my XML String is just containing only few fields data and rest of the data is truncated. The XML data is not properly closed also.

CALL TRANSFORMATION is throwing run time error also. In the tutorial u sent me contains the following under the

"Extract the Data" section but lt_xml_data internal table didn't use any where in the code.

lt_xml_data TYPE STANDARD TABLE OF xstring.

APPEND xml_data TO lt_xml_data.

-


Now my problem is : Not all the data is comming into xml string and th xml string is also not properly formatted. I am forwarding all my code, kindly correct me if any thing wrong. Once again thank you so much for spending you valuable time .

INCLUDE Zfp_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.

PERFORM load_file USING p_pdf CHANGING l_pdf.

  • get FP reference

l_fp = cl_fp=>get_reference( ).

*p_dest

try.

  • create PDF Object

l_pdfobj = l_fp->create_pdf_object( connection = 'ADS' ).

  • set document

l_pdfobj->set_document(

exporting

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.

PERFORM FILL_INT_TAB.

  • download data

  • PERFORM download_file USING l_data p_xml.

&----


*& Form FILL_INT_TAB

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FILL_INT_TAB .

  • data : i1 type i,

  • str1 type string,

  • str2(4000) type c.

DATA: xml_data TYPE xstring,

lt_xml_data TYPE STANDARD TABLE OF xstring.

APPEND xml_data TO lt_xml_data.

l_pdfobj->get_data(

IMPORTING

formdata = xml_data ).

  • Convert XML data from XSTRING format to STRING format

DATA: lv_xml_data_string TYPE string.

CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'

EXPORTING

im_xstring = xml_data

IMPORTING

ex_string = lv_xml_data_string.

  • Remove NEW-LINE character from XML data in STRING format

CLASS cl_abap_char_utilities DEFINITION LOAD.

REPLACE ALL OCCURENCES OF cl_abap_char_utilities=>newline IN lv_xml_data_string WITH ''.

  • Make the XML envelope compliant with identity transform

REPLACE '<?xml version="1.0" encoding="UTF-8"?><data>' IN lv_xml_data_string WITH '<?xml version="1.0" encoding="iso-8859-1"?><asx:abap xmlns :asx="http://www.sap.com/abapxml" version="1.0"><asx:values>'.

REPLACE '</data>' IN lv_xml_data_string WITH '</asx:values></asx:abap>'.

  • Apply the identity transform and convert XML into ABAP in one step

*DATA: wa_VNDBNK type ZVK_VNDBNK VALUE IS INITIAL,

*wa_VENDOR type ZHD_VENDOR value is initial,

*lv_subrc TYPE sysubrc VALUE IS INITIAL,

*lt_messtab TYPE STANDARD TABLE OF bdcmsgcoll,

*l_key type SWR_STRUCT-OBJECT_KEY,

*l_pack type zhd_vendor-lifnr.

*CALL TRANSFORMATION id

*SOURCE XML lv_xml_data_string

*RESULT Z_VNDBNK = wa_vndbnk.

  • Apply the identity transform and convert XML into ABAP in one step

DATA: wa_VNDBNK type ZTESTPDF VALUE IS INITIAL,

*wa_VENDOR type ZHD_VENDOR value is initial,

lv_subrc TYPE sysubrc VALUE IS INITIAL,

lt_messtab TYPE STANDARD TABLE OF bdcmsgcoll,

l_key type SWR_STRUCT-OBJECT_KEY.

*l_pack type zhd_vendor-lifnr.

WRITE : / lv_xml_data_string.

*CALL TRANSFORMATION id

*SOURCE XML lv_xml_data_string

*RESULT Z_VNDBNK = wa_vndbnk.

ENDFORM. " FILL_INT_TAB

OttoGold
Active Contributor
0 Kudos

Post last 250 characters of the XML string you get from the ADS... I want to see how it is formatted/ ended. Otto

Former Member
0 Kudos

Hi Otto,

The following is the code part.

<?xml version="1.0" encoding="iso-8859-1"?><asx:abap xmlns :asx="http://www.sap.com/abapxml" version="1.0"><asx:values><EE_GRP>1234</EE_GRP><RTEXT>5678</RTEXT><UNIT>12356</UNIT><

Edited by: Srinivasp on Aug 27, 2010 9:09 AM

OttoGold
Active Contributor
0 Kudos

Hello,

looks like the beginning of the string, not the end. Or this is everything you have/ get?

What data types do you use to manipulate it? Maybe it is getting truncated because of the wrong data types...?

Otto

Former Member
0 Kudos

Hi Otto,

I suspect that there is some problem with data conversion from Xstring to String.

String can only contain 250 characters. even though I have the data in XString, I only can get 250 characters.

Can U pls help me by suggesting a way to Convert XML data from XSTRING format to any internal table?

Regards,

Srini

OttoGold
Active Contributor
0 Kudos

FILL_INT_TAB . * data : i1 type i, * str1 type string, * str2(4000) type c. DATA: xml_data TYPE xstring, lt_xml_data TYPE STANDARD TABLE OF xstring. APPEND xml_data TO lt_xml_data. l_pdfobj->get_data( IMPORTING formdata = xml_data ). * Convert XML data from XSTRING format to STRING format DATA: lv_xml_data_string TYPE string. CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING' EXPORTING im_xstring = xml_data IMPORTING ex_string = lv_xml_data_string.

This look pretty weird. I don´t understand the append before using the tablem, but I can see it in the tutorial as well.

What is the length of the xml-data and lt_xml_data in debug? Are these ok and the probleam apperas in the ECATT?

Otto

p.s.: The original tutorial (I didn´t know it was changed) was not using the object approach, but only a sequence of FM calls. So I am a little puzzled.

Former Member
0 Kudos

Hi Otto,

XML_DATA data contains 510 characters

and LT_XML_DATA is blank

OttoGold
Active Contributor
0 Kudos

Last try, then I get run out of ideas. Change ECATT* to FM SCMSXSTRINGSTRING.

Otto

OttoGold
Active Contributor
0 Kudos

My code (which works):

FUNCTION zpdf_get_filestream.
*"----------------------------------------------------------------------
*"*"Lokální rozhraní:
*"  EXPORTING
*"     VALUE(LENGTH) TYPE  ZPDF_UPLOAD_FILELEN
*"     VALUE(RAWTAB) TYPE  ZPDF_UPLOAD_RAWTAB
*"----------------------------------------------------------------------

  DATA lt_file_table TYPE filetable.
  DATA lv_rc TYPE i.

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    CHANGING
      file_table              = lt_file_table
      rc                      = lv_rc
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      not_supported_by_gui    = 4
      OTHERS                  = 5.

******************************************
  DATA lv_filename TYPE string.
  READ TABLE lt_file_table INTO lv_filename INDEX 1.

******************************************
  cl_gui_frontend_services=>gui_upload(
    EXPORTING
      filename = lv_filename
      filetype = 'BIN'
    IMPORTING
      filelength = length
    CHANGING
      data_tab = 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 ).

ENDFUNCTION.

OttoGold
Active Contributor
0 Kudos

FUNCTION zpdf_get_form_string.
*"----------------------------------------------------------------------
*"*"Lokální rozhraní:
*"  IMPORTING
*"     VALUE(FILELEN) TYPE  ZPDF_UPLOAD_FILELEN
*"     VALUE(RAWTAB) TYPE  ZPDF_UPLOAD_RAWTAB
*"  EXPORTING
*"     REFERENCE(STRINGDATA) TYPE  STRING
*"----------------------------------------------------------------------

  DATA lv_pdf_data TYPE xstring.
**  DATA rawline LIKE LINE OF rawtab.
**  LOOP AT rawtab INTO rawline.
**    CONCATENATE lv_pdf_data rawline INTO lv_pdf_data.
**  ENDLOOP.

  CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
    EXPORTING
      input_length       = filelen
*     FIRST_LINE         = 0
*     LAST_LINE          = 0
   IMPORTING
     BUFFER             = lv_pdf_data
    tables
      binary_tab         = 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.


*****************************************
* 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.
* 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 = lv_pdf_data ).
* Tell PDF object to extract data
    lo_pdfobj->set_extractdata( ).
* Execute the call to ADS
    lo_pdfobj->execute( ).

    DATA: xml_data TYPE xstring,
          lt_xml_data TYPE STANDARD TABLE OF xstring.
    APPEND xml_data TO lt_xml_data.
    lo_pdfobj->get_data(
    IMPORTING
    formdata = xml_data ).
  ENDTRY.
*****************************************

* Convert XML data from XSTRING format to STRING format
  CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
    EXPORTING
      im_xstring = xml_data
    IMPORTING
      ex_string  = stringdata.
* Remove NEW-LINE character from XML data in STRING format
  CLASS cl_abap_char_utilities DEFINITION LOAD.
  REPLACE ALL OCCURENCES OF cl_abap_char_utilities=>newline IN
    stringdata WITH ''.

ENDFUNCTION.

OttoGold
Active Contributor
0 Kudos
REPORT  zpdf_upload_test_01.

DATA lv_filelen TYPE zpdf_upload_filelen.
DATA lt_rawtab  TYPE zpdf_upload_rawtab.
DATA lv_data    TYPE string.

*********************************************************
CALL FUNCTION 'ZPDF_GET_FILESTREAM'
  IMPORTING
    length = lv_filelen
    rawtab = lt_rawtab.

*********************************************************
CALL FUNCTION 'ZPDF_GET_FORM_STRING'
  EXPORTING
    filelen    = lv_filelen
    rawtab     = lt_rawtab
  IMPORTING
    stringdata = lv_data.

*********************************************************
* Make the XML envelope compliant with identity transform
REPLACE '<?xml version="1.0" encoding="UTF-8"?><data>'
IN lv_data WITH '<?xml version="1.0" encoding="iso-8859-1"?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"><asx:values>'.

REPLACE '</data>'
IN lv_data WITH '</asx:values></asx:abap>'.

*********************************************************
DATA docparams TYPE sfpsy.
CALL TRANSFORMATION id
SOURCE XML lv_data
RESULT sfpsy = docparams.

*********************************************************
MESSAGE 'Data has been read successfully' TYPE 'I'.
Former Member
0 Kudos

Dear Otto,

Thank you so much for your reply. I would appreciate, if you kindly provide me code for

types :

1. zpdf_upload_filelen

2. zpdf_upload_rawtab

and FMs

1. 'ZPDF_GET_FILESTREAM'

2. 'ZPDF_GET_FORM_STRING'

which u have used in your coing.

Regards,

Srini

OttoGold
Active Contributor
0 Kudos

Dear Srini,

it´s a pity you didn´t bother to read all the piece of the code I posted. I must remember not to help too much the next time when some people don´t care. Feels like you´re a little lazy, aren´t you?

By the way the DDIC types you can see it the headers of those function modules.

You´d better do better the next time...

Otto

Former Member
0 Kudos

Dear Otto,

I didn't notice the header part of the code you have forwarded to me. Apologies for the same.Infact I have already tried the code similar to this and facing the problem with string type declaration (Only containing 256 char and rest of the data is missing). U have suggested me other FM , but it also stoes the data in a string.Anyway, I will try that FM also ....

Thanks alot for ur time spending to resolve my issue....

Regards,

Srini