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

Dynamic perform

Former Member
0 Likes
1,999

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???

8 REPLIES 8
Read only

Former Member
0 Likes
1,239

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

Read only

0 Likes
1,239

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

Read only

0 Likes
1,239

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

Read only

0 Likes
1,239

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

Read only

Former Member
0 Likes
1,239

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

Read only

Former Member
0 Likes
1,239

Refer to link below;

[]

Read only

0 Likes
1,239

Wowww thank u very much Iam so happy:-)

Read only

0 Likes
1,239

I would be happy if you rewarded