Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

problem in creating sales order with BAPI_SALESDOCU_CREATEFROMDATA1.

Hi everybody

I am not able create a sales order with BAPI_SALESDOCU_CREATEFROMDATA1.i also did debugging.its not throwing up any errors in return table. return table is empty. but when i check the BAPI in se37 with same data its creating the sales order.

Here i am attaching my program.please kindly can anyone have a look and tell me whether i did anything wrong in the program.

thx in advance.

&----


*& Report YORDERCREATE

*&

&----


*&

*&

&----


REPORT YORDERCREATE.

data: v_vbeln like vbak-vbeln.

data: header like bapisdhead1.

data: headerx like bapisdhead1x.

data: item like bapisditem occurs 0 with header line.

data: itemx like bapisditemx occurs 0 with header line.

data: partner like bapipartnr occurs 0 with header line.

data: return like bapiret2 occurs 0 with header line.

data: it_schedules_inx like bapischdlx occurs 0 with header line.

data: it_schedules_in like bapischdl occurs 0 with header line.

types: begin of itab,

auart like vbak-auart,

vkorg like vbak-vkorg,

vtweg like vbak-vtweg,

spart like vbak-spart,

kunnr like kuagv-kunnr,

kunnr1 like kuwev-kunnr,

posnr like vbup-posnr,

matnr like mara-matnr,

Tquan type string,

end of itab.

data: it-out type table of itab with header line.

data: menge(10) type c.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\VA01.TXT'

  • FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = it-out.

loop at it-out.

header-doc_type = it-out-auart.

headerx-doc_type = 'X'.

header-sales_org = it-out-vkorg.

headerx-sales_org = 'X'.

header-distr_chan = it-out-vtweg.

headerx-distr_chan = 'X'.

header-division = it-out-spart.

headerx-division = 'x'.

headerx-updateflag = 'I'.

*********************************************************

*partner data

*********************************************************

partner-partn_role = 'SP'.

partner-partn_numb = it-out-kunnr.

append partner.

partner-partn_role = 'SH'.

partner-partn_numb = it-out-kunnr1.

append partner.

*********************************************************

*item data

*********************************************************

itemx-updateflag = 'I'.

item-itm_number = it-out-posnr.

itemx-itm_number = 'X'.

item-material = it-out-matnr.

itemx-material = 'X'.

item-target_qty = it-out-tquan..

itemx-target_qty = 'X'.

APPEND item.

APPEND itemx.

.

*loop at it-out.

*write:/ it-out-auart,it-out-vkorg.

*endloop.

*

***********************************************************

CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'

EXPORTING

SALESDOCUMENT = v_vbeln

SALES_HEADER_IN = header

SALES_HEADER_INX = headerx

  • SENDER = SENDER

  • BINARY_RELATIONSHIPTYPE = 'VORL'

  • INT_NUMBER_ASSIGNMENT = ' '

IMPORTING

SALESDOCUMENT_EX = v_vbeln

TABLES

RETURN = return

SALES_ITEMS_IN = item

SALES_ITEMS_INX = itemx

SALES_PARTNERS = partner.

  • SALES_SCHEDULES_IN = SALES_SCHEDULES_IN

  • SALES_SCHEDULES_INX = SALES_SCHEDULES_INX

  • SALES_CONDITIONS_IN = SALES_CONDITIONS_IN

  • SALES_CFGS_REF = SALES_CFGS_REF

  • SALES_CFGS_INST = SALES_CFGS_INST

  • SALES_CFGS_PART_OF = SALES_CFGS_PART_OF

  • SALES_CFGS_VALUE = SALES_CFGS_VALUE

  • SALES_CFGS_BLOB = SALES_CFGS_BLOB

  • SALES_CCARD = SALES_CCARD

  • KEY_TABLE = KEY_TABLE

endloop.

loop at return where type = 'E' or type = 'A'.

exit.

endloop.

if sy-subrc = 0.

write:/ 'error in creating document'.

else.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

  • IMPORTING

  • RETURN = RETURN

.

commit work and wait.

write:/ 'document',v_vbeln,'created'.

endif.

.

Not what you were looking for? View more on this topic or Ask a question