cancel
Showing results for 
Search instead for 
Did you mean: 

Submit data to an ABAP program from an offline form

Former Member
0 Kudos

Hello Forms experts,

the requirement goes like this: I have an internal table that will be passed to the form (via interface context) in the form the data will be changed by the user and the changes must be reflected in the internal table.-

I have to send back data from a table which data is modified inside a PDF form and send it back to an ABAP program for further process.

So far my development goes like this

- I have an ABAP program where I defined an internal table with the data to fill the table in the pdf form.

- I created an Interface that has one Import parameter (other than docparams) defined as the internal table that will have the data passed from this program to the form. this context interface object is bound to the form context and is put into the form layout by dragging and dropping from the data view. so the binding are done correctly.

- In my program I called the Function module that generates the form by using this function

CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'

EXPORTING i_name = 'my_form_name'

IMPORTING e_function_name = lv_function_name ....

this gives me the name of the function module associated to the form name I am passing by.

- I call the function module gave by the previous call

CALL FUNCTION lv_function_name

EXPORTING /1bcdwb/docparams = docparams

/1bcdwb/itable = itable

IMPORTING

/1bcdwb/formoutput = formoutput

this will raise the pdf file preview where I can modify the data of some fields (not every field, due to key contrainst)

Now I have a problem, because in one hand the forums I read all talks about the Web Service using but to do it, I have to bind each table field to a field in the web service, loosing the bind from the internal table.

does the IMPORTING part in the CALL FUNCTION lv_function_name can have another parameter for the modified data in the form table so in my program i can get this object and continue working with the internal table ??

any suggestion, question, observation or comment is welcome.

in advance, thanks a lot.

EDIT:

Workaround:

download the pdf file into local computer. upload the file into the system and get the data from that pdf to update the data in the internal table... is that possible??

other option: Is there any chance to get the context attribute that represents the table from the interface context to the function module that called this form at the first place?

Edited by: Mauricio Poblete on Mar 23, 2010 10:17 PM

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

thanks everyone who reply this thread,

I tried several solutions: the standar one is to use the TRANSFORMATION method and modify the specifications in the ID object.

but the solution I took to do it was this one.

DATA: lt_file_table TYPE filetable,

lv_rc TYPE i,

lv_filename TYPE string,

lv_filelength TYPE i,

  • lt_rawtab type STANDARD TABLE of ZSMSC_TAB.

lt_rawtab TYPE TABLE OF char255.

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.

*lv_filename = p_pdf.

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 ).

  • 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,

pdf_data TYPE xstring.

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

EXPORTING

input_length = lv_filelength

  • FIRST_LINE = 0

  • LAST_LINE = 0

IMPORTING

buffer = 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.

lo_pdfobj = lo_fp->create_pdf_object( connection = 'ADS' ).

  • Set document

