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

Calling subroutine dynamically

Former Member
0 Likes
3,870

Hi,

I have found the following SAP Help page ([Naming Subroutines|http://help.sap.com/saphelp_nw2004s/helpdata/EN/9f/db978335c111d1829f0000e829fbfe/content.htm]) regarding the dynamic subroutine call. But I wonder why the following code could not work.



PROGRAM zpld_test_goh.

DATA: subrname TYPE c LENGTH 4 VALUE 'test',
      programname type c LENGTH 20 value  'zpld_test_goh'.

PERFORM (subrname) IN PROGRAM (programname) IF FOUND.

FORM test.

  WRITE 'hello'.

ENDFORM. 

Could anyone please enlighten me on this issue?

Thanks in advance.

Regards,

Joon Meng

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
1,231

Hello,

PROGRAM ZTEST01335.

DATA: SUBRNAME TYPE C LENGTH 4 VALUE 'TEST',
      PROGRAMNAME TYPE C LENGTH 20 VALUE  'ZTEST01335'.

PERFORM (SUBRNAME) IN PROGRAM (PROGRAMNAME) IF FOUND.

*&---------------------------------------------------------------------*
*&      Form  test
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM TEST.

  WRITE 'hello'.

ENDFORM.                    "test

I think it is so because you have given the names in small case.

BR,

Suhas

2 REPLIES 2
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
1,232

Hello,

PROGRAM ZTEST01335.

DATA: SUBRNAME TYPE C LENGTH 4 VALUE 'TEST',
      PROGRAMNAME TYPE C LENGTH 20 VALUE  'ZTEST01335'.

PERFORM (SUBRNAME) IN PROGRAM (PROGRAMNAME) IF FOUND.

*&---------------------------------------------------------------------*
*&      Form  test
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM TEST.

  WRITE 'hello'.

ENDFORM.                    "test

I think it is so because you have given the names in small case.

BR,

Suhas

Read only

Former Member
0 Likes
1,231

Hi Suhas,

Thanks for the quick reply. It is solved now! Full points awarded.

Thanks again.

Regards,

Joon Meng