cancel
Showing results for 
Search instead for 
Did you mean: 

Smartform in Abap Webdynpro

Former Member
0 Kudos

Hi Expert,

I am new to SmartForm and WDP. I try to follow the below instruction to do, but got lots of error. Could anyone help me on this?

http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0de1eb8-0b98-2910-7996-8a3c2fcf6...

My smartform name is ZSGPayslip and with 1 parameter named "MYDATE".

According to the instruction, I should only create 1 node and 1 attribute, but I am not sure why the below code is calling another. Please hlep.

Thanks,

WF

Edited by: williamfok on Feb 1, 2010 12:59 PM

Edited by: williamfok on Feb 1, 2010 12:59 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello William,

When you try to display smartforms as the PDF documents in WD. These are the steps you need to do:

1. Create a node with cardinality 1..1 and under that an attribute PDF_SOURCE of type XSTRING.

2. Drag and drop an ITF UI element to your view and bind the PDFSOURCE property of UI element to the node attribute PDF_SOURCE.

Now you need to fill this PDF_SOURCE attribute from your existing smartform data which will be used by the framework to display PDF.

1. Read your smartfrom and get its data in XSTRING format. Use CONVERT_OTF function module to get data in XSTRING.

2. Once you get the XSTRING format of your smartforms you need to bind this to PDF_SOURCE attribute.

Just check your code and see if you are missing something.

Thanks,

Abhishek

Former Member
0 Kudos

Hi,

I am also trying to do the same and get the dump "Conversion not possible". Actually mt table doesn't have any entry and may be this is the problem.

But I don't know why I am getting this dump. For your reference myt code is as above;

DATA: l_xfile TYPE xstring,

job_outp_inf TYPE ssfcrescl,

lt_pre_pdf TYPE STANDARD TABLE OF tline,

l_formname TYPE tdsfname VALUE 'ZSAN_TEST',

l_fm_name TYPE rs38l_fnam.

DATA: lv_control_parameters TYPE ssfctrlop,

lv_output_options TYPE ssfcompop,

lv_ssf_output TYPE ssfcrescl.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = l_formname

IMPORTING

fm_name = l_fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2.

IF sy-subrc NE 0.

  • Error message

ENDIF.

  • Set relevant control parameters

lv_control_parameters-getotf = 'X'.

lv_control_parameters-no_dialog = 'X'.

lv_control_parameters-preview = 'X'.

  • Set relevant Output options

lv_output_options-tdnewid = 'X'.

lv_output_options-tddelete = space.

"'/1BCDWB/SF00000548'

CALL FUNCTION l_fm_name

EXPORTING

control_parameters = lv_control_parameters

output_options = lv_output_options

user_settings = ' '

IMPORTING

job_output_info = lv_ssf_output

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4.

IF sy-subrc NE 0.

  • Error message

ENDIF.

job_outp_inf-otfdata = lv_ssf_output-otfdata.

'I am not getting the value in this table'

CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'

EXPORTING

i_otf = job_outp_inf-otfdata

EXCEPTIONS

convert_otf_to_pdf_error = 1

cntl_error = 2.

IF sy-subrc NE 0.

  • Error message

ENDIF.

DATA: l_size TYPE i.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = l_size

bin_file = l_xfile

TABLES

otf = job_outp_inf-otfdata

lines = lt_pre_pdf.

  • Get message manager

IF sy-subrc NE 0.

ENDIF.

DATA:

node_node TYPE REF TO if_wd_context_node,

elem_node TYPE REF TO if_wd_context_element,

stru_node TYPE if_main=>element_node ,

item_pdf_source LIKE stru_node-pdf_source.

  • navigate from <CONTEXT> to <NODE> via lead selection

node_node = wd_context->get_child_node( name = if_main=>wdctx_node ).

  • get element via lead selection

elem_node = node_node->get_element( ).

item_pdf_source = l_xfile.

  • Set single attribute

elem_node->set_attribute(

EXPORTING

name = `PDF_SOURCE`

value = item_pdf_source ).

Former Member
0 Kudos

DATA: l_xfile TYPE xstring,

job_outp_inf TYPE ssfcrescl,

lt_pre_pdf TYPE STANDARD TABLE OF tline,

