bapi 'BAPI_DOCUMENT_CREATE2'可以模拟前台的tcode CV01N创建文档。
CV01N 前台操作,简单介绍如下:
输入document,type,part 和version相关内容,回车进入下一屏幕,
输入描述,设置status和authorization group,然后点击保存即可。
下面是模拟上述操作的例子代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
REPORT ztest_cv01n. DATA: lwa_documentdata TYPE bapi_doc_draw2. data: lwa_return TYPE bapiret2. DATA: lit_cl_allocs TYPE tt_dms_bapi_class_allocation, lwa_cl_allocs LIKE LINE OF lit_cl_allocs. DATA:l_documenttype LIKE bapi_doc_aux-doctype, "document type l_documentnumber LIKE bapi_doc_aux-docnumber, "document no. l_documentpart LIKE bapi_doc_aux-docpart, "document part l_documentversion LIKE bapi_doc_aux-docversion. "version DATA: lit_descriptions TYPE TABLE OF bapi_doc_drat, "Description lwa_descriptions TYPE bapi_doc_drat. "Description lwa_documentdata-documenttype = 'TS1'. lwa_documentdata-documentnumber = '596096009'. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = lwa_documentdata-documentnumber IMPORTING output = lwa_documentdata-documentnumber. lwa_documentdata-documentversion = '00'. lwa_documentdata-documentpart = '000'. lwa_documentdata-statusintern = 'SP'. "Lock lwa_documentdata-authoritygroup = 'SHW'. "authority group *lwa_cl_allocs-classtype = '017'. *lwa_cl_allocs-classname = 'SCK_DMS'. *APPEND lwa_cl_allocs TO lit_cl_allocs. CLEAR lwa_descriptions. CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = sy-langu IMPORTING output = lwa_descriptions-language_iso. lwa_descriptions-description = 'Stone test'. APPEND lwa_descriptions TO lit_descriptions. CALL FUNCTION 'BAPI_DOCUMENT_CREATE2' EXPORTING documentdata = lwa_documentdata IMPORTING documenttype = l_documenttype documentnumber = l_documentnumber documentpart = l_documentpart documentversion = l_documentversion return = lwa_return TABLES * characteristicvalues = lt_char_vals classallocations = lit_cl_allocs documentdescriptions = lit_descriptions * objectlinks = lt_obj_links * DOCUMENTSTRUCTURE = * DOCUMENTFILES = * LONGTEXTS = * COMPONENTS = . IF lwa_return-type = 'S' OR lwa_return-type = 'W' OR lwa_return-type IS INITIAL. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK' * IMPORTING * RETURN = . |
以上。
发表评论