Skip to Content
0
Former Member
Apr 22, 2009 at 04:51 AM

table insert from itab

20 Views

Hi,

I have all datas in my itab.there are multiple mblnr in single date .but in my 'Z' table i am getting one mblnr.why multiple mblnrs are not inserted.

 LOOP AT ITAB.

         IT_ZTPLSTOCK-MATNR = ITAB-MATNR_I.
         IT_ZTPLSTOCK-WERKS = ITAB-WERKS_I.
         IT_ZTPLSTOCK-MJAHR = ITAB-MJAHR.
         IT_ZTPLSTOCK-BUDAT = ITAB-BUDAT.
   
 IF ITAB-BWART_I = '101'.
      IT_ZTPLSTOCK-MENGE1 = ITAB-MENGE_I.
      IT_ZTPLSTOCK-MEINS1 = ITAB-MEINS_I.
      IT_ZTPLSTOCK-DMBTR1 = ITAB-DMBTR_I.
      IT_ZTPLSTOCK-BWART = ITAB-BWART_I.
      IT_ZTPLSTOCK-MBLNR = ITAB-MBLNR.
    
ELSEIF ITAB-BWART_I = '102'.
      IT_ZTPLSTOCK-MENGE1 = ITAB-MENGE_I.
      IT_ZTPLSTOCK-MEINS1 = ITAB-MEINS_I.
      IT_ZTPLSTOCK-DMBTR1 = ITAB-DMBTR_I.
      IT_ZTPLSTOCK-BWART = ITAB-BWART_I.
      IT_ZTPLSTOCK-MBLNR = ITAB-MBLNR.

    ELSEIF ITAB-BWART_I = '201'.
      IT_ZTPLSTOCK-MENGE2 = ITAB-MENGE_I.
      IT_ZTPLSTOCK-MEINS2 = ITAB-MEINS_I.
      IT_ZTPLSTOCK-DMBTR2 = ITAB-DMBTR_I.
      IT_ZTPLSTOCK-BWART = ITAB-BWART_I.
      IT_ZTPLSTOCK-MBLNR = ITAB-MBLNR.

    ELSEIF ITAB-BWART_I = '202'.
      IT_ZTPLSTOCK-MENGE2 = ITAB-MENGE_I.
      IT_ZTPLSTOCK-MEINS2 = ITAB-MEINS_I.
      IT_ZTPLSTOCK-DMBTR2 = ITAB-DMBTR_I.
      IT_ZTPLSTOCK-BWART = ITAB-BWART_I.
      IT_ZTPLSTOCK-MBLNR = ITAB-MBLNR.

    APPEND IT_ZTPLSTOCK.
    CLEAR IT_ZTPLSTOCK.
  ENDLOOP.
  LOOP AT IT_ztplstock.
    MOVE-CORRESPONDING IT_ztplstock TO ZTPLSTOCK.
    INSERT ZTPLSTOCK.
  ENDLOOP.

suggest some ideas.

with regards,

Bathri