How to Close a PO/PO Line in Code

Summary/Background

Below is an extract of code to close a PO/PO line.

Details

Close a PO:

#####################################################################################$CLOSE_PURCHASE_ORDER
 
Call ECR_TRACE ("Closing Purchase Order",0) From GESECRAN 
 
Local Char YWPOHNUM(GLONPOH)
Local Integer YWMSGFLG
Local Integer YWRET
 
 YWPOHNUM = YPO_CLE_POHNUM
  If YWPOHNUM <> ""
    Call ECR_TRACE ("Closing Purchase Order"-YWPOHNUM,0) From GESECRAN
    YWMSGFLG = 3 #add to trace file
    GOK=1
    Call TRTPOHCLE (YWPOHNUM, YWMSGFLG, YWRET) From TRTACHDIV1
    If GOK=1
      Call ECR_TRACE ("PO closed"-YWPOHNUM,0) From GESECRAN
    Else
      Call ECR_TRACE ("Unable to close PO!"-YWPOHNUM,1) From GESECRAN
    Endif
  Endif 
Return
#####################################################################################

Close a PO Line:

#####################################################################################$CLOSE_PURCHASE_ORDER_LINES
 
Local Integer NI
Local Char    YWPOHNUM(GLONPOH)
Local Integer YWPOPLIN
Local Integer YWPOPSEQ
Local Integer YWSENS
Local Integer YWMSGFLG
 
If YPO_LINCLE_CNT > 0
  Call ECR_TRACE ("Closing Purchase Order Lines",0) From GESECRAN
Endif
 
For NI = 1 To YPO_LINCLE_CNT
  YWPOHNUM = YPO_LINCLE_POHNUM(NI)
  YWPOPLIN = YPO_LINCLE_POPLIN(NI)
  If YWPOHNUM <> "" & YWPOPLIN > 0
    Call ECR_TRACE ("Closing Purchase Order Line"-YWPOHNUM+"/"+num$(YWPOPLIN),0) From GESECRAN
    YWPOPSEQ = 1
    YWSENS   = 1
    GOK      = 1
    Call DIVPOQCLE(YWPOHNUM,YWPOPLIN,YWPOPSEQ,YWSENS,3) From TRTACHDIV1
    If GOK=1
      Call ECR_TRACE ("PO line closed",0) From GESECRAN
    Else
      Call ECR_TRACE ("Unable to close PO line!",1) From GESECRAN
    Endif
  Endif
Next
 
Return
#####################################################################################
Scroll to Top