SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Close open Sales order



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Wed Sep 05, 2007 4:09 pm    Post subject: Close open Sales order Reply with quote

Author: Rajesh Manchal

Description : You can use the follwing program to Close all the Open Sales Orders which are closed actually but not in the SAP System becuase there was a difference in the initial quantity and the qnantity deliverd. Please be aware that the program takes the a series of sales orders and closes them by chaning the ordered quantity to the deliverd quantity by adjusting the scheduling line agreement data with the sales order data.

Code:
TABLES: vbak, vbap, vbep.
select-options Sales for vbak-vbeln obligatory.
data itab like vbap occurs 0 with header line.
data itab1 like vbap occurs 0 with header line. select * from vbap into table itab where vbeln in Sales.loop at itab.select single * from vbap  where vbeln = itab-vbeln.if vbap-KWMENG NE itab-KBMENG. write:/ itab-vbeln color 1.
update vbap
set KWMENG = itab-KBMENG
where vbeln = itab-vbeln.update vbap
set LSMENG = itab-KBMENG
where vbeln = itab-vbeln.
*endif.select single * from vbep where vbeln =  itab-vbeln and ETENR = '0001'.if sy-subrc = 0.
update vbep
set WMENG = itab-KBMENG
where vbeln = itab-vbeln
and ETENR = '0001'.update vbep
set CMENG = itab-KBMENG
where vbeln = itab-vbeln
and ETENR = '0001'.endif.

CALL FUNCTION 'SD_SALES_DOCUMENT_UPDATE'
  EXPORTING
    I_VBELN                = itab-vbeln
*   I_ACTIVITY             =
*   I_FORCE_DATALOSS       = 'X'
*   I_PROGRAM              = 'SAPMV45A'
*   I_PERFORM              =
*   I_FORCE_COMMIT         = 'B'
*   I_SET_MANEK            =
* EXCEPTIONS
*   UPDATE_FAILED          = 1
*   READ_FAILED            = 2
*   ASSIGN_FAILED          = 3
*   PERFORM_FAILED         = 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.endif.
endloop.TOP-OF-PAGE.
write:/ 'The following orders are closed' color 2.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.