‎2007 Oct 10 6:56 AM
Hi Experts
Here I am giving a part of my code which i am using to upload data in database usind bdc. data is inserted successfully in all tables . What i have given here is data insertion in table VBSN ....here i am getting only one record, for next record i want a new line should be added and so on ...but whats happening is its showing only very first record i uploaded, no new record is inserting in my table..Please check my code and suggest me what wrong in my code?
<b>*********THIS IS NOT THE COMPLETE CODE************</b>
tables: vbsn , vbap.
DATA: itab_vbsn type table of vbsn with header line.
DATA: w_vbeln LIKE vbap-vbeln.
DATA : wa2 TYPE vbsn.
DATA: l_itmcd LIKE vbap-matnr,
l_pos LIKE vbap-posnr,
l_unit LIKE mara-meins.
DATA: BEGIN OF itab_nag OCCURS 0,
nagdt(8) TYPE c,
time(6) TYPE c,
itmcd(18) TYPE c,
qty(10) TYPE c,
gate(4) TYPE c,
a11(4) TYPE c, "New Field
nagno(35) TYPE c,
vbeln(10) TYPE c,"SCHEDULING AGREEMENT
END OF itab_nag.
SELECT SINGLE * INTO CORRESPONDING FIELDS OF itab_vbsn FROM vbsn WHERE vbeln EQ w_vbeln
AND posnr EQ l_pos.
IF sy-subrc NE 0.
wa2-vbeln = w_vbeln.
wa2-posnr = l_pos.
wa2-aeskd = itab_nag-nagno.
INSERT vbsn FROM wa2.
ENDIF.
‎2007 Oct 10 7:32 AM
Hi Annu-
You are selecting only one record using SELECT SINGLE *..and that is the reaosn why only one record is getting uploaded..
What u do is..
SELECT * from VBSN into table itab_vbsn where <conditions>.
insert into VBSN values itab_vbsn.
BTW, why do want to retrieve the records from VBSN and uplaod the same to the same table??
Cheers
‎2007 Oct 10 8:23 AM
Hi Shakir
I am not retrieving the records from VBSN and uplaoding the same toVBSN table.
What i am doing here is retriving data from vbsn and then checking if <b>sy-subrc NE</b><b> 0</b>. That mean if that data not in vbsn <b>insert</b> it in vbsn using insert command
‎2007 Oct 10 7:33 AM
Hi
MAy be you are uploading a record which is already existing in the table.i.e.check key fields..
‎2007 Oct 10 7:35 AM
‎2007 Oct 10 7:40 AM
INSERT vbsn FROM wa2.
Never try to do this through ABAP code, this is not advisable as it may create inconsistency in SAP data.
try to find out Function modules, BAPIS to accomplish the same task