cancel
Showing results for 
Search instead for 
Did you mean: 

why cant I use BASE while declaring table inline?

sh4il3sh
Participant
0 Kudos

hello experts,

here lt_schdx will only have only line because every time a new line is added, old ones are removed.
if I had table declared beforehand I could use BASE but it's not allowed here.
any alternative because BASE statement is not allowed, my code below:

LOOP AT lt_item ASSIGNING FIELD-SYMBOL(<ls_item>).

DATA(lt_schdx) =
VALUE cod_t_bapischdlx( ( updateflag = 'I'
          itm_number = COND #( WHEN <ls_item>-posnr IS NOT INITIAL THEN 'X' )
          sched_line = '0001'
          req_date   = COND #( WHEN <ls_item>-edatu IS NOT INITIAL THEN 'X' )
          date_type  = 'X'
          req_qty    = 'X' ) ).

ENDLOOP.

 

View Entire Topic
Sandra_Rossi
Active Contributor

You cannot use DATA(itab) = VALUE ttyp( BASE itab ... ) just because the BASE internal table must already exist, it's just a special case to have the same itab used both in the inline declaration and after BASE that SAP didn't want to handle specifically (as far as I understand).

It's very acceptable to have explicitly a "clear" before the LOOP:

DATA(lt_schdx) = VALUE cod_t_bapischdlx( ).

LOOP AT lt_item ASSIGNING FIELD-SYMBOL(<ls_item>).

  lt_schdx = VALUE #(
             BASE lt_schdx
             ( ... = ...
               ... = ... ) ).

I'm not against using INSERT INTO TABLE too:

DATA(lt_schdx) = VALUE cod_t_bapischdlx( ).

LOOP AT lt_item ASSIGNING FIELD-SYMBOL(<ls_item>).

  INSERT VALUE #( ... = ...
                  ... = ... )
      INTO TABLE lt_schdx.

 

sh4il3sh
Participant
0 Kudos

I actually ended up doing Clear part and INSERT INTO TABLE.

hopefully it comes in newer releases.