2005 Aug 08 8:59 AM
Theres 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
2005 Aug 08 9:17 AM
Hi,
You can use a dynamic subroutine.
GENERATE SUBROUTINE POOL itab NAME name.
Svetlin
2005 Aug 08 9:52 AM
hello,Svetlin Rusev
May you tell me more detailed information?
2005 Aug 08 10:08 AM
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).
2005 Aug 08 9:21 AM
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.
2005 Aug 08 10:06 AM
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'.