lo_pdfobj->set_document(

EXPORTING

pdfdata = 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,

t_return TYPE STANDARD TABLE OF bapiret2,

t_per_info TYPE STANDARD TABLE OF smum_xmltb,

lfs_per_info TYPE smum_xmltb,

ls_zcrm_oppt_info TYPE ZCRM_OPPT_INFO,

lt_zcrm_oppt_info type ZCRMT_OPPT_INFO,

tag_open TYPE TDSFFLAG.

APPEND xml_data TO lt_xml_data.

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.

LOOP AT t_per_info INTO lfs_per_info.

CASE lfs_per_info-cname.

WHEN 'OPPT_ID'.

ls_zcrm_oppt_info-OPPT_ID = lfs_per_info-cvalue.

....

WHEN 'EXPORT_STAMP'. "this is the last field in the record.

ls_zcrm_oppt_info-EXPORT_STAMP = lfs_per_info-cvalue.

append ls_zcrm_oppt_info to lt_zcrm_oppt_info.

clear ls_zcrm_oppt_info.

tag_open = ''.

WHEN OTHERS.

ENDCASE.

ENDLOOP.

itable = lt_zcrm_oppt_info.

hope i solve another question.

OttoGold
Active Contributor
0 Kudos

did you check the value of the source xml? sometimes you can find some obscure characters in there... If there are some, the transformation doesn´t work. Otto

p.s. like #

Former Member
0 Kudos

Hi again,

I could skip the error in the TRANSFORMATION calling, but the wa_vnbdnk workarea is not filled...

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

DATA: wa_VNDBNK type ZSMSC_TAB VALUE IS INITIAL,

lv_subrc TYPE sysubrc VALUE IS INITIAL,

lt_messtab TYPE STANDARD TABLE OF bdcmsgcoll,

l_key type SWR_STRUCT-OBJECT_KEY.

CALL TRANSFORMATION id

SOURCE XML lv_xml_data_string

RESULT Z_VNDBNK = wa_vndbnk.

according to SAP help the TRANSFOMATION syntax goes like this

CALL TRANSFORMATION {trans|(name)}

[PARAMETERS {p1 = e1 p2 = e2 ...}|(ptab)]

[OBJECTS {o1 = e1 o2 = e2 ...}|(otab)]

[OPTIONS a1 = e1 a2 = e2 ...]

SOURCE {XML sxml}

| {{bn1 = e1 bn2 = e2 ...}|(stab)}

RESULT {XML rxml}

| {{bn1 = f1 bn2 = f2 ...}|(rtab)}.

So my final question (and with this i mean it is final) is the RESULT it has something to do with SAP objects?? because the Z_VNDBNK = wa_vndbnk assignment is not done... wa_vndbnk is empty, but no error are raised

help me on this final one and i will aprreciate my entire life!... hahaha

thanks in advance.

andrs_sarcevic
Contributor
0 Kudos

Hi Mauricio,

I remember followed the same tutorial last year and worked like a charm.

Have you done the following lines of the example? I'm sure you missed something in there.

  • Convert XML data from XSTRING format to STRING format

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

  • Make the XML envelope compliant with identity transform

Cheers,

Andres.

Former Member
0 Kudos

forgot to mention that ZSMSC_TAB is the internal table like EKPO but some of the fields are deactivated in the PDF form... I mean, some fields are not passed to the form, so when the form is submitted using this program might have some problems... how to define which data goes to wich field in the internal table when the data is back??

again, thanks a lot for your time.

Former Member
0 Kudos

HI,

Sorry for non-formatted text, I just edit it after posting and came to that... sorry again.

I am not able to watch the awesome tutorial you said... :'( maybe you link is wrong...

I have another option to do it but an error was raised and I don't know where is the problem.

I am following this tutorial:Link:[Offline Interactive Forms Using ABAP|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c2567f2b-0b01-0010-b7b5-977cbf80665d?quicklink=index&overridelayout=true]. Everything goes good until this:

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

DATA: wa_VNDBNK type ZSMSC_TAB VALUE IS INITIAL,

  • wa_VENDOR type ZCOUNTRY 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 "<-- here is were the error is raised.

SOURCE XML lv_xml_data_string

RESULT Z_VNDBNK = wa_vndbnk.

Do you have any idea on what might be wrong? If I have more than a table inside this PDF form so I have to encapsulate the table structure somehow?

Thanks for the cheers to my country... we are recovering really slowy, but we are all in our feets... thanks for the worry.

Hope for you reply.

OttoGold
Active Contributor
0 Kudos

Hello,

i am sorry, but I am lazy to read that not formatted text. Please use the markups the next time.

If you need to bein with offline forms, please follow this awesome tutorial:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c2567f2b-0b01-0010-b7b5-977cbf806...

Regards Otto

andrs_sarcevic
Contributor
0 Kudos

It wasn't easy to read your message, all in the same long line.

If you're talking about OFFLINE form, I suppose you don't have a live connection to the backend, so your first workaround would be suitable, but probably annoying for the user. Have you thought of submit the information as an attached file through e-mail?

It's not so hard to accomplished and there is plenty of examples in SDN.

Is there any chance to get the context attribute that represents the table from the interface context to the function module that called this form at the first place?

I if get that right, sounds difficult (and weird). Probably with an FM FP_*?

Hope this helps.

Cheers,

Andres.

PD: ¡Fuerza Chile!