CMIR data not copied while creating sales order from BAPI
hi all,
we are using BAPI to crate sales order.
but when we create SO manually, few fields at item level are derived automatically from CMIR...
Can we achieve same behavior through bapi also...
regards,
taranam
Hi Suraj,
So, You mean we need to derive COPA derivations for Copy by reference of a Sales Order,
If so could you please let me know how to do it.
Regards,
sg
Similar Messages
-
Hello,
I am getting this Error message"error determining posting period(infostructure S008,Variant Z2,RC3)" while creating Sales order from Inbound Idocs in the IDOC,which is affecting sales order creation.
While viewing this Info structure S008, I could see no records have been maintained. Wanted to know the reasons behind this Hard error?
Is it something related to Date Field used in the Update Rules for this Infostructure which is causing this posting period error?
Appreciate your inputs on this.
Thanks and Regards
Mohammed RoshanThank you Jelena,I checked the Ship. Delivery dates in the IDOC which are for Current Fiscal Year- 20140703 and 20140711,Could there be any other reason for this error?
Could it be an issue with e Update rule in this Infostructire S008
Secondly when we try change the update rule thru MC25 for this Infostructure S008,It gives a message"
"Maintenance of SAP standard updates not allowed"
Kindly advice
Thanks and Regards
Mohammed Roshan -
Problem while creating sales order using BAPI
Hi all,
i am creating a sales order from the purchase order data.
when my client will send a PO in EDI format, my 3rd party edi tool will convert that edi formatted PO to text format. then i will upload that text formatted PO to my program then i will create a SO from those uploaded PO data using BAPI BAPI_SALESORDER_CREATEFROMDAT2.
but,no sales order is being created.& also i am not getting any return message.by debugging also, i am not getting the error.plz suggest where i am doing mistake.below is the coding.
DATA:
gfilename LIKE rlgrap-filename.
*--Internal tables
DATA: BEGIN OF i_item OCCURS 50. "Create Material Document Item
INCLUDE STRUCTURE BAPISDITM .
DATA: END OF i_item .
DATA: BEGIN OF i_partner OCCURS 20. "Return parameter
INCLUDE STRUCTURE BAPIPARNR.
DATA: END OF i_partner.
DATA: BEGIN OF i_schedule OCCURS 20. "Return parameter
INCLUDE STRUCTURE BAPISCHDL .
DATA: END OF i_schedule.
DATA: BEGIN OF i_cond OCCURS 20. "Return parameter
INCLUDE STRUCTURE BAPICOND .
DATA: END OF i_cond.
DATA: BEGIN OF i_part OCCURS 0, " Internal table for split data
part(20),
END OF i_part.
DATA: BEGIN OF i_return OCCURS 20. "Return parameter
INCLUDE STRUCTURE bapiret2.
DATA: END OF i_return.
*-- Work areas
DATA: BEGIN OF wa_header . "sales Document Header Data
INCLUDE STRUCTURE BAPISDHD1.
DATA: END OF wa_header .
*DATA: BEGIN OF wa_return . "Output Structure
INCLUDE STRUCTURE BAPIRET2.
*DATA: END OF wa_return .
DATA: begin of sorder.
INCLUDE STRUCTURE BAPIVBELN.
DATA: end of sorder.
data:begin of t_upload,
ebeln(10), "PO no(seagate)
aedat like sy-datum , "PO date
bsart(4) , "PO type
vdatu like sy-datum , "requested delivery date
kunnr(10) , "customer no-sold-to-party
kunak like vbak-kunnr, "bill-to-party
name1_s(20), "name1 of sold-to-party
name2_s(15), "name2 of sold-to-party
land1_s(3), "country
ort01_s(10), "city
regio_s(3), "region(state/province)
pstlz_s(10), "postal code
adrnr_s(10), "address
bstkd_e(10), "end customer purchase order
posex(6), "end customer PO line no(item no)
kdmat(18), "end customer material no(part no)
kunag(10), "ship-to-party
name1_c(20), "name1 of ship-to-party
name2_c(15), "name2 of ship-to-party
land1_c(3), "country
ort01_c(10), "city
regio_c(3), "region(state/province)
pstlz_c(10), "postal code
adrnr_c(10), "address
posnr(6), "item no(seagate PO line no)
pstyv(4), "item category
matnr(18), "material no(seagate 9 digit part no)
zmeng(13), "Target quantity in sales unit
vrkme like vbap-vrkme, "sales unit
meins(3), "UOM
posnr_tot like vbap-posnr,"Total no. of line items
werks(4), "plant
vstel like vbap-vstel, "shipping point
empst(10), "receiving point
shtyp(4), "shipment type
route(6), "route
vsbed(2), "shipping conds
rkfkf like vbap-rkfkf, "method of billing for co/ppc orders
zterm(4), "terms of payment key
inco1(3), "F.O.B inco term1
inco2(3), "F.O.B inco term2
end of t_upload.
Data: wa_upload like t_upload,
i_upload like standard table of t_upload.
Data:v_kunnr like kna1-kunnr,
v_posnr like vbap-posnr,
v_matnr like vbap-matnr,
v_zmeng like vbap-zmeng,
v_kunag like kna1-kunnr.
*---Constants
CONSTANTS: c_comma TYPE c VALUE ',', " For splitting data at commas
c_01(2) TYPE c VALUE '01', " For movement code in Bapi
c_b TYPE c VALUE 'B', " For mvt. Indicator in Bapi
c_creat(5) TYPE c VALUE 'CREAT', " For button text
c_clear(5) TYPE c VALUE 'CLEAR', " For clear button
c_mvmt(4) TYPE c VALUE 'MVMT',
c_ok(2) TYPE c VALUE 'OK',
c_error(5) TYPE c VALUE 'Error'.
*--SELECTION SCREEN DESIGN--
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.
PARAMETERS:
p_auart LIKE vbak-auart, " order type
p_vkorg LIKE vbak-vkorg, " sales org
p_vtweg LIKE vbak-vtweg, " dist channel
p_spart LIKE vbak-spart, " division
p_vkgrp LIKE vbak-vkgrp, " sales group
p_vkbur LIKE vbak-vkbur, "sales office
p_file(256) default 'c:/saleorder.txt'. "File name
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN PUSHBUTTON 15(10) v_create USER-COMMAND creat.
SELECTION-SCREEN PUSHBUTTON 40(10) v_clear USER-COMMAND clear.
INITIALIZATION -
INITIALIZATION.
v_create = c_creat .
v_clear = c_clear.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM selectfile USING p_file.
*--AT SELECTION_SCREEN--
AT SELECTION-SCREEN .
IF sy-ucomm = c_clear.
PERFORM f_clear.
ELSE.
IF sy-ucomm <> c_mvmt.
**--- Validating the input data.
PERFORM f_check_inputs.
ELSEif sy-ucomm = c_creat.
*--- Validating the input data.
PERFORM f_check_inputs.
*-- Uploading the PO data.
PERFORM f_PO_upload.
*---checking the PO data
PERFORM f_check_upload_data.
*---create sales order from PO data
PERFORM f_Sales_order_create.
ENDIF.
FORM f_PO_upload.
gfilename = p_file.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = gfilename
filetype = 'DAT'
TABLES
data_tab = i_upload
EXCEPTIONS
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
OTHERS = 10.
IF sy-subrc <> 0.
MESSAGE i398(00) WITH '(WS_UPLOAD)'
' Errors occured with exception '
sy-subrc.
ENDIF.
ENDFORM. " f_PO_upload
*& Form selectfile
text
-->P_P_FILE text
FORM selectfile CHANGING value(filename) TYPE c.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = gfilename
def_path = 'C:\'
mask = ',*.txt.'
mode = 'O'
title = 'Select File Name'
IMPORTING
filename = filename
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
ENDFORM. " selectfile
FORM f_Sales_order_create.
PERFORM f_fill_header.
PERFORM f_fill_partner.
PERFORM f_fill_item.
PERFORM f_call_BAPI.
ENDFORM. " f_Sales_order_create
*& Form f_fill_header
text
--> p1 text
<-- p2 text
FORM f_fill_header.
move p_auart to wa_header-doc_type.
move p_vkorg to wa_header-sales_org.
move p_vtweg to wa_header-distr_chan.
move p_spart to wa_header-division.
move p_vkgrp to wa_header-sales_grp.
move p_vkbur to wa_header-sales_off.
Read table i_upload into wa_upload index 1.
move wa_upload-ebeln to wa_header-purch_no_c.
move wa_upload-aedat to wa_header-purch_date.
move wa_upload-bsart to wa_header-po_method.
move wa_upload-vdatu to wa_header-req_date_h.
move wa_upload-bstkd_e to wa_header-purch_no_s.
*move wa_upload-route to wa_header-route.
move wa_upload-vsbed to wa_header-ship_cond.
move wa_upload-empst to wa_header-rec_point.
move wa_upload-shtyp to wa_header-ship_type.
move wa_upload-zterm to wa_header-pmnttrms.
move wa_upload-inco1 to wa_header-incoterms1.
move wa_upload-inco2 to wa_header-incoterms2.
ENDFORM. " f_fill_header
*& Form f_fill_partner
text
--> p1 text
<-- p2 text
FORM f_fill_partner.
if not wa_upload-kunnr is initial.
select single kunnr from kna1 into v_kunnr
where kunnr = wa_upload-kunnr.
if sy-subrc <> 0.
Message E014 with 'customer does not exist'.
else.
move 'AG' to i_partner-partn_role.
move wa_upload-kunnr to i_partner-partn_numb.
move wa_upload-land1_s to i_partner-country.
move wa_upload-name1_s to i_partner-name.
move wa_upload-name2_s to i_partner-name_2.
move wa_upload-ort01_s to i_partner-city.
move wa_upload-regio_s to i_partner-region.
move wa_upload-pstlz_s to i_partner-postl_code.
move wa_upload-adrnr_s to i_partner-address.
append i_partner.
endif.
endif.
if not wa_upload-kunag is initial.
select single kunnr from kna1 into v_kunag
where kunnr = wa_upload-kunag.
if sy-subrc <> 0.
Message E015 with 'end customer does not exist'.
else.
move 'WE' to i_partner-partn_role.
move wa_upload-kunag to i_partner-partn_numb.
move wa_upload-land1_c to i_partner-country.
move wa_upload-name1_c to i_partner-name.
move wa_upload-name2_c to i_partner-name_2.
move wa_upload-ort01_c to i_partner-city.
move wa_upload-regio_c to i_partner-region.
move wa_upload-pstlz_c to i_partner-postl_code.
move wa_upload-adrnr_c to i_partner-address.
append i_partner.
endif.
endif.
ENDFORM. " f_fill_partner
*& Form f_fill_item
text
--> p1 text
<-- p2 text
FORM f_fill_item.
loop at i_upload into wa_upload.
if not wa_upload-matnr is initial.
select single maramatnr msegmenge into (v_matnr, v_zmeng) from
mara inner join mseg on maramatnr = msegmatnr
where mara~matnr = wa_upload-matnr.
if sy-subrc <> 0.
Message E016 with 'material no does not exist'.
elseif v_zmeng LT wa_upload-zmeng.
Message E017 with 'order quantity is greater than the quantity present'.
endif.
endif.
move wa_upload-posnr to i_item-itm_number.
move wa_upload-pstyv to i_item-item_categ.
move wa_upload-matnr to i_item-material.
move wa_upload-zmeng to i_item-target_qty.
move wa_upload-meins to i_item-target_qu.
move wa_upload-werks to i_item-plant.
*move wa_upload-meins to wa_vbap-meins.
*move wa_upload-posnr_tot to wa_vbap-posnr_tot.
move wa_upload-posex to i_item-po_itm_no.
move wa_upload-kdmat to i_item-cust_mat22.
move wa_upload-inco1 to i_item-incoterms1.
move wa_upload-inco2 to i_item-incoterms2.
move wa_upload-zterm to i_item-pmnttrms.
move wa_upload-empst to i_item-rec_point.
move wa_upload-shtyp to i_item-ship_type.
move wa_upload-route to i_item-route.
append i_item.
PERFORM f_fill_schedule_line.
PERFORM f_fill_conditions.
ENDLOOP.
ENDFORM. " f_fill_item
*& Form f_fill_schedule_line
text
--> p1 text
<-- p2 text
FORM f_fill_schedule_line.
move wa_upload-matnr to i_schedule-itm_number.
move sy-datum to i_schedule-req_date.
move wa_upload-zmeng to i_schedule-req_qty.
append i_schedule.
ENDFORM. " f_fill_schedule_line
*& Form f_fill_conditions
text
--> p1 text
<-- p2 text
FORM f_fill_conditions.
move wa_upload-matnr to i_cond-itm_number.
move sy-datum to i_cond-conpricdat.
append i_cond.
ENDFORM. " f_fill_conditions
*& Form f_clear
text
--> p1 text
<-- p2 text
FORM f_clear.
clear:p_auart,
p_vkorg,
p_vtweg,
p_spart,
p_vkgrp,
p_vkbur.
ENDFORM. " f_clear
*& Form f_call_BAPI
text
--> p1 text
<-- p2 text
FORM f_call_BAPI.
clear:i_item,i_partner,i_schedule.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN =
ORDER_HEADER_IN = wa_header
ORDER_HEADER_INX =
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
TESTRUN =
CONVERT = ' '
IMPORTING
SALESDOCUMENT = sorder
TABLES
RETURN =
ORDER_ITEMS_IN = i_item
ORDER_ITEMS_INX =
ORDER_PARTNERS = i_partner
ORDER_SCHEDULES_IN = i_schedule
ORDER_SCHEDULES_INX =
ORDER_CONDITIONS_IN = i_cond.
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 =
ORDER_KEYS =
EXTENSIONIN =
PARTNERADDRESSES =
if not ( sorder-vbeln is initial ).
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
write: /'Order number:', sorder.
else.
loop at i_return.
write: / i_return-id, i_return-number, i_return-message(80).
endloop.
*write: /'Error'.
endif.
*loop at i_return.
*write: / i_return-id, i_return-number, i_return-message(80).
*endloop.
ENDFORM. " f_call_BAPIHI
Pricing will be carried basing on the pricing
procedure.
Case1: Prices will be carried out automatically if
necessary condition records are maintained for the
condition type.
For this you can go to Sales Order-> Item Conditions
In the screen you can click on command button Analysis,
which gives you the list of condition types associated
to the pricing procedure. By clicking on the condition
type you can know the action that has taken place.
Case2: Manually forcing prices for Items.
To do this, you have to populate ORDER_CONDITIONS_IN &
ORDER_CONDITIONS_INX. Also note to identify the item
numbers, you manually pass the item number for each item
in the sales order, use the same item number for
populating conditions.
Parameters required:
ORDER_CONDITIONS_IN:
ITM_NUMBER, COND_TYPE, COND_VALUE, CURRENCY
ORDER_CONDITIONS_INX:
ITM_NUMBER, COND_TYPE, UPDATEFLAG, COND_VALUE,CURRENCY.
Hope the above info helps you. Do revert back if you
need more info.
Kind Regards
Eswar -
Setting user specific contract data while creating sales order using BAPI
Hi all,
I am creating sales order using BAPI - BAPI_SALESORDER_CREATEFROMDAT2.
Now my problem is that there is no structure for contract data (i.e. VEDA), system automatically set contract data using customization values.
I am doing some validations on cotract data in MV45AFZZ which fails, because these validations are performed on standard values, user specific values r not set.
How to handle this issue, your small clue may help a lot.
Regards,
S@meerHI
Pricing will be carried basing on the pricing
procedure.
Case1: Prices will be carried out automatically if
necessary condition records are maintained for the
condition type.
For this you can go to Sales Order-> Item Conditions
In the screen you can click on command button Analysis,
which gives you the list of condition types associated
to the pricing procedure. By clicking on the condition
type you can know the action that has taken place.
Case2: Manually forcing prices for Items.
To do this, you have to populate ORDER_CONDITIONS_IN &
ORDER_CONDITIONS_INX. Also note to identify the item
numbers, you manually pass the item number for each item
in the sales order, use the same item number for
populating conditions.
Parameters required:
ORDER_CONDITIONS_IN:
ITM_NUMBER, COND_TYPE, COND_VALUE, CURRENCY
ORDER_CONDITIONS_INX:
ITM_NUMBER, COND_TYPE, UPDATEFLAG, COND_VALUE,CURRENCY.
Hope the above info helps you. Do revert back if you
need more info.
Kind Regards
Eswar -
Not able to create sales order using BAPI - BAPI_SALESORDER_CREATEFROMDAT2
Hi Experts,
I am not able to create sales order . I am using BAPI - BAPI_SALESORDER_CREATEFROMDAT2
to create sales order .I am passing external sales order number to the parameter
SALESDOCUMENTIN.
I am getting following error.
"524 |Only quantity 1 EA is allowed (Item 00001"
Here EA is UOM(Unit of measurement).
Below is the sample program through which i am trying to create the sales order.
*& Report ZSDC_SALES_TEST
report zsdc_sales_test.
*DATA: wa_bapi_header TYPE bapisdhd1.
Include Name - ZSDC_SALES_ORD_UPLOAD_TOP
Program Name - ZSDC_SALES_ORD_UPLOAD_1393
Program Title - Include for Data Declaration and selection screen
Created by - Lalitha W
Created on - 18-Nov-2008
Object ID - SD_C_1393_SALES_ORDER_UPLOAD
Request Id - SD3K905579
Description - This is a common INCLUDE for data declarations and
*selection screen details.
HISTORY
Date |Developer |Req by | Description |Reference ID
| | | |
| | | |
TYPE-POOLS
*TYPE-POOLS: truxs, abap, slis.
TABLES
*TABLES: t100.
TYPES
types:begin of ty_header,
auart(4) type c, " Sales Order Type
vkorg(4) type c, " Sales Organization
vtweg(2) type c, " Distrubution Channel
spart(2) type c, " Division
kunnr_1(10) type c, " Sold to Party
kunnr_2(10) type c, " Ship to Party
augru(3) type c, " Order Reason
bstkd(35) type c, " PO Number
bstdk(10) type c, " PO Date
ketdat(10) type c, " Required Delivery Date
zterm(4) type c, " Payment Terms
inco1(3) type c, " Inco Terms -1
inco2(28) type c, " Inco Terms -2
prsdt(10) type c, " pricing date
waerk(5) type c, " Document Currency
vkbur(4) type c, " Sales Office
vkgrp(3) type c, " Sales group
pltyp(2) type c, " Price List type
kdgrp(2) type c, " Customer Group
bstkd_e(35) type c, " Ship-to-party PO number
submi(10) type c, " Collective Number
bname(35) type c, " Name
ihrez(12) type c, " Your Reference
kschl_1(4) type c, " Condition Type
kbetr_1(11) type c, " Amount
kschl_2(4) type c, " Condition Type
kbetr_2(11) type c, " Amount
kschl_3(4) type c, " Condition Type
kbetr_3(11) type c, " Amount
partner_1(25) TYPE c, " Partner(Bill To Party Number)
partner_2(25) TYPE c, " Partner(Payer Number)
partner_3(25) TYPE c, " Partner(Sales Responsible Number)
partner_4(25) TYPE c, " Partner(Order admin)
partner_5(25) TYPE c, " Partner(Contact person)
partner_1(10) type c, " Partner(Bill To Party Number)
partner_2(10) type c, " Partner(Payer Number)
partner_3(10) type c, " Partner(Sales Responsible Number)
partner_4(10) type c, " Partner(Order admin)
partner_5(10) type c, " Partner(Contact person)
tdspras_1(2) type c,
text_1(500) type c, " Text Before Items Z012
tdspras_2(2) type c,
text_2(500) type c, " Invocie Up Z034
tdspras_3(2) type c,
text_3(500) type c, " Invocie Down Z035
tdspras_4(2) type c,
text_4(500) type c, " Customer Reference Continue Z018
tdspras_5(2) type c,
text_5(500) type c, " Dispatch Marks/ Order Z019
tdspras_6(2) type c,
text_6(500) type c, " Ordered By Z003
tdspras_7(2) type c,
text_7(500) type c, " Sales Parameters Z002
kvgr1(3) type c, " Industry
kvgr2(3) type c, " customer BU
end of ty_header.
types: begin of ty_item,
bstkd(35) type c, " PO Number
bstdk(10) type c, " PO Date
bstkd_e(35) type c, " Ship-to-party PO number
posnr(6) type c, " POSTION NUMBER
matnr(18) type c, " Material Number
kwmeng(18) type c, " Order Quantity
pstyv(4) type c, " Sales doc. item categ
kursk(18) type c, " EXCHANGE RATE****
ffprf(8) type c, " DIP PROFILE
werks(4) type c, " Delivering Plant
vstel(4) type c, " SHIPPING POINT
lgort(4) type c, " STORAGE LOCATION
route(6) type c, " Route
kurrf(18) type c, " EXCHANGE RATE-FI
ntgew(18) type c, " Net Weight
brgew(18) type c, " Gross Weight
gewei(3) type c, " Weight Unit
prctr(10) type c, " profit center
abgrs(6) type c, " RESULT ANALYSIS KEY
kalsm_k(4) type c, " COSTING SHEET
kschl_1(4) type c, " Condition Type
kbetr_1(11) type c, " Amount
kschl_2(4) type c, " Condition Type
kbetr_2(11) type c, " Amount
kschl_3(4) type c, " Condition Type
kbetr_3(11) type c, " Amount
text_1(500) type c, " material Text 0001
tdspras_1(1) type c,
text_2(500) type c, " Pr Text 9001
tdspras_2(1) type c,
end of ty_item.
types: begin of ty_schedule_line,
bstkd(35) type c, "PO number
bstdk(10) type c, "PO date
bstkd_e(35) type c, "Ship-to-party PO number
posnr(6) type c, "sales doc.Item
etdat(10) type c, "Schedule line date
wmeng(2) type c, "Order Quantity
end of ty_schedule_line.
types: begin of ty_err ,
auart(4) type c, " Sales Order Type
vkorg(4) type c, " Sales Organization
vtweg(2) type c, " Distrubution Channel
spart(2) type c, " Division
kunnr_1(10) type c, " Sold to Party
kunnr_2(10) type c, " Ship to Party
augru(3) type c, " Order Reason
bstkd(35) type c, " PO Number
bstdk(10) type c, " PO Date
ketdat(10) type c, " Required Delivery Date
zterm(4) type c, " Payment Terms
inco1(3) type c, " Inco Terms -1
inco2(28) type c, " Inco Terms -2
prsdt(10) type c, " pricing date
waerk(5) type c, " Document Currency
vkbur(2) type c, " Sales Office
vkgrp(3) type c, " Sales group
pltyp(2) type c, " Price List type
kdgrp(2) type c, " Customer Group
bstkd_e(35) type c, " Ship-to-party PO number
submi(10) type c, " Collective Number
bname(35) type c, " Name
ihrez(12) type c, " Your Reference
kschl_1(4) type c, " Condition Type
kbetr_1(11) type c, " Amount
kschl_2(4) type c, " Condition Type
kbetr_2(11) type c, " Amount
kschl_3(4) type c, " Condition Type
kbetr_3(11) type c, " Amount
partner_1(25) type c, " Partner(Bill To Party Number)
partner_2(25) type c, " Partner(Payer Number)
partner_3(25) type c, " Partner(Sales Responsible Number)
partner_4(25) type c, " Partner(Order admin)
partner_5(25) type c, " Partner(Contact person)
tdspras_1(2) type c,
text_1(500) type c, " Text Before Items Z012
tdspras_2(2) type c,
text_2(500) type c, " Invocie Up Z034
tdspras_3(2) type c,
text_3(500) type c, " Invocie Down Z035
tdspras_4(2) type c,
text_4(500) type c, " Customer Reference Continue Z018
tdspras_5(2) type c,
text_5(500) type c, " Dispatch Marks/ Order Z019
tdspras_6(2) type c,
text_6(500) type c, " Ordered By Z003
tdspras_7(2) type c,
text_7(500) type c, " Sales Parameters Z002
kvgr1(3) type c, " Industry
kvgr2(3) type c, " customer BU
message(600) type c,
end of ty_err.
types: begin of ty_t685a,
kschl type kschl,
krech type krech,
end of ty_t685a.
INTERNAL TABLES
***header
data: g_krech_1(4) type c, " Calculation type for condition
g_krech_2(4) type c, " Calculation type for condition
g_krech_3(4) type c. " Calculation type for condition
g_krech_4(4) TYPE c, " Calculation type for condition
g_krech_5(4) TYPE c, " Calculation type for condition
g_krech_6(4) TYPE c, " Calculation type for condition
g_krech_7(4) TYPE c, " Calculation type for condition
g_krech_8(4) TYPE c, " Calculation type for condition
g_krech_9(4) TYPE c, " Calculation type for condition
g_krech_10(4) TYPE c, " Calculation type for condition
g_krech_11(4) TYPE c, " Calculation type for condition
g_krech_12(4) TYPE c, " Calculation type for condition
g_krech_13(4) TYPE c, " Calculation type for condition
g_krech_14(4) TYPE c, " Calculation type for condition
g_krech_15(4) TYPE c, " Calculation type for condition
g_krech_16(4) TYPE c, " Calculation type for condition
g_krech_17(4) TYPE c, " Calculation type for condition
g_krech_18(4) TYPE c, " Calculation type for condition
g_krech_19(4) TYPE c, " Calculation type for condition
g_krech_20(4) TYPE c. " Calculation type for condition
Items
data: g_krech_item_1(4) type c, " Calculation type for condition
g_krech_item_2(4) type c, " Calculation type for condition
g_krech_item_3(4) type c. " Calculation type for condition
g_krech_item_4(4) TYPE c, " Calculation type for condition
g_krech_item_5(4) TYPE c, " Calculation type for condition
g_krech_item_6(4) TYPE c, " Calculation type for condition
g_krech_item_7(4) TYPE c, " Calculation type for condition
g_krech_item_8(4) TYPE c, " Calculation type for condition
g_krech_item_9(4) TYPE c, " Calculation type for condition
g_krech_item_10(4) TYPE c, " Calculation type for condition
g_krech_item_11(4) TYPE c, " Calculation type for condition
g_krech_item_12(4) TYPE c, " Calculation type for condition
g_krech_item_13(4) TYPE c, " Calculation type for condition
g_krech_item_14(4) TYPE c, " Calculation type for condition
g_krech_item_15(4) TYPE c, " Calculation type for condition
g_krech_item_16(4) TYPE c. " Calculation type for condition
data: it_t685a type standard table of ty_t685a.
data: wa_bapi_header type bapisdhd1,
wa_bapi_headerx TYPE bapisdhd1x,
it_bapi_item type table of bapisditm,
it_bapi_itemx TYPE TABLE OF bapisditmx,
it_bapi_cond type table of bapicond,
it_bapi_condx TYPE TABLE OF bapicondx,
it_bapi_partner type table of bapiparnr,
it_bapi_shdl type table of bapischdl,
it_bapi_shdlx TYPE TABLE OF bapischdlx,
it_bapi_order_text type TABLE OF BAPISDTEXT,
it_bapireturn type table of bapiret2.
data: wa_bapi_item like line of it_bapi_item,
wa_bapi_itemx LIKE LINE OF it_bapi_itemx,
wa_bapi_cond like line of it_bapi_cond,
wa_bapi_condx LIKE LINE OF it_bapi_condx,
wa_bapi_partner like line of it_bapi_partner,
wa_bapi_shdl like line of it_bapi_shdl,
wa_bapi_shdlx LIKE LINE OF it_bapi_shdlx,
wa_bapi_order_text like LINE OF it_bapi_order_text,
wa_bapireturn like line of it_bapireturn.
*DATA: zmode(1) VALUE 'N'.
data: it_header type standard table of ty_header.
*DATA: it_temp_header TYPE STANDARD TABLE OF ty_header.
data: it_item type standard table of ty_item.
*DATA: it_temp_item TYPE STANDARD TABLE OF ty_item.
data: it_err type standard table of ty_err.
data: it_fline1 type standard table of tline,
wa_fline1 type tline.
data: it_thead1 type thead.
data: it_fline2 type standard table of tline,
wa_fline2 type tline.
data: it_thead2 type thead.
data: it_fline3 type standard table of tline,
wa_fline3 type tline.
data: it_thead3 type thead.
data: it_fline4 type standard table of tline,
wa_fline4 type tline.
data: it_thead4 type thead.
data: it_fline5 type standard table of tline,
wa_fline5 type tline.
data: it_thead5 type thead.
data: wa_header like line of it_header,
wa_item like line of it_item,
wa_err type ty_err,
wa_bill LIKE LINE OF it_bill,
wa_bill1 LIKE LINE OF it_bill,
wa_iterr like line of it_err,
wa_t685a like line of it_t685a.
wa_bill_item TYPE ty_bill_item.
data: it_schedule_line type standard table of ty_schedule_line,
wa_schedule_line type ty_schedule_line.
data: sales_order_no type bapivbeln-vbeln.
data: ext_sales_order_no type bapivbeln-vbeln.
Variable to be used to separate the fields which are concatenated by a
runtime character
*DATA: g_tabchar(1) TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
*DATA: wa_truxs_t_text_data TYPE truxs_t_text_data.
*DATA: g_filename TYPE string,
g_path TYPE string,
g_fullpath TYPE string,
g_user_action TYPE i,
g_file_encoding TYPE abap_encoding.
*DATA : g_text(8192),
data : g_mstring1(100) type c,
g_mstring2(100) type c,
g_mstring3(100) type c,
g_mstring4(100) type c,
g_mstring5(100) type c.
data: g_count1 type ebelp,
g_str_count1(6) type c.
data: g_count type ebelp,
g_str_count(6) type c.
*DATA: f_subrc LIKE sy-subrc,
f_subrc1 LIKE sy-subrc,
f_error(500) TYPE c,
item1(27) TYPE c,
item2(27) TYPE c,
item3(27) TYPE c,
item4(27) TYPE c,
i TYPE ekpo-ebelp.
*DATA: g_billplan_header TYPE c,
g_billplan_item TYPE c.
data : g_external_so type vbak-vbeln. "SO
SELECTION-SCREEN
selection-screen begin of block frame1 with frame title text-001 .
parameters:p_file1 type rlgrap-filename, "OBLIGATORY, "Header data.
p_file2 type rlgrap-filename, "OBLIGATORY, "Item Data.
p_file3 type rlgrap-filename, "Schedule line.
p_file4 type rlgrap-filename ."OBLIGATORY. "Error file.
selection-screen end of block frame1.
start-of-selection.
wa_bapi_header-doc_type = 'Z0MX'. "order type
wa_bapi_header-sales_org = '0130'."sales org
wa_bapi_header-distr_chan = '13'. "distr channel
wa_bapi_header-division = '13'. "division
Old code from copied program
wa_bapi_header-purch_no_s = wa_header-kunnr_2. " Ship to party
New code as required in Finland project
We are using to Header ->Order Tab -> Ship to Party -> Purchase order no (BSTKD_E) to store Old legacy SO number
wa_bapi_header-purch_no_s = 'MX100443'. "External SO i.e Old legacey SO number
wa_bapi_header-ref_1_s = '0000666666'. "Sold to party
wa_bapi_header-ord_reason = wa_header-augru.
wa_bapi_header-purch_no_c = 'ddr1234'. " PO number
wa_bapi_header-purch_date = sy-datum. " PO date
wa_bapi_header-req_date_h = sy-datum. " Required Delivery Date
wa_bapi_header-pmnttrms = '01'. " Payment Terms
wa_bapi_header-incoterms1 = wa_header-inco1.
wa_bapi_header-incoterms2 = wa_header-inco2.
wa_bapi_header-price_date = wa_header-prsdt. " Pricing date
wa_bapi_header-currency = wa_header-waerk. " Document Currency
wa_bapi_header-sales_grp = wa_header-vkgrp. " Sales group
wa_bapi_header-price_list = wa_header-pltyp. " Price list type
wa_bapi_header-cust_group = wa_header-kdgrp. " Cust Group
wa_bapi_header-ship_type = wa_header-vsart. " Shipping Type
wa_bapi_header-purch_no_s = wa_header-bstkd_e. " Ship-to-party po number
wa_bapi_header-collect_no = wa_header-submi. " Collective No.
wa_bapi_header-name = wa_header-bname. " Name
wa_bapi_header-ref_1 = wa_header-ihrez. " Your Reference
wa_bapi_header-cust_grp1 = wa_header-kvgr1. " Industry
wa_bapi_header-cust_grp2 = wa_header-kvgr2. " Customer BU
*ENDFORM. " f_header
IF wa_header-partner_1 IS NOT INITIAL.
wa_bapi_partner-partn_role = 'AG'.
wa_bapi_partner-partn_numb = '0000666666'.
wa_bapi_partner-itm_number = '000000'.
append wa_bapi_partner to it_bapi_partner.
clear wa_bapi_partner.
ENDIF.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = wa_header-partner_2
importing
output = wa_header-partner_2.
IF wa_header-partner_2 IS NOT INITIAL.
wa_bapi_partner-partn_role = 'WE'.
wa_bapi_partner-partn_numb = '0000666666'.
wa_bapi_partner-itm_number = '000000'.
append wa_bapi_partner to it_bapi_partner.
clear wa_bapi_partner.
ENDIF.
perform f_item.
data : order_items_inx type table of bapisditmx with header line.
order_items_inx-material = 'X'. "
order_items_inx-target_qty = 'X'. "
order_items_inx-comp_quant = 'X'. "
order_items_inx-trgqty_den = 'X'.
order_items_inx-rnddlv_qty = 'X'.
order_items_inx-updateflag = 'I'.
order_items_inx-target_qu = 'X'.
order_items_inx-plant = 'X'. "
append order_items_inx.
call function 'BAPI_SALESORDER_CREATEFROMDAT2'
exporting
salesdocumentin = 'MX11111152'
order_header_in = wa_bapi_header
order_header_inx = wa_bapi_headerx
importing
salesdocument = sales_order_no
tables
return = it_bapireturn
order_items_in = it_bapi_item
order_items_inx = order_items_inx
order_partners = it_bapi_partner
order_conditions_in = it_bapi_cond.
if sy-subrc is initial.
commit work.
endif.
*& Form f_item
text
form f_item .
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = wa_item-posnr
importing
output = wa_item-posnr.
wa_item-posnr = '000010'.
IF sy-subrc EQ 0. "IS INITIAL.
move wa_item-posnr to g_str_count."commented out by shakti
ENDIF.
wa_bapi_item-itm_number = wa_item-posnr. " Line item
WA_BAPI_ITEM-PO_ITM_NO = WA_ITEM-EBELP.
wa_bapi_item-division = wa_item-spart.
wa_bapi_item-purch_no_c = 'ddr1234'. " po number
wa_bapi_item-purch_date = sy-datum. " po date
wa_bapi_item-purch_no_s = 'MX11111112'. " Ship-to-party po number
wa_item-matnr = 'MAXIMO_SERVICE'.
call function 'CONVERSION_EXIT_MATN1_INPUT'
exporting
input = wa_item-matnr
importing
output = wa_item-matnr
exceptions
length_error = 1
others = 2.
if sy-subrc is initial.
wa_bapi_item-material = wa_item-matnr. "material
endif.
wa_bapi_item-target_qty = '1'. " Order qty
wa_bapi_item-comp_quant = '1'.
wa_bapi_item-target_qu = 'EA'.
wa_bapi_item-fixed_quan = '1'.
wa_bapi_item-comp_quant = wa_item-kwmeng.
wa_bapi_item-trgqty_den = '1'.
wa_bapi_item-rnddlv_qty = wa_item-kwmeng.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_item-ps_psp_pnr
IMPORTING
output = wa_item-ps_psp_pnr.
IF sy-subrc = 0.
wa_bapi_item-wbs_elem = wa_item-ps_psp_pnr.
ENDIF.
wa_bapi_item-item_categ = 'ZMAX'.
wa_bapi_item-ex_rate_fi = wa_item-kurrf.
wa_bapi_item-dli_profil = wa_item-ffprf. " Dynamic item processor profile
wa_bapi_item-route = wa_item-route. " route
wa_bapi_item-exchg_rate = wa_item-kursk.
wa_bapi_item-plant = '2090'. " Plant
wa_bapi_item-ship_point = 'FN11'. " Shipping point
wa_bapi_item-store_loc = wa_item-lgort. " stg loc
REPLACE ALL OCCURRENCES OF ',' IN wa_item-ntgew WITH '.'.
REPLACE ALL OCCURRENCES OF ',' IN wa_item-brgew WITH '.'.
wa_bapi_item-net_weight = wa_item-ntgew. "
wa_bapi_item-gross_wght = wa_item-brgew. "
call function 'CONVERSION_EXIT_CUNIT_INPUT'
exporting
input = wa_item-gewei
language = sy-langu
importing
output = wa_item-gewei.
EXCEPTIONS
unit_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
wa_bapi_item-untof_wght = 'KG'. " weight unit
replace all occurrences of ',' in wa_item-kursk with '.'.
replace all occurrences of ',' in wa_item-kurrf with '.'.
wa_bapi_item-profit_ctr = wa_item-prctr. " Profit center
wa_bapi_item-resanalkey = wa_item-abgrs. " RESULT ANALYSIS KEY
wa_bapi_item-cstg_sheet = wa_item-kalsm_k. " COSTING SHEET
append wa_bapi_item to it_bapi_item.
endform. " f_item
Thanks & regards,
Chetansee the following to create sales order:-
*& Report ZSALESORDER
*&DEVELOPED BY JANI KRUPA 4.10.2008
REPORT ZSALESORDER.
Parameters
Sales document type
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
PARAMETERS: p_auart TYPE auart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Sales organization
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Distribution channel
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Division.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
PARAMETERS: p_spart TYPE spart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Sold-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Ship-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Material
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Quantity.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Plant
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
PARAMETERS: p_plant TYPE werks_d .
SELECTION-SCREEN END OF LINE.
Complete Deliver
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text10 FOR FIELD p_autlf.
PARAMETERS: p_autlf TYPE autlf DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
Data declarations.
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: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.
DATA: lt_schedules_ink TYPE STANDARD TABLE OF bapisdhead1
WITH HEADER LINE.
Initialization.
INITIALIZATION.
v_text = 'Order type'.
v_text1 = 'Sales Org'.
v_text2 = 'Distribution channel'.
v_text3 = 'Division'.
v_text4 = 'Sold-to'.
v_text5 = 'Ship-to'.
v_text6 = 'Material'.
v_text7 = 'Quantity'.
v_text9 = 'Plant'.
v_text10 = 'Complete delivery'.
Start-of-selection.
START-OF-SELECTION.
Header data
Sales document type
header-doc_type = p_auart.
headerx-doc_type = 'X'.
Sales organization
header-sales_org = p_vkorg.
headerx-sales_org = 'X'.
Distribution channel
header-distr_chan = p_vtweg.
headerx-distr_chan = 'X'.
Division
header-division = p_spart.
headerx-division = 'X'.
headerx-updateflag = 'I'.
*Complete delivery
header-COMPL_DLV = p_autlf.
header-COMPL_DLV = 'X'.
Partner data
Sold to
partner-partn_role = 'AG'.
partner-partn_numb = p_sold.
APPEND partner.
Ship to
partner-partn_role = 'WE'.
partner-partn_numb = p_ship.
APPEND partner.
ITEM DATA
itemx-updateflag = 'I'.
Line item number.
item-itm_number = '000010'.
itemx-itm_number = 'X'.
Material
item-material = p_matnr.
itemx-material = 'X'.
Plant
item-plant = p_plant.
itemx-plant = 'X'.
Quantity
item-target_qty = p_menge.
itemx-target_qty = 'X'.
item category
itemx-ITEM_CATEG = 'X'.
APPEND item.
APPEND itemx.
ITEM DATA
itemx-updateflag = 'I'.
Line item number.
item-itm_number = '000020'.
itemx-itm_number = 'X'.
Material
item-material = p_matnr.
itemx-material = 'X'.
Plant
item-plant = p_plant.
itemx-plant = 'X'.
Quantity
item-target_qty = p_menge.
itemx-target_qty = 'X'.
APPEND item.
APPEND itemx.
Fill schedule lines
lt_schedules_in-itm_number = '000010'.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty = p_menge.
APPEND lt_schedules_in.
Fill schedule line flags
lt_schedules_inx-itm_number = '000010'.
lt_schedules_inx-sched_line = '0001'.
lt_schedules_inx-updateflag = 'X'.
lt_schedules_inx-req_qty = 'X'.
APPEND lt_schedules_inx.
Fill schedule lines
lt_schedules_in-itm_number = '000020'.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty = p_menge.
APPEND lt_schedules_in.
Fill schedule line flags
lt_schedules_inx-itm_number = '000020'.
lt_schedules_inx-sched_line = '0001'.
lt_schedules_inx-updateflag = 'X'.
lt_schedules_inx-req_qty = 'X'.
APPEND lt_schedules_inx.
Call the BAPI to create the sales order.
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING
sales_header_in = header
sales_header_inx = headerx
IMPORTING
salesdocument_ex = v_vbeln
TABLES
return = return
sales_items_in = item
sales_items_inx = itemx
sales_schedules_in = lt_schedules_in
sales_schedules_inx = lt_schedules_inx
sales_partners = partner.
Check the return table.
LOOP AT return WHERE type = 'E' OR type = 'A'.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / 'Error in creating document'.
ELSE.
Commit the work.
COMMIT WORK AND WAIT.
WRITE: / 'Document ', v_vbeln, ' created'.
ENDIF. -
Problem in uploading multiple line items while Creating sales order by BAPI
Hi experts , Im able to create sales order with one item while using this program, but the problem is when iam having multiple items or multiple sales order , iam not able to createthe line items , though its creating sales order header , Iam copy pasting my code , please add the additional code to my code to take more than 1 line items ,This is urgent requirement . Points will be rewarded for answers , Thanks in advance
*& Report Z_SO_CREATE_BAPI
REPORT Z_SO_CREATE_BAPI.
DATA: i_header TYPE bapisdhd1 occurs 0 with header line.
DATA: i_details TYPE bapisditm OCCURS 0 WITH HEADER LINE.
DATA: i_partner TYPE bapiparnr OCCURS 0 WITH HEADER LINE.
DATA: i_return1 TYPE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: i_return2 TYPE bapiret2.
data : ORDER_HEADER_IN like BAPISDHD1.
data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with HEADER LINE .
data : ORDER_ITEMS_INX Like BAPISDITMX occurs 0 with HEADER LINE .
data : RETURN like BAPIRET2 occurs 0 with header line.
data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
header line.
DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
LiNE.
data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
header line.
data : ORDER_SCHEDULES_INX like BAPISCHDLX occurs 0 with
header line.
data : BEGIN OF TAB OCCURS 0,
SRNO(4),
DOC_TYPE like ORDER_HEADER_IN-dOC_TYPE,
SALES_ORG LIKE ORDER_HEADER_IN-SALES_ORG,
DISTR_CHAN LIKE ORDER_HEADER_IN-DISTR_CHAN,
DIVISION like ORDER_HEADER_IN-DIVISION,
REQ_DATE_H(10),
PURCH_DATE(10),
PMNTTRMS LIKE ORDER_HEADER_IN-PMNTTRMS,
PURCH_NO_C LIKE ORDER_HEADER_IN-PURCH_NO_C,
ITM_NUMBER like BAPISDITM-ITM_NUMBER,
MATERIAL LIKE ORDER_ITEMS_IN-MATERIAL ,
PLANT LIKE ORDER_ITEMS_IN-PLANT,
TARGET_QTY LIKE ORDER_ITEMS_IN-TARGET_QTY,
ITM_NUMBERX like ORDER_ITEMS_INX-ITM_NUMBER ,
MATERIALX LIKE ORDER_ITEMS_INX-MATERIAL ,
CUST_MAT22 LIKE ORDER_ITEMS_IN-CUST_MAT22,
PLANTX LIKE ORDER_ITEMS_INX-PLANT,
TARGET_QTYX LIKE ORDER_ITEMS_INX-TARGET_QTY,
ITM_NUMBER LIKE ORDER_ITEMS_IN-ITM_NUMBER,
MATERIAL LIKE ORDER_ITEMS_IN-MATERIAL ,
PARTN_ROLE LIKE ORDER_PARTNERS-PARTN_ROLE,
PARTN_NUMB LIKE ORDER_PARTNERS-PARTN_NUMB,
END OF TAB.
DATA: v_vbeln TYPE bapivbeln-vbeln.
selection-screen begin of block b1 with frame.
skip 3.
parameter:p_infile like rlgrap-filename obligatory.
skip 3.
selection-screen end of block b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
PERFORM value_help.
start-of-selection.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = p_infile
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = tab.
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
**Validation for the Create SO screen
*AT SELECTION-SCREEN ON BLOCK na_create.
Loop at Tab.
i_header-doc_type = TAB-DOC_TYPE .
i_header-sales_org = TAB-SALES_ORG.
i_header-distr_chan = TAB-DISTR_CHAN .
i_header-division = TAB-DIVISION .
append i_header.
*endloop.
i_partner-partn_role = TAB-PARTN_ROLE .
i_partner-partn_numb = TAB-PARTN_NUMB.
APPEND i_partner.
i_details-material = TAB-MATERIAL .
APPEND i_details.
endloop.
*Bapi for Creating SO
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN = v_vbeln
order_header_in = i_header
ORDER_HEADER_INX =
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
TESTRUN =
CONVERT = ' '
IMPORTING
SALESDOCUMENT = v_vbeln
tables
RETURN = i_return1
ORDER_ITEMS_IN = i_details
ORDER_ITEMS_INX = ORDER_ITEMS_INX
order_partners = i_partner .
ORDER_SCHEDULES_IN =
ORDER_SCHEDULES_INX =
ORDER_CONDITIONS_IN =
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 =
ORDER_KEYS =
EXTENSIONIN =
PARTNERADDRESSES =
IF NOT v_vbeln IS INITIAL.
*Bapi Commit Work
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
return = i_return2
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
IMPORTING
RETURN =
ENDIF.
LOOP AT i_return1 . "INTO wa_return1.
WRITE:/ i_return1-message.
ENDLOOP.
FORM value_help .
CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
EXPORTING
DEF_FILENAME = ' '
DEF_PATH = ' '
MASK = ',.,..'
MODE = 'O'
TITLE = ' '
IMPORTING
FILENAME = p_infile
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform.
txt file data
order type salesorg distch divison materialno parter role
TA PB01 01 00 000000000000000852 WE
Partner no
8101000000Hi Neerja,
you can reffer this sample code. It may not be complet soluation for your poblem,
but you will get some idea.
*& Report ZBAPI_SALESORDER_CREATE
*& Author : Karthik
REPORT ZBAPI_SALESORDER_CREATE.
data : ORDER_HEADER_IN like BAPISDHD1.
data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with
header line.
data : RETURN like BAPIRET2 occurs 0 with header line.
data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
header line.
DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
LINE.
data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
header line.
data : BEGIN OF TAB OCCURS 0,
SRNO(4),
DOC_TYPE like ORDER_HEADER_IN-dOC_TYPE,
SALES_ORG LIKE ORDER_HEADER_IN-SALES_ORG,
DISTR_CHAN LIKE ORDER_HEADER_IN-DISTR_CHAN,
DIVISION like ORDER_HEADER_IN-DIVISION,
REQ_DATE_H(10),
PURCH_DATE(10),
PMNTTRMS LIKE ORDER_HEADER_IN-PMNTTRMS,
PURCH_NO_C LIKE ORDER_HEADER_IN-PURCH_NO_C,
ITM_NUMBER like BAPISDITM-ITM_NUMBER,
CUST_MAT22 LIKE ORDER_ITEMS_IN-CUST_MAT22,
PLANT LIKE ORDER_ITEMS_IN-PLANT,
TARGET_QTY LIKE ORDER_ITEMS_IN-TARGET_QTY,
PARTN_ROLE LIKE ORDER_PARTNERS-PARTN_ROLE,
PARTN_NUMB LIKE ORDER_PARTNERS-PARTN_NUMB,
END OF TAB.
data: itab1 like alsmex_tabline occurs 0 with header
line.
DATA: gd_currentrow type i.
data : PURCHASEORDER like ekko-ebeln.
Data: tot_rec type i, "Total Records
gd_update type i, "Main Table Increement Counter
gd_lines type i, "Success Table increement Counter
w_textout like t100-text. "VARIABLE TO GET ERRORLOG
data : begin of it_success occurs 0,
SALESDOCUMENT LIKE BAPIVBELN-VBELN, "PROJECT
end of it_success.
data : begin of it_error occurs 0,
srno(4),
err_msg(73) TYPE c, "TO RETREIVE ERROR MESSAGES
end of it_error.
data : srno(4).
DATA : SALESDOCUMENT LIKE BAPIVBELN-VBELN.
selection-screen begin of block b1 with frame.
skip 3.
parameter:p_infile like rlgrap-filename obligatory.
skip 3.
selection-screen end of block b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
PERFORM value_help.
start-of-selection.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_infile
i_begin_col = '1'
i_begin_row = '2' "Do not require
headings
i_end_col = '22'
i_end_row = '10000'
TABLES
intern = itab1
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
message e010(zz) with text-001. "Problem uploading
Excel Spreadsheet
endif.
*perform open_group.
sort itab1 by row col.
Get first row retrieved
read table itab1 index 1.
Set first row retrieved to current row
gd_currentrow = itab1-row.
loop at itab1.
Reset values for next row
if itab1-row ne gd_currentrow.
append tab .
clear tab.
gd_currentrow = itab1-row.
endif.
SHIFT ITAB1-VALUE LEFT DELETING LEADING SPACE.
case itab1-col.
when '0001'.
TAB-SRNO = itab1-value.
when '0002'.
TAB-DOC_TYPE = itab1-value.
when '0003'.
TAB-SALES_ORG = itab1-value.
when '0004'.
TAB-DISTR_CHAN = itab1-value.
when '0005'.
TAB-DIVISION = itab1-value.
when '0006'.
TAB-REQ_DATE_H = itab1-value.
when '0006'.
TAB-PURCH_DATE = itab1-value.
when '0007'.
TAB-PMNTTRMS = itab1-value.
when '0008'.
TAB-PURCH_NO_C = itab1-value.
when '0009'.
TAB-ITM_NUMBER = itab1-value.
when '0010'.
TAB-CUST_MAT22 = itab1-value.
when '0011'.
TAB-PLANT = itab1-value.
when '0012'.
TAB-TARGET_QTY = itab1-value.
when '0013'.
TAB-PARTN_ROLE = itab1-value.
when '0014'.
TAB-PARTN_NUMB = itab1-value.
endcase.
endloop.
append tab.
clear tab.
sort tab by SRNO.
LOOP AT TAB.
concatenate tab-REQ_DATE_H+4(4)
tab-REQ_DATE_H2(2) tab-REQ_DATE_H0(2) into
tab-REQ_DATE_H.
concatenate tab-PURCH_DATE+4(4)
tab-PURCH_DATE2(2) tab-PURCH_DATE0(2) into
tab-PURCH_DATE.
SRNO = TAB-SRNO.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = tab-PARTN_NUMB
IMPORTING
OUTPUT = tab-PARTN_NUMB.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = tab-CUST_MAT22
IMPORTING
OUTPUT = tab-CUST_MAT22.
IF TAB-SRNO = SRNO.
ORDER_HEADER_IN-DOC_TYPE = TAB-DOC_TYPE.
ORDER_HEADER_IN-SALES_ORG = TAB-SALES_ORG.
ORDER_HEADER_IN-DISTR_CHAN = TAB-DISTR_CHAN.
ORDER_HEADER_IN-REQ_DATE_H = TAB-REQ_DATE_H.
ORDER_HEADER_IN-PURCH_DATE = TAB-PURCH_DATE.
ORDER_HEADER_IN-PMNTTRMS = TAB-PMNTTRMS.
ORDER_HEADER_IN-PURCH_NO_C = TAB-PURCH_NO_C.
ORDER_HEADER_IN-DIVISION = tab-DIVISION.
ORDER_ITEMS_IN-ITM_NUMBER = tab-ITM_NUMBER.
ORDER_ITEMS_IN-material = TAB-CUST_MAT22.
ORDER_ITEMS_IN-PLANT = TAB-PLANT.
APPEND ORDER_ITEMS_IN.
ORDER_PARTNERS-PARTN_ROLE = TAB-PARTN_ROLE.
ORDER_PARTNERS-PARTN_NUMB = TAB-PARTN_NUMB.
APPEND ORDER_PARTNERS.
ORDER_SCHEDULES_IN-ITM_NUMBER = tab-ITM_NUMBER.
ORDER_SCHEDULES_IN-REQ_QTY = tab-TARGET_QTY.
append ORDER_SCHEDULES_IN.
ENDIF.
AT END OF SRNO.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN =
ORDER_HEADER_IN = ORDER_HEADER_IN
ORDER_HEADER_INX =
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
TESTRUN =
CONVERT = ' '
IMPORTING
SALESDOCUMENT = SALESDOCUMENT
TABLES
RETURN = RETURN
ORDER_ITEMS_IN = ORDER_ITEMS_IN
ORDER_ITEMS_INX =
ORDER_PARTNERS = ORDER_PARTNERS
ORDER_SCHEDULES_IN = ORDER_SCHEDULES_IN
ORDER_SCHEDULES_INX =
ORDER_CONDITIONS_IN =
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 =
ORDER_KEYS = ORDER_KEYS
EXTENSIONIN =
PARTNERADDRESSES =
IF SALESDOCUMENT <> SPACE.
commit work.
ADD 1 TO gd_update.
it_success-SALESDOCUMENT = SALESDOCUMENT.
append it_success.
CLEAR :SALESDOCUMENT,ORDER_HEADER_IN.
REFRESH : RETURN,ORDER_ITEMS_IN,ORDER_PARTNERS.
ELSE.
loop at return.
it_error-SRNO = tab-SRNO.
it_error-err_msg = return-MESSAGE .
Append it_error.
ENDLOOP.
CLEAR :SALESDOCUMENT,ORDER_HEADER_IN.
REFRESH : RETURN,ORDER_ITEMS_IN,ORDER_PARTNERS.
ENDIF.
endat.
endloop.
DESCRIBE TABLE it_success LINES gd_lines.
IF gd_lines GT 0.
Display result report column headings
PERFORM display_column_headings.
Display result report
PERFORM DISPLAY_SUCESS.
ENDIF.
IF SUCESS FAILS Display Error Report
DESCRIBE TABLE it_error LINES gd_lines.
IF gd_lines GT 0.
PERFORM errorheadings.
PERFORM errorreport.
ENDIF.
*& Form display_column_headings
text
FORM display_column_headings.
WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.
SKIP.
WRITE:2 'The following records inserted
successfully:'(013).
WRITE:/ sy-uline(15).
FORMAT COLOR COL_HEADING.
WRITE:/ sy-vline,
(10) 'Sales order'(004), sy-vline.
WRITE:/ sy-uline(15).
ENDFORM. "display_column_headings
*Subroutine to display SUCESS REPORT
FORM DISPLAY_SUCESS.
FORMAT COLOR COL_NORMAL.
LOOP AT it_success.
WRITE:/ sy-vline,
(10) it_success-SALESDOCUMENT, sy-vline.
CLEAR it_success.
ENDLOOP.
WRITE:/ sy-uline(15).
REFRESH: it_success.
FORMAT COLOR COL_BACKGROUND.
ENDFORM. "
DISPLAY_REPORT
*& Form errorreport
text
FORM errorreport.
LOOP AT it_error.
WRITE:/ sy-vline,
(10) it_error-SRNO, sy-vline,
(40) it_error-err_msg, sy-vline.
ENDLOOP.
WRITE:/ sy-uline(104).
REFRESH: it_error.
endform. "errorreport
*& Form ERRORHEADINGS
text
FORM ERRORHEADINGS.
SKIP.
WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
SKIP.
WRITE:2 'The following records failed during
update:'(008).
WRITE:/ sy-uline(104).
FORMAT COLOR COL_HEADING.
WRITE:/ sy-vline,
(10) 'ERROR.'(009), sy-vline.
WRITE:/ sy-uline(104).
FORMAT COLOR COL_NORMAL.
ENDFORM. "ERRORHEADINGS
**& Form value_help
text
--> p1 text
<-- p2 text
FORM value_help .
CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
EXPORTING
DEF_FILENAME = ' '
DEF_PATH = ' '
MASK = ',.,..'
MODE = 'O'
TITLE = ' '
IMPORTING
FILENAME = p_infile
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. "value_help
Regards,
Amit. -
Dump while creating sales order using BAPI
Hi Experts,
I am trying to create a sales order in my alv report using BAPI_SALESORDER_CREATEFROMDAT2. I get a dump while executing the program. Please suggest me where I am going wrong.
|Source Code Extract |
|Line |SourceCde |
| 1|FORM FRM_KOND_BASIS_604. |
| 2|*{ INSERT DEVK910738 1 |
| 3| |
| 4|data: zuomqtyo LIKE ekpo-menge, |
| 5| zuomqtyn LIKE ekpo-menge, |
| 6| zqty1 type i, |
| 7| zqty2(11) type n. |
| 8| |
| 9|** Round up billing qty |
| 10| if komp-zzLTKZA ne 'VAR'. |
| 11| |
|>>>>>| zqty1 = xkwert. |
| 13| compute zqty2 = zqty1 / 1000. |
| 14| xkwert = zqty2 * 1000. |
| 15| |
| 16| exit. |
| 17| endif. |
| 18| |
| 19| |
| 20|** Samples |
| 21| |
| 22| if komp-MATKL = '5400'. |
| 23| |
| 24| check not xkomv-kmein is initial. |
| 25| check not komp-vrkme is initial. |
| 26| |
| 27|** Make sure base is correct when sales unit and pricing unit differ |
| 28| if komp-vrkme ne xkomv-kmein. |
| 29| |
| 30| zuomqtyo = komp-MGAME. |
| 31| |
Thanks.John,
Here is what I am doing.
*Assign Header Data And Move To Header Data Final Table
GS_ORDERHEADERIN-DOC_TYPE = GC_AUART.
GS_ORDERHEADERIN-SALES_ORG = GC_SORG.
GS_ORDERHEADERIN-DISTR_CHAN = GC_DISTC.
GS_ORDERHEADERIN-DIVISION = GC_DIVI.
GS_ORDERHEADERIN-ORD_REASON = GC_AUGRU.
GS_ORDERHEADERIN-REQ_DATE_H = WA-USAGE_DATE.
GS_ORDERHEADERIN-PURCH_DATE = WA-USAGE_DATE.
GS_ORDERHEADERIN-PURCH_NO_C = WA-USAGE_DOC.
*Assign Header Data And Move To Header Data Final Table
GS_ORDERHEADERINX-DOC_TYPE = GC_FLAG.
GS_ORDERHEADERINX-SALES_ORG = GC_FLAG.
GS_ORDERHEADERINX-DISTR_CHAN = GC_FLAG.
GS_ORDERHEADERINX-DIVISION = GC_FLAG.
GS_ORDERHEADERINX-ORD_REASON = GC_FLAG.
GS_ORDERHEADERINX-REQ_DATE_H = GC_FLAG.
GS_ORDERHEADERINX-PURCH_DATE = GC_FLAG.
GS_ORDERHEADERINX-PURCH_NO_C = GC_FLAG.
*ASSIGN ITEMS DATA AND MOVE TO ITEMS DATA FINAL TABLE
GS_ORDERITEMSIN-ITM_NUMBER = WA-POSNR.
GS_ORDERITEMSIN-MATERIAL = WA-MATERIAL.
GS_ORDERITEMSIN-TARGET_QTY = WA-EXT_QTY. "EXT_QTY is of type LFIMG
GS_ORDERITEMSIN-TARGET_QU = WA-EXT_UOM. "EXT_UOM is of type VRKME
APPEND GS_ORDERITEMSIN TO GT_ORDERITEMSIN.
CLEAR GS_ORDERITEMSIN.
*Assign Items Data And Move To Items Data Final Table
GS_ORDERITEMSINX-ITM_NUMBER = WA-POSNR.
GS_ORDERITEMSINX-MATERIAL = GC_FLAG.
GS_ORDERITEMSINX-TARGET_QTY = GC_FLAG.
GS_ORDERITEMSINX-TARGET_QU = GC_FLAG.
APPEND GS_ORDERITEMSINX TO GT_ORDERITEMSINX.
CLEAR GS_ORDERITEMSINX.
*Assign Schedule Lines Data And Move To Schedule Lines Final Table
GS_ORDER_SCHEDULES_IN-ITM_NUMBER = WA-POSNR.
GS_ORDER_SCHEDULES_IN-REQ_DATE = WA-USAGE_DATE.
GS_ORDER_SCHEDULES_IN-REQ_QTY = WA-EXT_QTY. "EXT_QTY is of type LFIMG
APPEND GS_ORDER_SCHEDULES_IN TO GT_ORDER_SCHEDULES_IN.
CLEAR GS_ORDER_SCHEDULES_IN.
*Assign Schedule Lines Data And Move To Schedule Lines Final Table
GS_ORDER_SCHEDULES_INX-ITM_NUMBER = WA-POSNR.
GS_ORDER_SCHEDULES_INX-REQ_DATE = GC_FLAG.
GS_ORDER_SCHEDULES_INX-REQ_QTY = GC_FLAG.
APPEND GS_ORDER_SCHEDULES_INX TO GT_ORDER_SCHEDULES_INX.
CLEAR GS_ORDER_SCHEDULES_INX.
*Assign Sold-To-Partner Data And Move To Final Partners Table
GS_ORDERPARTNERS-PARTN_ROLE = GC_SP.
GS_ORDERPARTNERS-PARTN_NUMB = GV_SOLD.
APPEND GS_ORDERPARTNERS TO GT_ORDERPARTNERS.
CLEAR GS_ORDERPARTNERS.
*Assign Ship-To-Partner Data And Move To Partners Table
GS_ORDERPARTNERS-PARTN_ROLE = GC_SH.
GS_ORDERPARTNERS-PARTN_NUMB = GV_SHIP.
APPEND GS_ORDERPARTNERS TO GT_ORDERPARTNERS.
CLEAR GS_ORDERPARTNERS.
*Clear Global Variable Field Of Sales Document
CLEAR:GV_SALESDOCUMENT.
"Right after pressing F6 button after this. It gives me dump.
*Call Function Module To Create Sales Order
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = GS_ORDERHEADERIN
ORDER_HEADER_INX = GS_ORDERHEADERINX
IMPORTING
SALESDOCUMENT = GV_SALESDOCUMENT
TABLES
ORDER_ITEMS_IN = GT_ORDERITEMSIN
ORDER_ITEMS_INX = GT_ORDERITEMSINX
ORDER_SCHEDULES_IN = GT_ORDER_SCHEDULES_IN
ORDER_SCHEDULES_INX = GT_ORDER_SCHEDULES_INX
ORDER_PARTNERS = GT_ORDERPARTNERS
RETURN = GT_BAPIRETURN.
IF SY-SUBRC = 0.
*Call Function Module For BAPI Commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = GC_FLAG.
ENDIF.
All my BAPI tables have been filled with required data in them. But, still it is giving me a dump.
I would really appreciate if some one could suggest me where I am going wrong.
Thanks. -
Freight Carrier missing while creating sales order using BAPI
Hi All,
I am using BAPI BAPI_SALESORDER_CREATEFROMDAT2 to create sales order. At header level, I am passing sold-to-party,ship-to-party and Freight Carrier fields as partners.
When the sales order is created it is creating partners sold-to-party,ship-to-party but freight carrier is missing in the partners.
To partners inernal table, I am passing the partner role and partner number as following:
int_partners-PARTN_ROLE = 'AG'.
int_partners-PARTN_NUMB = int_order-kunnr.
append int_partners.
clear int_partners.
int_partners-PARTN_ROLE = 'FC'. "Frieght carrier
int_partners-PARTN_NUMB = int_order-kunnr2.
append int_partners.
clear int_partners.
int_partners-PARTN_ROLE = 'WE'.
int_partners-PARTN_NUMB = int_order-kunnr1.
int_partners-NAME = int_order-name1.
int_partners-NAME_2 = int_order-name2.
int_partners-STREET = int_order-street.
int_partners-POSTL_CODE = int_order-post_code1.
int_partners-COUNTRY = int_order-country.
int_partners-CITY = int_order-city1.
int_partners-REGION = int_order-region.
int_partners-TRANSPZONE = int_order-transpzone.
int_partners-TAXJURCODE = int_order-taxcode.
int_partners-district = int_order-city2.
append int_partners.
clear int_partners.
Freight Carrier is set up as a "Vendor" instead of Customer in our system.
If anyone has solution to pass "Freight Carrier" through BAPI, please let me know.
Thanks,
Sonali.For Vendor (Freight carrier) , I checked the master data and it has partner function defined as VN (vendor).
I have another issue with the salesorder create BAPI:
I am getting error
"E - 000010 : Condition rate does not agree with init. indicator for condition PR00"
when I am updating the PR00 condition value with '0.0' .
Please advice if anyone has any idea.
Thanks,
Sonali.
Thanks,
Sonali. -
Error while creating Sales Order Through BAPI
Hi Friends,
i am creating a RFC where i have to create sales order .
I am using bapi
BAPI_SALESORDER_CREATEFROMDAT2
for same and entering values to it.
I got the following return messages:
S V4 233 SALES_HEADER_IN has been processed successfully
S V4 233 SALES_ITEM_IN has been processed successfully
S V1 311 BDN Order 3112800903 has been saved
But when I go to transaction VA03 and enter the number i get the following error:
SD document 3112800903 is not in the database or has been archived
Can any one know how to resolve this error.I am also using BAPI_TRANSACTION_COMMIT with wait = 'X'.
Regards,
Santosh AlleHi,
Try to check the return message once.
SD document 3112800903 is not in the database or has been archived
You will get this message if the sales document is deleted from the database .The BAPI 'BAPI_SALESORDER_CHANGE' is used to delete salesorder.Check whether anyone has deleted it
Also, sometimes it may take few seconds to update the sales order in the database when using BAPI. Check the transaction after some time.
Regards,
Lakshman.
Edited by: Lakshman N on May 14, 2010 7:43 AM -
Avoid substitute material.., while creating sales order with BAPI?
Hi experts.
I use BAPI_SALESDOCU_CREATEFROMDATA1 function module to create a sales order.
Material A has a substitute material B with substitute reason 0005.
So if I use material A when creating sales order with above BAPI function, the order is created with material B.
I don't want to substitute the material automatically. I want to create the sales order with material A.
What should I do? Help me please.
Thanks in Advance.Hi bvrn Reddy,
I know, your message is almost two years old, but, did you find a solution? I'm facing the same problem. The material A has B as substitute, but in va01 a popup appears (its customizing inside the substitution reason, strategy = A). Of course, we have no popup inside the bapi, but there must be a way to decide which material the bapi should use. At the moment I only get the substitute, never the old mat (even there is something in stock).
Maybe you've got a helpful hint for me, thanks!
Ben -
Query not working while creating Sales Order... Need suggestions
Dear All,
My client requirement involves creation of Sales Orders both as standalone as well as based on Quotations, depending on the case. Now there is a UDF created in the Item Master Data called "U_Unit" which should be populated in another UDF (U_BPQty) in the Sales Order and Sales Quotation which can be changed at the transaction level.
The requirement is if the Sales Order is created based on Quotation, the system should take the value from 'U_BPQty" of "Sales Quotation" and populate in the Sales Order. if the Sales Order is created as stand-alone, it should take the value from U_Unit field of the Item Master Data. I wrote the following query for that purpose and using it as a FMS but its not working.
Can you suggest me where I am going wrong?
Declare @Base varchar
Declare @Item varchar
Declare @Draw varchar
Declare @BaseQty varchar
Set @Base = (Select Case When $[$38.44.0] is Null then 0 when $[$38.44.0] is not Null then $[$38.44.0] end)
Set @Item = ($[$38.1.0])
Set @Draw = (SELECT T0.U_BPQty from QUT1 T0 INNER JOIN OQUT T1 ON T0.DocEntry = T1.DocEntry INNER JOIN RDR1 T2 ON T2.BaseRef = T1.DocNum WHERE T0.ItemCode = @Item)
Set @BaseQty = (SELECT T0.U_Unit from OITM T0 WHERE T0.ItemCode = $[$38.1.0])
Select Case when (@Base = 0) then @BaseQty when (@Base <> 0) then @Draw end
Thanks and regards,
Bharath SHi Bharath.......
As you said if SQ not there and SO is directly punched then it should Pick up U_Unit else if SQ has target of SO then U_BP then your query working fine.
But if SQ not there and Del is directly punched instead of SO then it should Pick up U_Unit else if SQ has target of Delivery and not SO then U_BP. Is it?
In such case its not working?
If yes then use this query.......
declare @basedoc as nvarchar
set @basedoc=$[DLN1.BaseType.0]
If @basedoc<1
Begin
Select T0.U_Unit from OITM T0 Where T0.ItemCode=$[DLN1.ItemCode.0]
End
If @basedoc>1
Begin
Select T0.U_BPQty From QUT1 T0 where T0.docentry=$[DLN1.BaseEntry.0] and T0.ItemCode=$[DLN1.ItemCode.0]
End
Else use this......
declare @basedoc as nvarchar
set @basedoc=$[DLN1.BaseType.0]
If @basedoc<1
Begin
Select T0.U_Unit from OITM T0 Where T0.ItemCode=$[DLN1.ItemCode.0]
End
If @basedoc>1
Begin
Select T0.U_BPQty From RDR1 T0 where T0.docentry=$[$38.45.0] and T0.ItemCode=$[DLN1.ItemCode.0]
End
Regards,
Rahul -
Error : 'Tax Jurisdiction is not determined' while creating sales order
Hi,
I'm creating a sales order using the BAPI : BAPI_SALESORDER_CREATEFROMDAT1.
I'm passing the following values in ORDER_HEADER_IN parameter:
doc_type,sales_org,distr_chan,division,po_method,sales_off,req_date_h,data_type,purch_no,purch_date,price_date.
I'm passing the following values in SD_ORDER_PARTNERS:
partn_role,partn_numb,name,langu,region,country.
The following fields are passed in SD_ORDER_ITEMS:
material,req_qty,sales_unit,store_loc (space is passed for st.loc),req_date,po_method,req_date,plant.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'
EXPORTING
order_header_in = sd_order_header
IMPORTING
return = return1
salesdocument = order_number
sold_to_party = sd_sold_to_party
ship_to_party = sd_ship_to_party
billing_party = sd_billing_party
TABLES
order_items_in = sd_order_items_in
order_partners = sd_order_partners
order_items_out = sd_order_items_out.
The system returns a message in RETURN1 saying that : 'Tax jurisdiction is not determined'.
Please let me know if I'm missing something.
Thanks,
Narsingh.Do you want to use the customer master address for the ship-to? Does the ship-to on the customer master haver a tax jurisdiction determined? Did you change the values in region/country from what they are on the customer master which would cause the tax jurisdiction determined on the customer master to be re-determined and thus rejected? You don't need to send address values in the partner table if you intend to use the customer master values...
-
Error "Item 000010 does not exist" while creating sales order in VA01
Dear All,
As per customer requirement we are trying to validate shipping data( item level) and unloading point( item level) by customer enhancement.
Enhancement: V45A0003
Function Module: EXIT_SAPMV45A_003
INCLUDE: ZXVVAU05
Inside include we have written validation code that if user enters any wrong value for shipping data or unloading data
system will throw error message accordingly.
It is working fine and we are getting error message if wrong shipping data or unloading data is entered.
But after the error message is displayed if we try to save the sales order again system throws a STOP message as a POPUP
saying "Item 000010 does not exist".
Now,if we enter proper shipping data or unloading data and try to save the salesorder it is throwing error "Item 000010 does not exist"..
Please let me know your valuable input on this.
Regards
Arindam
Edited by: Arindam Ganguly on Mar 11, 2010 1:55 PMIt sounds like your error routine has prevented the insertion of the data in VBAP or XVBAP internal tables. Therefore, upon return to the screen and SAVE, SAP is examining the VBAP or XVBAP table, comparing to the 'I' index table probably, and finding that there is supposed to be an item 10, but it's not in the necessary table(s). This may be resulting because your internal tables are now inconsistent.
Look at where your inserted error coding is occurring...you may want to move that to the SAVE_DOCUMENT_PREPARE routine in MV45AFZZ, so that everything will have been built, and a final check of the content will stop the sales order save until the data is corrected.
Edited by: Breakpoint on Mar 11, 2010 3:29 PM -
PARTNER PROCESSING OBJECT BUS2032 NOT FOUND WHILE CREATING SALES ORDER
Hi All,
I am not able to create a sales order it gives a Error "PARTNER PROCESSING OBJECT BUS2032 not found". Can any one inform me what could be a problem. Thanks in advance.Yes, The Partner function SP is active.
We had a work around.
When the sales order was saved, being in Partner function Tab we got the error message. However when we returned to the Overview and saved the Order, we were through with the same. But, Iam not sure how could this happen. -
Confirmation Quantity issue while creating Sales order using BAPI
Hi SDN,
Can anyone of you help mein the below issue:
I have a program to create a sales order using upload file. for this i use "BAPI_SALESORDER_CREATEFROMDAT2" & for changing existing "BAPI_SALESORDER_CHANGE".
Now If the upload file contains the Same Material, Based on other conditions, it needs to create Multiple sales order.
When the first Salesorder is created, the Quantity is getting confirmed (Confirmed quantity VBEP-BMENG). But during actual run, since the confirmation is getting done for the same material in the above Sales order, the confirmation is not being done in the subsequent Sales order".
This poses a problem for business, user need to manual refresh the u201Cconfirmed quantity for each line item in the particular SO where it failed during program upload.
Also while uploading using the BAPI, if we wait forsometime after creating the first sales order in Debug, then the above material is unlocked & the confirmation quantity is done for the subsequent sales order also.
But in the actual run, this is creating a problem. Some Refresh or Unlocking problem.
Can you please suggest a suitable solution for this issue.
Thanks & regrads,
Chaitanya LBKHave you tried backorder processing?
V_V1
V_V2
V_RA
V_R1
V_R2
Maybe you are looking for
-
Help! Can't open psd file
I've been working on a large file for a while. I've been using the same computer with CS2. Now, the same computer, won't open the file I've been working on. The file has never been worked on using a different computer or a different version of Photos
-
An Illustrator error occurred: 1346458189 ('PARM')
Hello everyone, I am trying to open some documents in Illustrator CS4 by javascript, walk through all layers including sublayers, doing something (for now just reading the layernames and showing them at an alert), closing the document and continue wi
-
Quick tip help. How to add to vector layers using shape tool
This is something that's bugged me for a few versions and I'm sure someone has a tip for this. When I use Shape Layer tool, I get a solid color with a vector mask. The tool always makes a new layer every time I use the tool. So to get around that, I
-
Can Any body Send Me Sample Repositorys ?
Hi Can any body send me the Sample Repositorys (.xml files or xds file ) praveen.sapmdm @gmail.com Edited by: g.praveen kumar on Jun 20, 2008 6:23 PM
-
ICal to Mail drag & drop not working in OSX 10.10
In a frequently used work flow I dragged an iCalendar entry and dropped it to mail, where it was received as .ical attachment. Sometimes I used copy/paste to insert the entry's data as plain text. This does not work any more with 10.10. Is there any