SAP-游标

当数据特别多的时候SELECT可能会内表溢出

PARAMETERS: p_size TYPE num6 DEFAULT 10000.

 OPEN CURSOR WITH HOLD g_cursor FOR SELECT * FROM (tabname)  WHERE (condwher).
  DO.
    lv_index = sy-index.
    CONDENSE lv_index NO-GAPS.
    FETCH NEXT CURSOR g_cursor INTO CORRESPONDING 
FIELDS OF TABLE  PACKAGE SIZE p_size.
    IF sy-subrc <> 0.
      CLOSE CURSOR g_cursor.
      EXIT.
   ELSE.
      IF lt_temp IS NOT INITIAL.
        SELECT *
          FROM /bshm/fa_pcd
          APPENDING TABLE gt_fa_pcd
           FOR ALL ENTRIES IN lt_temp
         WHERE ordernr   = lt_temp-ordernr
           AND ordertype = lt_temp-ordertype
           AND posnum    = lt_temp-posnum
           AND fieldname = 'KI'.
      ENDIF.
    ENDIF.
  ENDDO.
  CLOSE CURSOR: g_cursor.

你可能感兴趣的:(SAP-游标)