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: 

dynamic 'subr_identifier' in PERFORM

Former Member
0 Kudos

Dear SAP friends,

Is there a way to build 'subr_identifier' dynamically in the PERFORM statement:

PERFORM <subr_identifier>

I tried this:

 METHOD  handle_pushbutton_click.

FIELD-SYMBOLS <PT> TYPE ANY.
DATA: fs_value TYPE c.
    CASE fcode.
      WHEN 'CHECK'.
          CONCATENATE 'check_'
                                   wa-ptype
                 INTO   fs_value.          
            ASSIGN fs_value TO <PT>.
            PERFORM <PT>.
    ENDCASE.
  ENDMETHOD.                           "handle_pushbutton_clicked

But I am getting a compile error "the form <PT> does not exist".

Any thoughts?

Thank you

Tatyana

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

Hello Tatyana,

Try this way..

<b>REPORT ZTEST_NP.</b>

data: l_form(30) type c.

l_form = 'WRITE_DATA'.

start-of-selection.

perform (l_form) <b> in program ztest_np if found.</b>

form write_data.

write: ' I was executed...!'.

endform.

4 REPLIES 4

Former Member
0 Kudos

Hi

When you use PERFORM it expects the appropriate FORM (routine).

Do you have routne with Check_Value?? (assume you have 'Value' in the variable wa-ptype.

I mean

FORM Check_Value.

-


code

-


ENDFORM.

If you have this you will not get any error.

Regards

Surya.

naimesh_patel
Active Contributor
0 Kudos

Hello Tatyana,

Try this way..

<b>REPORT ZTEST_NP.</b>

data: l_form(30) type c.

l_form = 'WRITE_DATA'.

start-of-selection.

perform (l_form) <b> in program ztest_np if found.</b>

form write_data.

write: ' I was executed...!'.

endform.

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.



METHOD  handle_pushbutton_click.
 
FIELD-SYMBOLS <PT> TYPE ANY.
DATA: fs_value TYPE c.
    CASE fcode.
      WHEN 'CHECK'.
          CONCATENATE 'check_'
                                   wa-ptype
                 INTO   fs_value.          
            ASSIGN fs_value TO <PT>.
            PERFORM (<PT>) IN PROGRAM <program name>.
    ENDCASE.
  ENDMETHOD.                           "handle_pushbutton_clicked

Regards,

Ferry Lianto

Former Member
0 Kudos

Naimesh,

Your code works! Thank you very much.

I have changed l_form = 'WRITE_DATA' to 'l_form = 'write_data' and added 'TRANSLATE l_form TO UPPER CASE.'

Just wanted to make a point that l_form variable has to be in upper case. Otherwise the program dumps.

REPORT ztest_np.

DATA: l_form(30) TYPE c.
l_form = 'write_data'.
START-OF-SELECTION.
  TRANSLATE l_form TO UPPER CASE.
  PERFORM (l_form) IN PROGRAM ztest_np IF FOUND.

FORM write_data.
  WRITE: ' I was executed...!'.
ENDFORM.                    "write_data

Thanks,

Tatyana.