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

insert problem

Former Member
0 Likes
778

hi sap guru's,

can you all pls help me out for insert problem.when i compile then it shows The work area "GS_ZCOURIER1" is not long enough error message. so can you pls let me know how to insert data into table.


 TYPES: BEGIN OF t_zcourier,
          vbeln TYPE zcourier-vbeln,
          erdat TYPE zcourier-erdat,
          sent_date TYPE zcourier-sent_date,
          courier_no TYPE zcourier-courier_no,
          courier_cnts TYPE zcourier-courier_cnts,
          othr_cnts TYPE zcourier-othr_cnts,
        END OF t_zcourier.

  DATA : gt_zcourier1 TYPE STANDARD TABLE OF t_zcourier,
         gs_zcourier1 TYPE t_zcourier.

 SELECT SINGLE vbeln erdat sent_date courier_no courier_cnts othr_cnts
         FROM zcourier 
         INTO CORRESPONDING FIELDS OF gs_zcourier1
         WHERE vbeln = zcourier-vbeln
         AND erdat  = zcourier-erdat
         AND courier_cnts = zcourier-courier_cnts
         AND sent_date = zcourier-sent_date
         AND courier_no = zcourier-courier_no
         AND othr_cnts = zcourier-othr_cnts.

      IF sy-subrc = 0.
        MESSAGE s020.
      ELSE.
        zcourier-erdat = sy-datum.
        zcourier-ernam = sy-uname.

        gs_zcourier1-vbeln = zcourier-vbeln.
        gs_zcourier1-erdat = zcourier-erdat.
        gs_zcourier1-sent_date = zcourier-sent_date.
        gs_zcourier1-courier_no = zcourier-courier_no.
        gs_zcourier1-courier_cnts = zcourier-courier_cnts.
        gs_zcourier1-othr_cnts = zcourier-othr_cnts.

        INSERT into zcourier values gs_zcourier1.
    ENDIF.

1 ACCEPTED SOLUTION
Read only

former_member233090
Active Contributor
0 Likes
747

Hi,

can you check this table zcourier do you have any primary key which shd be there in the internal table which you have created, pls check it. definetely your problem will be solved.

This error comes when the ztable and the work area is different, check the ztable and the internal table once,

bhavana

6 REPLIES 6
Read only

Former Member
0 Likes
747

Hi,

Check your Database table zcourier, may be the field MANDT is there but you have missed in your work area GS_ZCOURIER1. Then add the field mandt in GS_ZCOURIER1 and assign the value sy-mandt to that.

Regards

Dillip Sahoo

Read only

Former Member
0 Likes
747

Hi,

Use this statement :

INSERT zcourier FROM gs_zcourier1.

Jitendra

Read only

Former Member
0 Likes
747

Hi,

the problem is in your else condition.

IF sy-subrc = 0.
        MESSAGE s020.
      ELSE.
        zcourier-erdat = sy-datum.
        zcourier-ernam = sy-uname.
 
        gs_zcourier1-vbeln = zcourier-vbeln.
        gs_zcourier1-erdat = zcourier-erdat.
        gs_zcourier1-sent_date = zcourier-sent_date.
        gs_zcourier1-courier_no = zcourier-courier_no.
        gs_zcourier1-courier_cnts = zcourier-courier_cnts.
        gs_zcourier1-othr_cnts = zcourier-othr_cnts.
 
        INSERT into zcourier values gs_zcourier1.
    ENDIF.

I guess you should assign gs_zcourier1 values to zcourier rather than zcourier values to gs_zcourier1.

cheers,

Sany.

Read only

Former Member
0 Likes
747

Hi Atulks!!

Only do this , that make ur workarea just like the structur of your custom DB Table.

Else it will give u error. so do like this.

data: it_workarea like zcourier.

then populate ur work area and then insert it into db table.

Read only

former_member233090
Active Contributor
0 Likes
748

Hi,

can you check this table zcourier do you have any primary key which shd be there in the internal table which you have created, pls check it. definetely your problem will be solved.

This error comes when the ztable and the work area is different, check the ztable and the internal table once,

bhavana

Read only

Former Member
0 Likes
747

SOLVED