I am trying to automate the creation of an intercompany sales order upon approval of the PO. I first ran into the issue that I could not call the bo for another company within a BPM. I got around this by switching the company in the UI, and then calling a custom .p file directly from the UI. My code is firing without errors, and all messages are being correctly written to the appserv logs, but the Sales order is not being created. Can anyone see what I am doing wrong?
‘’'<
{bo/SOPOLink/SOPOLink_ds.i}
{lib/globals.i}
define input parameter ponum as character.
DEFINE VAR hICPOLINK AS HANDLE NO-UNDO.
DEFINE VAR cPricesDifferQuestionText AS CHARACTER NO-UNDO.
DEFINE VAR cGlbPartQuestionText AS CHARACTER NO-UNDO.
DEFINE VAR needsConfig AS LOGICAL NO-UNDO.
DEFINE VAR morePages AS LOGICAL NO-UNDO.
DEFINE VAR cUnitPricesDifferMessage AS CHARACTER NO-UNDO.
DEFINE VAR cCurrenciesDifferMessage AS CHARACTER NO-UNDO.
DEFINE VAR cUOMDifferMessage AS CHARACTER NO-UNDO.
MESSAGE ponum.
FOR EACH IMOrderHed WHERE IMOrderHed.company=‘GPI’ AND IMOrderHed.icponum = INT(ponum) NO-LOCK.
IF NOT VALID-HANDLE(hICPOLINK) THEN DO:
RUN bo/SOPOLink/SOPOLink.p PERSISTENT SET hICPOLINK no-error.
MESSAGE ‘SOPOLink handle created’.
END.
RUN GetRows IN hICPOLINK (INPUT “IMOrderHed.ICPONum = '” + ponum + “’ BY ICPONum”,INPUT “”,INPUT “”,INPUT “”,{&output_dataset_SOPOLinkDataSet},INPUT 0,INPUT 0,OUTPUT morePages) NO-ERROR.
RUN GetbyID IN hICPOLINK (INPUT INT(IMOrderHed.icponum),INPUT "I",INPUT IMOrderHed.intQueID, {&output_dataset_SOPOLinkDataSet}) NO-ERROR.
MESSAGE 'After Getbyid'.
RUN GetOrderDtl IN hICPOLINK ({&output_dataset_SOPOOrderDtlDataSet},INPUT 0, INPUT 0, INPUT 1, INPUT 1, OUTPUT morePages) NO-ERROR.
RUN GetOrderMsc IN hICPOLINK ({&output_dataset_SOPOOrderMscDataSet},INPUT 0, INPUT 0, INPUT 0, INPUT 1, INPUT 1, OUTPUT morePages ) NO-ERROR.
RUN GetOrderRel IN hICPOLINK ({&output_dataset_SOPOOrderRelDataSet},INPUT 0, INPUT 0, INPUT 0, INPUT 1, INPUT 1, OUTPUT morePages ) NO-ERROR.
RUN CheckSOPODifferences IN hICPOLINK (INPUT FALSE, INPUT IMOrderHed.intQueID, OUTPUT cUnitPricesDifferMessage, OUTPUT cCurrenciesDifferMessage,OUTPUT cUOMDifferMessage) NO-ERROR.
RUN CheckReadyForOrder IN hICPOLINK (INPUT IMOrderHed.intQueID, INPUT FALSE, OUTPUT cGlbPartQuestionText, OUTPUT cPricesDifferQuestionText) NO-ERROR.
MESSAGE 'after check ready for order'.
FOR EACH ttIMOrderHed:
MESSAGE 'ttimorderhed found'.
TTIMOrderHed.ReadyforOrder = TRUE.
END.
MESSAGE 'after updating temp record.'.
RUN UPDATE IN hICPOLINK ({&input-output_dataset_SOPOLinkDataSet}) NO-ERROR.
MESSAGE ‘After Update’.
RUN ProcessSuggestions IN hICPOLINK (OUTPUT needsConfig, {&output_dataset_SOPOOrderDtlDataSet} ) NO-ERROR.
MESSAGE ‘After Process Suggestions’.
DELETE OBJECT hICPOLINK NO-ERROR.
END.
‘’’