SalesOrder Creation
Hi, experts,
I want to create a sales order according to this data in ABSL.
AccountID=1
Shitp-ToID=1
Description="Test1"
ExternalReference="123"
Item 1-> ProductID="1"
Quantity="2"
Item 2-> ProductID="2";
Quantity="3";
Can anybody help me please to create that SalesOrder?
Regards,
May T.
Please refer to this link for more information.
Re: New Instance Of Sales Order in ABSL
Hi, May T.
Your first question is
( I can't find AccountID and Quantity path. So I can't assign them with my data.)
I think AccountID is SalesOrder>>Party>>PartyKey>>PartyID.
Quantity may be SalesOrder>>Item>>ItemProduct>>QuantityMeasureUnitCode.
This is helpful for you.
About your second question,
(it is really hard to create an instance. The SalesOrder includes a lot of nodes and hard to understand (for me)).
please try following some codes.
var dataSaleOrderItem : elementsof SalesOrder.Item; //for SalesOrder's Item
var saveHeaderData;
var saveItemData;
var saveAccountData;
//You must create SalesOrder Instance first.
saveHeaderData = SalesOrder.Create();
if(saveHeaderData.IsSet()) {
//After SalesOrderRoot is created, you can input some values(fields like node[0,1]) because these fields already created too.
saveHeaderData.Party.GetFirst().RoleCode = "1";
saveHeaderData.Party.GetFirst().PartyKey.PartyID = "A_Test01";
//Create your input values.
saveAccountData = saveHeaderData.Party.Create();
//And you can input fields like node[0,n] with some loop
dataSaleOrderItem.ID = "10";
//To Create SalesOrder Item
saveItemData = saveHeaderData.Item.Create(dataSaleOrderItem);
if(saveItemData.IsSet()) {
saveItemData.ItemProduct.ProductKey.ProductID = "P_Test01";
saveItemData.ItemProduct.QuantityMeasureUnitCode = "EA";
//To Create SalesOrder Item Product
saveItemData.ItemProduct.Create();
I think this is helpful for you.
Best Regard,
Sue Chal.
Similar Messages
-
Bapi-salesorder creation error in creating document
hai friends..
iam doing creation of sales order using bapi .-structures..
but error in creating doucment ....
can u send me some example .. abt sales order .creation ..
once u check my code ...
DATA: BEGIN OF HEADER OCCURS 0,
VBELN LIKE BAPIVBELN-VBELN,
AUART LIKE VBAK-AUART,
VKORG LIKE VBAK-VKORG,
VTWEG LIKE VBAK-VTWEG ,
SPART LIKE VBAK-SPART,
VKBUR LIKE VBAK-VKBUR,
KUNNR LIKE BAPIPARNR-PARTN_NUMB ,"vbak-kunnr,
END OF HEADER.
DATA: BEGIN OF ITEM OCCURS 0,
VBELN LIKE BAPIVBELN-VBELN,
POSNR LIKE BAPISDITM-ITM_NUMBER ,"vbap-posnr,
MATNR LIKE VBAP-MATNR,
NETWR LIKE VBAP-NETWR,
KWMENGE LIKE VBAP-KWMENG,
WERKS LIKE VBAP-WERKS,
NETPR LIKE VBAP-NETPR,
END OF ITEM.
DATA: ORDER_HEADER_IN LIKE BAPISDHD1,
ORDER_HEADER_INX LIKE BAPISDHD1X.
DATA: ITAB_HEAD likE order_header_in,
ITAB_HEADX likE ORDER_HEADER_INX.
DATA: ITAB_ITEM TYPE STANDARD TABLE OF BAPISDITM WITH HEADER LINE,
ITAB_ITEMX TYPE STANDARD TABLE OF BAPISDITMX WITH HEADER LINE.
DATA: KUST TYPE STANDARD TABLE OF BAPIPARNR WITH HEADER LINE,
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA: VNO LIKE BAPIVBELN-VBELN,
VCNT LIKE VBAP-POSNR.
LOOP AT HEADER.
VCNT = 10.
CLEAR ITAB_HEAD.
ORDER_HEADER_IN-REFOBJTYPE = 'OR'.
ORDER_HEADER_IN-REFOBJKEY = 'OR'.
ORDER_HEADER_IN-REFDOCTYPE = 'OR'.
ORDER_HEADER_IN-DOC_TYPE = HEADER-AUART.
ITAB_HEAD-DOC_TYPE = HEADER-AUART.
ITAB_HEAD-SALES_ORG = HEADER-VKORG.
ITAB_HEAD-DISTR_CHAN = HEADER-VTWEG.
ITAB_HEAD-DIVISION = HEADER-SPART.
ITAB_HEAD-SALES_OFF = HEADER-VKBUR.
KUST-PARTN_NUMB = HEADER-KUNNR.
ITAB_HEADX-DOC_TYPE = 'X'.
ITAB_HEADX-SALES_ORG = 'X'.
ITAB_HEADX-DISTR_CHAN = 'X'.
ITAB_HEADX-DIVISION = 'X'.
ITAB_HEADX-SALES_OFF = 'X'.
LOOP AT ITEM WHERE VBELN = HEADER-VBELN.
REFRESH RETURN.
ITAB_ITEM-ITM_NUMBER = VCNT.
ITAB_ITEM-MATERIAL = ITEM-MATNR.
ITAB_ITEM-NET_WEIGHT = ITEM-KWMENGE.
APPEND ITAB_ITEM.
ITAB_ITEMX-ITM_NUMBER = VCNT.
ITAB_ITEMX-MATERIAL = 'X'.
ITAB_ITEMX-NET_WEIGHT = 'X'.
APPEND ITAB_ITEMX.
VCNT = VCNT + 10 .
ENDLOOP.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN = SALESORDER
ORDER_HEADER_IN = ITAB_HEAD
ORDER_HEADER_INX = ITAB_HEADX
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
TESTRUN =
CONVERT = ' '
IMPORTING
SALESDOCUMENT = VNO
TABLES
RETURN = RETURN
ORDER_ITEMS_IN = ITAB_ITEM
ORDER_ITEMS_INX = ITAB_ITEMX
ORDER_PARTNERS = KUST.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
IMPORTING
RETURN = RETURN.
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.
ENDIF.
WRITE: / ' Sales Order NO IS: ', VNO.
WRITE: / SPACE.
CLEAR VNO.
WRITE SY-ULINE.
ENDLOOP.
my HEader is 123 OR 1000 30 10 SATYA.
ITem 2 IS 123 10 HAI 15
once u check it ......Hi Satya,
just check this
REPORT Z_STANDARD_SALES_ORDER no standard page heading.
DATA DECLARATION
CONSTANTS : C_X VALUE 'X'.
Structures to hold Sales order header data
DATA : HEADER LIKE BAPISDHD1," OCCURS 0 WITH HEADER LINE,
HEADERX LIKE BAPISDHD1X." OCCURS 0 WITH HEADER LINE.
Internal Tables to hold Sales order ITEM DATA
DATA : ITEM LIKE BAPISDITM OCCURS 0 WITH HEADER LINE,
ITEMX LIKE BAPISDITMX OCCURS 0 WITH HEADER LINE.
Internal Tables to hold Partners ITEM DATA
DATA : PART LIKE BAPIPARNR OCCURS 0 WITH HEADER LINE.
Internal Tables to hold Partners SCHEDULE DATA
DATA: SCHEDULE LIKE BAPISCHDL OCCURS 0 WITH HEADER LINE,
SCHEDULEX LIKE BAPISCHDLX OCCURS 0 WITH HEADER LINE.
Internal table to hold messages from BAPI call
DATA: RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA W_MSG(150).
*DATA: begin of wa_MESSAGE,
message(150),
end of wa_message.
*DATA: itab_msg like table of wa_message with header line.
Data: Begin of Record occurs 0,
Control type i,
DOC_TYPE like HEADER-DOC_TYPE,
SALES_ORG like HEADER-SALES_ORG,
DISTR_CHAN like HEADER-SALES_ORG,
DIVISION like HEADER-DIVISION,
PURCH_NO_C like HEADER-PURCH_NO_C,
PARTN_NUMB like PART-PARTN_NUMB ,
PARTN_ROLE like PART-PARTN_ROLE ,
ITM_NUMBER like ITEM-ITM_NUMBER,
MATERIAL like ITEM-MATERIAL,
TARGET_QTY like item-TARGET_QTY,
REQ_QTY LIKE BAPISCHDL-REQ_QTY,
TARGET_QU like item-TARGET_QU,
PLANT like ITEM-PLANT,
PMNTTRMS like header-PMNTTRMS,
End of record.
data: itab like ALSMEX_TABLINE occurs 0,
wa like ALSMEX_TABLINE.
data: SO like BAPIVBELN-VBELN.
Selection Screen
selection-screen begin of block b1 with frame title text-001.
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
selection-screen end of block b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM GET_FILE USING P_FILE.
Start of Selection
start-of-selection.
DATA: xl type string.
xl = '*.xls'.
IF not P_FILE CP xl.
Message 'Wrong input file format' type 'E'.
ENDIF.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 13
I_END_ROW = 3000
TABLES
INTERN = itab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DATA POPULATION
loop at itab into wa.
if wa-col = '0001'.
record-Control = wa-value.
elseif wa-col = '0002'.
record-DOC_TYPE = wa-value.
elseif wa-col = '0003'.
record-SALES_ORG = wa-value.
elseif wa-col = '0004'.
record-DISTR_CHAN = wa-value.
elseif wa-col = '0005'.
record-DIVISION = wa-value.
elseif wa-col = '0006'.
record-PURCH_NO_C = wa-value.
elseif wa-col = '0007'.
record-PARTN_NUMB = wa-value.
elseif wa-col = '0008'.
record-PARTN_ROLE = wa-value.
elseif wa-col = '0009'.
record-PMNTTRMS = wa-value.
elseif wa-col = '0010'.
record-ITM_NUMBER = wa-value.
elseif wa-col = '0011'.
record-MATERIAL = wa-value.
elseif wa-col = '0012'.
record-REQ_QTY = wa-value.
elseif wa-col = '0013'.
record-TARGET_QU = wa-value.
elseif wa-col = '0014'.
record-PLANT = wa-value.
endif.
AT END OF row.
APPEND record.
CLEAR: wa, record.
ENDAT.
endloop.
DATA: tot_lines type i,
tot_po type i,
index type i.
describe table record lines tot_lines.
read table record index tot_lines.
tot_po = record-control.
DO tot_po times.
index = index + 1.
clear: HEADER,HEADERX,ITEM[],ITEMX[],RETURN,RETURN[],SCHEDULE[],SCHEDULEX[], PART[],PART.
refresh: ITEM[],ITEMX[],RETURN[],SCHEDULE[],SCHEDULEX[],PART[] .
POPULATE HEADER FLAG.
HEADERX-UPDATEFLAG = c_x.
HEADERX-doc_type = c_x.
HEADERX-SALES_ORG = c_x.
HEADERX-DISTR_CHAN = c_x.
HEADERX-DIVISION = c_x.
HEADERX-PURCH_NO_C = c_X.
HEADERX-PMNTTRMS = c_X.
loop at record where control = index.
POPULATE HEADER DATA FOR PO
HEADER-DOC_TYPE = record-DOC_TYPE.
HEADER-SALES_ORG = record-SALES_ORG.
HEADER-DISTR_CHAN = record-DISTR_CHAN.
HEADER-DIVISION = record-DIVISION.
HEADER-PURCH_NO_C = record-PURCH_NO_C.
HEADER-PMNTTRMS = record-PMNTTRMS.
*POPULATE ITEM DATA.
ITEM-ITM_NUMBER = record-ITM_NUMBER.
ITEM-MATERIAL = record-material.
ITEM-TARGET_QTY = record-TARGET_QTY.
ITEM-TARGET_QU = record-TARGET_QU.
ITEM-PLANT = record-PLANT .
APPEND ITEM.
*POPULATE ITEM FLAG TABLE
ITEMX-ITM_NUMBER = record-ITM_NUMBER.
ITEMX-UPDATEFLAG = C_X.
ITEMX-TARGET_QTY = C_X.
ITEMX-PLANT = C_X .
ITEMX-MATERIAL = C_X .
ITEMX-TARGET_QU = C_X .
APPEND ITEMX.
*POPULATE SCHEDULE TABLE
SCHEDULE-ITM_NUMBER = RECORD-ITM_NUMBER.
SCHEDULE-REQ_QTY = RECORD-REQ_QTY.
APPEND SCHEDULE.
*POPULATE SCHEDULE TABLE
SCHEDULEX-ITM_NUMBER = RECORD-ITM_NUMBER.
SCHEDULEX-REQ_QTY = C_X.
APPEND SCHEDULEX.
endloop.
*POPULATE PARTNER TABLE
PART-PARTN_NUMB = record-PARTN_NUMB.
PART-PARTN_ROLE = record-PARTN_ROLE.
APPEND PART.
*BAPI CALL
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = HEADER
ORDER_HEADER_INX = HEADERX
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
TESTRUN =
CONVERT = ' '
IMPORTING
SALESDOCUMENT = SO
TABLES
RETURN = RETURN
ORDER_ITEMS_IN = ITEM
ORDER_ITEMS_INX = ITEMX
ORDER_PARTNERS = PART
ORDER_SCHEDULES_IN = SCHEDULE
ORDER_SCHEDULES_INX = SCHEDULEX
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 =
loop at return where type = 'E' and ID NE 'MEPO' and ID NE 'BAPI'.
WRITE:/ Return-message.
endloop.
*Confirm the document creation by calling database COMMIT
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
*Messages
loop at return where type = 'S' and number ne '233'.
WRITE:/ Return-message.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = return-ID
LANG = SY-LANGU
NO = return-NUMBER
IMPORTING
MSG = W_MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE W_MSG.
itab_msg-message = w_msg.
append itab_msg.
clear: W_MSG.
ENDLOOP.
enddo.
-->P_W_FILE text
FORM GET_FILE USING P_W_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
CHANGING
FILE_NAME = P_W_FILE
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.
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. "GET_FILE
Regards,
Sachin -
hi,
i am trying to create a salesorder in r/3 from website using jco. can any one tell me the sites where i can get the stuff regarding this.
thanking u in advance.
regards,
mounika.hi,
You need to call the BAPI - BAPI_SALESORDER_CREATEFROMDAT2
Here is a simple example...
import com.sap.mw.jco.*;
public class Bapi1 extends Object{
JCO.Client mConnection;
JCO.Repository mRepository;
public Bapi1(){
try{
mConnection = JCO.createClient(client,userid,password,
lang,host,system no );
mConnection.connect();
mRepository = new JCO.Repository("MyRepos", mConnection);
}catch(Exception ex){
ex.printStackTrace();
System.exit(1);
JCO.Function function = null;
JCO.Table codes = null;
try{
function = this.createFunction("BAPI_SALESORDER_CREATEFROMDAT2");
if (function == null){
System.out.println("BAPI_SALESORDER_CREATEFROMDAT2" + "not found in SAP");
System.exit(1);
//here you need to pass the paramters also.........
//pass all the parameters needed for the creation of the sales order in JCO.Structure.
mConnection.execute(function);
JCO.Structure returnStructure = function.getExportParameterList().getStructure("RETURN");
if (!(returnStructure.getString("TYPE").equals("")||
returnStructure.getString("TYPE").equals("S"))){
System.out.println(returnStructure.getString("MESSAGE"));
System.exit(1);
}catch(Exception ex){
ex.printStackTrace();
System.exit(1);
mConnection.disconnect();
public JCO.Function createFunction(String name) throws Exception{
try{
IFunctionTemplate ft = mRepository.getFunctionTemplate(name.toUpperCase());
if (ft == null)
return null;
return ft.getFunction();
}catch(Exception ex){
throw new Exception("Probelm retrieving JCO.Fucntion object");
public static void main(String agrs[]){
Bapi1 app = new Bapi1();
Hope you will find it useful
Regards,
Richa. -
LSMW Upload SalesOrder Creation:problem in assigning Partner type SH and SP
Hi
I'm trying to upload sales order creation data using LSMW -BAPI Method
Business Object : BUS2032
Method : CREATEFROMDAT2
Message type : SALESORDER_CREATEFROMDAT2
Basic Type : SALESORDER_CREATEFROMDAT202
and I'm passing the following header data
Sales Order Type, Sales organisation, Distribution Channel, Division, Sold To Party, Ship To party,
Purchase order number, PO Date, Requested delivery date, Order Reason, Payment terms, Incoterms part1, Incoterms part2, Document Currency.
and the following item data
MATERIAL NUMBER
Order quantity
Storage Location
Item Category
Item Usage
Reason for Rejection
Plant
Net Weight
Gross Weight
Condition Type
Amount
Internal Order Number
I'm assigning the header data to structure <b>E1BPSDHD1</b>
and Item data to <b>E1BPSDITM,E1BPSDITM1</b>
and Partner data to structure <b>E1BPPARNR</b>.
When I am assigning Partner data to the structure E1BPPARNR, I want to assign both <b>sold-to-party</b> and <b>ship-to-party</b> ,(because I have two source fields of this type) but there is only target field related to the partner data , here I am assigning <b>partner type as SP</b> and <b>partner number as sold-to-party</b>, still there is an unassigned field ship-to-party, for this field I am unable to find a relevant target field so please help me how can I assing These two flat file fields <b>(sold-to-party,ship-to-party)</b>
Looking for further more information : if there is many sold-to-party's and many ship-to-party's how can I go that in this situation i.e maintaining Many to Many relationship using LSMW tool
Thanks in advance
regards
RajasekharHere is what you have to do.
In field mapping, double click on the field PARTN_NUMB (or any field of that structure) in change mode. This opens up the code editor. There just enter the following code. I am assuming you are doing only these fields. But if you are mapping more fields of this structure, you have to map them here.
E1BPPARNR-PARTN_NUMB = ORDERHEADER-KUNAG.
E1BPPARNR-PARTN_ROLE = 'AG'.
E1BPPARNR-ITM_NUMBER = '000000'.
*-- add more field mappings here, if needed
TRANSFER_RECORD.
*-- Now pass the Ship-to record
E1BPPARNR-PARTN_NUMB = ORDERHEADER-KUNWE.
E1BPPARNR-PARTN_ROLE = 'WE'.
E1BPPARNR-ITM_NUMBER = '000000'.
*-- Add more partners if needed by copying the above code.
Remember, you need to do TRANSFER_RECORD only that many times as you have the partners. There will be one 'TRANSFER_RECORD' at the end of this structure, so keep that in mind.
Srinivas -
Hi,
I am a new to the ALE scenario.
In the current project, whenever a Purchase Order is created, a coresspponding sales order is automatically generated using ALE. My questions are:
1) Is an Idoc generated in this scenario to create the sales order?
2) If yes, then from where can I get the message type, idoc type and the function module used, if the Idoc has already been archived.
3) If the salesorder is created without an Idoc (in this ALE scenario) then how can I find out which program is being used to create the sales order.
Any help would be greatly appreciated.
Thanks in advance.
Mickhi,
http://****************/Tutorials/ALE/ALEMainPage.htm
dis is the link where u can find d solution to ur problem,if u find it useful .
regards,
ric.s -
Salesorder creation through webpage
Dear SDN's,
here i got the requirement where sales orders get automatically get created based on the input provided from front end i.e through webpage where Enduser enters the details such as CustomerName,Address,Material,QTYand salesorder number which we specify explicitly
after clicking SAVE button in the webpage in the backend i.e SAP system should get updated.
Help in this regards how to proceed further
Regards
jaipal reddyPlease note that this forum is dedicated to development and deployment of .Net applications that connect and interact with BusinessObjects Enterprise, BusinessObjects Edge, or Crystal Reports Server. This includes the development of applications using the BusinessObjects Enterprise, Report Application Server, Report Engine, and Web Services SDKs.
SAP product support is done in SAP forums. Please reports to the correct forum.
Ludek -
Hi,
Iam creating sale order through function module using BAPI_SALESORDER_CREATEFROMDAT2 , After creating salesorder I checked that salesorder in VA03 and check ' incompletion log' the screen show CONFIGURATION. What could be the reason Can any body help me.
RegardsHi,
Please find the bellow code which may help you in resolving the issue. may be you are missing some parameters code will help in checking them.
<Garbled code removed by moderator>
Regards,
Goutam Kolluru.
Edited by: goutam kolluru on Feb 6, 2012 5:43 AM
Edited by: goutam kolluru on Feb 6, 2012 5:45 AM
Edited by: Vinod Kumar on Feb 6, 2012 10:24 AM -
Error while salesorder creation using bapi
Hi All
while testing the bapi salesordercreatefromdat2 in se37 ,its working.
but in reports i m passing same data with this bapi ,its not working.
its showing error message like:sales document type OR is not defined.
so where is the problem.Hi
Check with the value of import parameter ORDER_HEADER_IN-DOC_TYPE you are passing to function module BAPI_SALESORDER_CREATEFROMDAT2.
Regards
Srilaxmi -
Hi All,
I have a requirement as described below.
while creating a sales order, if u go to header level and then partners tab in that, u would see a table like structure where u have sold-to-party, ship to party, bill to party, and payer.
My requirement is that i need to select ship-to-party and press details button then i want to change the details there.everything is working fine at the moment.
but i have a doubt that the order of ship to party, sold to party , payer and bill-to-party wouldnt be same all the time.now the ship-to-party is in 4th position.so, in BDC recording it is GVS_TC_DATA-SELKZ(04), i am setiing that to 'X' and iam going ahead.what if the position changes?
is there anyway that i can trace the ship-to-party position whether it is in position 1 or 2 or 3 or 4.
could some one help me with this.
Thanks in advance,
sureshUse the function module VIEW_KUAGV. Pass soldto details and document details being created in inport parameter comwa and pass shipto number in WE_INPUT and fif_no_dialog = 'X',no_address_data = 'X'.
This gives the exact structure of how the partners will appear when you create a sales order in table xvbpa. You can find the positions of partners from the table.
Award points if answer is helpfull. -
Hi Gurus,
Can you please provide IDOC type to create sales order . I have checked with orderise01 to 05 but it couldn't match the fields,Can any body provide correct Idoc type?
Thank you,
Usha.GHi Usha,
Check out ORDERS0<n>, where <n> between 1 and 5 (don't think there's a higher version than 5, but didn't check). This works fine for creating sales orders.
Cheers, harald -
IDOC fialed while creation of sales oredr
Hi Experts
We are creating sales order through IDOC and for creating SO we are using BAPI_SALESORDER_CREATEFROMDAT2 but idoc is getting failed with error
' Internal error: 10 , 000010 , NOT_ALL_INPUT_DATA_PROCESSED '
Not able to understand when this error comes. Please letme know what is the issue?
Thanks,
AmitHi,
See this [Thread|Salesorder creation through BAPI;
Also.
[Link|http://searchsap.techtarget.com/expert/KnowledgebaseAnswer/0,289625,sid21_gci1027244,00.html]
Rhea. -
Userexit in BAPI sales order creation
HI all,
My requirement is one SERIALNUMBER field add BAPI salesorder creation.
That field not existed in satndard BAPI structures.BAPI input XML file.
Salesorder>extras(menu)>Technical object->serialmumber[RIPW0SERNR).
please give any enhancement serial number BAPI sales order creation.
Thanks.
Edited by: sreddy GPs on Sep 23, 2008 5:59 AMHello,
Whatever the Structure that you are refering to in the BAPI for Sales Order Creation, use an Append Structure to add the SERIALNUMBER field to the existing Standard BAPI Structure.
For your information, the following are the BAPIs that can be used for Sales Order Creation.
BAPI_SALESORDER_CREATEFROMDAT1
BAPI_SALESORDER_CREATEFROMDAT2
BAPI_SALESORDER_CREATEFROMDATA
BAPI_SALESORDER_CREATEBOS
Hope it would serve your purpose.
Thanks and Regards,
Venkat Phani Prasad Konduri -
Quantity update into sales order using BAPI_SALESORDER_CREATEFROMDAT2
Hi All,
I am able to create a sales order using the BAPI "BAPI_SALESORDER_CREATEFROMDAT2".
But even after assinging the Target_quntity and the Target_quantity_units, the values are not getting updated into the Sales order, but the sales order gets created .
Did anyone of you had a similare problem, how was it solved.
cold some one please help me out on this.
RegardsHi
I had used below code (using <b>BAPI_SALESORDER_CREATEFROMDAT1</b>)..but never faced any problem.. you can try the same...
Regards,
Raj
REPORT z_sd_salesorder_create
NO STANDARD PAGE HEADING
LINE-SIZE 150
MESSAGE-ID zz.
S T R U C T U R E D E C L A R A T I O N S *
TYPES: BEGIN OF x_ppl,
ppl_order(18), " ppl Orderno
auart(4), " Sales Doc Type
vkorg(4), " Sales Organization
vtweg(2), " Distribution Channel
spart(2), " Division
div(3), " Division
kunnr(10), " Sold-to Party
date(10), " Doc Dt
matnr(18), " Item Matnr#
uom(3), " UOM
qty(15), " Qty
kschl(4), " Pricing condiiton type
kbetr(11), " Rate
END OF x_ppl.
TYPES: BEGIN OF x_file,
loc(30), " Location
div(3), " Division
ppl_order(18), " ppl Orderno
kunnr(10), " Sold-to Party
date(10), " Doc Dt
matnr(20), " Item Matnr#
qty(15), " Qty
uom(3), " UOM
kbetr(11), " Rate
discount(5), " Discount
END OF x_file.
TYPES: BEGIN OF x_output,
ppl_order(18), " ppl Orderno
mesg(130), " Mesg Success/Error
END OF x_output.
TYPES: BEGIN OF x_werks,
name2(30), " Location
werks TYPE werks_ext, " Plant
END OF x_werks.
TYPES: BEGIN OF x_info,
vkorg TYPE vkorg , " Sales org
vtweg TYPE vtweg, " Dist channel
werks TYPE werks_ext," Plant
spart TYPE spart, " Storage Loc
END OF x_info.
TYPES: BEGIN OF x_material,
ppl_prdid(20), " ppl Prd id
matnr TYPE matnr, " Material (SAP)
END OF x_material.
I N T E R N A L T A B L E D E C L A R A T I O N S *
DATA: it_file TYPE STANDARD TABLE OF x_file WITH HEADER LINE." File Data
DATA: it_data TYPE STANDARD TABLE OF x_ppl WITH HEADER LINE." ppl File
DATA: it_out TYPE STANDARD TABLE OF x_output WITH HEADER LINE. " Outcome
DATA: it_werks TYPE STANDARD TABLE OF x_werks WITH HEADER LINE. " Plant
DATA: it_info TYPE STANDARD TABLE OF x_info WITH HEADER LINE. " Othr Info
DATA: it_matnr TYPE STANDARD TABLE OF x_material WITH HEADER LINE. " Material Info
DATA: it_item TYPE STANDARD TABLE OF bapiitemin WITH HEADER LINE. "Order Itm data
DATA: it_partner TYPE STANDARD TABLE OF bapipartnr WITH HEADER LINE. "Order Partner data
V A R I A B L E S D E C L A R A T I O N S *
DATA : v_correct TYPE i,
v_error TYPE i,
v_total TYPE i,
v_return LIKE bapireturn1,
v_index LIKE sy-tabix.
*- Return values
DATA: it_orderh TYPE bapisdhead, "Order Hdr data
order TYPE bapivbeln-vbeln,
soldto TYPE bapisoldto,
shipto TYPE bapishipto,
return TYPE bapireturn1.
DATA: hdate TYPE sy-datum.
U S E R I N P U T S S C R E E N *
SELECTION-SCREEN: BEGIN OF BLOCK blk01 WITH FRAME TITLE text-t01.
PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY. " File name
SELECTION-SCREEN END OF BLOCK blk01.
S E L E C T I O N S C R E E N *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM get_file.
S t a r t o f S e l e c t i o n *
START-OF-SELECTION.
PERFORM get_upload.
PERFORM validate_data. " Validate the data
PERFORM data_swap. " Prepare the data for processing
IF NOT it_data[] IS INITIAL.
PERFORM get_update. " Create SalesOrders
ELSE.
MESSAGE i001(zz) WITH text-001.
STOP.
ENDIF.
E n d o f S e l e c t i o n *
END-OF-SELECTION.
IF NOT it_data[] IS INITIAL.
PERFORM get_write.
ENDIF.
*& Form get_file
Get File name
FORM get_file .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = syst-repid
mask = '*'
CHANGING
file_name = p_file
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
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. " get_file
*& Form get_upload
to upload the file
FORM get_upload .
DATA l_file TYPE string.
CLEAR: it_file, it_file[].
l_file = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = it_file
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.
ELSEIF sy-subrc = 0.
SORT it_file BY loc ppl_order.
ENDIF.
ENDFORM. " get_upload
*& Form get_update
Creating mapping Data in Z table
FORM get_update .
DATA: l_itemno(2) TYPE n,
l_partner TYPE parvw,
l_kunnr TYPE kunnr,
l_matnr TYPE matnr,
l_mesg TYPE string,
l_kbetr TYPE p DECIMALS 2.
DATA: l_in_qty LIKE vbap-zmeng,
l_meins LIKE mara-meins,
l_qty LIKE vbap-zmeng.
CLEAR: v_correct, v_error, v_total.
SORT it_data BY ppl_order.
LOOP AT it_data.
CLEAR v_index.
v_index = sy-tabix.
*- New SalesOrder
AT NEW ppl_order.
READ TABLE it_data INDEX v_index.
CLEAR: it_orderh, it_item, it_partner,
order, soldto, shipto, return,
it_item[], it_partner[].
v_total = v_total + 1. "Increment Total SalesOrders counter
CLEAR l_itemno.
l_itemno = '10'.
*- Covert date fields into Internal format
CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'
EXPORTING
datum = it_data-date
dtype = 'DATS'
IMPORTING
idate = it_data-date.
*- Populate SalesOrder header data.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
input = it_data-auart
IMPORTING
output = it_data-auart.
it_orderh-doc_type = it_data-auart.
it_orderh-sales_org = it_data-vkorg.
it_orderh-distr_chan = it_data-vtweg.
it_orderh-division = it_data-spart.
it_orderh-purch_no = 'DEPOT'.
it_orderh-price_date = it_data-date. "Doc Dt
it_orderh-req_date_h = it_data-date. "Del.Dt
it_orderh-purch_no_s = it_data-ppl_order.
*- Partner data
CLEAR: l_partner, l_kunnr.
*- Convert Partner type into internal format
l_partner = 'SP'. "SoldTo Party
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
input = l_partner
IMPORTING
output = l_partner.
*- Convert Customer into internal format
l_kunnr = it_data-kunnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = l_kunnr
IMPORTING
output = l_kunnr.
it_partner-partn_role = l_partner.
it_partner-partn_numb = l_kunnr.
APPEND it_partner.
CLEAR it_partner.
ENDAT.
*- Item data
it_item-itm_number = l_itemno.
*- Convert material number into internal format
CLEAR l_matnr.
l_matnr = it_data-matnr.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = l_matnr
IMPORTING
output = l_matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
it_item-material = l_matnr.
*- Call FM to get new qty based on SAP UOM
CLEAR: l_meins, l_qty, l_in_qty.
l_in_qty = it_data-qty.
CALL FUNCTION 'Z_GET_QTY_FROM_UOM'
EXPORTING
matnr = it_item-material
in_meins = it_data-uom
in_qty = l_in_qty
IMPORTING
out_meins = l_meins
quantity = l_qty.
IF sy-subrc = 0.
it_data-qty = l_qty.
it_data-uom = l_meins.
ENDIF.
it_data-qty = it_data-qty * 1000.
it_item-req_qty = it_data-qty.
it_item-sales_unit = it_data-uom.
it_item-req_date = it_data-date.
*- Pricing data
it_item-cond_type = it_data-kschl. "Pricing condition
CLEAR l_kbetr.
l_kbetr = it_data-kbetr / 10. "Price (Rate)
it_item-cond_value = l_kbetr.
APPEND it_item.
CLEAR it_item.
*- Increment Item counter.
l_itemno = l_itemno + 10.
*- At end of SalesOrder
AT END OF ppl_order.
READ TABLE it_data INDEX v_index.
*- Call the BAPI for SalesOrder creation
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'
EXPORTING
order_header_in = it_orderh
IMPORTING
salesdocument = order
sold_to_party = soldto
ship_to_party = shipto
return = return
TABLES
order_items_in = it_item
order_partners = it_partner.
IF sy-subrc = 0.
COMMIT WORK.
ENDIF.
v_return = return+0(1).
IF v_return = 'E'.
v_error = v_error + 1.
CLEAR l_mesg.
l_mesg = return.
CONDENSE l_mesg.
ELSE.
v_correct = v_correct + 1.
CLEAR l_mesg.
CONCATENATE 'Salesorder'(007) order 'successfully created.'(008)
INTO l_mesg SEPARATED BY space.
CONDENSE l_mesg.
ENDIF.
*- Populate the output table
CLEAR it_out.
it_out-ppl_order = it_data-ppl_order.
it_out-mesg = l_mesg.
APPEND it_out.
CLEAR it_out.
ENDAT.
ENDLOOP.
ENDFORM. " get_update
*& Form get_write
Write the results
FORM get_write .
WRITE:/ 'Total Number of Records :'(002), v_total COLOR 1.
WRITE:/ 'Total Correct Records :'(003), v_correct COLOR 3.
WRITE:/ 'Total Error Records :'(004), v_error COLOR 6.
SKIP 3.
IF NOT it_out[] IS INITIAL.
WRITE:/5 'ppl Order #'(005),
28 'Message'(006).
ENDIF.
SKIP 1.
LOOP AT it_out.
WRITE:/5 it_out-ppl_order,
28 it_out-mesg.
ENDLOOP.
ENDFORM. " get_write
*& Form validate_data
Validate the data
FORM validate_data .
DATA: l_bstkde TYPE bstkd_e.
LOOP AT it_file.
SELECT bstkd_e INTO l_bstkde
UP TO 1 ROWS
FROM vbkd
WHERE bstkd_e = it_file-ppl_order.
ENDSELECT.
IF sy-subrc = 0. " This ppl Order is already been created in SAP, so delete record
DELETE it_file.
ENDIF.
ENDLOOP.
SORT it_file BY ppl_order.
ENDFORM. " validate_data
*& Form data_swap
Prepare the data for processing
FORM data_swap .
CLEAR: it_werks, it_info, it_matnr, it_data,
it_werks[], it_info[], it_matnr[], it_data[].
IF NOT it_file[] IS INITIAL.
*- Get the plant from location
SELECT name2
werks
INTO CORRESPONDING FIELDS OF TABLE it_werks
FROM t001w FOR ALL ENTRIES IN it_file
WHERE name2 = it_file-loc.
IF sy-subrc = 0.
SORT it_werks BY name2 werks.
*- Get the Sales Org, Division and Distribution Channel
IF NOT it_werks[] IS INITIAL.
SELECT vkorg
vtweg
werks
INTO CORRESPONDING FIELDS OF TABLE it_info
FROM tvkwz FOR ALL ENTRIES IN it_werks
WHERE werks = it_werks-werks.
IF sy-subrc = 0.
LOOP AT it_info.
it_info-spart = '99'.
MODIFY it_info INDEX sy-tabix.
ENDLOOP.
SORT it_info BY vkorg vtweg werks.
ENDIF.
ENDIF.
ENDIF.
*- Get material from ppl material
SELECT ppl_prdid
matnr
FROM zppl_master
INTO TABLE it_matnr FOR ALL ENTRIES IN it_file
WHERE ppl_prdid = it_file-matnr.
IF sy-subrc = 0.
SORT it_matnr BY ppl_prdid matnr.
ENDIF.
ENDIF.
*- Update the data in it_data
LOOP AT it_file.
CLEAR it_data.
it_data-auart = 'OR'.
it_data-auart = 'OR'. " CHANGED BY Jo ON 3103005
READ TABLE it_werks WITH KEY name2 = it_file-loc BINARY SEARCH.
IF sy-subrc = 0.
READ TABLE it_info WITH KEY werks = it_werks-werks BINARY SEARCH.
IF sy-subrc = 0.
it_data-vkorg = it_info-vkorg.
it_data-vtweg = it_info-vtweg.
ENDIF.
ENDIF.
*- Material
READ TABLE it_matnr WITH KEY ppl_prdid = it_file-matnr BINARY SEARCH.
IF sy-subrc = 0.
it_data-matnr = it_matnr-matnr.
ENDIF.
it_data-ppl_order = it_file-ppl_order.
it_data-date = it_file-date.
CONCATENATE it_file-kunnr it_file-loc+1(2) INTO it_data-kunnr.
it_data-qty = it_file-qty.
it_data-uom = it_file-uom.
it_data-kbetr = it_file-kbetr.
*- Pricing condition
it_data-kschl = 'PR00'.
CASE it_file-div.
WHEN 'BRN'.
it_data-div = '04'.
WHEN 'GEN'.
it_data-div = '03'.
WHEN 'IVF'.
it_data-div = '02'.
WHEN 'OPH'.
it_data-div = '01'.
ENDCASE.
it_data-spart = it_data-div.
APPEND it_data.
CLEAR it_data.
ENDLOOP.
ENDFORM. " data_swap -
Find header-text in VA01 before save
In a salesorder creation (VA01) I have inserted a text in the header.
Goto - header - text.
Before saving the document, I need to see if there is any text - and what the text is.
The tables are not updated, so I can't make a look-up there.
Any suggestions?
Br
LarsHi
I found this old post with valuable info from Bianchi, but there was no complete example, so here is one.
I made this solution in a VL01N exit, but it should be quit easy to adjust it to work in VA01, and many other transactions.
* Get the texts
DATA: memory_id(30).
DATA theader LIKE thead.
DATA BEGIN OF catalog OCCURS 50.
INCLUDE STRUCTURE tcatalog.
DATA END OF catalog.
* 1. Get catalog of current texts -
* the catalog links the text ids (TDID) to an internal id for the temporary texts
REFRESH catalog.
IMPORT catalog FROM MEMORY ID 'SAPLSTXD'.
IF sy-subrc > 0.
CLEAR catalog. REFRESH catalog.
ENDIF.
* Find internal catalog id for text Z022
LOOP AT catalog WHERE tdobject = 'VBBK'
AND tdid = 'Z022'.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
* Build memory id for the selected text id (Z022)
CONCATENATE 'SAPLSTXD' catalog-id INTO memory_id.
* Import data from memory
IMPORT thead TO theader
tline TO it_lines
FROM MEMORY ID memory_id.
* I didn't bother to investigate the following routine - it just seems to be working
PERFORM read_reference_lines(saplstxd)
TABLES it_lines
USING sy-mandt
theader.
* IT_LINES now contains the temporay text in same format as
* if it was read from database with function module READ_TEXT
LOOP AT it_lines ASSIGNING <fs_lines>.
CASE sy-tabix.
WHEN 1.
g_tline_z022_1 = <fs_lines>.
WHEN 2.
g_tline_z022_2 = <fs_lines>.
WHEN 3.
g_tline_z022_3 = <fs_lines>.
WHEN 4.
g_tline_z022_4 = <fs_lines>.
WHEN 5.
g_tline_z022_5 = <fs_lines>.
WHEN OTHERS.
EXIT.
ENDCASE.
ENDLOOP.
ENDIF.
Message was edited by: Thomas Madsen Nielsen
PS. This example will only work in create mode (VL01N). In Change mode VL02N you need in some cases to read the data from database with READ_TEXT. -
hi ,
i transfered legacy data to sap system using bapi.
for that i used salesorder creation bapi.
'BAPI_SALESORDER_CREATEFROMDAT2'.
it is uploading my header data and item data .
even it set the values correctly.
but the above rfc not creating saledocument.
where i did mistake pls rectify my problem.hi michel i agree with u. i called 'bapi_transction_commit' first
after than i called bapi_saleorder_createformdat2.
i checked in debugging modein that function module.
it gives sy-subrc 4 for the below statement
fbgenmac 'BAPI_SALESORDER_CREATEFROMDAT2'.
how i will rectify this problem.
do u want the code.
i will send my code.
Edited by: kartik p on Sep 22, 2008 5:00 PM
Maybe you are looking for
-
Create a structure type at runtime
Hi friends, is it possible to create a local structure type dynamically(at run time).My situation is as follows : The user gives a period of time - for Example from "05.03.2009" to "04.03.2010" Depending on the number of months between the period of
-
The "Library Albums" component (with star ratings etc.) does not appear on my Library Inspector tab. I downloaded A3 about 3 weeks ago, and it has never appeared. Am I missing something or misreading the documentation?
-
Drill down report is showing popup even though it's disable in column properties
Hello, I am facing an functionality issue where I have crated Summary to drill down report. Summary is chart and drill down is table view and I am using OBIEE Action link here. Now I have disabled the Popup in column properties so when user click th
-
How to install Mobile 7.1 client in a PDA.
Hi all, we have developed a sample application on PDA and tested in emulator. It worked fine. We have to deploy the application (.sda files) tro PPC 2003 device. For that we have to install Mobile client. What all files are reuired to install Mobile
-
Is it possible to open our application at a specified time ?
I want to do an application that auto Launches itself at a specified time and do its task. For example Anti Virus applications in Windows will launch every day automatically at a specified time given by the user and cleans the system. I searched full