Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

passing data to smart forms...

Former Member
0 Kudos

Hi,

I am learning smartforms and so far have done the following.

1. Using transaction smartforms, created a Ztestsmartform with one page named "coverpage". the page contains two window elements named, vendorname and faxnum. saved and activated the form.

2. wrote a zprogram to retrieve data from tables and pass on to the form. I have created an internal table to hold the data. i am not clear on how to pass that data to my form ?? should i loop the itab and call the function "SSF_FUNCTION_MODULE_NAME" ?? how to pass my itab data then ??

please explain !!

whats the purpose of calling function FM_NAME ??

i took the function module code from a sample available on the net.

thanks

-


REPORT ZPROGFORSMARTFORMS.

TABLES: LFA1, LFB1.

DATA: BEGIN OF VENDOR_DATA OCCURS 0,

VENDORNAME LIKE LFB1-LIFNR,

FAXNUM LIKE LFA1-TELFX,

END OF VENDOR_DATA.

DATA: VENDOR_LIST LIKE VENDOR_DATA OCCURS 0 WITH HEADER LINE.

SELECT ALIFNR BTELFX INTO TABLE VENDOR_LIST FROM LFB1 AS A INNER JOIN LFA1 AS B ON ALIFNR = BLIFNR.

LOOP AT VENDOR_LIST.

ENDLOOP.

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'ZTESTSMARTFORM'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

FM_NAME = FM_NAME

EXCEPTIONS

NO_FORM = 1

NO_FUNCTION_MODULE = 2

OTHERS = 3.

if sy-subrc <> 0.

WRITE: / 'ERROR 1'.

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

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

endif.

call function FM_NAME

  • EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

  • CONTROL_PARAMETERS =

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

TABLES

GS_MKPF = INT_MKPF

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.

5 REPLIES 5

Former Member
0 Kudos

Hi,

In Smartform >Go to Form InterfaceTables --> add your internal table under tables

as INT_MKPF TYPE MKPF

read this doc:

http://www.sapgenie.com/abap/smartforms_detail.htm

Message was edited by: Lanka Murthy

Message was edited by: Lanka Murthy

Former Member
0 Kudos


*---Passing data to SMARTFORMS
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname           = 'ZSMARTFORMNAME'
    IMPORTING
      fm_name            = fm_name
    EXCEPTIONS
      no_form            = 1
      no_function_module = 2
      OTHERS             = 3.
.....

Now, call the retrieved FM by passing the exporting and table parameters! 
This should match the exporting and table parameters that you have declared in your form interface 
(under global settings)

  CALL FUNCTION fm_name
    EXPORTING
      zxekko           = zxekko
      zxpekko          = zxpekko
    TABLES
      l_xekpo          = l_ekpo
      l_xekpa          = l_ekpa
      l_xpekpo         = l_pekpo
      l_xeket          = l_eket
      l_xtkomv         = l_tkomv
      l_xekkn          = l_ekkn
      l_xekek          = l_ekek
      l_xkomk          = l_komk
    EXCEPTIONS
      formatting_error = 1
      internal_error   = 2
      send_error       = 3
      user_canceled    = 4
      OTHERS           = 5.

0 Kudos

Then in your form, under the window where you want to display the values from your itab, create a table-element. If you select the data tab of the table element you will find a block to define the loop!

sreemsft
Contributor
0 Kudos

Hi Sha,

1) As client dependency is one of the drawback in the scripts, we use smart forms.

2) When you run a Smartform it gives you a function module, using tha you can run the smart form from your driver program by calling it in the same.

3) You give the smartform name and the function module name in the SSF_FUNCTION_MODULE_NAME.

4) While calling the function module in the driver program, first run the smart form and call it using PATTERN, then you change the Call function name as the below example.

5) You can pass the tables to the table parameters which will come from the function module.

Please see the below Driver program of a smartform.

-


report zsree_temp_smart .

data: it_sree type standard table of zsree_marc.

data: x_sree1 type zsree_temp.

parameters: p_matnr type mara-matnr.

start-of-selection.

perform select_data.

end-of-selection.

perform smart_form.

&----


*& Form SELECT_DATA

&----


  • text

----


form select_data .

select single

matnr

ersda

ernam

mtart

from mara

into x_sree1 where matnr = p_matnr.

if x_sree1 is not initial.

select matnr

werks

pstat

lvorm

from marc

into table it_sree

where matnr = x_sree1-matnr.

endif.

endform. " SELECT_DATA

&----


*& Form SMART_FORM

&----


  • text

----


form smart_form .

data: l_p_form type tdsfname.

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'ZSREE_TEMP'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

importing

fm_name = l_p_form

exceptions

no_form = 1

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

call function l_p_form

exporting

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

  • CONTROL_PARAMETERS =

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

x_sree = x_sree1

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

tables

it_zsree = it_sree

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.

endform. " SMART_FORM

Please do not forget to give rewards if it can help you better.

Thanks,

Sreekanth

Former Member
0 Kudos

Hi,

Once you populate the Internal table in your case VENDOR_LIST in driver program then call the functional module which you have mention

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZTESTSMARTFORM'

IMPORTING

fm_name = fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

call function FM_NAME

  • EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

  • CONTROL_PARAMETERS =

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

TABLES

GS_MKPF = VENDOR_LIST

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

In the Layout in main window First create table

then Enter table no of columns, size of each row then go to data tab

Loop sub tab first click the check box Internal table before that make sure you pass the Import parameter VENDOR_LIST type VENDOR_DATA .

declare the vendor_data as structure & add fields into it.

Internal table vendor_list into wa_vendor_list in sub LOOP tab.

later drag the fields by clicking field on/off.

I hope thsi will help you out.

Thanks

Rajeev