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

TABLE_ILLEGAL_STATEMENT in modify statement

Former Member
10,325

Hi,

I am getting a dump( TABLE_ILLEGAL_STATEMENT) in modify statement in a section of my code where I want to modify two fields named amt_plan and qty_plan into an internal table gt_final.

Thanks..


    SELECT objnr gjahr wrttp versn uspob wkg001 wkg002 wkg003 wkg004 wkg005 wkg006 wkg007 wkg008 wkg009
           wkg010 wkg011 wkg012 meg001 meg002 meg003 meg004 meg005 meg006 meg007 meg008 meg009 meg010
           meg011 meg012 FROM coss INTO TABLE gt_coss FOR ALL ENTRIES IN gt_afvc
           WHERE objnr = gt_afvc-objnr OR wrttp = 1 OR versn = 0 OR gjahr NE ''.

    LOOP AT gt_coss INTO gw_coss.
      READ TABLE gt_final INTO gw_final WITH KEY objnr = gw_coss-objnr.
      IF sy-subrc = 0.
        gw_final-amt_plan = gw_coss-wkg001 + gw_coss-wkg002 + gw_coss-wkg003 + gw_coss-wkg004
                            + gw_coss-wkg005 + gw_coss-wkg006 + gw_coss-wkg007 + gw_coss-wkg008
                            + gw_coss-wkg009 + gw_coss-wkg010 + gw_coss-wkg011 + gw_coss-wkg012.

        gw_final-qty_plan = gw_coss-meg001 + gw_coss-meg002 + gw_coss-meg003 + gw_coss-meg004
                            + gw_coss-meg005 + gw_coss-meg006 + gw_coss-meg007 + gw_coss-meg008
                            + gw_coss-meg009 + gw_coss-meg010 + gw_coss-meg011 + gw_coss-meg012.
*        APPEND gw_final TO gt_final.
        MODIFY gt_final FROM gw_final.
      ENDIF.
      CLEAR: gw_final, gw_coss.
    ENDLOOP.

Edited by: Paaavan on Dec 20, 2011 11:08 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
5,483

Hi,

You need to use MODIFY table gt_final from gw_final as you are not trying to update the gt_final table in a loop.

Thanks and Regards,

Sriranjani Chimakurthy.

10 REPLIES 10
Read only

Former Member
0 Likes
5,483

Thats because you are looping table gt_coss and modifying table gt_final.

This is not allowed.

pk

Read only

0 Likes
5,483

Thanks Kishan ji..

But how can I reflect the changes in gt_final with two fields named amt_plan and qty_plan

Read only

Former Member
0 Likes
5,483

Hi,

Modify using Transporting with this 2 fileds amt_plan, qty_plan.

it will works.

Regards,

Sanjay Gogikar

Read only

Former Member
0 Likes
5,483

Hi,

Try using 'TRANSPORITING' along with it.

MODIFY gt_final FROM gw_final transporting amt_plan qty_plan.

Regards,

Sharin

Read only

Former Member
0 Likes
5,483

Hi,

Use transporting keyword

Modify itab from wa transporting field1 field2.

Field1 and field2 are modifying fields in your internal table

Regards,

G.Aditya

Edited by: Aditya.G on Dec 20, 2011 3:48 PM

Read only

Former Member
0 Likes
5,483

Hi,

Can you try moving the gt_final into some temp internal table and do this action. Also try with Transporting the required fields.

Regards

senthil kumar

Read only

Former Member
0 Likes
5,484

Hi,

You need to use MODIFY table gt_final from gw_final as you are not trying to update the gt_final table in a loop.

Thanks and Regards,

Sriranjani Chimakurthy.

Read only

Former Member
0 Likes
5,482

Hi,

Following changes need to be done :



data : l_tabix type sy-tabix.

LOOP AT gt_coss INTO gw_coss.
      READ TABLE gt_final INTO gw_final WITH KEY objnr = gw_coss-objnr.
      IF sy-subrc = 0.
     clear l_tabix.
      l_tabix = sy-tabix.
        gw_final-amt_plan = gw_coss-wkg001 + gw_coss-wkg002 + gw_coss-wkg003 + gw_coss-wkg004
                            + gw_coss-wkg005 + gw_coss-wkg006 + gw_coss-wkg007 + gw_coss-wkg008
                            + gw_coss-wkg009 + gw_coss-wkg010 + gw_coss-wkg011 + gw_coss-wkg012.
 
        gw_final-qty_plan = gw_coss-meg001 + gw_coss-meg002 + gw_coss-meg003 + gw_coss-meg004
                            + gw_coss-meg005 + gw_coss-meg006 + gw_coss-meg007 + gw_coss-meg008
                            + gw_coss-meg009 + gw_coss-meg010 + gw_coss-meg011 + gw_coss-meg012.
*        APPEND gw_final TO gt_final.
        MODIFY gt_final FROM gw_final index l_tabix transporting amt_plan qty_plan.

 (Check syntax here , maybe index comes after transporting)

      ENDIF.
      CLEAR: gw_final, gw_coss.
ENDLOOP.

When the internal table you are using is not in loop, you will have to explicitly give the index as wel..

Regards,

Arun

Edited by: arun warrier on Dec 20, 2011 3:52 PM

Read only

Former Member
0 Likes
5,482

As it is giving a problem with ur table index's in the loop since the read stament is been used in it. you can use the index or transpoting the fields.

I prefer Rather than using modify use the field symbols will not give the dump.

Read only

naresh_bammidi
Contributor
0 Likes
5,482

hi,

use the following syntax

MODIFY it_final from wa_final index sy-tabix.