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: 

Calling subroutine dynamically

Former Member
0 Kudos

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

SuhaSaha
Advisor
Advisor

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

SuhaSaha
Advisor
Advisor

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

Former Member
0 Kudos

Hi Suhas,

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

Thanks again.

Regards,

Joon Meng