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

Modifying internal table

Former Member
0 Likes
8,752

Hi Folks,

I have internal table with 6 fields. it has already filled values for 5 fields. I am trying to fill the values for 6th field, by keeping in loop of another itab. after passing variable i used modify statement. But its going to short dump. Could any body help whats the error i made.I am givng the pice of code..pls help me...thanks in advance..

loop at ictrl_tab where error = 'X'.

it_error-e_mess = ictrl_tab-e_mess.

MODIFY it_error transporting e_mess.

endloop.

Shyam...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,517

Assuming that you have to modify only 1 record in it_error then you have to identify the exact record in table it_error before modifying it using the MODIFY statement.

Please use the READ statement to identify the record to be modified and use the additions TABLE and INDEX of the MODIFY statement to modify the exact record of the internal table it_error.

However, if you have to modify all the entries in it_error then use the WHERE addition

to specify the records to be modified.

Please provide the declarations of the internal tables to help you further.

13 REPLIES 13
Read only

Former Member
0 Likes
2,517

Hi,

You need to use the following statement :

MODIFY it_error from it_error transporting e_mess

As if your modify table statement is in some other table loop it gives dump. Try to take value in some work area and then write

Modify itab from wa transporting XXXXX.

Hope this helps!!

Regards,

lalit

Read only

nikhil_chitre
Active Participant
0 Likes
2,517

Hi,

What is the Short dump Description .

could you describe little bit in detail about ur code.

Regards,

Nikhil

Read only

former_member195383
Active Contributor
0 Likes
2,517

declare an work area of the type similar to it_error .

say it is wa_error.

try the below...

loop at ictrl_tab where error = 'X'.

wa_error-e_mess = ictrl_tab-e_mess.

MODIFY it_error from wa_error transporting e_mess.

endloop.

Read only

Former Member
0 Likes
2,517

Hi Shyam,

Can you please tell us the text display in the short dump...

Use

Modify <table  from <workarea> transporting...

Best regards,

raam

Read only

Former Member
0 Likes
2,518

Assuming that you have to modify only 1 record in it_error then you have to identify the exact record in table it_error before modifying it using the MODIFY statement.

Please use the READ statement to identify the record to be modified and use the additions TABLE and INDEX of the MODIFY statement to modify the exact record of the internal table it_error.

However, if you have to modify all the entries in it_error then use the WHERE addition

to specify the records to be modified.

Please provide the declarations of the internal tables to help you further.

Read only

0 Likes
2,517

Hi all thanks for your answers. I changed my statement as

MODIFY it_error from it_error transporting e_mess.

Even though its going to dump again.

Dump message is

Error analysis

You attempted to change, delete or create a line in the

internal table "\PROGRAM=YTV_TR_0150R\DATA=IT_ERROR[]", but no valid cursor

exists

for the table.

Possible reasons:

1. The relevent ABAP/4 statement does not include the addition

"...INDEX...", although the statement is not

inside a "LOOP...ENDLOOP" loop processing this table.

2. The relevent ABAP/4 statement was called from within a

"LOOP...ENDLOOP" loop after a DELETE

"\PROGRAM=YTV_TR_0150R\DATA=IT_ERROR[]".

Should i use work area mandatorily..because i need to change the logic in the program at some places again....Thanks...

Edited by: shyam prasad on Jul 11, 2008 6:06 AM

Read only

0 Likes
2,517

As explained before, please identify the record that has to be modified before modifying the internal table

Check the examples given below


PARAMETERS p_carrid TYPE scarr-carrid. 

DATA scarr_tab TYPE SORTED TABLE OF scarr 
               WITH UNIQUE KEY carrid. 

DATA scarr_wa TYPE scarr. 

SELECT * 
       FROM scarr 
       INTO TABLE scarr_tab. 

READ TABLE scarr_tab INTO scarr_wa 
     WITH TABLE KEY carrid = p_carrid. 

scarr_wa-currcode = 'EUR'. 

MODIFY TABLE scarr_tab FROM scarr_wa 
       TRANSPORTING currcode. 


PARAMETERS p_carrid TYPE scarr-carrid. 

DATA scarr_tab TYPE SORTED TABLE OF scarr 
               WITH UNIQUE KEY carrid. 

DATA: idx      TYPE sy-tabix, 
      scarr_wa TYPE scarr. 

SELECT * 
       FROM scarr 
       INTO TABLE scarr_tab. 

READ TABLE scarr_tab 
     WITH TABLE KEY carrid   = p_carrid 
     TRANSPORTING NO FIELDS. 

idx = sy-tabix. 

scarr_wa-currcode = 'EUR'. 

MODIFY scarr_tab INDEX idx FROM scarr_wa 
       TRANSPORTING currcode. 

Read only

0 Likes
2,517

The syntax that you are using is only supported with the WHERE addition of the MODIFY statement as shown below


PARAMETERS: p_carrid TYPE sflight-carrid, 
            p_connid TYPE sflight-connid, 
            p_plane1 TYPE sflight-planetype, 
            p_plane2 TYPE sflight-planetype. 

DATA sflight_tab TYPE SORTED TABLE OF sflight 
                 WITH UNIQUE KEY carrid connid fldate. 

DATA sflight_wa TYPE sflight. 

SELECT * 
       FROM sflight 
       INTO TABLE sflight_tab 
       WHERE carrid = p_carrid AND 
             connid = p_connid. 

sflight_wa-planetype = p_plane2. 

MODIFY sflight_tab FROM sflight_wa 
       TRANSPORTING planetype WHERE planetype = p_plane1. 

So, the conclusion is either to use WHERE addition(with the current syntax that you are using ) or to identify the exact record using the READ statement as shown in the previous post and then use the MODIFY statment specifying the INDEX of the internal table record to be modified.

Read only

Former Member
0 Likes
2,517

Hi Shyam,

If you are facing any problem in Modify statement. then the best way is to just debug the program at the runtime and check if the header value contains the data. If it contains then it should work in the program

But as I understand you are not able to put the value in the header . First check the header value is coming correct if it is coming then do the modify statement

MODIFY it_error transporting e_mess.

&************Reward Point if helpful***********&

Read only

0 Likes
2,517

Hi chidanand,

thansk for ur anser..Data is coming correctly to the header. When the cursor reaches the modify statemtn..its going to dump...

Read only

Former Member
0 Likes
2,517

loop at ictrl_tab where error = 'X'.

it_error-e_mess = ictrl_tab-e_mess.

MODIFY it_error transporting e_mess.

endloop.

It is because you should give the INDEX addition for modifying the value like.

MODIFY it_error transporting e_mess index 1. 0r

MODIFY it_error transporting e_mess index sy-tabix.

if you have a linking field between the two internal tables, you can READ the it_error with that field and modify it_error using INDEX SY-TABIX.

because after read statement correct SY-TABIX would be returned.

reward points if u find this helpful

Read only

Former Member
0 Likes
2,517

HI,

You are looping ictrl_tab and modifying it_error, by your code you can modify only ictrl_tab.

By this you are encountering the dump.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
2,517

Hi all,

Thanks for you answes. Problem solved now...