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

data not getting inserted in table vbsn

Former Member
0 Likes
1,128

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.

5 REPLIES 5
Read only

abdulazeez12
Active Contributor
0 Likes
862

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

Read only

0 Likes
862

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

Read only

Former Member
0 Likes
862

Hi

MAy be you are uploading a record which is already existing in the table.i.e.check key fields..

Read only

Former Member
0 Likes
862

Hi,

TRy to use modify statment

Regards,

Niyaz

Read only

Former Member
0 Likes
862

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