l_formname TYPE tdsfname VALUE 'ZSAN_TEST',

l_fm_name TYPE rs38l_fnam.

DATA: lv_control_parameters TYPE ssfctrlop,

lv_output_options TYPE ssfcompop,

lv_ssf_output TYPE ssfcrescl.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = l_formname

IMPORTING

fm_name = l_fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2.

IF sy-subrc NE 0.

  • Error message

ENDIF.

  • Set relevant control parameters

lv_control_parameters-getotf = 'X'.

lv_control_parameters-no_dialog = 'X'.

lv_control_parameters-preview = 'X'.

  • Set relevant Output options

lv_output_options-tdnewid = 'X'.

lv_output_options-tddelete = space.

"'/1BCDWB/SF00000548'

CALL FUNCTION l_fm_name

EXPORTING

control_parameters = lv_control_parameters

output_options = lv_output_options

user_settings = ' '

IMPORTING

job_output_info = lv_ssf_output

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4.

IF sy-subrc NE 0.

  • Error message

ENDIF.

job_outp_inf-otfdata = lv_ssf_output-otfdata.

CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'

EXPORTING

i_otf = job_outp_inf-otfdata

EXCEPTIONS

convert_otf_to_pdf_error = 1

cntl_error = 2.

IF sy-subrc NE 0.

  • Error message

ENDIF.

DATA: l_size TYPE i.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = l_size

bin_file = l_xfile

TABLES

otf = job_outp_inf-otfdata

lines = lt_pre_pdf.

  • Get message manager

IF sy-subrc NE 0.

ENDIF.

Former Member
0 Kudos

Hi,

Can you please suggest me how you will be able to do the same.

Former Member
0 Kudos

Hi Sanket,

Were you able to get the output after CONVERT_OTF?

If yes, then after CONVERT_OTF you need to convert the OTFDATA to XSTRING.

  • convert OTF data to XSTRING

DATA lv_content TYPE xstring.

FIELD-SYMBOLS <fs_x> TYPE x.

LOOP AT lt_pre_pdf INTO ls_pre_pdf.

ASSIGN ls_pre_pdf TO <fs_x> CASTING.

CONCATENATE lv_content <fs_x> INTO lv_content IN BYTE MODE.

ENDLOOP.

this will give you the XSTRING which you need to pass to the context attribute which is binded to the pdfsource of ITF.

Thanks,

Abhishek

german_meneses
Explorer
0 Kudos

Really thanks, that works for me with RFM retreive smartform in WebDynpro Java!

Former Member
0 Kudos

To call A smartform in Web dynpro View, Make an Interactive UI element on Layout

Create A node name  PDF with an attribute SOURCE type string in context tab of view.

Bind the Interactive UI element with Source attribute . And write the below code in WDDOINIT method to call Smartform  ZG2_SMARTFORM_TEST.

method WDDOINIT.

* Reading Node for display

   DATA LO_ND_NODE_FOR_DISPLAY TYPE REF TO IF_WD_CONTEXT_NODE.

   DATA LO_EL_NODE_FOR_DISPLAY TYPE REF TO IF_WD_CONTEXT_ELEMENT.

   DATA LS_NODE_FOR_DISPLAY TYPE WD_THIS->ELEMENT_NODE_FOR_DISPLAY.

* navigate from <CONTEXT> to <NODE_FOR_DISPLAY> via lead selection

   LO_ND_NODE_FOR_DISPLAY = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_NODE_FOR_DISPLAY ).

* get element via lead selection

   LO_EL_NODE_FOR_DISPLAY = LO_ND_NODE_FOR_DISPLAY->GET_ELEMENT( ).

* get all declared attributes

   LO_EL_NODE_FOR_DISPLAY->GET_STATIC_ATTRIBUTES(

     IMPORTING

       STATIC_ATTRIBUTES = LS_NODE_FOR_DISPLAY ).

* Calling Smartform

   DATA LV_SMARTFORM       TYPE RS38L_FNAM.

   DATA LS_SSFCTRLOP       TYPE SSFCTRLOP.

   DATA LS_OUTPUT_OPTIONS  TYPE SSFCOMPOP.

   DATA LS_JOB_OUTPUT_INFO TYPE SSFCRESCL.

   DATA LT_LINES           TYPE STANDARD TABLE OF TLINE.

   DATA LV_BIN_FILESIZE    TYPE I.

   DATA LV_PDF_XSTRING     TYPE XSTRING.

   data LT_OTFDATA TYPE TABLE OF ITCOO.

