如何處理用代碼創建SD Sales order時遇到的錯誤消息KI 180
阿新 • • 發佈:2018-10-30
transacti ret sdh must UNC lin nsa end mage
錯誤消息KI 180:You must enter a company code for transaction Create sales document
代碼:
REPORT zcreate_so. DATA: ls_header TYPE bapisdhd1, ls_headerx TYPE bapisdhd1x, lt_bapiret2 LIKE bapiret2 OCCURS 0 WITH HEADER LINE. ls_header-serv_date = ‘20200101‘. ls_header-doc_type = ‘TA‘. ls_headerx-doc_type = ‘X‘. ls_headerx-updateflag = ‘U‘. CALL FUNCTION ‘SD_SALESDOCUMENT_CREATE‘ EXPORTING sales_header_in = ls_header sales_header_inx = ls_headerx int_number_assignment = ‘X‘ TABLES return = lt_bapiret2. LOOP AT lt_bapiret2 ASSIGNING FIELD-SYMBOL(<return>) WHERE type = ‘E‘. WRITE:/ ‘Error:‘, <return>-message COLOR COL_NEGATIVE. RETURN. ENDLOOP.
通過調試,發現錯誤消息是在下面的函數裏拋出的:
原因:事務碼VA03,打開一個已有的Sales Order,Goto->Header->Billing, 查看Company code:
得知Company code存儲於表VBAK的字段BUKRS裏。
解決方案:上述代碼加上下面兩行,問題即解決:
ls_header-comp_cde_b = ‘0001‘.
ls_headerx-comp_cde_b = ‘X‘.
要獲取更多Jerry的原創文章,請關註公眾號"汪子熙":
如何處理用代碼創建SD Sales order時遇到的錯誤消息KI 180