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

Data Extraction

Former Member
0 Likes
738

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

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
715

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

6 REPLIES 6
Read only

Former Member
0 Likes
715

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

Read only

0 Likes
715

Hi Srihari.

Thanks for u r replay.

please tell me how to fetch the data from t_data.

regards

prajwala.k

Read only

0 Likes
715

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

Read only

Former Member
0 Likes
715

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.

Read only

Clemenss
Active Contributor
0 Likes
716

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

Read only

Former Member
0 Likes
715

thnks to all