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 with modifying Internal table using work area

Former Member
0 Likes
1,164

hi I am working on a BADI development

I have a trouble changing a particular parameter et_reqcap using work area

The parameter ET_REQCAP is of table type /SAPAPO/PPM_TTD_REQCAP...

and

ET_REQCAPX is of table type /SAPAPO/PPM_TTX_REQCAP

I dont have any syntax errors but when I am executing it the BADI triggers but I see the short dump.. You attempted to change, delete or create a line in the internal table "???", but no valid cursor exists for the table.

But will table type have a index ??


METHOD /sapapo/if_ex_ppm_calc~calc_bucket_cons.

  DATA: w_reqcap     TYPE /sapapo/reqcap,
        w_etreqcap_x TYPE /SAPAPO/PPM_TEX_REQCAP,
        w_etreqcap   TYPE /SAPAPO/PPM_TED_REQCAP. "/SAPAPO/PPM_TED_REQCAP

  LOOP AT it_reqcap INTO w_reqcap.
    IF w_reqcap-cap2 <> 1.

      w_etreqcap-cap2   = 1.
      w_etreqcap_x-cap2 = 'X'.

      MODIFY et_reqcap    from w_etreqcap   index 1 TRANSPORTING cap2.
      MODIFY et_reqcap_x  from w_etreqcap_x index 1 TRANSPORTING cap2.
    ENDIF.
  ENDLOOP.

  BREAK-POINT.

ENDMETHOD.

4 REPLIES 4
Read only

Former Member
0 Likes
700

Hi!

Yes tables do have an index.

Within the LOOP, you can use the SY-TABIX variable, which points always to the last used record.

It is tricky, becaus if you give a READ TABLE statement within the LOOP, the SY-TABIX will point at the found record what READ TABLE provided.

I suggest you to put a break-point into the code and you will see, what is wrong.

Regards

Tamá

Read only

0 Likes
700

I will check at runtime how many records IT_REQCAP possesses.. if it has only 1 during runtime all the time the I can directly read it and change the valyes of EQ_REQCAP..

this should simplify things.. anyways let me test it and then get back

Read only

franois_henrotte
Active Contributor
0 Likes
700

this error happens beacuse your internal table et_reqcap_x is empty

so when using INDEX 1 for this table, a short dump happens

Read only

Former Member
0 Likes
700

Does et_reqcap and et_reqcap_x contains data that needs to be modified? If that is, there should be no problem. An error will occur if it has no data and your pointing to index 1 which don't exist.

Or do you want to modify or save the data.

Use APPEND if you're inserting new data.