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
8101000000
Hi 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.
Similar Messages
-
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 -
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 -
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. -
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 -
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 -
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. -
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 -
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,
taranamHi 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 -
Creating sales order using bapi
while creating sales order using bapi serial no is added in dat but its not saving.
plz replyHi
See tha sample code for sales order creation
SALES ORDER INPUT CREATION.
PARAMETERS: p_auart TYPE auart OBLIGATORY.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
PARAMETERS: p_spart TYPE vtweg OBLIGATORY.
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
*ITEM
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
PARAMETERS: p_itcat TYPE pstyv OBLIGATORY.
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.
HEADER DATA
header-doc_type = p_auart.
headerx-doc_type = 'X'.
header-sales_org = p_vkorg.
headerx-sales_org = 'X'.
header-distr_chan = p_vtweg.
headerx-distr_chan = 'X'.
header-division = p_spart.
headerx-division = 'X'.
headerx-updateflag = 'I'.
PARTNER DATA
partner-partn_role = 'AG'.
partner-partn_numb = p_sold.
APPEND partner.
partner-partn_role = 'WE'.
partner-partn_numb = p_ship.
APPEND partner.
ITEM DATA
itemx-updateflag = 'I'.
item-itm_number = '000010'.
itemx-itm_number = 'X'.
item-material = p_matnr.
itemx-material = 'X'.
item-plant = p_plant.
itemx-plant = 'X'.
item-target_qty = p_menge.
itemx-target_qty = 'X'.
item-target_qu = 'EA'.
itemx-target_qu = 'X'.
item-item_categ = p_itcat.
itemx-item_categ = '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.
Call the BAPI
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 WORK AND WAIT.
WRITE: / 'Document ', v_vbeln, ' created'.
ENDIF.
after that check in the table VBAP whether serial number is cretaed or not
Reward points if useful
Regards
Anji -
Same material can exist on multiple line items for the same order.
Hi
Is there any specific customising setting or web shop setting through which we can restrict user to add same material on multiple line items for the same order ?
RegardsNo.
But if this is a must requirement, you can do an elaborate check during order save in ORDER_SAVE BAdI and return error. So, it will be only during order save.
Eawar Ram
http://www.parxlns.com -
Error while creating sales order with ref to contract
while creating sales order, with refernce to contract system is giving a message
Configuration not possible for material : Reason 3 --> Help
Message no. V1360
and the message is as follwed can any one explain
Diagnosis
This may have been caused by one of the following:
1. The configuration profile for the material allows or requires the bill of materials to be exploded during order processing. However, a plant has not been specified in the item.
2. The configuration profile of the material allows or requires the bill of materials to be exploded during order processing, but the order quantity in the item must be greater than 0.
3. A configuration profile has not been maintained
or
A configuration is not permitted for the material
or
4. The configuration profile of the material allows or requires the bill ofmaterials to be exploded during order processing. However, the system could not determine a date because important data is missing from the item (see incompletion log).Hi
I think you have both Variant configuration and BOM.
Pls ensure the following.
1. BOM masterdata is maintained for the variants
2. Variant configuration is configured correctly
Configuration profile is created for the material
Knowledge base object and run time version are available
3. Maintain materials as not relevant for delivery or dont give delivery quantity as 0
Once you are sure that these are in proper shape, you can start creating order. The problem wont come.
Reward points if it helps you. -
How to avoide entry of same material in line item in same sales order?
Dear SD Experts,
In my project client has requirement related to Material in sales order. Client wants " while creating sales order (VA01) that time particular Material should use one time in the sales order". If same material used more than one time in item line in the existing sales order that time system must give the Error Massage.
Kindly suggest me how can I fulfill above requirement.
Regards,
Manzoor AhmadHi Manzoor Ahmad,
This is an interesting requirement and this cannot be achieved through Standard SAP functionality. We can achive this through custom development in Userexit MV45AFZZ with the help of Developer . The logic has to be while creating sales order , you have created line no 10 with "matl no 1234 " and again trying to use the same material in line no 30 , then the system has to check all the line items that are created before the line no 30 . This same logic need to be applied for Tcode VA02 also.
Please post the the solution once implemented.
Thanks and regards
Veera -
How to change the status of material while creating sales order via BDC
Hai.
In BDC while creating sales order( va01 posting ) it is stucking up in middle saying material is new. I.e Sales order (va01) is not getting created because of material status is new . I want to create sales order (va01) even material status is new.
pls give me out the solution. Points will be rewarded.
thanks & regards,
sami.Hi,
If you drag the line item a little towards the right side, you will find a filed material entered. The one you see in the material filed on sales order over view screen is the one determined. You can as well double click and see the fields material entered and material determined.
Is there anything else you are expecting to see as part of analysis ?
Regards
Sadhu Kishore -
Keep Quote line item numbers in Sales order
While creating a Sales order from Quote, SAP always creates line items with 100,200,300...and so on.
If quote has 3 line items say 100,110, & 120 and we create a sales order with reference to this quote in VA01. The sales order line items become 100,200 & 300.
The requirement is for Sales order to also have same line item numbers i.e. 100,110 & 120.
To retain quote line item numbers in Sales order the ABAP change will be in VOFM or user exit?Hi,
It is not a straight forward thing. Adding data to table XVBAP won't work. It will create inconsistency. There are so many other tables involve here too, like, VBPA, VBUP, VBKD, KONV. There can be other tables too based on how your sales order is configured.
Also, modifying these tables (XTAB, YTAB ) in this user-exit may cause database inconsistency.
Regards,
RS
Maybe you are looking for
-
Live Cam Voice OR wireless connection; not both
My new Live! Cam Voice blocks my wireless Internet connection. The Webcam works fine for taking photos and making little videos. But if I'm online, and plug the Webcam into a USB port, my connection is cut and I cannot restore it. Unplug the Webcam a
-
Introduction of Bebo, a control pad for SAP sessions
Hello community, Bebo for is a small utility to watch, navigate and control all SAP sessions of the SAP GUI for Windows. Bebo is an acronym, in long description it means Best Boy. A Best Boy is the first assistant of the lighting technician in movie
-
I shot (as a guest) at a wedding this past weekend and was playing around with some of the in-camera custom white balance to get around the lovely green and magenta lighting at the reception. Aperture's processing of these RAW files is COMPLETELY bor
-
How to cluster the war file conatining the jsp and servlet by using wl6.0sp1?
There three wlsever6.0 sp1. One is admin server and doesn't join the cluster. Two servers are cluster server. I use the admin console to deploy the war file and the war file conatains the jsp and servlet.
-
Unable to open the Excel document in browser
Hi, I have configured excel service in CA, and i started Excel calculated service. but unable to open the excel document in web browser. getting below error message. ULS LOG Excel Services Application Web Front End acbd Critical Unable to reach Excel