Skip to Content
author's profile photo Former Member
Former Member

Dynamic program generation problem

Hi guys,

Does subroutine in dynamically generated program can't be be invoked with parameter?

If perform dyn subroutine without any parameters, it's run well, anybody can tell me why?

REPORT z_test.

TYPES: BEGIN OF tp_sflight,

carrid TYPE sflight-carrid,

connid TYPE sflight-connid,

fldate TYPE sflight-fldate,

price TYPE sflight-price,

END OF tp_sflight.

DATA: BEGIN OF fld_list OCCURS 0,

fld_name(20),

END OF fld_list.

DATA: gt_outtab TYPE TABLE OF tp_sflight WITH HEADER LINE.

DATA: source_line(72).

DATA:

gi_source LIKE STANDARD TABLE OF source_line,

l_prog_name(30) TYPE c,

l_msg(120) TYPE c,

l_line(10) TYPE c,

l_word(10) TYPE c,

l_off(3) TYPE c.

START-OF-SELECTION.

SELECT * FROM sflight

INTO CORRESPONDING FIELDS OF TABLE gt_outtab

UP TO 10 ROWS.

fld_list-fld_name = 'connid'.

APPEND fld_list.

fld_list-fld_name = 'price'.

APPEND fld_list.

APPEND 'PROGRAM MY_SUBPOOL.' TO gi_source.

APPEND 'FORM WRITE_DYN_CONTENT USING wa TYPE sflight.' TO gi_source.

LOOP AT fld_list.

CLEAR source_line.

CONCATENATE 'WRITE wa-' fld_list-fld_name '.' INTO source_line.

APPEND source_line TO gi_source.

ENDLOOP.

APPEND 'ENDFORM.' TO gi_source.

GENERATE SUBROUTINE POOL gi_source

NAME l_prog_name MESSAGE l_msg LINE l_line

WORD l_word OFFSET l_off.

IF sy-subrc <> 0.

WRITE : / 'Error', l_msg.

ENDIF.

WRITE l_prog_name.

LOOP AT gt_outtab.

PERFORM write_dyn_content <b>USING gt_outtab </b> IN PROGRAM (l_prog_name).

ENDLOOP.

Regards,

Tim

Message was edited by: jingen tang

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 18, 2006 at 07:58 AM

    Hi

    I can work fine, but you have to define the parameter using the same type:

    See these pieces of your code:

    DATA: gt_outtab TYPE TABLE OF tp_sflight WITH HEADER LINE.

    APPEND 'FORM WRITE_DYN_CONTENT USING wa TYPE sflight.' TO gi_source.

    So gt_outtab and wa are of different types:

    Try to use this declaration:

    DATA: gt_outtab TYPE TABLE OF sflight WITH HEADER LINE.

    and your subroutine'll work fine

    Max

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi

      From SAP help:

      Notes

      1- Temporary subroutine pools belong to the runtime context of the generating program, i.e. to the roll area of the internal mode from which the generation is performed. They may therefore be addressed only within this context, i.e. the generated FORM routines can only be called from within the generating mode.

      2- Up to 36 temporary subroutine pools can currently be managed for each roll area.

      So it means you can generate max 36 subroutine, but your code generate a subroutine for every record of GT_OUTTAB, so if this table has more 36 records, the program try'll to generate more than 36 subroutine, but a dump'll occurs at 37th record.

      So if you want to prevent this you should generate the subroutine once and moreover you'll improve the performance because generate subroutine only once.

      You can prevent an eventual dump using CATCH/ENDCATCH

      LOOP AT GT_OUTTAB.

      CATCH SYSTEM-EXCEPTIONS GENERATE_SUBPOOL_DIR_FULL = 1.

      PERFORM WRITE_DYN_CONTENT IN PROGRAM (L_PROG_NAME) USING GT_OUTTAB.

      ENDCATCH.

      IF SY-SUBRC <> 0.

      • Other subroutines can't be called

      EXIT.

      ENDIF.

      ENDLOOP.

      Max

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.