SELECT-OPTIONS: s_werks FOR marcv-werks .
RANGES: xbdart FOR resb-bdart.
START-OF-SELECTION.
CLEAR xtab. REFRESH xtab.
CALL FUNCTION 'MB_ADD_PURCHASE_ORDER_QUANTITY' "未清采购订单数
EXPORTING
x_elikz = ''
x_loekz = ''
x_matnr = '002100000000000618'
x_meins = 'PC'
TABLES
xtab = xtab
xwerks = s_werks.
WRITE / 'XTAB:'.
LOOP AT xtab.
PERFORM write_wa USING xtab 'XXXXXXX' 'X' 'X'.
ENDLOOP.
REFRESH xbdart.
CLEAR xbdart.
xbdart-sign = 'I'.
xbdart-option = 'EQ'.
xbdart-low = 'AR'.
APPEND xbdart.
xbdart-low = 'MR'.
APPEND xbdart.
CLEAR xtab1. REFRESH xtab1.
CALL FUNCTION 'MB_ADD_RESERVATION_QUANTITIES' "预留的
EXPORTING
x_matnr = '002100000000000618'
x_xloek = space
x_kzear = space
x_kzwso = ''
TABLES
xtab1 = xtab1
xwerks = s_werks
xbdart = xbdart.
WRITE / 'XTAB1:'.
LOOP AT xtab1.
PERFORM write_wa USING xtab1 'XXXXXXX' 'X' 'X'.
ENDLOOP.
CLEAR xtab2. REFRESH xtab2.
CALL FUNCTION 'MB_SELECT_GR_BLOCKED_STOCK' "收货冻结的库存
EXPORTING
x_matnr = '002100000000000618'
x_meins = 'PC'
x_kzwso = ''
TABLES
xtab2 = xtab2
xwerks = s_werks.
WRITE / 'XTAB2:'.
LOOP AT xtab2.
PERFORM write_wa USING xtab2 'XXXXXXX' 'X' 'X'.
ENDLOOP.
CLEAR xtab4. REFRESH xtab4.
CALL FUNCTION 'MB_SELECT_SD_SCHEDULED_STOCK' "交货计划
EXPORTING
x_matnr = '002100000000000618'
x_kzwso = ''
TABLES
xtab4 = xtab4
xwerks = s_werks.
WRITE / 'XTAB4:'.
LOOP AT xtab4.
PERFORM write_wa USING xtab4 'XXXXXXX' 'X' 'X'.
ENDLOOP.
CLEAR xtab5. REFRESH xtab5.
CALL FUNCTION 'MATERIAL_QUANTITIES_FAUF'
EXPORTING
matnr = '002100000000000618'
kzwso = ''
TABLES
famng_tab = xtab5
werks_tab = s_werks.
WRITE / 'XTAB5:'.
LOOP AT xtab5.
PERFORM write_wa USING xtab5 'XXXXXXX' 'X' 'X'.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Form write_wa
*&---------------------------------------------------------------------*
FORM write_wa USING wa fieldmask newline alllen.
DATA: str TYPE string ,
str_idx TYPE string ,
f_index TYPE i ,
f_len TYPE i .
FIELD-SYMBOLS: <f_field> .
f_len = STRLEN( fieldmask ).
IF newline = 'X'. WRITE / ''.ENDIF.
POSITION 1 .
DO .
ASSIGN COMPONENT sy-index OF STRUCTURE wa TO <f_field>.
IF sy-subrc <> 0 OR sy-index > f_len.
EXIT.
ELSE.
str_idx = sy-index .
CONDENSE str_idx.
f_index = sy-index - 1.
IF fieldmask+f_index(1) = 'X'.
IF alllen = ''.
str = <f_field> .
WRITE str.
ELSE.
WRITE <f_field>.
ENDIF.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. "write_wa