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

problem reading data from nested internal table.

Former Member
0 Likes
975

Hi,

Below is my code;

*********SAP Code********

TYPES: BEGIN OF v54a0_scdd,

fknum LIKE vfkk-fknum,

change LIKE vfkkd-updkz,

x TYPE v54a0_scd,

y TYPE v54a0_scd,

tvtf LIKE tvtf,

END OF v54a0_scdd.

  • SCD table for dialog

TYPES: v54a0_scdd_tab TYPE v54a0_scdd OCCURS 1.

*********SAP Code********

*Custom declaration*****

data: wa_freight_costs type v54a0_scdd_tab.

data: it_freight_costs type v54a0_scdd_tab occurs 0.

*****Here data is getting appended to it_freight_costs. P_frieght_costs is coming from standard program.

move p_freight_costs TO wa_FREIGHT_COSTS.

append wa_freight_costs to it_freight_costs.

clear wa_freight_costs.

***Now the problem is here. I am not able to read the data from the nested internal table x-item.

if i use <fs_f_costs> to move data from it_freight_costs in the outer loop, i get a syntax error; <i> "the line type of the table it_freight_costs is not compatible with field symbol type <fs_f_costs>" </i>

FIELD-SYMBOLS: <fs_f_costs> type line of v54a0_scdd_tab.

LOOP AT it_freight_costs assigning <fs_f_costs>.

LOOP AT <fs_f_costs>-x-item ASSIGNING <fs_freight_item>.

<b> I want to read <fs_freight_item>-vfkp-netwr.</b>

ENDLOOP.

Can anyone guide me?

6 REPLIES 6
Read only

Former Member
0 Likes
846

You should move <b><fs_f_costs>-x</b> to a new internal table and then read <b>item</b> from that IT....Then you could assign values to the FS....

Greetings,

Blag.

Read only

0 Likes
846

Thanks Blag. But as i said i am getting the sytax error at the outer loop itself. Once i pass this only then i can think about the second loop.

Read only

Former Member
0 Likes
846

Please note that TYPE v54a0_scdd_tab is already an internal table type. Instead of try to declare your custom declarations as follows.

*Custom declaration*****

data: wa_freight_costs type v54a0_scdd.

data: it_freight_costs type v54a0_scdd occurs 0.

Read only

0 Likes
846

I have tried this one. in this case when i am trying to <b>append</b> the data to it_freight_costs, during the runtime it is giving me a dump which says <b><i>conversion from V54A0_SCDD_TAB to V54A0_SCDD is not supported.</i></b>

Read only

0 Likes
846

This message was moderated.

Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
846

A quick look at how I would do this. Note I haven't checked if this compiles just done a quick brain-dump.

  DATA: lr_f_costs TYPE REF TO v54a0_scdd_tab,
        lr_f_cost TYPE REF TO v54a0_scdd.

  LOOP AT it_freight_costs REFERENCE INTO lr_f_costs.
    LOOP AT lr_f_costs->* REFERENCE INTO lr_f_cost.

    ENDLOOP.

  ENDLOOP.

As you can see I personally prefer pointers to field symbols - I don't believe there is any performance differences and because of my background in other languages pointers make more sense to me.

Cheers

Graham Robbo