2006 Dec 15 6:48 AM
hi all,
The select statment i have used is as follows.
select <field 1>
<field 2>
.
.
<field n>
from <dbtable>
into table <internal table>
for all entries in <internal table 2>
where <field 1> = <internal table 2>-<field>+len(offset).
In the above statement the length and offset were hard coded. When i tried giving the code dynamically, the statement was generating an error. I would like to know if there is any other alternative for a statement like this.
regards,
chaitanya.
2006 Dec 15 7:04 AM
Hi Chaitanya,
It will give error, You should not use offsets.
<i>Take one more internal table and take copy of data into that table.
Modify the tables as per your offset value.
Please in select query</i>
It will work
Regards
Bhupal Reddy
hi all,
The select statment i have used is as follows.
select <field 1>
<field 2>
.
.
<field n>
from <dbtable>
into table <internal table>
for all entries in <internal table 2>
where <field 1> = <internal table 2>-<field>+len(offset).
In the above statement the length and offset were hard coded. When i tried giving the code dynamically, the statement was generating an error. I would like to know if there is any other alternative for a statement like this.
regards,
chaitanya.
2006 Dec 15 6:55 AM
Hello,
Loop at the second internal table and move the substring part (with dynamic offset) to another internal table or another fiold in the same table. Use this new field/table in the for all entries clause.
Regards,
Manoj
2006 Dec 15 7:04 AM
Hi,
In the internal table 2 -
have a new field "offset" which will
have the value = <internal table 2>-<field>+len(offset).
To do this u do a
loop at internal table 2.
<nternal table 2>-offset = <internal table 2>-<field>+len(offset).
modify nternal table 2.
endloop.
Then u have the select statement
select <field 1>
<field 2>
.
.
<field n>
from <dbtable>
into table <internal table>
for all entries in <internal table 2>
<b>where <field 1> = <internal table 2>-<offset>.</b>
-
santhosh
2006 Dec 15 7:04 AM
Hi Chaitanya,
It will give error, You should not use offsets.
<i>Take one more internal table and take copy of data into that table.
Modify the tables as per your offset value.
Please in select query</i>
It will work
Regards
Bhupal Reddy
2006 Dec 15 7:05 AM
Hello,
Move the string field(you want to trim or extract) into another field and then use that field in the condition
sumthing like,
gv_field = field+len(offset)
and then,
select <field 1>
<field 2>
.
.
<field n>
from <dbtable>
into table <internal table>
for all entries in <internal table 2>
where <field 1> = <internal table 2>-<gv_field>
Regards,
Shehryar Dahar
2006 Dec 15 7:17 AM
Hi guys,
thanks all for you replies. All have given seemingly the same alternative. I have tried it, but the project in which i am using it, this alternative would be a performance issue because of an extra loop that i have to do. I would be glad if there is anyother alternative in addition to this.
Thankyou and regards,
chaitanya.
2006 Dec 15 9:44 PM
You might want to try generated code which would give you the chance to do things like dynamically assigning offset and length in a select statement.
You just write your statements into an internal table and turn it into executable code.
Remember: there is no syntax-check whithin the text-table, so be extra careful whith it.
Example - just copy, paste and adapt to your needs:
REPORT ZEXMP_GENERATE.
data: BEGIN OF lgtx OCCURS 0,
lgart TYPE lgart,
lgtxt TYPE lgtxt,
END OF lgtx.
offset and length to be set dynamically
data: i_off(3) TYPE n VALUE 3,
i_len(3) TYPE n VALUE 4.
texttable for your code
data: formline(75).
data: formtab like table of formline.
data: repid type sy-repid.
your <internal table 2>
data: BEGIN OF t1 occurs 0,
cfield(10),
END OF t1.
start-of-selection.
some nonsense, except for +3(4)
APPEND 'bla/101foo' to t1.
APPEND 'bla/102foo' to t1.
APPEND 'bla/103foo' to t1.
APPEND 'bla/104foo' to t1.
APPEND 'bla/106foo' to t1.
APPEND 'bla/107foo' to t1.
APPEND 'bla/108foo' to t1.
*build up the source
APPEND 'PROGRAM SUBPOOL.' TO formtab. "ESSENTIAL!!!!
APPEND 'FORM SEL4ALL USING t_in' TO formtab. "your formname
APPEND ' CHANGING t_out.' TO formtab.
remember! you're outside your program context, so globals won't be visible
from here. DDIC-references would have made life easier
local copies, because Form SEL4ALL wouldn't know, they're tables
APPEND 'DATA: BEGIN OF t1 occurs 0,' TO formtab.
APPEND ' cfield(10),' TO formtab.
APPEND ' END OF t1.' TO formtab.
APPEND 'DATA: BEGIN OF lgtx OCCURS 0,' TO formtab.
APPEND ' lgart TYPE lgart,' TO formtab.
APPEND ' lgtxt TYPE lgtxt,' TO formtab.
APPEND ' END OF lgtx.' TO formtab.
APPEND ' t1[] = t_in.' TO formtab.
*
APPEND ' SELECT LGART LGTXT FROM T512T' TO formtab.
APPEND ' INTO TABLE lgtx' TO formtab.
APPEND ' FOR ALL ENTRIES IN T1' TO formtab.
build up the dynamic part
concatenate
' WHERE LGART = T1-CFIELD+' i_off '(' i_len ')' INTO formline.
APPEND formline TO formtab.
APPEND ' AND SPRSL = SY-LANGU.' to formtab.
APPEND ' T_OUT = LGTX[].' TO formtab.
APPEND 'ENDFORM.' TO formtab.
make it executable
GENERATE SUBROUTINE POOL formtab NAME repid.
and doit
PERFORM sel4all IN PROGRAMM (repid) USING t1[]
CHANGING lgtx[].
it works!
LOOP AT lgtx.
WRITE:/ lgtx-lgart, lgtx-lgtxt.
ENDLOOP.
hope it does the trick for you.
regards
2006 Dec 15 10:35 PM
How are you getting data in to ur internaltable2. if you are getting one entry at a time, so i would suggest to add a field to the internal table and move the offset value in it.
Now using this field you can use for all entries.
However if you are not getting data into internal tbale2 as a single record at a time then you have to loop.
Hope this helps.
Shreekant.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |