‎2010 May 29 5:45 AM
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.
‎2010 May 29 8:32 AM
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
‎2010 May 29 6:02 AM
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
‎2010 May 29 6:27 AM
Hi,
Use this statement :
INSERT zcourier FROM gs_zcourier1.
Jitendra
‎2010 May 29 6:32 AM
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.
‎2010 May 29 7:18 AM
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.
‎2010 May 29 8:32 AM
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
‎2010 May 29 12:08 PM