Application Development 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: 

Work Area 'ITAB' is not long enough ?

sagar_ranasingh
Participant
0 Kudos

Hello Gurus,

i have an internal table ITAB, which has all the fields of DB table ZDESC which has all total 6 fields ( 3-key fields).

I am fetching 4 fields from scrren to ITAB including the key fields.

and then saving these data into ZDESC table .

But here the error is - work area 'ITAb' is not long enough.

whats the reason and how to solve this ?

here is my code , its so simple

.

PAI include.

-



case ok_code.

when 'enter'

  IT_HEAD-CCODE = S_CCODE .                                   * s_code = screen field.
  IT_HEAD-PCODE = S_PCODE .                                    *  first three field are key fields except c_name
   IT_HEAD-BCODE = S_BCODE .
  IT_HEAD-CNAME = S_CNAME .  

when 'save'.

modify zdesc from table it_head.

endcase.

dats it.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Do check if your table is deinfed as:

you are confusing between table and work area.

1. Have clear distiction between table and work area.

DATA: it_head type table of ZDESC.

DATA: wa_head type ZDEC.

MODIFICATION TO DB TABLE:

From Table:

MODIFY ZDESC FROM TABLE IT_HEAD

From Workarea:

MODIFY ZDESC FROM WA_HEAD.

Moreover your work area seems to be not of same type as your table.

In that case you have to use UPDATE ,

CHEERS !

12 REPLIES 12

Sm1tje
Active Contributor
0 Kudos

does it also have the mandt field?

0 Kudos

no MANDT field is nt there .

but adding MANDT field , solves the error..

whats the reason?

Sm1tje
Active Contributor
0 Kudos

I can't go into the exact details, but here's how I see it.

For DB operations, there is no check on individual fields but on actual length. So (the total length of your internal table is compared to the length of the database table.

Former Member
0 Kudos

Hi,

Your internal table and the corresponding work area should be of the same structure as the database table. All database tables have a key field MANDT. So it goes without saying that your internal table and the work area should contain the MANDT field too.

Former Member
0 Kudos

Actually not all DB tables have MANDT field, some tables are cross-client, that is no MANDT field.

raymond_giuseppi
Active Contributor
0 Kudos

The internal table record must be at least as long as the database structure, look at online help with F1. (or [Work Areas in Open SQL Statements |http://help.sap.com/abapdocu/en/ABENOPEN_SQL_WA.htm]) (except: client/mandt)

If you don't have the whole data to update you MUST either

- read the actual database, update an internal table of same length/field order and then update database

- use syntax like [UPDATE dbtab SET expr1 WHERE expr2|http://help.sap.com/abapdocu/en/ABAPUPDATE_SOURCE.htm#!ABAP_ALTERNATIVE_1@1@]

NB 1: you must not only have every field of the database table, but they must be in the same sequence and have the same definition, so the same internal length (so you must have field MANDT, even if you left the field initial)

NB 2 : i hope some lines are not copied here from your program. Else whet if user press SAVE and not ENTER first time, where is the APPEND, is IT_HEAD actually an internal table ?

Regards,

Raymond

Former Member
0 Kudos

Do check if your table is deinfed as:

you are confusing between table and work area.

1. Have clear distiction between table and work area.

DATA: it_head type table of ZDESC.

DATA: wa_head type ZDEC.

MODIFICATION TO DB TABLE:

From Table:

MODIFY ZDESC FROM TABLE IT_HEAD

From Workarea:

MODIFY ZDESC FROM WA_HEAD.

Moreover your work area seems to be not of same type as your table.

In that case you have to use UPDATE ,

CHEERS !

sagar_ranasingh
Participant
0 Kudos

thnks for all ur knoweledge

0 Kudos

how to add mandt field ? I am new to ABAP.

0 Kudos

You can start with BC courses if you are new to ABAP, for example BC400 or BC430 ABAP Dictionary.

as for your question it depends where you want to add MANDT field, in ABAP Dictionary or in a Defined type via TYPES in your program.

If you want to add new field in ABAP dictionary use Se11 if in your program use SE38, there type TYPES: put your cursor on it and press F1 and read the docu.

0 Kudos

This message was moderated.

Former Member
0 Kudos

This message was moderated.