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 external perform / subroutine pool

Former Member
0 Likes
2,438

Hello.

I generated a subroutine pool (GENERATE SUBROUTINE POOL). Within this subroutine pool i implemented a FORM routine.

Now I try to call the FORM routine with dynamic external perform and get a PERFORM_NOT_FOUND shortdump.

I am using the following syntax:

PERFORM (<field containing the name of the FORM routine>) IN PROGRAM (<field containing the 'name' of the subroutine pool (e.g. '%_T03PD0'>).

What is my mistake?

20 REPLIES 20
Read only

Former Member
0 Likes
2,257

hi mike ,

1. are you telling me that you are getting the dump only if you specify the subroutine and program name dynamically ?

2. if you specify it statically, does it work?

3. also, are you developing the subroutine pool dynamically?

4. have you cross-checked in se38 if the subroutine pool is in active status?

regards,

anand mandalika.

Read only

0 Likes
2,257

1. subroutine is generate dynamically (SYNTAX-CHECK: OK);

name of subroutine also dynamically

2. Yes is case of the name of the subroutine (e.g PERFORM formxx IN PROGRAM (prog).

3. Yes

4. How?! -> dynamically implemented subroutine pool

Read only

0 Likes
2,257

I'm sorry, i overlooked the fact that you are generating it dynamically. you cannot verify in SE38.

But have you checked the sy-subrc after generation ?

<i>Generation errors can occur, if the program contains errors in the declaration statements that are not recognized during the static syntax check.</i>

Also use the error-handling for the GENERATE SUBROUTINE POOL statement (described clearly in the online documentation).

Read only

0 Likes
2,257

Sorry, but... of course i checked the SY-SUBRC and of course i did the normal error handling after GENERATE SUBROUTINE POOL ...

Read only

0 Likes
2,257

Hi Mike,

can you give the code snippet here so that i may be able to detect if something's wrong?

Regards,

Anand Mandalika.

Read only

0 Likes
2,257

REPORT ZMS_TEST_LI.

TYPES: DIV_TABLE(5000) TYPE C OCCURS 0.

DATA: GT_TMPTAB TYPE DIV_TABLE,

GT_BATCH LIKE /RTC/SV_LI001 OCCURS 0,

GS_BATCH LIKE LINE OF GT_BATCH,

GV_TABNAME LIKE DD02L-TABNAME VALUE '/RTC/SV_LI001',

GV_SRNAME LIKE SY-REPID,

GV_FORMROUTINE LIKE SY-REPID.

TABLES: /RTC/AS_INDX.

START-OF-SELECTION.

  • build name of subroutine:

  • 'form_' + <name of ABAP-Suite customizing table>

CONCATENATE 'f_' GV_TABNAME INTO GV_FORMROUTINE.

REPLACE '/' WITH SPACE INTO GV_FORMROUTINE.

REPLACE '/' WITH SPACE INTO GV_FORMROUTINE.

CONDENSE GV_FORMROUTINE NO-GAPS.

TRANSLATE GV_FORMROUTINE TO LOWER CASE.

PERFORM GENERATE_IMPORT_FORM USING GV_TABNAME

CHANGING GV_SRNAME

GV_FORMROUTINE

SY-SUBRC.

  • check whether SUBROUTINE POOL was generated

CHECK SY-SUBRC EQ 0.

PERFORM F_RTCSV_LI001 IN PROGRAM (GV_SRNAME)

  • PERFORM (gv_formroutine) IN PROGRAM (gv_srname)

TABLES GT_TMPTAB

IF FOUND.

LOOP AT GT_TMPTAB INTO GS_BATCH.

WRITE: / GS_BATCH-MANDT,

GS_BATCH-KEYTYPE,

GS_BATCH-KEYCOMP,

GS_BATCH-KEYVERS,

GS_BATCH-KEYVALUE,

GS_BATCH-LICENCE.

APPEND GS_BATCH TO GT_BATCH.

ENDLOOP. "LOOP AT gt_tmptab INTO gs_batch

MODIFY (GV_TABNAME) CLIENT SPECIFIED FROM TABLE GT_BATCH.

IF SY-SUBRC EQ 0.

DELETE FROM /RTC/AS_INDX

WHERE RELID = 'TS' AND

SRTFD = GV_TABNAME.

ENDIF. "IF sy-subrc EQ 0

************************************************************************

FORM GENERATE_IMPORT_FORM

USING IV_TABNAME LIKE DD02L-TABNAME

CHANGING EV_SRNAME LIKE SY-REPID

EV_FORMROUTINE LIKE SY-REPID

EV_SUBRC LIKE SY-SUBRC.

DATA: LT_PROGTAB(72) TYPE C OCCURS 0,

LV_PROGTAB LIKE LINE OF LT_PROGTAB,

LV_ITABNAME LIKE DD02L-TABNAME,

TV_MSG LIKE SY-LISEL,

TV_WORD LIKE SY-LISEL,

TV_LIN LIKE SY-LISEL.

CONSTANTS: LC_PREFIX(3) TYPE C VALUE 'it_'.

LOCAL: LT_PROGTAB, LV_PROGTAB,

LV_ITABNAME,

TV_MSG, TV_WORD, TV_LIN.

  • generate name of form routine ->EV_FORMROUTINE

CONCATENATE 'f_' IV_TABNAME INTO EV_FORMROUTINE.

WHILE SY-SUBRC EQ 0.

  • eliminate all slashes as long as found in EV_FORMROUTINE

REPLACE '/' WITH SPACE INTO EV_FORMROUTINE.

ENDWHILE. "WHILE sy-subrc EQ 0

CONDENSE EV_FORMROUTINE NO-GAPS.

TRANSLATE EV_FORMROUTINE TO LOWER CASE.

  • generate name of internal table ->LV_ITABNAME

CONCATENATE LC_PREFIX IV_TABNAME INTO LV_ITABNAME.

TRANSLATE LV_ITABNAME TO LOWER CASE.

MOVE 'PROGRAM srpool.' TO LV_PROGTAB.

APPEND LV_PROGTAB TO LT_PROGTAB.

MOVE 'TYPES: div_table(5000) TYPE c OCCURS 0.' TO LV_PROGTAB.

APPEND LV_PROGTAB TO LT_PROGTAB.

MOVE 'TABLES: /rtc/as_indx.' TO LV_PROGTAB.

APPEND LV_PROGTAB TO LT_PROGTAB.

CONCATENATE 'FORM' EV_FORMROUTINE INTO LV_PROGTAB SEPARATED BY SPACE.

APPEND LV_PROGTAB TO LT_PROGTAB.

MOVE ' TABLES data_tab TYPE div_table.' TO LV_PROGTAB.

APPEND LV_PROGTAB TO LT_PROGTAB.

  • do the DATA stuff within EV_FORMROUTINE

CONCATENATE ' DATA:' LV_ITABNAME 'LIKE' IV_TABNAME 'OCCURS 0,'

INTO LV_PROGTAB

SEPARATED BY SPACE.

APPEND LV_PROGTAB TO LT_PROGTAB.

MOVE ' lv_tmp LIKE LINE OF data_tab.' TO LV_PROGTAB.

APPEND LV_PROGTAB TO LT_PROGTAB.

CONCATENATE ' IMPORT' LV_ITABNAME 'FROM DATABASE /rtc/as_indx(ts)'

INTO LV_PROGTAB

SEPARATED BY ' '.

APPEND LV_PROGTAB TO LT_PROGTAB.

CONCATENATE ' ID ''' IV_TABNAME '''.' INTO LV_PROGTAB.

APPEND LV_PROGTAB TO LT_PROGTAB.

CONCATENATE ' LOOP AT' LV_ITABNAME 'INTO lv_tmp.' INTO LV_PROGTAB

SEPARATED BY SPACE.

APPEND LV_PROGTAB TO LT_PROGTAB.

MOVE ' APPEND lv_tmp TO data_tab.' TO LV_PROGTAB.

APPEND LV_PROGTAB TO LT_PROGTAB.

MOVE ' ENDLOOP.' TO LV_PROGTAB.

APPEND LV_PROGTAB TO LT_PROGTAB.

  • MOVE 'ENDFORM.' TO lv_progtab.

CONCATENATE 'ENDFORM. "FORM' EV_FORMROUTINE

INTO LV_PROGTAB

SEPARATED BY SPACE.

APPEND LV_PROGTAB TO LT_PROGTAB.

  • check the generated ABAP code for syntax errors

SYNTAX-CHECK FOR LT_PROGTAB

MESSAGE TV_MSG

LINE TV_LIN

WORD TV_WORD.

  • SY-SUBRC=0 indicates that the source code checked has no syntax errors

IF SY-SUBRC EQ 0.

GENERATE SUBROUTINE POOL LT_PROGTAB

NAME EV_SRNAME.

ENDIF. "IF sy-subrc EQ 0

MOVE SY-SUBRC TO EV_SUBRC.

IF SY-SUBRC EQ 0.

  • do the household ...

REFRESH LT_PROGTAB.

FREE LT_PROGTAB.

ENDIF. "IF sy-subrc EQ 0

CLEAR: LV_PROGTAB, LV_ITABNAME.

ENDFORM. "FORM generate_import_form

Read only

0 Likes
2,257

Hi Mike,

Unfortunately , the structure /RTC/AS_INDX does not exist in my system. I guess it is a custom-structure. Is it there in any standard SAP Product ?

Coming to your program, In the debug mode, i see that there's the following statement inside the FORM...ENDFORM block of the dynamic subroutine table.

TABLES data_tab TYPE div_table.

It may be because of some code that i have commented out. but just check it out nevertheless.

And lastly, put a break point at the generate subroutine pool statement and create another sample program with exatcly the same code and try calling it again dynamically. do you still get an error ?

In the meanwhile i will try to do something about this missing structure.

Regards,

Anand Mandalika.

Read only

0 Likes
2,257

The structure /RTC/AS_INDX is a structure in our customer namespace.

Read only

0 Likes
2,257

Also , in the following statement, replace SY-SUBRC with some other local / gloabl variable.

PERFORM GENERATE_IMPORT_FORM USING    GV_TABNAME
                             CHANGING GV_SRNAME
                                      GV_FORMROUTINE
                                      SY-SUBRC.

Just to be on the safe side..

Regards,

Anand Mandalika.

Read only

0 Likes
2,257

Okay , I may have stumbled upon something here...

the subroutine name and the program name must contain the names of a subroutine or program in block capitals when the statement is executed (dynamic external subroutine call).

That doesn't seem to be the case here...

Regards,

Anand Mandalika.

Read only

0 Likes
2,257

OK, but that´s not the reason for ths misbehaviour described above!

Read only

0 Likes
2,257

check the other answer i have given...

Read only

0 Likes
2,257

I don´t get a shortdump in case i address the subroutine statically.

Read only

0 Likes
2,257

yes , i know that. But the documentation says that in case of dynamic specification, you have to use the upper case...just try it out.

Read only

0 Likes
2,257

OK, that works pretty fine. But... How comes that one has to use the upper case name of the subroutine here? ...

Read only

0 Likes
2,257

hi,

specifying a dynamic argument in uppercase is not specific to this case. Even when you call a FM or a method dynamically, the name should always be in UPPERCASE.

Regards,

Anand Mandalika.

P.S. Now that you have solved your problem, don't you want to reward points ?

Read only

0 Likes
2,257

Well, when it comes to calling a FM i am used to passing the name in upper case but not when it comes to FORM routines... but... OK!

PS: You are really frantic on gettings these points, aren´t you? Seems as if you REALLY spend a lot of time here. -- Don´t you have anything else to do?? )

Read only

0 Likes
2,257

Well, I do some parallel processing and try to manage it. but this question was interesting, i must confess. the solution turned out to bee too simple , though.

But sometimes people don't give the points or reward a very low score (like in this case, for example )

Read only

0 Likes
2,257

OK, but just that one: I DON`T KNOW HOW SOMEONE CAN BE SO CURIOUS ON THESE POINTS ... it´s just ... nothing. There a lot of other forums on the web where you don´t have these points and they working pretty well!

Read only

0 Likes
2,257

Trust me , if they had points, they would work even better !!

But you see, the idea of having points is really amazing. It is <b>not</b> just NOTHING !!! There's some kind of a competitive spirit which really drives people to answer the question. And I'm yet to come across a place like SDN where you have got so many hundereds of weblogs / technical articles on very advanced technical stuff in SAP (and otherwise). <i>And they get recognized, as well.</i>

Isn't it really innovative? Nobody else had thought of it.

And there are some secret-goodies in store for the guys who score good points. You get to see your name in the top-contributors and people suddenly start <i>knowing</i> you!!

Thomas Jung and Craig Cmehil et al seem to have almost become household names of the SDNer.

And the points just mean that SAP values the contributor, in it's own way, giving away goodies at every possible occassion.

Regards,

Anand Mandalika.