‎2010 Apr 21 10:01 AM
Dear all,
I wanted to create a dynamic perform. Here I will show u an example
...
PERFORM get_correct_umlaut TABLES lt_bkpf.
....
PERFORM get_correct_umlaut TABLES lt_bseg.
....
PERFORM get_correct_umlaut TABLES lt_vbak.
.....
.....
.....
form get_correct_umlaut TABLES pt_any_table TYPE ANY TABLE.
endform. " get_correct_umlaut
I have a syntax error. What is the right way to define a dynamic PERFORM like this???
‎2010 Apr 21 10:42 AM
Hi,
to avoid syntax error, you should use :
FORM form_name TABLES tab_name TYPE table.
...
ENDFORM.
Depending what you want to do in this FORM you can eg. declare the field-symbols of type any, and loop through the table tab_name assigning this field-symbol and process it.
Write sth more what you would like to achieve through this procedure.
Regards,
MC
‎2010 Apr 21 10:57 AM
Hi,
thank u very much for this information. I will make a dynamic perform. This mean I want to loop to any tables, which comes throw this perform. For example
Field-symbols: <ft_any_table> type any table.
FORM form_name TABLES tab_name TYPE <ft_any_table>.
assign component tab_name of structure <fs_any_struc>.
loop at tab_name ASSIGNING <fs_any_struc>.
endloop.
ENDFORM.
Compiler say <ft_any_table>. is unknown. Do you know now what I want to do?
Edited by: handeglo on Apr 21, 2010 12:02 PM
‎2010 Apr 21 11:08 AM
Simply skipp the typing for table at all
FORM form_name TABLES tab_name. "now tab_name is generic one (you can pass any table)
ENDFORM.
Regards
Marcin
‎2010 Apr 21 11:15 AM
Hi,
Field-symbols: <ft_any_table> type standard table."Instead of any table Use standard table Because Tables parameter only
" support Standard table
FORM form_name TABLES tab_name LIKE <ft_any_table>. " Use LIKE Key word
assign component tab_name of structure <fs_any_struc>.
loop at tab_name ASSIGNING <fs_any_struc>.
endloop.
ENDFORM
‎2010 Apr 21 11:42 AM
Hi,
According to what you wrote, I suppose you want to achieve only quasi-dynamic procedure, since you are differentiating the type with case in your Form..
Thus, I think that following approach will satisfy your requirements:
DATA: it_mseg TYPE TABLE OF mseg,
it_mkpf TYPE TABLE OF mkpf.
SELECT *
FROM mseg
INTO TABLE it_mseg
UP TO 100 ROWS.
SELECT *
FROM mkpf
INTO TABLE it_mkpf
UP TO 90 ROWS.
PERFORM do_sth TABLES it_mseg.
PERFORM do_sth TABLES it_mkpf.
*&---------------------------------------------------------------------*
*& Form DO_STH
*&---------------------------------------------------------------------*
FORM do_sth TABLES local_itab TYPE table.
DATA: r_type TYPE REF TO cl_abap_structdescr,
type_name TYPE string.
FIELD-SYMBOLS: <mseg> TYPE mseg,
<mkpf> TYPE mkpf.
r_type ?= cl_abap_typedescr=>describe_by_data( local_itab ).
CALL METHOD r_type->get_relative_name
RECEIVING p_relative_name = type_name.
CASE type_name.
WHEN 'MKPF'.
LOOP AT local_itab ASSIGNING <mkpf>.
IF <mkpf>-budat EQ '20090101'. "just an example
* some calculations...
ENDIF.
ENDLOOP.
WHEN 'MSEG'.
LOOP AT local_itab ASSIGNING <mseg>.
IF <mseg>-menge GT '1000'. "just an example
* some calculations...
ENDIF.
ENDLOOP.
WHEN OTHERS.
* skip
ENDCASE.
ENDFORM. " DO_STH
Regards,
MC
Edited by: Marcin Cudo on Apr 21, 2010 12:43 PM
‎2010 Apr 21 12:13 PM
‎2010 Apr 21 12:16 PM
‎2010 Apr 22 8:06 AM