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 append

Former Member
0 Likes
384

hi all

i got a internal table, how to dynamic append the line to the internal?

below is my code

DATA: line(256) TYPE c,

text_tab LIKE STANDARD TABLE OF line,

field LIKE line.

this is a static append.

<b>line = '444444'.

APPEND line TO text_tab.

line = '555555'.

APPEND line TO text_tab.

line = '666666'.

APPEND line TO text_tab.</b>

how to make it dynamic append to internal table

Thanks

1 REPLY 1
Read only

Former Member
0 Likes
293

Hi

Check this sample report

REPORT z_dynamic_program.

TABLES:dd02l,
vlcvehicle.

FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE,
<fs_warea> TYPE ANY,
<fs_any> TYPE ANY.

DATA:t_anytable TYPE REF TO data,
f_warea TYPE REF TO data,
tb_condition(72) TYPE c OCCURS 0 WITH HEADER LINE.



DATA:w_dynproname TYPE sy-repid,
w_msg(70) TYPE c.

DATA:t_code(72) TYPE c OCCURS 0 WITH HEADER LINE.


PARAMETERS:pa_tnam LIKE dd02l-tabname.
SELECT-OPTIONS:so_comm FOR vlcvehicle-zz_commnos.


START-OF-SELECTION.

SELECT SINGLE * FROM dd02l WHERE tabname = pa_tnam.

IF sy-subrc NE 0.
STOP.
ENDIF.


APPEND 'Program SubPool.' TO t_code.
APPEND ' ' TO t_code.


CONCATENATE 'TYPES TY_TABLE TYPE ' pa_tnam ' OCCURS 0.'
INTO t_code SEPARATED BY space.
APPEND t_code.

CONCATENATE 'TYPES TY_WAREA TYPE ' pa_tnam '.'
INTO t_code SEPARATED BY space.
APPEND t_code.


APPEND 'Form generate_table changing p_table type ref to data '
TO t_code.
APPEND ' p_warea type ref to data.'
TO t_code.


APPEND ' create data p_table type (''TY_TABLE''). '
TO t_code.
APPEND ' create data p_warea type (''TY_WAREA''). '
TO t_code.

APPEND 'Endform. ' TO t_code.


GENERATE SUBROUTINE POOL t_code
NAME w_dynproname
MESSAGE w_msg.


IF sy-subrc NE 0.
WRITE : / w_msg.
STOP.
ENDIF.

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

* Call the subroutine to get reference to dyn table
PERFORM generate_table IN PROGRAM (w_dynproname)
CHANGING t_anytable
f_warea.


ASSIGN t_anytable->* TO <fs_table>.
ASSIGN f_warea->* TO <fs_warea>.


***** Fetch the data from the database based on the Commission number
* and the Table name
SELECT *
INTO TABLE <fs_table>
FROM (pa_tnam)
WHERE Z_COMMNOS IN so_comm.

IF sy-subrc NE 0.
STOP.
ENDIF.


DELETE FROM (pa_tnam) WHERE Z_COMMNOS IN so_comm.

IF sy-subrc EQ 0.
WRITE:/ sy-dbcnt.
ENDIF.


END-OF-SELECTION.

Regards

Pavan