How to deal with the error message Ki 180 encountered when creating an SD sales order using code

Source: Internet
Author: User

Error message Ki 180: You must enter a company code for transaction create sales document

Code:

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.

After debugging, it is found that the error message is thrown in the following function:

Cause: the transaction code is va03. Open an existing sales order, Goto-> header-> billing, and view the company code:

The company code is stored in the bukrs field of the vbak table.

Solution: Add the following two lines to the above Code to solve the problem:

ls_header-comp_cde_b = ‘0001‘.ls_headerx-comp_cde_b = ‘X‘.

For more original Jerry articles, follow the Public Account "Wang zixi ":

How to deal with the error message Ki 180 encountered when creating an SD sales order using code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.