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: 

create internal table from an existing internal table.

Former Member
0 Kudos
768

There’s an internal table , which have 10 columns, and I have to select records from it filtering by two columns co_a (which have value 1,2,3,4,5), and co_b ( which is used to store date).

I need three type subset ,

1. co_a =1 and co_b = date( getting from another internal table)

1. co_a =3 and co_b = date( getting from another internal table)

1. co_a =2,4,5 and co_b = date( getting from another internal table)

How can I get the subset(it may be another internal set) dynamically

5 REPLIES 5

Former Member
0 Kudos
158

Hi,

You can use a dynamic subroutine.

GENERATE SUBROUTINE POOL itab NAME name.

Svetlin

0 Kudos
158

hello,Svetlin Rusev

May you tell me more detailed information?

0 Kudos
158

Hi,

This code maybe will be helpful for you.

DATA itab TYPE TABLE OF string.

data: s1(1) value 1,

s2(2) value 1.

APPEND 'FORM MYSUBR' to itab.

APPEND 'PROGRAM SUBPOOL.' to itab.

if ....

APPEND 'loop at itab1 into wa1 where ( co_a = s1 or co_a = s2 ) and co_b = date.' TO itab.

elseif ...

APPEND 'loop at itab1 into wa1 where co_a = s2 and co_b = date.' TO itab.

endif.

APPEND 'append lines of wa1 to itab2.' TO itab.

APPEND 'endloop.' TO itab.

APPEND 'ENDFORM' to itab.

GENERATE SUBROUTINE POOL itab NAME prog.

PERFORM ('mysubr') IN PROGRAM (prog).

jayanthi_jayaraman
Active Contributor
0 Kudos
158

Hi,

types : begin of ty,

co_a ...

...

end of ty.

data : itab1 type standard table of ty,

itab2 type standard table of ty,

itab3 type standard table of ty,

wa1 type ty.

..I assume that you populated data in itab1.

loop at itab1 into wa1 where ( co_a = '1' or co_a = '3' ) and co_b = date.

append lines of wa1 to itab2.

endloop.

loop at itab1 into wa1 where ( co_a = '2' or co_a = '4' or co_a = '5' ) and co_b = date.

append lines of wa1 to itab3.

endloop.

If you need more clarifications,kindly get back.Otherwise,if you find these as useful,kindly reward points.

Former Member
0 Kudos
158

Hi, Mei Xie

He mentioned GENERATE SUBROUTINE POOL. It's a technology for ABAP to generate subroutine in dynamicaly code.

You can write your code just in a long text internal table ,and call GENERATE SUBROUTINE POOL to generate the subroutine. The difference between it and the normal way is we can dynamically change the code according to some condition.

some link as following:

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db999535c111d1829f0000e829fbfe/frameset.htm

Hope my explain is clearly.

But by the way, I'm not very clear about your question, specially the 'subset'.