‎2007 Sep 08 11:54 AM
Hi all.
please look at this code.
form get_data using t_data like it_data .
SELECT zsettlement~ecod
zsettlement~alwnc
zsettlement~elnc
zsettlement~salp
zsettlement~salc
zsettlement~bons
zsettlement~advn
zsettlement~notp1
zsettlement~recv
zsettlement~idca
zsettlement~stat
zsettlement~gratu
zsettlement~remark
zsettlement~lwd
ZSETTLEMENT~ESI
ZSETTLEMENT~PF
INTO CORRESPONDING FIELDS OF TABLE t_data
FROM zsettlement as zsettlement
WHERE zsettlement~slno in s_slno
AND zsettlement~ecod in s_ecod
.
i want to select single value from t_data.
how to do this , if i use statement like this
total = zsettlement~remark.
it will give error bocoz there is no header line . is there any other way so that i can fetch the value from t_data.
please help me .
Regards.
prajwala.k
‎2007 Sep 08 8:10 PM
Hi prajwal,
as it is goog programming practice your internal table t_data is declared a a table without header line.
If you want to use values from a specific table body line, you have to access this table line.
Slow and old-fashioned approach is moving the contents into a work area
data:
wa_t_data like line of it_data.
loop at t_data into wa_t_data.
total = wa_t_data-remark.
* ...
endloop.
Fast and direct-access:
field.symbols:
<data> like line of it_data.
loop at t_data assigning <data>.
total = <data>-remark.
* ...
endloop.
The approach using field-symbols is up to 5 times faster.
Regards,
Clemens
‎2007 Sep 08 12:03 PM
Prajwala,
I do not understand your query completely, Please explain what exactly you need, but a suggestion for you:
You do not have to use <tablename>~fieldname for every field if you are not using inner joins.
Your current query can be re written like this :
SELECT ecod
alwnc
elnc
salp
salc
bons
advn
notp1
recv
idca
stat
gratu
remark
lwd
ESI
PF
INTO CORRESPONDING FIELDS OF TABLE t_data
FROM zsettlement
WHERE slno in s_slno
AND ecod in s_ecod.
Also try to declare you t_data as the same type as your fields for selections, and avoid using INTO CORRESPONDING FIELDS OF, This hampers performance.
Thanks,
Srihari
‎2007 Sep 08 12:15 PM
Hi Srihari.
Thanks for u r replay.
please tell me how to fetch the data from t_data.
regards
prajwala.k
‎2007 Sep 08 12:23 PM
Prajwala,
Are you trying read data from the internal table ?
then do this.
DATA: wa_data like line of t_data.
READ TABLE t_data into wa_data WITH KEY <field1> = <value>.
Read F1 documentation for more help.
Thanks,
Srihari
‎2007 Sep 08 12:51 PM
According to your coding t_data must have the header line with it.
And here if total is the total of all the remarks of the internal table then just code like this.
loop at t_data.
total = total+t_data-remark.
endloop.
write:/ total.
‎2007 Sep 08 8:10 PM
Hi prajwal,
as it is goog programming practice your internal table t_data is declared a a table without header line.
If you want to use values from a specific table body line, you have to access this table line.
Slow and old-fashioned approach is moving the contents into a work area
data:
wa_t_data like line of it_data.
loop at t_data into wa_t_data.
total = wa_t_data-remark.
* ...
endloop.
Fast and direct-access:
field.symbols:
<data> like line of it_data.
loop at t_data assigning <data>.
total = <data>-remark.
* ...
endloop.
The approach using field-symbols is up to 5 times faster.
Regards,
Clemens
‎2007 Sep 10 6:19 AM