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 custom smartform from a custom program...

Former Member
0 Kudos

Hello Gurus,

Since, the function module gets generated dynamically at runtime when smartform is activated, I know that first I should use "SSF_FUNCTION_MODULE_NAME" and pass custom smartform name to it to get the name of function module. Then I have to use call function '/XXXXXXXXX'.

Now, I am writing a custom code and I want the data from my select program in custom program to be passed to smartform ? How can I pass the data from my custom program to smartform ? Do I pass it before using function module "SSF_FUNCTION_MODULE_NAME" ? If yes, how ?

Regards,

Rajesh.

1 ACCEPTED SOLUTION

GauthamV
Active Contributor
0 Kudos

hi,

u have to declare ur structures in form interface and can retrive the data from custom program.

check this sample code.

declare structure in interface.

WA_MKPF TYPE MKPF.

write ur custom code lik this.

DATA: wahz TYPE zmemigo_form_header,

wa_mkpf TYPE mkpf.

DATA: t_itemz LIKE zmemigo_form_item OCCURS 0,

t_mseg TYPE mseg OCCURS 0,

waitemz TYPE zmemigo_form_item,

waitem TYPE mseg.

DATA : form_name TYPE tdsfname VALUE 'ZPS_STN'.

DATA : fnc_module TYPE rs38l_fnam.

SELECT SINGLE mblnr INTO wa_mkpf-mblnr FROM mseg

CLIENT SPECIFIED WHERE mandt EQ sy-mandt

AND mblnr EQ p_mblnr

AND mjahr EQ p_mjahr

AND bwart EQ '351'

AND shkzg EQ 'H'.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = form_name

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

fm_name = fnc_module

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 fnc_module

EXPORTING

wa_headz = wahz

wa_mkpf = wa_mkpf

TABLES

it_itemz = t_itemz

it_mseg = t_mseg

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.

3 REPLIES 3

Former Member
0 Kudos

In form interface if you declare internal table then it appears in fm you called there you can pass the data that is selected.

former_member761936
Active Participant
0 Kudos

Hi Rajesh,

In SMart form there is form interface there you need to declare internal tables .To declare internal table you should have reference structure of Internal table in data base.Then only you can define Internal tables in smart form.Then after declaring Internal tables in smart form using dictionary structures, when you call smart form using function module '/XXXXXX' the internal tables which you declared in the form come automatically come as parameters, you can pass data to that internal tables.

Alternatively you can retrive all the data in the smart form it self.

Thanks and Regards,

Narendra.Soma

GauthamV
Active Contributor
0 Kudos

hi,

u have to declare ur structures in form interface and can retrive the data from custom program.

check this sample code.

declare structure in interface.

WA_MKPF TYPE MKPF.

write ur custom code lik this.

DATA: wahz TYPE zmemigo_form_header,

wa_mkpf TYPE mkpf.

DATA: t_itemz LIKE zmemigo_form_item OCCURS 0,

t_mseg TYPE mseg OCCURS 0,

waitemz TYPE zmemigo_form_item,

waitem TYPE mseg.

DATA : form_name TYPE tdsfname VALUE 'ZPS_STN'.

DATA : fnc_module TYPE rs38l_fnam.

SELECT SINGLE mblnr INTO wa_mkpf-mblnr FROM mseg

CLIENT SPECIFIED WHERE mandt EQ sy-mandt

AND mblnr EQ p_mblnr

AND mjahr EQ p_mjahr

AND bwart EQ '351'

AND shkzg EQ 'H'.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = form_name

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

fm_name = fnc_module

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 fnc_module

EXPORTING

wa_headz = wahz

wa_mkpf = wa_mkpf

TABLES

it_itemz = t_itemz

it_mseg = t_mseg

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.