ABAP顾问
分类:
2009-03-15 16:04:36
REPORT zmm026 NO STANDARD PAGE HEADING LINE-COUNT 120.
TABLES eban.
DATA: header TYPE bapimereqheader,
headerx TYPE bapimereqheaderx ,
number LIKE bapimereqheader-preq_no,
return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
item LIKE bapimereqitemimp OCCURS 0 WITH HEADER LINE,
itemx LIKE bapimereqitemx OCCURS 0 WITH HEADER LINE .
START-OF-SELECTION.
* header-pr_type = 'NB'.
* headerx-pr_type = 'X'.
*
* item-preq_item = '00001'.
* item-pur_group = 'J03'.
* item-short_text = 'test'.
* item-material = '001100000000017159'.
* item-plant = '1020'.
* item-store_loc = '2020'.
* item-quantity = '21'.
* item-deliv_date = '20090403'.
* APPEND item.
* itemx-preq_item = '00001'.
* itemx-preq_itemx = 'X'.
* itemx-pur_group = 'X'.
* itemx-short_text = 'X'.
* itemx-material = 'X'.
* itemx-plant = 'X'.
* itemx-store_loc = 'X'.
* itemx-quantity = 'X'.
* itemx-deliv_date = 'X'.
* APPEND itemx.
*
*
* item-preq_item = '00002'.
* item-pur_group = 'J03'.
* item-short_text = 'test2'.
* item-material = '001100000000031833'.
* item-plant = '1010'.
* item-store_loc = '1070'.
* item-quantity = '31'.
* item-deliv_date = '20090403'.
* APPEND item.
* itemx-preq_item = '00002'.
* itemx-preq_itemx = 'X'.
* itemx-pur_group = 'X'.
* itemx-short_text = 'X'.
* itemx-material = 'X'.
* itemx-plant = 'X'.
* itemx-store_loc = 'X'.
* itemx-quantity = 'X'.
* itemx-deliv_date = 'X'.
* APPEND itemx.
SELECT MAX( erdat ) INTO eban-erdat FROM eban .
SELECT SINGLE * FROM eban WHERE erdat = eban-erdat.
header-pr_type = eban-bsart.
headerx-pr_type = 'X'.
item-preq_item = '00001'.
item-pur_group = eban-ekgrp.
item-short_text = 'test'.
item-material = eban-matnr.
item-plant = eban-werks.
item-store_loc = eban-lgort.
item-quantity = '4'.
item-deliv_date = sy-datum + 10.
IF eban-bwtar <> ''.
item-val_type = eban-bwtar.
ENDIF.
item-preq_price = '12'.
APPEND item.
itemx-preq_item = '00001'.
itemx-preq_itemx = 'X'.
itemx-pur_group = 'X'.
itemx-short_text = 'X'.
itemx-material = 'X'.
itemx-plant = 'X'.
itemx-store_loc = 'X'.
itemx-quantity = 'X'.
itemx-deliv_date = 'X'.
IF eban-bwtar <> ''.
itemx-val_type = 'X'.
ENDIF.
itemx-preq_price = 'X'.
APPEND itemx.
CALL FUNCTION 'BAPI_PR_CREATE'
EXPORTING
prheader = header
prheaderx = headerx
IMPORTING
number = number
TABLES
return = return
pritem = item
pritemx = itemx.
COMMIT WORK AND WAIT .
IF return[] IS INITIAL.
WRITE: / 'no messages'.
ELSE.
LOOP AT return.
WRITE: / return-type,
(2) return-id,
return-number,
(80) return-message,
(20) return-parameter,
(3) return-row,
return-field.
ENDLOOP.
ENDIF.