‎2008 Jun 04 8:19 AM
hi all,
I want to know can we call smartform in webdynpro.
If possible can any body give me the procedure how we can do it.
Thanks And Regards,
Sreelatha Gullapalli
‎2008 Jun 04 8:45 AM
Sure you can call a smartform in WebDynpro (ABAP):
This is the procedure:
1. Create your smartform (if not already available).
2. Create a view in which smartform should be displayed.
3. Insert interactive form UI element for smartform to be displayed in.
4. In method WDDOINIT (for example), retrieve the FM for the smartform.
5. Call function module for smartform (set control parameter getotf to 'X' and no_dialog also to 'X'. Set device type).
6. In import parameter job_output_info-otfdata the pdf is contained.
7. call FM CONVERT_OTF to convert to pdf format.
8. Now the bin_file will be returned (import parameter).
9. Use this data to set the attribute of the smartform UI element.
Example coding:
METHOD wddoinit.
DATA:
node_diamond_data TYPE REF TO if_wd_context_node,
elem_diamond_data TYPE REF TO if_wd_context_element,
stru_diamond_data TYPE if_smartform_view=>element_diamond_data,
tab_diamond_data TYPE if_smartform_view=>elements_diamond_data.
DATA:
node_remarks TYPE REF TO if_wd_context_node,
elem_remarks TYPE REF TO if_wd_context_element,
stru_remarks TYPE if_smartform_view=>element_remarks ,
item_remarks_text LIKE stru_remarks-remarks_text.
DATA:
node_smartform_pdf TYPE REF TO if_wd_context_node,
elem_smartform_pdf TYPE REF TO if_wd_context_element,
stru_smartform_pdf TYPE if_smartform_view=>element_smartform_pdf ,
item_stones_data LIKE stru_smartform_pdf-stones_data.
DATA:
lt_diamonds TYPE zpo_ssp_list_t,
lt_lines TYPE TABLE OF tline.
DATA:
ls_output_options TYPE ssfcompop,
ls_control_parameters TYPE ssfctrlop,
ls_output_data TYPE ssfcrescl.
DATA:
lv_form_name TYPE tdsfname VALUE 'ZMM_P_SSPS',
lv_function_module_name TYPE rs38l_fnam,
lv_devtype TYPE rspoptype,
lv_pdf_len TYPE i,
lv_pdf_xstring TYPE xstring.
* navigate from <CONTEXT> to <DIAMOND_DATA> via lead selection
node_diamond_data =
wd_context->get_child_node(
name = if_smartform_view=>wdctx_diamond_data ).
* Retrieve diamond data from context.
node_diamond_data->get_static_attributes_table(
IMPORTING
table = tab_diamond_data ).
* Copy Diamond data.
lt_diamonds[] = tab_diamond_data[].
* navigate from <CONTEXT> to <REMARKS> via lead selection
node_remarks =
wd_context->get_child_node(
name = if_smartform_view=>wdctx_remarks ).
* get element via lead selection
elem_remarks = node_remarks->get_element( ).
* get single attribute
elem_remarks->get_attribute(
EXPORTING
name = `REMARKS_TEXT`
IMPORTING
value = item_remarks_text ).
*-----------------------------------------------------------------------
* Get name of generated function module
*-----------------------------------------------------------------------
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING formname = lv_form_name
* variant = ' '
* direct_call = ' '
IMPORTING fm_name = lv_function_module_name
EXCEPTIONS no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
* error handling
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
*-----------------------------------------------------------------------
* Setting of output options
*-----------------------------------------------------------------------
* language
ls_control_parameters-langu = sy-langu.
* set control parameters to get the output format (OTF) from Smart Forms
ls_control_parameters-no_dialog = 'X'.
ls_control_parameters-getotf = 'X'.
* get device type from language
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = sy-langu
* i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = lv_devtype
EXCEPTIONS
no_language = 1
language_not_installed = 2
no_devtype_found = 3
system_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
* error handling
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* set device type in output options
ls_output_options-tdprinter = lv_devtype.
CALL FUNCTION lv_function_module_name
EXPORTING
control_parameters = ls_control_parameters
output_options = ls_output_options
user_settings = 'X'
it_diamonds = lt_diamonds
iv_remarks = item_remarks_text
IMPORTING
job_output_info = ls_output_data
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 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.
* now convert the final document (OTF format) into PDF format
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_pdf_len
bin_file = lv_pdf_xstring " binary file
TABLES
otf = ls_output_data-otfdata
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5
.
IF sy-subrc <> 0.
* error handling
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* navigate from <CONTEXT> to <SMARTFORM_PDF> via lead selection
node_smartform_pdf =
wd_context->get_child_node(
name = if_smartform_view=>wdctx_smartform_pdf ).
* get element via lead selection
elem_smartform_pdf = node_smartform_pdf->get_element( ).
* get single attribute
item_stones_data = lv_pdf_xstring.
elem_smartform_pdf->set_attribute(
EXPORTING
name = `STONES_DATA`
value = item_stones_data ).
ENDMETHOD.
‎2008 Jun 04 8:45 AM
Sure you can call a smartform in WebDynpro (ABAP):
This is the procedure:
1. Create your smartform (if not already available).
2. Create a view in which smartform should be displayed.
3. Insert interactive form UI element for smartform to be displayed in.
4. In method WDDOINIT (for example), retrieve the FM for the smartform.
5. Call function module for smartform (set control parameter getotf to 'X' and no_dialog also to 'X'. Set device type).
6. In import parameter job_output_info-otfdata the pdf is contained.
7. call FM CONVERT_OTF to convert to pdf format.
8. Now the bin_file will be returned (import parameter).
9. Use this data to set the attribute of the smartform UI element.
Example coding:
METHOD wddoinit.
DATA:
node_diamond_data TYPE REF TO if_wd_context_node,
elem_diamond_data TYPE REF TO if_wd_context_element,
stru_diamond_data TYPE if_smartform_view=>element_diamond_data,
tab_diamond_data TYPE if_smartform_view=>elements_diamond_data.
DATA:
node_remarks TYPE REF TO if_wd_context_node,
elem_remarks TYPE REF TO if_wd_context_element,
stru_remarks TYPE if_smartform_view=>element_remarks ,
item_remarks_text LIKE stru_remarks-remarks_text.
DATA:
node_smartform_pdf TYPE REF TO if_wd_context_node,
elem_smartform_pdf TYPE REF TO if_wd_context_element,
stru_smartform_pdf TYPE if_smartform_view=>element_smartform_pdf ,
item_stones_data LIKE stru_smartform_pdf-stones_data.
DATA:
lt_diamonds TYPE zpo_ssp_list_t,
lt_lines TYPE TABLE OF tline.
DATA:
ls_output_options TYPE ssfcompop,
ls_control_parameters TYPE ssfctrlop,
ls_output_data TYPE ssfcrescl.
DATA:
lv_form_name TYPE tdsfname VALUE 'ZMM_P_SSPS',
lv_function_module_name TYPE rs38l_fnam,
lv_devtype TYPE rspoptype,
lv_pdf_len TYPE i,
lv_pdf_xstring TYPE xstring.
* navigate from <CONTEXT> to <DIAMOND_DATA> via lead selection
node_diamond_data =
wd_context->get_child_node(
name = if_smartform_view=>wdctx_diamond_data ).
* Retrieve diamond data from context.
node_diamond_data->get_static_attributes_table(
IMPORTING
table = tab_diamond_data ).
* Copy Diamond data.
lt_diamonds[] = tab_diamond_data[].
* navigate from <CONTEXT> to <REMARKS> via lead selection
node_remarks =
wd_context->get_child_node(
name = if_smartform_view=>wdctx_remarks ).
* get element via lead selection
elem_remarks = node_remarks->get_element( ).
* get single attribute
elem_remarks->get_attribute(
EXPORTING
name = `REMARKS_TEXT`
IMPORTING
value = item_remarks_text ).
*-----------------------------------------------------------------------
* Get name of generated function module
*-----------------------------------------------------------------------
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING formname = lv_form_name
* variant = ' '
* direct_call = ' '
IMPORTING fm_name = lv_function_module_name
EXCEPTIONS no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
* error handling
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
*-----------------------------------------------------------------------
* Setting of output options
*-----------------------------------------------------------------------
* language
ls_control_parameters-langu = sy-langu.
* set control parameters to get the output format (OTF) from Smart Forms
ls_control_parameters-no_dialog = 'X'.
ls_control_parameters-getotf = 'X'.
* get device type from language
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = sy-langu
* i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = lv_devtype
EXCEPTIONS
no_language = 1
language_not_installed = 2
no_devtype_found = 3
system_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
* error handling
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* set device type in output options
ls_output_options-tdprinter = lv_devtype.
CALL FUNCTION lv_function_module_name
EXPORTING
control_parameters = ls_control_parameters
output_options = ls_output_options
user_settings = 'X'
it_diamonds = lt_diamonds
iv_remarks = item_remarks_text
IMPORTING
job_output_info = ls_output_data
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 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.
* now convert the final document (OTF format) into PDF format
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_pdf_len
bin_file = lv_pdf_xstring " binary file
TABLES
otf = ls_output_data-otfdata
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5
.
IF sy-subrc <> 0.
* error handling
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* navigate from <CONTEXT> to <SMARTFORM_PDF> via lead selection
node_smartform_pdf =
wd_context->get_child_node(
name = if_smartform_view=>wdctx_smartform_pdf ).
* get element via lead selection
elem_smartform_pdf = node_smartform_pdf->get_element( ).
* get single attribute
item_stones_data = lv_pdf_xstring.
elem_smartform_pdf->set_attribute(
EXPORTING
name = `STONES_DATA`
value = item_stones_data ).
ENDMETHOD.
‎2008 Jun 04 11:24 AM
hi Micky,
What i have ti specify the interactive form property templatesource.
regards,
sreelatha gullapalli.
‎2008 Jun 04 2:44 PM
you don't need to specify the template source in this case since you are not calling any interactive online/offline Adobe Form (at least, that is not what read in your requirement), but merely a smartform. You only need to define the datasource in the context and use the XSTRING type.
‎2008 Jun 04 2:50 PM
hi Micky,
That problem got resolved but while executing it is not showing the smartform it is showing the following message
File does not begin with '%PDF-'.
can you please give me the solution.
regards,
sreelatha gullapalli
‎2008 Jun 04 3:55 PM
there are a few threads about this, just search SDN with 'File does not begin with '%PDF-'. I really don't know what causes this problem, but in the threads you will find, there are several solutions offered. So I would suggest to do a search and have a look at the threads.
Good luck.