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

how do I get a value from a table without a header?

Former Member
0 Likes
2,263

Hi experts,

My ABAP skills aren't very advanced ...

I have a local structure which I have filled with info from a Web Service:

importing
            get_webservice_response = ls_response.

This structure has two elements, the second of which interests me and is a table called get_webservice_return:

lt_mytable = ls_response-get_webservice_return.

So far so good, by doing this lt_mytable is the same as the table returned by the webservice. (It is a dynamic table which, depending on the returned results, can have zero lines or however many lines as there are results)

Now in that table, there is first a controller then there are values like firstname, lastname, company, zipcode etc...

I tried to do something like:

 lv_zipcode = lt_mytable-zipcode.

etc, but I get an error saying "LT_MYTABLE is a table without a header line and therefore has no component called ZIPCODE".

What should I have done?

How can I pass the values of a line to another structure ?

How can I pass the values of a column to another structure ?

In Web Dynpro I have a context with the same values as the lt_mytable, how do I pass all the values of the lt_mytable into the context nodes?

Thanks everyone,

Micol

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
1,433

You need to read a line of the internal table table into a work area, then move the value.

data: ls_mytable like line of lt_mytable.

read table lt_mytable into ls_mytable index 1.

lv_zipcode = ls_mytable-zipcode.

Regards,

Rich Heilman

Hi experts,

My ABAP skills aren't very advanced ...

I have a local structure which I have filled with info from a Web Service:

importing
            get_webservice_response = ls_response.

This structure has two elements, the second of which interests me and is a table called get_webservice_return:

lt_mytable = ls_response-get_webservice_return.

So far so good, by doing this lt_mytable is the same as the table returned by the webservice. (It is a dynamic table which, depending on the returned results, can have zero lines or however many lines as there are results)

Now in that table, there is first a controller then there are values like firstname, lastname, company, zipcode etc...

I tried to do something like:

 lv_zipcode = lt_mytable-zipcode.

etc, but I get an error saying "LT_MYTABLE is a table without a header line and therefore has no component called ZIPCODE".

What should I have done?

How can I pass the values of a line to another structure ?

How can I pass the values of a column to another structure ?

In Web Dynpro I have a context with the same values as the lt_mytable, how do I pass all the values of the lt_mytable into the context nodes?

Thanks everyone,

Micol

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
1,434

You need to read a line of the internal table table into a work area, then move the value.

data: ls_mytable like line of lt_mytable.

read table lt_mytable into ls_mytable index 1.

lv_zipcode = ls_mytable-zipcode.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,433

Hi,

You have to create a work area and move the values to the work area to get a value..

DATA: T_MARA TYPE STANDARD TABLE OF MARA.

DATA: WA TYPE MARA.

READ TABLE T_MARA INTO WA INDEX 1.

WRITE: / WA-MATNR.

Thanks,

Naren

Read only

Former Member
0 Likes
1,433

Hi

You can read the internal table on the basis of their Index Number

syntax is :

Read table <table-name> Index <Index-no>.