* -- Get the name of the smartform function module

   CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

     EXPORTING

       FORMNAME           = 'ZG2_SMARTFORM_TEST'

*     VARIANT            = ' '

*     DIRECT_CALL        = ' '

     IMPORTING

       FM_NAME            = LV_SMARTFORM

     EXCEPTIONS

       NO_FORM            = 1

       NO_FUNCTION_MODULE = 2

       OTHERS             = 3.

   IF SY-SUBRC <> 0.

     BREAK-POINT.

* Implement suitable error handling here

   ENDIF.

* -- Call the smartform

   LS_SSFCTRLOP-NO_DIALOG = SPACE.

   LS_SSFCTRLOP-GETOTF    = ABAP_TRUE.

   LS_SSFCTRLOP-NO_DIALOG = 'X'.

   LS_SSFCTRLOP-PREVIEW = 'X'.

   LS_SSFCTRLOP-GETOTF = 'X'.

   LS_SSFCTRLOP-LANGU = 'EN'.

   LS_SSFCTRLOP-DEVICE 'PRINTER'. "LOCAL_PRINTER2 'LOCAL_PRINTER1'.

   LS_OUTPUT_OPTIONS-TDPRINTER  = 'PDF'. "'PDF1'.

   LS_OUTPUT_OPTIONS-TDDEST     = 'LP01'.

   LS_OUTPUT_OPTIONS-TDIMMED    = 'X'.

   Ls_OUTPUT_OPTIONS-TDDELETE   = 'X'.

   Ls_OUTPUT_OPTIONS-TDLIFETIME = 'X'.

   Ls_OUTPUT_OPTIONS-TDDEST     = 'LOCL'.

   CALL FUNCTION LV_SMARTFORM

     EXPORTING

       CONTROL_PARAMETERS = LS_SSFCTRLOP

       OUTPUT_OPTIONS     = LS_OUTPUT_OPTIONS

       USER_SETTINGS      = 'X'

       GS_NODE_FOR_DISPLAY = LS_NODE_FOR_DISPLAY

*     custom_input       = ls_your_custom_smartform_input

     IMPORTING

       JOB_OUTPUT_INFO    = LS_JOB_OUTPUT_INFO

     EXCEPTIONS

       OTHERS             = 0.

REFRESH LT_OTFDATA.

LT_OTFDATA[] = LS_JOB_OUTPUT_INFO-OTFDATA[].

CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'

EXPORTING

I_OTF                    = LT_OTFDATA

EXCEPTIONS

CONVERT_OTF_TO_PDF_ERROR = 1

CNTL_ERROR               = 2

OTHERS                   = 3.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

* -- Convert the OTF data to xstring

   CALL FUNCTION 'CONVERT_OTF'

     EXPORTING

       FORMAT                = 'PDF'

       MAX_LINEWIDTH         = 255

     IMPORTING

       BIN_FILESIZE          = LV_BIN_FILESIZE

       BIN_FILE              = LV_PDF_XSTRING

     TABLES

       OTF                   = LT_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.

  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

   CHECK LV_PDF_XSTRING IS NOT INITIAL.

   DATA LO_ND_PDF TYPE REF TO IF_WD_CONTEXT_NODE.

   DATA LO_EL_PDF TYPE REF TO IF_WD_CONTEXT_ELEMENT.

   DATA LS_PDF TYPE WD_THIS->ELEMENT_PDF.

   DATA LV_SOURCE TYPE WD_THIS->ELEMENT_PDF-SOURCE.

* navigate from <CONTEXT> to <PDF> via lead selection

   LO_ND_PDF = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_PDF ).

* get element via lead selection

   LO_EL_PDF = LO_ND_PDF->GET_ELEMENT( ).

* @TODO handle not set lead selection

   IF LO_EL_PDF IS INITIAL.

   ENDIF.

* set single attribute

   LO_EL_PDF->SET_ATTRIBUTE(

     NAME `SOURCE`

     VALUE = LV_PDF_XSTRING ).

endmethod.