SAP-ABAP-delivery exit-set all line item delivery positions before saving the delivery order and check whether the positions are consistent before posting

Source: Internet
Author: User

Development Requirement: the person who makes the delivery order must maintain the same delivery position for the same order. It is designed to change all rows to the same position as the first line before saving.

If inconsistency is found during shipment, the system will check if it does not pass the bill.

The user exit is as follows:

Modify userexit_save_document_prepare routine

 

The Code is as follows:

* Terra** form userexit_save_document_prepare ** contains ** this userexit can be used for changes or checks, before a ** document is saved. * *** if field T180-TRTYP contents 'h', the document will be ** created, else it will be changed. * *** this form is called at the beginning of form beleg_sichern ***** terra** form userexit_save_document_prepare. if sy-uname = 'hs014 '. break-point. endif. "Only process delivery to customers, and do not process inter-company transactions. if (tcode = 'vl02n 'or tcode = 'vl02' or tcode = 'vl01n' or tcode = 'vl01 ') and (xlikp-vkorg = '000000' or xlikp-vkorg = '000000 '). "data: xlips_c like lipsvb occurs 0 with header line. "data: I _lips like lipsvb occurs 0 with header line. data: c_lgort like xlips-lgort, I _idx type I, I _cnt type I, MSG type string. if sy-ucomm = 'wabu _ t '. "An error is reported if there are different positions to check the transfer. c_lgort = ''. I _idx = 0. loop at xlips. if I _idx = 0. "obtain the first row's location I _idx = I _idx + 1. c_lgort = xlips-lgort. endif. if c_lgort <> xlips-lgort. message 'there are different delivery positions in the delivery order. Please notify the sales assistant to correct the changes before posting. 'type '. endif. clear xlips. endloop. endif. if sy-ucomm = 'sich _ t' or sy-ucomm = 'yes '. "If it is saved (or the exit prompt is saved), the positions will be updated uniformly. c_lgort = ''. I _idx = 0. I _cnt = 0. loop at xlips. if I _idx = 0. "obtain the position I _idx = I _idx + 1 in the first line. c_lgort = xlips-lgort. if c_lgort = ''. message 'Enter the delivery position 'type' for the first line before saving the delivery order '. else. concatenate 'The warehouse you entered in the first line is 'c_lgort ', and the enhancement system will update all line items' to MSG according to this position. message MSG type 'I '. endif. endif. if c_lgort <> xlips-lgort. "Update position xlips-lgort = c_lgort. "U indicates that the record has been modified and needs to be updated. d Indicates deletion. I indicates that if xlips-updkz ='' is added ''. xlips-updkz = 'u '. endif. modify xlips. I _cnt = I _cnt + 1. endif. clear xlips. endloop. if I _cnt> 1. MSG = I _cnt. concatenate 'updates 'msg' row position 'into MSG. message MSG type 'I '. endif. endif. endif. endform. "userexit_save_document_prepare * eject

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.