ABAP函数:SD_VBAP_READ_WITH_VBELN(根据销售订单读取表vbap中的信息)


function:SD_VBAP_READ_WITH_VBELN
功能:根据销售订单读取表vbap中的信息
参数:
  import:I_VBELN                          订单号(必输项)
              I_BYPASSING_BUFFER     是否回避buffer
              I_REFRESH_BUFFER         是否清空buffer
  tables:ET_VBAPVB                        不清楚其意义
                   ET_VBAP                            vbap表

form:EDIT_LINES
功能:把READ_TEXT返回的LINES中的行按照TDFORMAT=“*”重新组织
原因:如果用CREATE_TEXT登录的长文本不存在该问题,如果是在前台业务登录的text,那么存到数据库的时候会在72位的地方换行,在lines这个表中的TDFORMAT设置为空,导致READ_TEXT返回的表中的行数也许不是你需要的行数。
代码:
FORM EDIT_LINES TABLES P_IT_LINES STRUCTURE TLINE.
  DATA:
    L_IT_LINES TYPE STANDARD TABLE OF TLINE,
    L_WA_LINES TYPE TLINE,
    L_WA_LINE1 TYPE TLINE,
    L_LINE TYPE I.
  DATA:
    L_INDEX TYPE I,
    L_I     TYPE I.
  READ TABLE P_IT_LINES TRANSPORTING NO FIELDS
    WITH KEY TDFORMAT = SPACE.
  CHECK SY-SUBRC = 0.
  L_LINE = LINES( P_IT_LINES ).
  CHECK L_LINE > 1.

  L_IT_LINES[] = P_IT_LINES[].
  CLEAR: P_IT_LINES[].

  L_INDEX = 2.
  DO.
    CLEAR: L_WA_LINES.
    READ TABLE L_IT_LINES INTO L_WA_LINES INDEX L_INDEX.
    IF SY-SUBRC <> 0.
      L_I = L_INDEX - 1.
      READ TABLE L_IT_LINES INTO L_WA_LINES INDEX L_I.
      IF SY-SUBRC = 0 .
        APPEND L_WA_LINES TO P_IT_LINES.
      ENDIF.
      EXIT.
    ENDIF.
    IF L_WA_LINES-TDFORMAT = '*'.
      L_I = L_INDEX - 1.
      CLEAR L_WA_LINE1.
      READ TABLE L_IT_LINES INTO L_WA_LINE1 INDEX L_I.
      APPEND L_WA_LINE1 TO P_IT_LINES.
      L_INDEX = L_I + 2.
    ELSE.
      L_I = L_INDEX - 1.
      READ TABLE L_IT_LINES INTO L_WA_LINE1 INDEX L_I.
      CONCATENATE L_WA_LINE1-TDLINE L_WA_LINES-TDLINE
             INTO L_WA_LINE1-TDLINE.
      APPEND L_WA_LINE1 TO P_IT_LINES.
      L_INDEX = L_INDEX + 2.
    ENDIF.
  ENDDO.
ENDFORM.                    " S4110_EDIT_LINES


你可能感兴趣的:(数据库,function,table,buffer,import,structure)