on 09-08-2008 7:15 AM
Hi,
When i am trying to create sales order using BAPI_SALESORDER_CREATEFROMDAT2 . i am facing the problem to upload quantity field in ITEM table. always it is uploading 0 quantity in each line item.
any one tell me how to pass quantity value in ITEM table.
kathir.
I think you might be passing only the oder quantity (order_items_in-target_qty) and not the schedule line quantity (order_schedules_in-req_qty). Only if both are passed to the sale order line item will be created with quantity.
Regards,
GSL.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thank u
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Paste the code so that we can analyze.
Regards,
GSL.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi GSL,
Please check the code and give me the good solution.
kathir.
REPORT ZBKSALES_ORDER_V2 .
types: begin of t_main ,
line type c,
auart type auart,
vkorg type vkorg,
vtweg type vtweg,
spart type spart,
kunnr type kunnr,
matnr type matnr,
menge type DZMENG,
augru type augru,
bstnk type BSTNK,
KSCHA type KSCHA,
rate type BAPIKBETR1,
tdid type tdid,
text type TDLINE,
parvw type PARVW,
end of t_main.
types: begin of t_header ,
line type c,
auart type auart,
vkorg type vkorg,
vtweg type vtweg,
spart type spart,
kunnr type kunnr,
augru type augru,
bstnk type BSTNK,
tdid type tdid,
text type TDLINE,
parvw type PARVW,
end of t_header.
data: i_main type table of t_main,
w_main type t_main,
i_header type table of t_header,
w_header type t_header.
data: c_tabix type sy-tabix,
pono type bstnk,
msg(112) type c,
count type i value 0,
unit type DZIEME value 'EA ',
number type char2 value '00'.
DATA: i_table type table of ALSMEX_TABLINE,
w_table type alsmex_tabline,
docu type BAPIVBELN-VBELN.
Data: head type BAPISDHD1,
item type BAPISDITM occurs 0 with header line ,
itemx type BAPISDITMX occurs 0 with header line ,
return type BAPIRET2 occurs 0 with header line,
re type BAPIRET2 occurs 0 with header line,
part type BAPIPARNR occurs 0 with header line,
text type BAPISDTEXT occurs 0 with header line,
sche type BAPISCHDL occurs 0 with header line,
schex type BAPISCHDLX occurs 0 with header line,
cond type BAPICOND occurs 0 with header line.
selection-screen: begin of block b1 with frame title text-001.
parameters: p_file type RLGRAP-FILENAME.
parameters: r1 radiobutton group mod default 'X',
r2 radiobutton group mod .
selection-screen: end of block b1.
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_file.
.
start-of-selection.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = 1
I_BEGIN_ROW = 4
I_END_COL = 14
I_END_ROW = 10
TABLES
INTERN = i_table
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
sort i_table by row col.
loop at i_table into w_table.
case w_table-col.
when '0001'.
w_main-line = w_table-value.
when '0002'.
w_main-auart = w_table-value.
when '0003'.
w_main-vkorg = w_table-value.
when '0004'.
w_main-vtweg = w_table-value.
when '0005'.
w_main-spart = w_table-value.
when '0006'.
w_main-kunnr = w_table-value.
when '0007'.
w_main-matnr = w_table-value.
when '0008'.
w_main-menge = w_table-value.
when '0009'.
w_main-augru = w_table-value.
when '0010'.
w_main-bstnk = w_table-value.
when '0011'.
w_main-kscha = w_table-value.
when '0012'.
w_main-rate = w_table-value.
when '0013'.
w_main-tdid = w_table-value.
when '0014'.
w_main-text = w_table-value.
endcase.
at end of row.
append w_main to i_main.
clear w_main.
endat.
endloop.
sort i_main by bstnk.
loop at i_main into w_main.
c_tabix = sy-tabix.
at new bstnk.
if w_main-line = '0'.
w_header-line = w_main-line.
w_header-auart = w_main-auart .
w_header-vkorg = w_main-vkorg .
w_header-vtweg = w_main-vtweg .
w_header-spart = w_main-spart .
w_header-kunnr = w_main-kunnr .
w_header-parvw = w_main-parvw .
w_header-bstnk = w_main-bstnk.
w_header-augru = w_main-augru.
w_header-tdid = w_main-tdid.
w_header-text = w_main-text.
pono = w_main-bstnk.
append W_header to i_header.
clear w_header.
else.
w_main-bstnk = pono.
modify i_main from w_main index c_tabix transporting bstnk.
endif.
endloop.
loop at i_header into w_header.
clear head.
number = '00'.
refresh: part,item,cond,sche, itemx,schex.
head-DOC_TYPE = w_header-auart.
head-SALES_ORG = w_header-vkorg.
head-DISTR_CHAN = w_header-vtweg.
head-DIVISION = w_header-spart.
head-PURCH_NO_C = w_header-bstnk.
part-PARTN_ROLE = 'SP' .
part-PARTN_NUMB = w_header-kunnr.
text-TEXT_ID = w_header-tdid.
text-LANGU = 'EN'.
text-TEXT_LINE = w_header-text.
append part.
append text.
loop at i_main into w_main where bstnk = w_header-bstnk AND
LINE = '1'.
number = number + 10.
item-itm_number = number.
item-MATERIAL = w_main-matnr.
ITEM-TARGET_QTY = W_MAIN-MENGE.
ITEM-TARGET_QU = unit.
itemx-itm_number = number.
itemx-updateflag = 'I'.
itemx-MATERIAL = 'X'.
ITEMx-TARGET_QTY = 'X' .
ITEMx-TARGET_QU = 'X'.
cond-ITM_NUMBER = number.
cond-COND_TYPE = w_main-kscha.
cond-COND_VALUE = w_main-rate.
sche-itm_number = number.
sche-req_qty = w_main-menge.
sche-req_date = sy-datum.
sche-sched_line = '0001'.
schex-itm_number = number.
schex-req_qty = 'X'.
schex-req_date = 'X'.
schex-sched_line = '0001'.
append item.
append itemx.
append cond.
append sche.
append schex.
endloop.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN =
ORDER_HEADER_IN = head
ORDER_HEADER_INX =
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
TESTRUN = r1
CONVERT = 'X'
IMPORTING
SALESDOCUMENT = docu
TABLES
RETURN = return
ORDER_ITEMS_IN = item
ORDER_ITEMS_INX = itemx
ORDER_PARTNERS = part
ORDER_SCHEDULES_IN =
ORDER_SCHEDULES_INX =
ORDER_CONDITIONS_IN = cond
ORDER_CONDITIONS_INX =
ORDER_CFGS_REF =
ORDER_CFGS_INST =
ORDER_CFGS_PART_OF =
ORDER_CFGS_VALUE =
ORDER_CFGS_BLOB =
ORDER_CFGS_VK =
ORDER_CFGS_REFINST =
ORDER_CCARD =
ORDER_TEXT = text
ORDER_KEYS =
EXTENSIONIN =
PARTNERADDRESSES =
.
if r1 = 'X'.
write:/ '----
'.
write:/ 'TEST RUN EXECUTION'.
write:/ '----
'.
loop at return .
msg = return-message.
condense msg.
write:/ return-type.
write: msg.
endloop.
else.
loop at return where type = 'E' or type = 'A'.
exit.
endloop.
if sy-subrc = 0.
write: 'Error in Creating Sales Document'.
else.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = re
.
if count = 0.
write:/ '___________________________' .
write:/ 'List of Sales order Created '.
write:/ '___________________________'.
skip.
endif.
write:/ ' sales Document',docu,'Created'.
count = 1.
endif.
endif.
Code seems to be ok. The diffence in yours and mine is:
1) We are not using order_items_inx and order_schedules_inx. Both are commented in call bapi FM.
2) We are passing plant (field "plant") also to order_items_in
3) We are passing sale UoM to field sales_unit. You are passing to field target_qu.
4) We are passing only itm_number, req_qty and req_date to order_schedules_in. Apart from these three you are passing sched_line also.
Try to change some of these and check.
Regards,
GSL.
Hello,
have you checked ORDER_ITEMS_INX-TARGET_QTY (and all the ORDER_ITEMS_INX fields corresponding to a value in ORDER_ITEMS_IN) are filled as 'X'
Regards,
Jim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.