-2

I need some help on how can I check every index's value of column A if there's a gap.

READ TABLE ZVBELNEXTTAB INDEX x.
curr = ZVBELNEXTTAB-EVBELN.
READ TABLE ZVBELNEXTTAB INDEX y.
next = ZVBELNEXTTAB-EVBELN.
chck = next - curr.

IF chck GT 1.

chck = chck - 1.
DO chck TIMES.
  ZVBELNEXTTAB-EVBELN = curr + 1.
  ZVBELNEXTTAB-BUKRS = ''.
  ZVBELNEXTTAB-WERKS = ''.
  ZVBELNEXTTAB-VBELN = ''.
  ZVBELNEXTTAB-FKDAT = ''.
  ZVBELNEXTTAB-VBLSTAT = ''.
  ZVBELNEXTTAB-ZPRN = ''.
  ZVBELNEXTTAB-UNAME = ''.
  ZVBELNEXTTAB-TYPE = ''.
  ZVBELNEXTTAB-MANDT = ''.
  APPEND ZVBELNEXTTAB.
  SORT ZVBELNEXTTAB BY evbeln.
ENDDO.

ENDIF.

enter image description here

enter image description here

since SAP ABAP doesn't support the concept of using array. I'd like to perform this action for the entire column data.

Thanks!

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Ryan Lopez
  • 29
  • 1
  • 8
  • 3
    Basically, ABAP supports tables (arrays) since a long long time. So, what do you mean? `ABAP doesn't support the concept of using array` – Sandra Rossi Jul 18 '18 at 05:27
  • in technical way of using an array i guess? unlike in other PL. i'm still a newbie in using ABAP. I tried to make a 1 Dimensional array by setting an internal table and then i created 2nd Dimensional array with the same set of data as the 1st dimension have but by using different key field. I'm still reading and watching tutorials for future stuff that i may use. – Ryan Lopez Jul 18 '18 at 06:00
  • 1
    Don't create multiple questions for the same task – Suncatcher Jul 18 '18 at 06:20

2 Answers2

0

Get a copy of original internal table zvbelnexttab And loop at copy internal table zvbelnexttab_copy. after that update original internal table-

DATA : lv_tab    TYPE sytabix.

LOOP AT zvbelnexttab_copy.

  curr = zvbelnexttab_copy-evbeln.  
  lv_tab = sy-tabix + 1.

  READ TABLE zvbelnexttab_copy INDEX lv_tab.
  next = zvbelnexttab_copy-evbeln.
  .....
  .....
  .....

ENDLOOP.
divScorp
  • 498
  • 1
  • 8
  • 17
0
  1. Sort your internal table by the field you want to fill gaps.
  2. Create variable TYPE field
  3. Loop at your table.
  4. if itab-field <> remembered_value + 1. <--- a gap, implement logic to insert/append whatever you want. Remember that your table is sorted and inserting there during the loop in non appropiate way may give bad results.
  5. remembered_value = tab-field
  6. endloop.

I suggest in point 4. you could append the new records to NEW internal table of the same type as the original and then insert it into db / merge it with your old itab.

Bananach
  • 1
  • 1
  • 3
  • i already generated the missing/gap between document #. but when i tried to append it in the old tab, it shows the error that there is no more space for the internal storage. – Ryan Lopez Jul 19 '18 at 00:55
  • Either there is an error in your logic or I can't help you :( – Bananach Jul 20 '18 at 06:42
  • i'd already fix the bugs :) i just going to add some color stuff in the ALV thanks a lot! – Ryan Lopez Jul 20 '18 at 07:20