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

indexing problem

santosh_kumar94
Participant
0 Likes
773

  dear experts,

i have one table control requirement.

suppose my table control have 4 column and 20 rows. it contain the first value as shown below

1st         2nd       3rd            4th

......................................................

10          kg      kilogram          2

now i want to upload data from 2nd row. i have written code for this like :

data : it type standard table of ............

        wa type ..........

data : lv_indx(2) type N,

lv_indx  = 2. ( if i assign here '1' it will overlap with 1st one.)

loop at it into wa.

// codes here......

lv_indx = lv_indx + 1.

endloop.

suppose i have uploaded 3 data here.(means 4 rows )

it works fine up to here.  now, problem cames here.

suppose  again i want to upload 3 data here..

so, data should comes to the 5th column , 6th & 7th.

how to solve this issue so, that data will be uploaded from next row.

help plz.

7 REPLIES 7
Read only

amy_king
Active Contributor
0 Likes
741

Hi Santosh,

I'm not sure I understand your question. What do you mean by "5th column , 6th & 7th"? You wrote your table has 4 columns-- are you trying to add new columns?

Or are you trying to append new rows onto the table, e.g., APPEND wa TO itab?

Or are you trying to insert a new row at a specific index in the table, e.g., INSERT wa INTO itab INDEX idx?

Please provide more detail about your requirement.

Cheers,

Amy

Read only

santosh_kumar94
Participant
0 Likes
741

sorry ,

   it's 5th, 6th & 7th rows..

Read only

0 Likes
741

Hi Santosh,

Then does APPEND or INSERT meet your requirement to add rows to the table?

Cheers,

Amy

Read only

0 Likes
741

  dear experts,

i have one table control requirement.

suppose my table control have 4 column and 20 rows. it contain the first value as shown below

1st         2nd       3rd            4th

......................................................

10          kg      kilogram          2

now i want to upload data from 2nd row. i have written code for this like :

data : it type standard table of ............

        wa type ..........

data : lv_indx(2) type N,

lv_indx  = 2. ( if i assign here '1' it will overlap with 1st one.)

loop at it into wa.

// codes here......

lv_indx = lv_indx + 1.

endloop.

suppose i have uploaded 3 data here.(means 4 rows )

it works fine up to here.  now, problem cames here.

suppose  again i want to upload 3 data here..

so, data should comes to the 5th , 6th & 7th rows.

how to solve this issue so, that data will be uploaded from next row.

help plz.

Read only

0 Likes
741

Actually,

  it's a bdc requirement. so, i have to upload data index wise.

apeend or insert doesn't work here..

Read only

0 Likes
741

Hi Santhosh,

No need to use index.

use the statement.

modify itab from wa_itab.

if sy-subrc ne 0.

append wa_itab tp itab.

endif.

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
741

Santosh, please be more specific in your questions. If you have mentioned at the very beginning that this was for BDC then the whole example wouldn't be necessary. Otherwise everyone just gets confused and you get no answer.

I believe this question (or a similar one) has already been answered on SCN since this is not an unusual task with BDC. In such cases it is usually required to read the existing entries first and then calculate the position where new entries need to be added. It might be more complex if data does not fit on one screen, so you'd have to program for scrolling. Please do more search on SCN, all this has already been discussed many times.

I'm assuming you have already done research to confirm that BDC is the only option and there is no BAPI or other alternative available. If not, please do so first.

Good luck.