0

I have the following functions that I am trying to modify to default in a Printer output destination within Pay Cycle Manager in FSCM 9.2, but need to get a better understanding of what the current customization is doing.

We have a custom function in Record PeopleCode (PYCYCL_STATRPT.PAY_RUN_AP_STATUS) (RowInit event) that is defined as follows:

Function GHS_Set_OutDest(&STATUS) Returns string;
   PYCYCL_STATRPT.SERVERNAME = "PSNT";
   PYCYCL_STATRPT.OUTDESTTYPE = "2";
   If &STATUS = "Z" Or
         &STATUS = "C" Then
      &GHS_STRING_ID = "OUTDEST_POSPAY";
   Else
      If Substring(PYCYCL_STATRPT.PAY_CYCLE, 1, 3) = "AUX" Then
         &GHS_STRING_ID = "OUTDEST_AUX";
      End-If;

      If Substring(PYCYCL_STATRPT.PAY_CYCLE, 1, 3) = "CTS" Then
         &GHS_STRING_ID = "OUTDEST_CTS";
      End-If;
      If Substring(PYCYCL_STATRPT.PAY_CYCLE, 1, 4) = "MAIN" Then
         &GHS_STRING_ID = "OUTDEST_MAIN";
      End-If;
      If Substring(PYCYCL_STATRPT.PAY_CYCLE, 1, 5) = "POSPY" Then
         &GHS_STRING_ID = "";
      End-If;
      If Substring(PYCYCL_STATRPT.PAY_CYCLE, 1, 5) = "QUICK" Then
         &GHS_STRING_ID = "OUTDEST_QUICK";
      End-If;
      If Substring(PYCYCL_STATRPT.PAY_CYCLE, 1, 6) = "REFUND" Then
         &GHS_STRING_ID = "OUTDEST_REFUND";
      End-If;
      If Substring(PYCYCL_STATRPT.PAY_CYCLE, 1, 2) = "R_" Then
         &GHS_STRING_ID = "OUTDEST_REFUND";
      End-If;
      If Substring(PYCYCL_STATRPT.PAY_CYCLE, 1, 5) = "RSTRT" Then
         &GHS_STRING_ID = "OUTDEST_RSTRT";
      End-If;
   End-If;
   SQLExec("SELECT STRING_TEXT FROM PS_STRINGS_TBL WHERE PROGRAM_ID = 'APY2055' AND STRING_ID = :1", &GHS_STRING_ID, &GHSOUTDEST);
   /*WinMessage("GHS_Set_OutDest_1: " | PYCYCL_STATRPT.PAY_RUN_AP_STATUS | " " | &STATUS | " " | &GHSOUTDEST, 64);*/
   Return (&GHSOUTDEST);
End-Function;

From what I can tell, it looks like this function returns the variable &GHSOUTDEST back to the code that is calling it, which I believe is below where it is being declared on other Record PeopleCode (PYCYCL_STATRPT.OUTDESTTYPE) (FieldChange event):

Declare Function GHS_Set_OutDest PeopleCode PYCYCL_STATRPT.PAY_RUN_AP_STATUS RowInit; /* GHS, declared in PYCYCL_STATRPT.OUTDESTTYPE.FieldChange */

&OPRID = %OperatorId;

Evaluate PYCYCL_STATRPT.OUTDESTTYPE
When = "2"
   SQLExec("select srvrdestfile from ps_opr_def_pycycl where oprid = :1", &OPRID, PYCYCL_STATRPT.OUTDEST);
   Break;
When = "3"
   SQLExec("select srvrdestprinter from ps_opr_def_pycycl where oprid = :1", &OPRID, PYCYCL_STATRPT.OUTDEST);
   Break;
When = "6"
   SetDefault(PYCYCL_STATRPT.OUTDEST);
   Break;
End-Evaluate;

/* PYCYCL_STATRPT.OUTDEST = GHS_Set_OutDest(PYCYCL_STATRPT.PAY_RUN_AP_STATUS); */

My question is, if where the function is Declared (immediately above) is what is calling the main function defined within PAY_RUN_AP_STATUS field, why am I not seeing the output (Return) variable (&GHSOUTDEST) being used in the Declaration statement? In the Evaluate statement below the function declaration, is the return values from the function being used in any way for the Evaluate instruction? It looks like the 2nd Bind variable in the SQLExec statement (PYCYCL_STATRPT.OUTDEST) is what is setting the OUTDEST field?

From here I would like to be able to default in a specific Printer destination path, depending on what step (status) the pay cycle manager is in, as it needs to go to a different location for check printing, then it does for printing the Advice.

Nick
  • 268
  • 8
  • 33

1 Answers1

0

If where the function is Declared (immediately above) is what is calling the main function defined within PAY_RUN_AP_STATUS field, why am I not seeing the output (Return) variable (&GHSOUTDEST) being used in the Declaration statement?

This is just how the declaration works. A function can have parameters and return values, but they are specified in the definition, not in the declaration. Your peoplecode is saying: I want to use the function GHS_Set_OutDest defined at PYCYCL_STATRPT.PAY_RUN_AP_STATUS RowInit. Go check the definition and what it needs(parameters) and returns, so that I can use it.

In the Evaluate statement below the function declaration, is the return values from the function being used in any way for the Evaluate instruction? It looks like the 2nd Bind variable in the SQLExec statement (PYCYCL_STATRPT.OUTDEST) is what is setting the OUTDEST field?

The function is actually never called. It is declared above the Evaluate statement, but it isn't used. It would be used below it, but it is commented here:

/* PYCYCL_STATRPT.OUTDEST = GHS_Set_OutDest(PYCYCL_STATRPT.PAY_RUN_AP_STATUS); */

From here I would like to be able to default in a specific Printer destination path, depending on what step (status) the pay cycle manager is in, as it needs to go to a different location for check printing, then it does for printing the Advice.

The function sets the destination type to 2 (PYCYCL_STATRPT.OUTDESTTYPE = "2";), which is output to file. The rest of the function fetches something based on the &STATUS parameter. It's not really clear because it is custom code: in PS_STRINGS_TBL there are no default OUTDEST_% entries. The OUTDESTTYPE for printer is 3.

Based
  • 950
  • 7
  • 18
  • Thanks Peter for the feedback. So on the PYCYCL_STATRPT.PAY_RUN_AP_STATUS RowInit PeopleCode, where that function is defined, does the function actually execute on it's own from the RowInit PeopleCode for RUN_AP_STATUS, or does the function require it to be called (from the OUTDESTYPE event), or otherwise in order to execute? – Nick Jul 19 '19 at 11:34
  • Also it appears then &GHSOUTDEST is really not being used in either PeopleCode event? I could not find any other references to this variable. Would it be used if `/* PYCYCL_STATRPT.OUTDEST = GHS_Set_OutDest(PYCYCL_STATRPT.PAY_RUN_AP_STATUS); */` wasn't commented out as the return value? Thanks very much, this is more helpful to my understanding than what I have seen in PeopleBooks. – Nick Jul 19 '19 at 11:39
  • @Nick, you are correct, uncommenting that line is the only change required to use the function. Be aware though that the evaluate statement above it may be it's replacement. It's hard to say as it's custom code and I obviously don't know the requirement. – Based Aug 05 '19 at 09:28