How to Close PO programmatically using 4GL Script in Sage X3


Purchase order can be manually closed by using the close button in Purchase order, but in some scenarios, it is not possible to close the purchase order manually. Under such circumstances, we need to call a subprogram from standard.

Following syntax is used to close the Purchase order



WPOHNUM: Purchase order number

WMSGFLG: It is Integer value which indicates error message

0:- No error Message

1:- error on screen (Call ERROR)


3:-Message in trace

WRET: (Return Code) It Contains an integer value.

By calling above subprogram we can close the Purchase order.

(Note: There is always a transaction in Progress when we use this sub-program)


Created a purchase Order

POH-Before-001.png POH-Before-002.png

Code for Closing the Purchase Order

Code For Closing POH.png

After execution of the Code, Purchase Order is closed as shown below.

POH-Before-001.png POH-After-002.png

Transforming businesses since 2009

For over a decade, Panni has helped companies transform their businesses to lead, innovate and be profitable. With the right combination of technology and experienced developers and consultants, we help companies with Change Management to achieve the organizational objectives. We believe in long-term relationships with our clients and provide top-notch support with fast turnaround times.

Looking for ERP advice?

or call us at +1-403-441-1113