创建采购申请(BAPI_REQUISITION_CR…
*&---------------------------------------------------------------------*
*& Report ZLM_TEST_028
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zlm_test_028.
DATA: BEGIN OF gt_data1 OCCURS 0,
*
KNTTP
TYPE STRING, "科目分配类别
*
TXZ01
TYPE STRING, "短文本
*
MATKL
TYPE STRING, "物料组
DATA: BEGIN OF gt_data OCCURS 0,
*
KNTTP
TYPE STRING, "科目分配类别
*
TXZ01
TYPE STRING, "短文本
*
MATKL
TYPE STRING, "物料组
DATA: BEGIN OF gt_out OCCURS 0,
DATA: pr_item LIKE TABLE OF bapiebanc WITH
HEADER LINE,
DATA: l_return LIKE pr_return.
DATA: lv_message(255).
DATA: pr_no TYPE bapiebanc-preq_no.
DATA: bnfpo TYPE bnfpo.
DATA: matnr TYPE matnr.
DATA: pp_file TYPE string.
PARAMETERS:p_file(128) .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
START-OF-SELECTION.
*&---------------------------------------------------------------------*
*&
Form GET_FILE
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM get_file .
*'',*.xls,*.XLS.'如果读入txt文件,在后边就需要用函数
* CALL FUNCTION 'WS_UPLOAD'
ENDFORM.
" GET_FILE
*&---------------------------------------------------------------------*
*&
Form GET_DATA
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM get_data .
* HEADER_LENGTH
= 0
* DAT_MODE
= ' '
* CODEPAGE
= ' '
* IGNORE_CERR
= ABAP_TRUE
* REPLACEMENT
= '#'
* CHECK_BOM
= '
'
* VIRUS_SCAN_PROFILE
=
* NO_AUTH_CHECK
= ' '
* IMPORTING
* FILELENGTH
=
* HEADER
=
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDFORM.
" GET_DATA
*&---------------------------------------------------------------------*
*&
Form CREATE_PR
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM create_pr .
* PR_ITEM-ACCTASSCAT
=
GT_DATA-KNTTP. "科目分配类别
* PR_ITEM-SHORT_TEXT
=
GT_DATA-TXZ01. "短文本
* PR_ITEM-MAT_GRP
= GT_DATA-MATKL.
"物料组
* EXPORTING
* SKIP_ITEMS_WITH_ERROR
=
* AUTOMATIC_SOURCE
=
'X'
* REQUISITION_LIMITS
=
* REQUISITION_CONTRACT_LIMITS
=
* REQUISITION_SERVICES
=
* REQUISITION_SRV_ACCASS_VALUES
=
* REQUISITION_SERVICES_TEXT
=
* REQUISITION_ADDRDELIVERY
=
* EXTENSIONIN
=
ENDFORM.
" CREATE_PR
*&---------------------------------------------------------------------*
*&
Form WRITE_OUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM write_out .
ENDFORM.
" WRITE_OUT
*以下为数据格式(行项目以回车键换行,列以TAB分隔):
*ZB 10 100009 10 EA 20100915 D005
*ZB 10 100008 10 EA 20100915 D005s
另外还有一个BAPI:BAPI_PR_CREATE,大致赋值如下
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.
http://blog.sina.com.cn/sapliumeng