Deleting Sales Order Details using BAPI_SALESORDER_CHANGE And Reinserting
Hi All,
I need to <b>change a Sales Order</b> in such a way that I would <b>delete all the existing Line Items</b> of that SO And <b>then reinsert new Line Items</b> as generally is the practice of saving a document.(Update Header-Delete Old Item Entries-Reinsert New Present Entries).
I coded a small test program in ABAP using the <b>BAPI_SALESORDER_GETLIST And BAPI_SALESORDER_CHANGE</b>.
In order to affect the Qty I have to update the Schedule Parameter also of the BAPI_SALESORDER_CHANGE Function.But this causes a new entry in VBEP.
eg:
<b>Before BAPI Calls</b>
SO-Number:9001
Header:9001,etc......
Detail:ItemNo=10,Material=xyz,TargetQty=100,etc..
Scedule:ItemNo=10,Scheduleline=1,Req_Qty=100,etc...
I coded the program such that
1.I <b>Get the List of Items</b> using BAPI_SALESORDER_GETLIST.
2.Call the <b>BAPI_SALESORDER_CHANGE</b> filling appropraite values in Parameters <b>with UpdateFlag = 'D'</b>
3.<b>Insert new values</b> in OrderItems And Schedule Parameters
say:
Detail:ItemNo=10,Material=xyz,TargetQty=25,etc..
Scedule:ItemNo=10,Scheduleline=1,Req_Qty=25,etc...
4.<b>Call the BAPI_SALESORDER_CHANGE</b> filling appropraite values in Parameters <b>with UpdateFlag = 'I'</b>
<b>The output now becomes.</b>Header:9001,etc......
Detail:ItemNo=10,Material=xyz,TargetQty=100,etc..
Scedule:ItemNo=10,Scheduleline=1,Req_Qty=100,etc...
ItemNo=10,Scheduleline=2,Req_Qty=25,etc...
Now After Commit when I see my <b>SO it shows me a qty of
125</b>.
I am attaching the code for your analysis.
Thanx in advance.
*& Report ZSM_CHANGESALESORDER *
REPORT ZSM_CHANGESALESORDER .
DATA:
For Calling the GetList BAPI Function
CUSTOMER_NUMBER LIKE BAPI1007-CUSTOMER,
SALES_ORGANIZATION LIKE BAPIORDERS-SALES_ORG,
IT_SALES_ORDERS LIKE TABLE OF BAPIORDERS,
WA_SALES_ORDERS LIKE LINE OF IT_SALES_ORDERS,
IT_RETURN LIKE TABLE OF BAPIRETURN,
WA_RETURN LIKE LINE OF IT_RETURN.
For Calling the ChangeFromData BAPI Function
DATA:
SALESDOCUMENT LIKE BAPIVBELN-VBELN,
WA_ORDER_HEADER_IN LIKE BAPISDH1,
WA_ORDER_HEADER_INX LIKE BAPISDH1X,
IT_ORDER_ITEM_IN LIKE TABLE OF BAPISDITM ,
WA_ORDER_ITEM_IN LIKE LINE OF IT_ORDER_ITEM_IN,
IT_ORDER_ITEM_INX LIKE TABLE OF BAPISDITMX ,
WA_ORDER_ITEM_INX LIKE LINE OF IT_ORDER_ITEM_INX,
IT_SCHEDULE_LINES LIKE TABLE OF BAPISCHDL ,
WA_SCHEDULE_LINES LIKE LINE OF IT_SCHEDULE_LINES,
IT_SCHEDULE_LINESX LIKE TABLE OF BAPISCHDLX ,
WA_SCHEDULE_LINESX LIKE LINE OF IT_SCHEDULE_LINESX,
IT_RETURN_CHG LIKE TABLE OF BAPIRET2,
WA_RETURN_CHG LIKE LINE OF IT_RETURN_CHG.
DATA:
IT_RETURN_CT LIKE BAPIRET2.
PARAMETERS:
P_SO LIKE VBAK-VBELN,
P_CUSTNO LIKE BAPI1007-CUSTOMER,
P_SORG LIKE BAPIORDERS-SALES_ORG.
START-OF-SELECTION.
SALESDOCUMENT = P_SO.
CUSTOMER_NUMBER = P_CUSTNO.
SALES_ORGANIZATION = P_SORG.
Retrieve the Existing Sales Order details for that Sales Order.
PERFORM GETREQSODETAILS.
Delete the Existing Sales Order details from that Sales Order.
PERFORM DELETEOLDSODETAILS.
Insert New details for that Sales Order.
PERFORM ADDNEWSODETAILS.
END-OF-SELECTION.
PERFORM COMMITTRANS.
*& Form GetReqSODetails
FORM GETREQSODETAILS .
CALL FUNCTION 'BAPI_SALESORDER_GETLIST'
EXPORTING
CUSTOMER_NUMBER = CUSTOMER_NUMBER
SALES_ORGANIZATION = SALES_ORGANIZATION
IMPORTING
RETURN = WA_RETURN
TABLES
SALES_ORDERS = IT_SALES_ORDERS.
*delete the Sales Order Details of Sales Orders other than the req.One
IF NOT IT_SALES_ORDERS[] IS INITIAL.
SORT IT_SALES_ORDERS BY SD_DOC.
LOOP AT IT_SALES_ORDERS INTO WA_SALES_ORDERS.
IF WA_SALES_ORDERS-SD_DOC NE SALESDOCUMENT.
DELETE IT_SALES_ORDERS.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " GetReqSODetails
*& Form deleteOldSODetails
FORM DELETEOLDSODETAILS .
DATA: IRECCOUNT TYPE I.
IRECCOUNT = 1.
*Clear all the Inernal Tables And Work Areas
*and Update the SO Header Index
PERFORM CLEARDATA.
PERFORM SOHEADERINDEX.
LOOP AT IT_SALES_ORDERS INTO WA_SALES_ORDERS.
*Fill the Order Details Index Internal Table
PERFORM FILLSODELETEDTLS_INDEX_PARAM
USING WA_SALES_ORDERS-ITM_NUMBER 'D'.
*Fill the Order Scedule Index Internal Table
PERFORM FILLSODELETESCH_INDEX_PARAM
USING WA_SALES_ORDERS-ITM_NUMBER IRECCOUNT 'D'.
ENDLOOP.
*call the Sales Order Change Fumction to delete the Existing Data
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = SALESDOCUMENT
ORDER_HEADER_INX = WA_ORDER_HEADER_INX
TABLES
RETURN = IT_RETURN_CHG
ORDER_ITEM_INX = IT_ORDER_ITEM_INX
SCHEDULE_LINESX = IT_SCHEDULE_LINESX.
ENDFORM. " deleteOldSODetails
*& Form SOHeaderIndex
FORM SOHEADERINDEX .
WA_ORDER_HEADER_INX-UPDATEFLAG = 'U'.
ENDFORM. " SOHeaderIndex
*& Form FillSODeleteDtls_Index_param
FORM FILLSODELETEDTLS_INDEX_PARAM
USING VALUE(P_ITM_NUMBER) VALUE(P_FLAG).
WA_ORDER_ITEM_INX-ITM_NUMBER = P_ITM_NUMBER.
WA_ORDER_ITEM_INX-UPDATEFLAG = P_FLAG.
APPEND WA_ORDER_ITEM_INX TO IT_ORDER_ITEM_INX.
ENDFORM. " FillSODeleteDtls_Index_param
*& Form FILLSODELETEsch_Index_PARAM
FORM FILLSODELETESCH_INDEX_PARAM
USING VALUE(P_ITM_NUMBER) VALUE(P_RECCOUNT) VALUE(P_FLAG).
WA_SCHEDULE_LINESX-ITM_NUMBER = P_ITM_NUMBER.
WA_SCHEDULE_LINESX-SCHED_LINE = P_RECCOUNT.
WA_SCHEDULE_LINESX-UPDATEFLAG = P_FLAG.
APPEND WA_SCHEDULE_LINESX TO IT_SCHEDULE_LINESX.
ENDFORM. " FILLSODELETEsch_Index_PARAM
*& Form addnewSODETAILS
FORM ADDNEWSODETAILS .
DATA: IRECCOUNT TYPE I, ITEMNO TYPE I.
IRECCOUNT = 1.
*Clear all the Inernal Tables And Work Areas
*and Update the SO Header Index
PERFORM CLEARDATA.
PERFORM SOHEADERINDEX.
WHILE IRECCOUNT <= 1.
ITEMNO = IRECCOUNT * 10.
*Fill the New Order Details in the Internal Table
PERFORM FILLSODTLDATA USING ITEMNO 'TEST FG' 37 .
*Fill the Order Details Index Internal Table
PERFORM FILLSODELETEDTLS_INDEX_PARAM USING ITEMNO 'I'.
*Fill the New Schedule Details in the Internal Table
PERFORM FILLSOSCHDATA USING ITEMNO IRECCOUNT 37 .
*Fill the Order Scedule Index Internal Table
PERFORM FILLSODELETESCH_INDEX_PARAM
USING ITEMNO IRECCOUNT 'I'.
IRECCOUNT = IRECCOUNT + 1.
ENDWHILE.
*call the Sales Order Change Fumction to Insert New Data
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = SALESDOCUMENT
ORDER_HEADER_INX = WA_ORDER_HEADER_INX
TABLES
RETURN = IT_RETURN_CHG
ORDER_ITEM_IN = IT_ORDER_ITEM_IN
ORDER_ITEM_INX = IT_ORDER_ITEM_INX
SCHEDULE_LINES = IT_SCHEDULE_LINES
SCHEDULE_LINESX = IT_SCHEDULE_LINESX.
ENDFORM. " addnewSODETAILS
*& Form clearData
FORM CLEARDATA .
CLEAR WA_ORDER_HEADER_INX.
CLEAR WA_ORDER_ITEM_INX.
REFRESH IT_ORDER_ITEM_INX.
CLEAR WA_SCHEDULE_LINESX.
REFRESH IT_SCHEDULE_LINESX.
CLEAR WA_RETURN.
REFRESH IT_RETURN.
CLEAR WA_ORDER_ITEM_IN.
REFRESH IT_ORDER_ITEM_IN.
CLEAR WA_SCHEDULE_LINES.
REFRESH IT_SCHEDULE_LINES.
ENDFORM. " clearData
*& Form FILLSODTLDATA
FORM FILLSODTLDATA USING VALUE(P_ITEMNO) VALUE(P_MATERIAL)
VALUE(P_TARGET_QTY) .
WA_ORDER_ITEM_IN-ITM_NUMBER = P_ITEMNO.
WA_ORDER_ITEM_IN-MATERIAL = P_MATERIAL.
WA_ORDER_ITEM_IN-TARGET_QTY = P_TARGET_QTY.
APPEND WA_ORDER_ITEM_IN TO IT_ORDER_ITEM_IN.
ENDFORM. " FILLSODTLDATA
*& Form FILLSOschDATA
FORM FILLSOSCHDATA USING VALUE(P_ITEMNO)
VALUE(P_RECCOUNT)
VALUE(P_REQ_QTY) .
WA_SCHEDULE_LINES-ITM_NUMBER = P_ITEMNO.
WA_SCHEDULE_LINES-SCHED_LINE = P_RECCOUNT.
WA_SCHEDULE_LINES-REQ_QTY = P_REQ_QTY.
APPEND WA_SCHEDULE_LINES TO IT_SCHEDULE_LINES.
ENDFORM. " FILLSOschDATA
*& Form committrans
FORM COMMITTRANS .
DATA:SUCCESSFLAG(1).
LOOP AT IT_RETURN_CHG INTO WA_RETURN_CHG.
IF WA_RETURN_CHG-TYPE = 'S'
AND WA_RETURN_CHG-ID = 'V1'
AND WA_RETURN_CHG-NUMBER = 311
AND SUCCESSFLAG IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = IT_RETURN_CT.
SUCCESSFLAG = 'X'.
ENDIF.
ENDLOOP.
IF SUCCESSFLAG IS INITIAL.
WRITE: 'SORRY SOME ERROR'.
ELSE.
WRITE: 'SUCCESSFUL'.
ENDIF.
ENDFORM. " committrans
Thanx wolfgang,
I needed that info.
As I had mentioned in the earlier posts, I want to delete the old Sales Order Item Details,
Schedule Details,Basic Price data And Reinsert data in the same.
I am giving u the algo that I have used.
1.<b>Get the SalesOrder Details</b> for a particular Sales Order using BAPI_SALESORDER_GETLIST(para:customer & sales Org and then deleting unwanted SO data).
2.<b>Delete</b> the Sales Order <b>Item Details,Schedule Details</b> using BAPI_SALESORDER_CHANGE.
3.<b>Commit</b> Transaction(<b>If I dont use this commit Error comes in Step No.7 while Commiting</b>)
using BAPI_TRANSACTION_COMMIT.
4.Check <b>Return Table</b> of both BAPI_SALESORDER_CHANGE and BAPI_TRANSACTION_COMMIT.
5.if Step No.4 is <b>Not okay</b> <b>then Rollback</b>(BAPI_TRANSACTION_TRANSACTIN) <b>and Exit</b> <b>else move to step 6</b>.
6.<b>Add New</b> Sales Order <b>Item Details,Schedule Details, Basic Price</b> using BAPI_SALESORDER_CHANGE.
7.<b>Commit Transaction</b> using BAPI_TRANSACTION_COMMIT.
8.<b>Check Return</b> Log of both BAPI_SALESORDER_CHANGE and BAPI_TRANSACTION_COMMIT.
9.if Step No.9 is okay then Exit else Rollback(BAPI_TRANSACTION_TRANSACTIN) and move to step 10.
10.Add Old Sales Order Item Details,Schedule Details, Basic Price from Data available in Internal
table(Filled in step.1 ) using BAPI_SALESORDER_CHANGE.
11.Commit Transaction using BAPI_TRANSACTION_COMMIT.
This <b>works fine in 1 server in which I get the message of Incomplete Data,etc...when I make a Sales Order from va01</b>.
But in another server where I dont this message,I get <b>error in step 7 or 11 as per the flow</b>.
The return structure of BAPI_TRANSACTION_COMMIT contains error with Message 'Updating was not possible'. Also the message 'Updation was terminated' cms frm the SAP server.
What could be the reason?
Thanx in advance
Similar Messages
-
How to update Sales Order status using BAPI_SALESORDER_CHANGE
Hi,
I want to update Sales Order status using BAPI_SALESORDER_CHANGE, this BAPI is called from middle ware, but there is no parameter to pass the status value to this function, please help me how to update sales order status using BAPI only.
Thanks
RKHi,
Can u give me details of what status u would like to update in sales order.
If we are able to update the status from VA02, Then BAPI will assist for the same.
Regards. -
Printing sales order details using adobe forms
hi all,
i need to print the sales order header and the respective item details using the adobe form.my requirement is to print the header on each and every page.
for suppose my header is say '1' it contains 20 item details,and the page can hold 15 item details.
there the fist two pages should have the header number as '1' and ill trigger a new page when ever a new header comes.so that the next details starts from fresh page.
i am getting the item details on each and evry page.i want to get the header details also on the each and everypage.
can anyone suggest me good answer.Hi
If you want to get the header details on every page, do the following steps
a) Select the Header row of a Table
b) Go to the Object palette, select the Pagination tab
c) Under Pagination tab check the check box "Include Header row in Subsequent Pages"
So that the header will come on all the pages
Path: Select Header row -> Object palette -> Pagination tab -> Include Header row in Subsequent Pages
Thanks
Srikanth(sriiiiiiii) -
Hi all,
Is there any way to get the details of the items which were deleted from an Sales Order?
Thanks in advance..Dear BI,
If the order is deleted then all the records are also deleted from the tables. The only option or line of hope is with BASIS. Check with him if he had some log or backup.
Thanks,
Raja -
Error in sales order creation using bapi
Hi,
Iam trying to create sales order by using BAPI_SALESORDER_CREATEFROMDAT1 and when iam trying to execute
the function module by passing all th eparameters and iam getting the error as
inspite of entering sold_to_party and ship_to_party details in table ORDER_PARTNERS
"enter the sold_to_party or ship to party details"
please help me out in this isue its an urgent.
Thanks.
sayed.Can you share the codes ?
Thanks.
Ashish -
Hi,
Is it possible to find a deleted sales order in SAP?
Thanks,
Malini.Individually
Even though the sales order is gone from the database, you can still see the change history of who deleted the order and when. ?To do this?go to Sales Order> Display>put the number in and go to Environment>Changes ?- then check and it will tell you the history. Hope this helps somewhat!
As a List
Though Sales orders are Deleted, they will be available in Change document tables CDHDR for header changes and CDPOS for item changes . Changes includes deletion also.
So run a Logic based on these two tables.
You shud get a report of all deleted sales order.
Use the report in the following link to base your logic.
http://www.sap-img.com/ab024.htm
Hope this Helps
VB -
In MD04 deleted sales order appearing
In my scanerio i found deleted sales order appearing in md04 and even it is not appearing in vbak table and at the same time sales order not appearing for display .
can some one help for the cause ..........??This is an error in the standard SAP programs (entries in VBBE table remain while they should be deteled). They made a program to clean up the entries in the VBBE table, it's program SDRQCR21
Best is to run a nightly job on this program.
You can check note 25444 for details.
Grtz,
Jan -
Delete Sales order and Purchase Order
Hello Experts,
Scenario 1: I would like to delete a Purchase Order using PORDCH03 idoc. I tried passing 'X', 'Y' and also 'D' to the deletion indicator at the header level, but the purchase order is not getting deleted. Can you let me know how can I delete an purchase order using IDOC.
Scenario 2: I would also like to delete a Sales order using ORDER05? Is this possible? I mean deleting Sales order. I do not want to update the reason for rejection, but I want to completly get rid of the sales order from the database.
Appreciate your help.
Thanks,
Suresh GantiHello Rob,
I am able to set the deletion indicator for the purchase order and it works fine. But for Sales orders we are using ORDERS05 and want to delete the Sales order. I was able to delete the line item, but not the whole order.
As you know we can delete the whole order using the BAPI.
sd_head_x_ls-updateflag = 'D'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = vbeln_lv
order_header_inx = sd_head_x_ls.
I want to achieve the same functionality using ORDERS05 IDOC.
Thanks,
Suresh Ganti -
Deleting Sales Order in CRM and connected R/3 - Help needed
I have a sales order created from the E-commerce scenario in CRM and has reflected in the R/3 system also.
Now I want to delete thi sales order from the systems.
I had cancelled this sales order from the webshop and thus the status in shown as completed.
Now when I delete the order in the CRM system it doesnt allow me to do so, though I have the option to delete the sales order (I am authorised to do it).
The error it gives is: "An error has occured in the system LOGPROD100 while copying the document".
If I delete it from the R/3 system it says you cant delete an order created in the CRM system.
Please guide me for this ASAP.
I will be ery thankful to any one who does it.
Thanks
Message was edited by:
Naresh DeepchandHey Vijay Duvvada,
I hope you are already referred below sap note and which explains scope & how to do -
1084315 - Consulting: Information about the multiple backend scenario
1763516 - How-to: Basic Setup of MEP
As explained by Rohit Sharma data should be start flowing to multiple sites.
please let me know if it does help.
Regards,
Arjun -
Sales order details uploading using BAPI method in LSMW
Hi Guys,
Sales order details uploading using BAPI in LSMW, could you please suggest me, is any standard method or programs is available for this.
I have some queries about this.
1) One header line having multiple line items, in this case we able to upload use the LSMW method,
if possible please tell me the steps.
2) Do we need to do any config changes while uploading data?
3) Flat file should be which format.
4) Steps to process each step wise if possible.
Please help me
Thanks,
Gourisanakar.Hi Gouri Sankar,
would you be able to upload the sales orders with multiple line items using BAPI LSMW?
if so could you plz suggest?
Thanks in advance.
Suresh/ -
FM to get sales order details with billing document .
hi ,
is there any standard FM or BAPI to get the sales order details with input as billing document ?
i have the billing document number now i need to get the sales order number and its details ..
is that possible ..
i very well know how to get it by using query, i need standard FM.
Points will be awarded for sure , if it helps .
Thanks and regards
JKHere is the list of BAPIs
BAPI_QUOTATION_GETDETAILBOS
BAPI_INQUIRY_GETDETAILBOS
BAPI_SALESORDER_GETDETAILBOS
SALES ORDER->
BAPISDORDER_GETDETAILEDLIST Sales Order: List of All Order Data
BAPI_ORDER_CHANGE_STATUS_GET Change status for order
BAPI_SALESDOCU_CREATEFROMDATA Creating a Sales Document
BAPI_SALESORDER_CHANGE Sales Order: Change Sales Order
BAPI_SALESORDER_CREATEFROMDAT1 Sales Order: Create Sales Order
BAPI_SALESORDER_CREATEFROMDAT2 Sales Order: Create Sales Order
BAPI_SALESORDER_CREATEFROMDATA Create sales order, no more maintenance
BAPI_SALESORDER_GETLIST Sales order: List of all orders for customer
BAPI_SALESORDER_GETSTATUS Sales order: Display status
BAPI_SALESORDER_SIMULATE Sales Order: Simulate Sales Order -
Change only material qunatity in sales order by using BAPI
Hi All,
How to change only the material quantity in existing sales order by using BAPI.
Please help me in this regards.
Regards
Deekshitha.Hi
See the sample code and do accordingly
REPORT Z_SALES_ORDER_CHANGE
NO STANDARD PAGE HEADING
LINE-SIZE 132
LINE-COUNT 65(0)
MESSAGE-ID ZZ.
TABLES: VBAP.
DATA:
V_FILEIN(90) TYPE C,
V_RECIN TYPE I,
V_RECVBAP TYPE I,
V_RECORDER TYPE I,
V_VBELN LIKE VBAP-VBELN,
ORDERHEADERINX LIKE BAPISDH1X.
DATA: BEGIN OF I_ORDERS OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
BRGEW(18) TYPE C,
VOLUM(18) TYPE C,
END OF I_ORDERS.
DATA: BEGIN OF I_OUTPUT OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
GEWEI LIKE VBAP-GEWEI,
BRGEW LIKE VBAP-BRGEW,
VOLUM LIKE VBAP-VOLUM,
CKWGT TYPE C,
CKVOL TYPE C,
END OF I_OUTPUT.
DATA: BEGIN OF ORDERITEMIN OCCURS 0.
INCLUDE STRUCTURE BAPISDITM.
DATA: END OF ORDERITEMIN.
DATA: BEGIN OF ORDERITEMINX OCCURS 0.
INCLUDE STRUCTURE BAPISDITMX.
DATA: END OF ORDERITEMINX.
DATA: BEGIN OF RETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF RETURN.
DATA: BEGIN OF BAPIRETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF BAPIRETURN.
PARAMETERS:
P_PATH(45) TYPE C DEFAULT '/usr/users/ftpsapom/' LOWER CASE,
P_FNAME(32) TYPE C DEFAULT '/sweetjo.txt' LOWER CASE.
START-OF-SELECTION.
CONCATENATE PATH AND FILE NAME INTO ONE VARIABLE
CONCATENATE P_PATH P_FNAME INTO V_FILEIN.
OPEN DATASET
IF V_FILEIN IS INITIAL.
MESSAGE E002 WITH 'FILE' V_FILEIN 'DOES NOT CONTAIN ANY DATA!'.
ELSE.
OPEN DATASET V_FILEIN
FOR INPUT
IN TEXT MODE.
IF SY-SUBRC = 0.
READ DATASET
DO.
READ DATASET V_FILEIN INTO I_ORDERS.
IF SY-SUBRC = 0.
APPEND I_ORDERS.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET
CLOSE DATASET V_FILEIN.
IF SY-SUBRC <> 0.
MESSAGE E002 WITH 'ERROR - CLOSING' V_FILEIN.
ENDIF.
ELSE.
MESSAGE E002 WITH 'ERROR - COULD NOT OPEN' V_FILEIN.
ENDIF.
ENDIF.
SORT AND REMOVE DUPLICATES FROM I_ORDERS
SORT I_ORDERS BY VBELN POSNR.
DELETE ADJACENT DUPLICATES FROM I_ORDERS.
POPULATE I_OUTPUT
LOOP AT I_ORDERS.
SHIFT I_ORDERS-POSNR LEFT DELETING LEADING SPACE.
CONCATENATE '0' I_ORDERS-POSNR INTO I_ORDERS-POSNR.
SELECT SINGLE BRGEW VOLUM
FROM VBAP
INTO (VBAP-BRGEW, VBAP-VOLUM)
WHERE VBELN = I_ORDERS-VBELN
AND POSNR = I_ORDERS-POSNR.
IF SY-SUBRC = 0.
IF VBAP-BRGEW = 0.
I_OUTPUT-CKWGT = 'X'.
ENDIF.
IF VBAP-VOLUM = 0.
I_OUTPUT-CKVOL = 'X'.
ENDIF.
I_OUTPUT-VBELN = I_ORDERS-VBELN.
I_OUTPUT-POSNR = I_ORDERS-POSNR.
I_OUTPUT-GEWEI = 'ST'.
I_OUTPUT-BRGEW = I_ORDERS-BRGEW.
I_OUTPUT-VOLUM = I_ORDERS-VOLUM.
APPEND I_OUTPUT.
CLEAR: I_OUTPUT.
ENDIF.
V_RECIN = V_RECIN + 1.
ENDLOOP.
POPULATE BAPI DATA AND RUN BAPI
CLEAR: ORDERHEADERINX, ORDERITEMIN, ORDERITEMINX,
RETURN, BAPIRETURN.
REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.
ORDERHEADERINX-UPDATEFLAG = 'U'.
LOOP AT I_OUTPUT WHERE CKWGT = 'X' OR CKVOL = 'X'.
V_RECVBAP = V_RECVBAP + 1.
IF I_OUTPUT-VBELN <> V_VBELN AND SY-TABIX <> 1.
V_RECORDER = V_RECORDER + 1.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = V_VBELN
ORDER_HEADER_INX = ORDERHEADERINX
TABLES
RETURN = RETURN
ORDER_ITEM_IN = ORDERITEMIN
ORDER_ITEM_INX = ORDERITEMINX.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = BAPIRETURN.
WRITE OUT RETURN
LOOP AT RETURN.
WRITE: / RETURN.
ENDLOOP.
WRITE: / BAPIRETURN.
SKIP.
CLEAR: ORDERITEMIN, ORDERITEMINX,
RETURN, BAPIRETURN.
REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.
ENDIF.
ORDERITEMIN-ITM_NUMBER = I_OUTPUT-POSNR.
ORDERITEMIN-UNTOF_WGHT = I_OUTPUT-GEWEI.
IF NOT I_OUTPUT-CKWGT IS INITIAL.
ORDERITEMIN-GROSS_WGHT = I_OUTPUT-BRGEW.
ORDERITEMINX-GROSS_WGHT = 'X'.
ENDIF.
IF NOT I_OUTPUT-CKVOL IS INITIAL.
ORDERITEMIN-VOLUME = I_OUTPUT-VOLUM.
ORDERITEMINX-VOLUME = 'X'.
ENDIF.
APPEND ORDERITEMIN.
ORDERITEMINX-ITM_NUMBER = I_OUTPUT-POSNR.
ORDERITEMINX-UNTOF_WGHT = 'X'.
ORDERITEMINX-UPDATEFLAG = 'U'.
APPEND ORDERITEMINX.
V_VBELN = I_OUTPUT-VBELN.
ENDLOOP.
RUN BAPI ON LAST ORDER
IF NOT ORDERITEMIN IS INITIAL.
V_RECORDER = V_RECORDER + 1.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = V_VBELN
ORDER_HEADER_INX = ORDERHEADERINX
TABLES
RETURN = RETURN
ORDER_ITEM_IN = ORDERITEMIN
ORDER_ITEM_INX = ORDERITEMINX.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = BAPIRETURN.
WRITE OUT RETURN
LOOP AT RETURN.
WRITE: / RETURN.
ENDLOOP.
WRITE: / BAPIRETURN.
SKIP.
ENDIF.
WRITE OUT RECORD COUNT FROM FILE
WRITE: / 'RECORD COUNT FROM FILE ', V_RECIN.
SKIP.
WRITE OUT RECORD COUNT FROM FILE
WRITE: / 'RECORD COUNT OF LINES TO CHANGE ', V_RECVBAP.
SKIP.
WRITE OUT RECORD COUNT FROM FILE
WRITE: / 'RECORD COUNT OF ORDERS TO CHANGE ', V_RECORDER.
SKIP.
TOP OF PAGE
TOP-OF-PAGE.
WRITE:/1(5) TEXT-H01, 6(8) SY-DATUM MM/DD/YY,
100(8) TEXT-H02, 126(8) SY-PAGNO.
WRITE:/1(5) TEXT-H03, 6(8) SY-UZEIT USING EDIT MASK '__:__:__',
20(77) TEXT-H04,
100(8) TEXT-H05, 108(25) SY-REPID.
WRITE:/1(6) TEXT-H06, 8(12) SY-UNAME,
20(4) TEXT-H07, 25(32) SY-HOST,
100(13) TEXT-H08, 121(8) SY-SYSID,
129 '/', 130(3) SY-MANDT.
ULINE.
SKIP.
Reward points if useful
Regards
Anji -
Hi,
Business needs to get the data back for all the deleted sales orders for a period. Is there any way these data can be retrieved. When I put the sales orders number system says "Sales Document XYZ is not in the database or has been archived".
Your views are much appreciated.
Regards
RajHi,
There is only one option available by which you can track changes done for a particular sales order which has been deleted.
thru VA02, go to an existing Sales order, click on tab ENVironment, changes.
Here, you will find, the existing sales order number. Delete this number and enter the number of the sales order that was deleted & for whose details you intend to RETRIVE.
You will get a change LOG, which will give u complete details of the changes done for that Sales order.
Reward points if found useful.
Regards,
C. Ramakrishna -
Delete pricing conditions line using BAPI_SALESORDER_CHANGE
Hi experts.
I've read the forum and OSS about this topic and don't have clear if it's possible to delete a price condition position (using BAPI). Using tx. VA02 I can delete pricing conditions, that's why I think should be possible.
We have a sales order created, and depending on the sold-to-party we have some discounts: RA00 (% discount) or RB00 (absolute discounts).
In some cases we need to insert/update or delete these pricing conditions. For insert/update, we don't have any problem using
BAPI_SALESORDER_CHANGE and setting the appropiate updateflag.
But... what would be the procedure to delete a discount, for example, RA00 fixed on a sales order? Has the logic_switch be informed specially?
wa_cond-itm_number = lt_cond-itm_number.
wa_cond-cond_type = lt_cond-cond_type.
APPEND wa_cond TO i_cond.
wa_condx-itm_number = lt_cond-itm_number.
wa_condx-cond_type = lt_cond-cond_type.
wa_condx-updateflag = 'D'.
APPEND wa_condx TO i_condx.
Lots of thanks.
JavierI am not positive on being able to delete a pricing condition through program.
Online when you try to change the pricing, SAP suggests us to redetermines the Pricing rather than just changing the values. And also the pricing condition config also plays a role... I think there was a setting which says Pricing condition to be manual which means you can add or delete the conditoin. -
Delete sales order created more than three days ago
Hi Experts,
"Business has created lot of sales order for prepayment. Only part of them are converted to deliveries, rest are stored in database.
In Open sales orders report old orders are confusing, because of Country legislation the conditions of a sales order are valid during 3 working days. Therefore after 3 days not paid orders should be deleted."
Kindly let me know if we have a standard fucntionality in SAP through which we can pull open sales order more than 3 days old and then can delete the same.
If not can you help me in understanding the Logical Flow that is needed to meet the Business Requirement through a customized program.
Looking forward to seeing your replies.Hi,
As per your business requirement stated above I recommend not to delete any sales order instead use a Zprogram for sales order and mark them as "MARK FOR REJECTION".
Doing this will solve your problem of getting unnecessary sales order in standrad report of Open sales order as in standard Rejected Sales order are not considred as in VA05 Report. and also keep record of the sales order created by you for future purpose.
further to this as per your business requirement you have to mark line Item wise "Mark For Rejection.
Here in coding you can give logic from Document creation date or Document Date + 3 Days if that is < system date then mark them for rejection.
Hope this solves your purpose.
Maybe you are looking for
-
How can I convert a WMV to an MOV?
I've been trying to convert a WMV to an MOV. However, I've been getting the error "The source compression type is not supported." I've used AME to convert this file type before. Not sure how I should proceed. Any ideas?
-
Hi.I have tried a program for RSA algorithm in java.The senderRSA encrypts a string with private key and n value. and sends to receiverRSA decrypts it with public key and n value.Before this public key and n are announced to receiver. I have first tr
-
Is there an incompatibility between I-Phone 6
Product : I-PHone 6 Model No MG482HN/A IOS : 8.1.2 Problem: Connectivity with BSNL(INDIA) Nano SIM Card to connect to Internet was found to be very poor.Wi-Fi connectivity at the same location is OK.For comparison connectivity of Samsung Galaxy S3 wi
-
To Whom It May Concern: I can not get my previewer to work. When I click on the attachment without opening it the below message pops up. This file cannnot be previewed because of an error with the following previewer: PDF Preview Handler for Vista T
-
My old computer died and will not turn on. How can I unsync to that one?