Application Development and Automation 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: 
Read only

Call to Fm dynamically

Former Member
0 Likes
1,294

HI all,

i need to call this Fm for 5 times,

my question is instead of calling to the Fm 5 times one by one there is way to do

that better (nicer) ,i don't want to use perform.

e.g.

lv_domain_name = 'DATFM'.

CALL FUNCTION 'DDIF_FIELDINFO_GET'

EXPORTING

tabname = iv_table_name

langu = sy-langu

lfieldname = iv_domain_name

TABLES

fixed_values = lt_domain_values

EXCEPTIONS

not_found = 1

internal_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • Implement suitable error handling here

ENDIF.

lv_domain_name = 'DCPFM'.

CALL FUNCTION 'DDIF_FIELDINFO_GET'

EXPORTING

tabname = iv_table_name

langu = sy-langu

lfieldname = iv_domain_name

TABLES

fixed_values = lt_domain_values

EXCEPTIONS

not_found = 1

internal_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • Implement suitable error handling here

ENDIF.

and so on...for 5 times

Best Regards

Nina

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,247

You can go for use macro for this.

DEFINE macro_call_fm.

CALL FUNCTION 'DDIF_FIELDINFO_GET'

EXPORTING

tabname = &1 "(iv_table_name)

langu = &2 " (sy-langu)

lfieldname = &3 " (iv_domain_name)

TABLES

fixed_values = lt_domain_values

EXCEPTIONS

not_found = 1

internal_error = 2

OTHERS = 3.

IF sy-subrc 0.

  • Implement suitable error handling here

ENDIF.

END-OF-DEFINITION.

macro_call_fm: iv_table_name sy-langu iv_domain_name.

.

.

.

HI all,

i need to call this Fm for 5 times,

my question is instead of calling to the Fm 5 times one by one there is way to do

that better (nicer) ,i don't want to use perform.

e.g.

lv_domain_name = 'DATFM'.

CALL FUNCTION 'DDIF_FIELDINFO_GET'

EXPORTING

tabname = iv_table_name

langu = sy-langu

lfieldname = iv_domain_name

TABLES

fixed_values = lt_domain_values

EXCEPTIONS

not_found = 1

internal_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • Implement suitable error handling here

ENDIF.

lv_domain_name = 'DCPFM'.

CALL FUNCTION 'DDIF_FIELDINFO_GET'

EXPORTING

tabname = iv_table_name

langu = sy-langu

lfieldname = iv_domain_name

TABLES

fixed_values = lt_domain_values

EXCEPTIONS

not_found = 1

internal_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • Implement suitable error handling here

ENDIF.

and so on...for 5 times

Best Regards

Nina

9 REPLIES 9
Read only

Former Member
0 Likes
1,247

Hi Nina,

Create a perform and call the FM in the perform

lv_domain_name = 'DATFM'.

Perform_get using lv_domain_name.
clear : lv_domain_name

lv_domain_name = 'DCPFM'.

Perform_get using lv_domain_name.
clear : lv_domain_name.

and so on 5 times......


FORM_get using lv_domain_name.

CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = iv_table_name
langu = sy-langu
lfieldname = iv_domain_name
TABLES
fixed_values = lt_domain_values
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc 0.
* Implement suitable error handling here
ENDIF.


ENDFORM.

Hope this will resolves your query.

Regards,

Manish

Edited by: Manish Bisht on Jun 30, 2009 6:34 PM

Read only

Former Member
0 Likes
1,247

Put the values of iv_domain_name into an intrnal table and then loop through the table calling the FM each time.

Rob

Read only

Former Member
0 Likes
1,247

Hi,

itab-domain_name = 'DATFM'. Append ITab.
 itab-domain_name = 'DCPFM'. Append ITab.

LOOP AT ITAB.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = iv_table_name
langu = sy-langu
lfieldname = itab-domain_name
TABLES
fixed_values = lt_domain_values
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc 0.
* Implement suitable error handling here
ENDIF.
ENDLOOP.

Read only

former_member194416
Contributor
0 Likes
1,247

You can check below sample, Or you can prepare an internal table using changing parameters and call function in loop statement.

TYPE-POOLS abap.

DATA: line TYPE c LENGTH 80,

text_tab LIKE STANDARD TABLE OF line,

filename TYPE string,

filetype TYPE c LENGTH 80,

fleng TYPE i.

DATA: func TYPE string,

ptab TYPE abap_func_parmbind_tab,

ptab_line TYPE abap_func_parmbind,

etab TYPE abap_func_excpbind_tab,

etab_line TYPE abap_func_excpbind.

func = 'GUI_DOWNLOAD'.

filename = 'c:\temp\text.txt'.

filetype = 'ASC'.

ptab_line-name = 'FILENAME'.

ptab_line-kind = abap_func_exporting.

GET REFERENCE OF filename INTO ptab_line-value.

INSERT ptab_line INTO TABLE ptab.

ptab_line-name = 'FILETYPE'.

ptab_line-kind = abap_func_exporting.

GET REFERENCE OF filetype INTO ptab_line-value.

INSERT ptab_line INTO TABLE ptab.

ptab_line-name = 'DATA_TAB'.

ptab_line-kind = abap_func_tables.

GET REFERENCE OF text_tab INTO ptab_line-value.

INSERT ptab_line INTO TABLE ptab.

ptab_line-name = 'FILELENGTH'.

ptab_line-kind = abap_func_importing.

GET REFERENCE OF fleng INTO ptab_line-value.

INSERT ptab_line INTO TABLE ptab.

...

etab_line-name = 'OTHERS'.

etab_line-value = 10.

INSERT etab_line INTO TABLE etab.

CALL FUNCTION func

PARAMETER-TABLE

ptab

EXCEPTION-TABLE

etab.

CASE sy-subrc.

WHEN 1.

...

...

ENDCASE.

Read only

0 Likes
1,247

HI Gungorj ,

the solution u suggest is without doing loop on the FM or i had to do loop also?

Best Regards

Nina

Edited by: Nina C on Jun 30, 2009 10:51 PM

Edited by: Nina C on Jul 1, 2009 7:06 AM

Read only

0 Likes
1,247

You can select the Domain from DD03L

DD03L~DOMNAME

Read only

Former Member
0 Likes
1,248

You can go for use macro for this.

DEFINE macro_call_fm.

CALL FUNCTION 'DDIF_FIELDINFO_GET'

EXPORTING

tabname = &1 "(iv_table_name)

langu = &2 " (sy-langu)

lfieldname = &3 " (iv_domain_name)

TABLES

fixed_values = lt_domain_values

EXCEPTIONS

not_found = 1

internal_error = 2

OTHERS = 3.

IF sy-subrc 0.

  • Implement suitable error handling here

ENDIF.

END-OF-DEFINITION.

macro_call_fm: iv_table_name sy-langu iv_domain_name.

.

.

.

Read only

0 Likes
1,247

HI Raj ,

the solution u suggest is without doing loop on the FM or i had to do loop also?

Best Regards

Nina

Read only

former_member194669
Active Contributor
0 Likes
1,247

I will suggest instead of calling this fm make a select from table DD01L and DD01T

or make a select on table view DD03M