project QadFinancials > class BBusinessRelation > method ApiStdMaintainTT

Description

With this method a Businessrelation can be added, modified or deleted.


Parameters


tApiBusinessRelationinputtemp-tableTemp-table that is the base for the data that will be created via this API method.
tApiAddressinputtemp-tableChild Temp-table Address for the main temp-table (BusinessRelation)
tApiContactinputtemp-tableChild Temp-table Contact for the main temp-table (BusinessRelation)
tApiVatNumberinputtemp-tableChild Temp-table VatNumber for the main temp-table (BusinessRelation)
tApiBusRelationSafDefaultinputtemp-tabletemp-table containing the SafDefault information for a BusinessRelation
icActioninputcharacterAction. Possible values;
"SAVE":U
"SAVESTORE":U
"STORE":U
"VALIDATE":U
ocLstPrimKeyoutputcharacterLstPrimKey
Char4 separated list with the primary keys of the newly created main-table records. The fields of a primkey are separated with Char2.
E.g. 1<Char2>2002<Char2>100<Char4>1<Char2>2002<Char2>101
ocLstReturnoutputcharacterLstReturn
Char4 separated list with the return-status of the newly created main-table records. Zero means no errors occured.
E.g. 0<Char4>-1<Char4>-504<Char4>1<Char4>0
ocLstRowidoutputcharacterLstRowid
Char4 separated list with the temporarely rowids (negative for new ones) of the newly created main-table records. .
E.g.
-1<Char2>aox00098001<Char2>-26
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBusinessRelation.ApiStdMaintainTTExtended
method BBusinessRelation.ApiStdMaintainXml


program code (program9/bbusinessrelation.p)

/* ======================================================================= */
/* Method Info: BusRel will be loaded based on the Logical or Physical Key */
/* ======================================================================= */

/* ============================================================================ */
/* Clear the instance:                                                          */
/* this will also clear the t_s tables that were filled in ApiMaintainByDataSet */
/* ============================================================================ */
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
        
/* ==================== */
/* Set Default Return   */
/* Parameter Validation */
/* ==================== */
assign oiReturnStatus         = -98
       vlDraftInstanceCreated = false.
if icAction = ? then assign icAction = "":U.
if icAction <> {&DAEMONACTION-SAVESTORE} and
   icAction <> {&DAEMONACTION-SAVE}      and
   icAction <> {&DAEMONACTION-STORE}     and
   icAction <> {&DAEMONACTION-VALIDATE}
then do:
    assign vcMessage      = trim(subst(#T-25'A business relation integration error occurred. The specified action (&1) must be in the list &2.':255(855)t-25#,trim(icAction),"{&DAEMONACTION-SAVESTORE},{&DAEMONACTION-SAVE},{&DAEMONACTION-STORE},{&DAEMONACTION-VALIDATE}":U))
           oiReturnStatus = -1.
    <M-1 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-844':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
    return.
end. /* if icAction <> {&DAEMONACTION-SAVESTORE} and */

/* ======================== */
/* Count main-table records */
/* ======================== */
for each tApiBusinessRelation no-lock:
    assign viMainTableRecordCount = viMainTableRecordCount + 1.
end. /* for each tApiBusinessRelation */
if viMainTableRecordCount = 0
then do:
    assign vcMessage      = trim(#T-26'The system cannot handle this API method correctly because incorrect input parameters have been provided.':255(856)t-26#) + ' ':U + 
                            trim(substitute(#T-27'No main table record (&1) found.':255(857)T-27#,"BusinessRelation":U))
           oiReturnStatus = -1.
    <M-3 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-847':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
    return.
end. /* viMainTableRecordCount = 0 */
                                       
/* ================================ */
/* Start loop on main-table records */
/* ================================ */
for each tApiBusinessRelation by tApiBusinessRelation.tc_Rowid :
    
    MAINBLOCK: DO:
    
    /* ========== */
    /* Initialize */
    /* ========== */
    assign vcMessage       = "":U
           vcNewRowID      = "":U
           vlWarningsFound = false
           vlSaveAsDraft   = icAction = {&DAEMONACTION-STORE}.
    
    /* =========================================== */
    /* Get the BusRel_ID based on the logical key  */
    /* =========================================== */
    if (tApiBusinessRelation.BusinessRelation_ID = 0    or
        tApiBusinessRelation.BusinessRelation_ID = ?)   and
        tApiBusinessRelation.BusinessRelationCode <> "" and
        tApiBusinessRelation.BusinessRelationCode <> ?
    then do :
         <Q-22 run BusinessRelationPrim (all) (Read) (NoCache)
          (input tApiBusinessRelation.BusinessRelation_ID, (BusinessRelationId)
           input tApiBusinessRelation.BusinessRelationCode, (BusinessRelationCode)
           output dataset tqBusinessRelationPrim) in BBusinessRelation >
        find tqBusinessRelationPrim where 
             tqBusinessRelationPrim.tcBusinessRelationCode = tApiBusinessRelation.BusinessRelationCode
             no-lock no-error.
        if available tqBusinessRelationPrim
        then assign tApiBusinessRelation.BusinessRelation_ID = tqBusinessRelationPrim.tiBusinessRelation_ID.
    end. /* if tApiBusinessRelation.BusinessRelation_ID = 0 or */
    
    /* ============================= */
    /* Load/Create BusinessRelation  */
    /* ============================= */
    if tApiBusinessRelation.BusinessRelation_ID = 0 or
       tApiBusinessRelation.BusinessRelation_ID = ?
    then assign viFcReturnSuper = -4.
    else do:
        <M-6 run DataLoad (input  '':U (icRowids), 
                   input  string(tApiBusinessRelation.BusinessRelation_id) (icPkeys), 
                   input  '':U (icObjectIds), 
                   input  '' (icFreeform), 
                   input  false (ilKeepPrevious), 
                   output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
    end. /* not if tApiBusinessRelation.BusinessRelation_ID = 0 */
    if viFcReturnSuper = -4 /* Dataload was not able to load the record as it does not exist */
    then do :
        assign viFcReturnSuper = 0.
        <M-7 run DataNew (output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
        if viFcReturnSuper <> 0
        then assign vcMessage = trim(substitute(#T-28'Cannot create a new instance. Error number: &1.':255(308)t-28#, string(viFcReturnSuper))) + " (03)":U.
        find first tBusinessRelation no-error.
    end. /* if viFcReturnSuper = -4 */
    else do:
        if viFcReturnSuper < 0
        then assign vcMessage = trim(substitute(#T-29'Cannot load the instance (error number: &1, instance ID: &2).':255(289)t-29#, string(viFcReturnSuper), string(tApiBusinessRelation.BusinessRelation_ID))) + " (04)":U.
        else do:
            find tBusinessRelation where
                 tBusinessRelation.BusinessRelation_ID = tApiBusinessRelation.BusinessRelation_ID
                 no-error.
            if not available tBusinessRelation
            then assign vcMessage = trim(substitute(#T-30'Cannot find the instance after it has been loaded (instance ID: &1).':255(290)t-30#, string(tApiBusinessRelation.BusinessRelation_ID))) + " (05)":U.
            else assign tBusinessRelation.tc_Status = "C":U.
        end. /* Not if viFcReturnSuper <> 0 */
    end. /* Not if viFcReturnSuper = -4 */
    
    /* ====================================== */
    /* Check for errors in the previous block */
    /* ====================================== */
    if vcMessage <> "":U
    then do:
        assign ocLstReturn   = ocLstReturn  + chr(4) + (if viFcReturnSuper = 0 then "-3":U else string(viFcReturnSuper))
               ocLstPrimKey  = ocLstPrimKey + chr(4) + "*":U
               ocLstRowid    = ocLstRowid   + chr(4) + "*":U
               vlSaveAsDraft = false.
        <M-8 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-848':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
        leave MAINBLOCK.
    end. /* if vcMessage <> "":U and ... */

    /* ====================== */
    /* Copy data for BusRel   */
    /* ====================== */          
    buffer-copy tApiBusinessRelation 
        except BusinessRelation_ID 
               tc_ParentRowid 
               tc_Rowid 
               tc_Status 
            to tBusinessRelation.
    if tBusinessRelation.tc_Status = "N":U
    then assign tBusinessRelation.BusinessRelationCode = tApiBusinessRelation.BusinessRelationCode.
    assign vcNewRowID                               = tBusinessRelation.tc_Rowid
           tApiBusinessRelation.BusinessRelation_ID = tBusinessRelation.BusinessRelation_ID /* Needed to set the prim-key after the Save */.
    
    /* =========================================== */
    /* Process all Child tables                    */
    /* =========================================== */
    <M-21 run ApiStdMaintainTTDetail (input  icAction (icAction), 
                                  input-output ocLstReturn (bcLstReturn), 
                                  input-output ocLstPrimKey (bcLstPrimKey), 
                                  input-output ocLstRowid (bcLstRowid), 
                                  input-output vlSaveAsDraft (blSaveAsDraft), 
                                  output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
    if viFcReturnSuper < 0
    then leave MAINBLOCK.
    else if viFcReturnSuper > 0
         then assign vlWarningsFound = true.
    
    /* =================================================== */
    /* This is where it ends if only SaveAsDraft is needed */
    /* =================================================== */
    if vlSaveAsDraft
    then do:
        assign ocLstReturn  = ocLstReturn  + chr(4) + "-1":U
               ocLstPrimKey = ocLstPrimKey + chr(4) + "*":U
               ocLstRowid   = ocLstRowid   + chr(4) + "*":U.
        leave MAINBLOCK.
    end. /* if vlSaveAsDraft */

    /* =============================== */
	/* Set Actvity                     */
	/* =============================== */
	if can-find (first tBusinessRelation where
		               tBusinessRelation.tc_Status = "N":U)
	then assign vcActivityCode = "Create":U.
	else if can-find (first tBusinessRelation where
		                    tBusinessRelation.tc_Status = "C":U)
    then assign vcActivityCode = "Modify":U.

    /* ============================================= */
    /* Validate the data and perform ExternalUpdates */
    /* ============================================= */
    <M-14 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
    if viFcReturnSuper < 0
    then do:
        assign ocLstReturn   = ocLstReturn  + chr(4) + string(viFcReturnSuper)
               ocLstPrimKey  = ocLstPrimKey + chr(4) + "*":U
               ocLstRowid    = ocLstRowid   + chr(4) + "*":U
               vlSaveAsDraft = (icAction <> {&DAEMONACTION-SAVE} and icAction <> {&DAEMONACTION-VALIDATE}).
        leave MAINBLOCK.
    end. /* if viFcReturnSuper <> 0 */
    else if viFcReturnSuper > 0
         then assign vlWarningsFound = true.
    <M-15 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
    if viFcReturnSuper < 0
    then do:
        assign ocLstReturn   = ocLstReturn  + chr(4) + string(viFcReturnSuper)
               ocLstPrimKey  = ocLstPrimKey + chr(4) + "*":U
               ocLstRowid    = ocLstRowid   + chr(4) + "*":U
               vlSaveAsDraft = (icAction <> {&DAEMONACTION-SAVE} and icAction <> {&DAEMONACTION-VALIDATE}).
        leave MAINBLOCK.
    end. /* if viFcReturnSuper <> 0 */
    else if viFcReturnSuper > 0
         then assign vlWarningsFound = true.
    
    /* ============= */
    /* Save the data */
    /* ============= */
    if icAction <> {&DAEMONACTION-VALIDATE}
    then do :
        <M-16 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
        if viFcReturnSuper < 0
        then do:
            assign ocLstReturn   = ocLstReturn  + chr(4) + string(viFcReturnSuper)
                   ocLstPrimKey  = ocLstPrimKey + chr(4) + "*":U
                   ocLstRowid    = ocLstRowid   + chr(4) + "*":U
                   vlSaveAsDraft = (icAction <> {&DAEMONACTION-SAVE} and icAction <> {&DAEMONACTION-VALIDATE}).
            leave MAINBLOCK.
        end. /* if viFcReturnSuper <> 0 */
        else if viFcReturnSuper > 0
             then assign vlWarningsFound = true.
    end. /* if icAction = {&DAEMONACTION-VALIDATE} */
    
    /* ============================================ */
    /* Indicate that everything was saved correctly */
    /* ============================================ */
    assign ocLstReturn  = ocLstReturn  + chr(4) + (if vlWarningsFound = true then "1":U else "0":U)
           ocLstPrimKey = ocLstPrimKey + chr(4) + string(tApiBusinessRelation.BusinessRelation_ID)
           ocLstRowid   = ocLstRowid   + chr(4) + vcNewRowid.
    
    END. /* MAINBLOCK */
    
    /* ================================================================== */        
    /* Handle errors: Store if SaveAsDraft is needed                      */
    /* Check: only 1 draft is allowed for a single bus-component instance */
    /* ================================================================== */
    if vlSaveAsDraft and 
       index(substr(ocLstReturn, r-index(ocLstReturn, chr(4)) + 1,-1,"CHARACTER":U),"-":U) <> 0 /* Negative return-status for this entry */
    then do:
        if vlDraftInstanceCreated = true
        then do :
            assign vcMessage     = trim(#T-31'Only one draft instance can be created per method call.':255(858)T-31#) + chr(10) + trim(#T-32'This second object will not be stored as a draft instance and so is an error.':255(859)t-32#).
            <M-23 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  1 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-2877':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
            next.
        end. /* if vlDraftInstanceCreated = true */
        <M-17 run StoreState
          (input  '(':U + tBusinessRelation.BusinessRelationName1 + ') ':U + trim(#T-33'The business relation was created using an API method.':200(860)t-33#) (icDescription), 
           input  ? (icUIClass), 
           output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
            /* if the draft succeded then reset the return parameters */
            assign vlDraftInstanceCreated                                         = true
                   entry(num-entries(ocLstReturn , chr(4)), ocLstReturn , chr(4)) = string(viFcReturnSuper)
                   entry(num-entries(ocLstPrimKey, chr(4)), ocLstPrimKey, chr(4)) = string(tApiBusinessRelation.BusinessRelation_ID)
                   entry(num-entries(ocLstRowid  , chr(4)), ocLstRowid  , chr(4)) = vcNewRowID.
    end. /* if vlSaveAsDraft and substr */
    
end. /* for each tApiBusinessRelation */

/* ============================================================ */
/* Trim the first character of ocLstReturn and primkey          */
/* Check for correct number and format of the return-parameters */
/* ============================================================ */
if length(ocLstReturn,"CHARACTER":U)  > 1 then assign ocLstReturn  = substring(ocLstReturn,2,-1,"CHARACTER":U).
if length(ocLstPrimKey,"CHARACTER":U) > 1 then assign ocLstPrimKey = substring(ocLstPrimKey,2,-1,"CHARACTER":U).
if length(ocLstRowid,"CHARACTER":U)   > 1 then assign ocLstRowid   = substring(ocLstRowid,2,-1,"CHARACTER":U).
if num-entries(ocLstReturn,chr(4))  <> viMainTableRecordCount or
   num-entries(ocLstPrimKey,chr(4)) <> viMainTableRecordCount or
   num-entries(ocLstRowid,chr(4))   <> viMainTableRecordCount
then do :
    assign vcMessage      = trim(#T-34'A business relation integration error occurred. An API method returned incomplete information. See other messages for further details.':200(861)t-34#) + chr(10) + 
                            trim(substitute(#T-35'Main table records: &1.':255(310)T-35#,string(viMainTableRecordCount))) + chr(10) + 
                            trim(substitute(#T-36'Return Statuses: &1.':255(311)T-36#,ocLstReturn))  + chr(10) +
                            trim(substitute(#T-37'Primary keys: &1.':255(312)T-37#,ocLstPrimKey)) + chr(10) +
                            trim(substitute(#T-38'Row IDs: &1.':255(313)T-38#,ocLstRowid)).
           oiReturnStatus = -3.
    <M-19 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-845':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
    Return.
end. /* if num-entries */
   
/* ===================================================== */
/* Set global return status based on the individual ones */
/* ===================================================== */
if ocLstReturn = substring(fill("0":U + CHR(4),viMainTableRecordCount),1,length(ocLstReturn,"CHARACTER":U),"CHARACTER":U)
then assign oiReturnStatus = 0.
else do : 
    if index(ocLstReturn,"-":U) <> 0        
    then do :
        assign vcMessage      = trim(#T-39'An error has occurred while running this API method. See other error messages for more details.':255(301)T-39#)
               oiReturnStatus = -1.
        <M-20 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-846':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
    end. /* index(ocLstReturn,"-":U) <> 0 */
    else do : 
        assign vcMessage      = trim(#T-40'A warning has occurred while running this API method. See other error messages for more details.':255(302)T-40#)
               oiReturnStatus = +1.
        <M-24 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'W':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-2878':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
    end. /* not if lookup */
end. /* not if ocLstReturn */


Sample code: how to call this method through RPCRequestService (QXtend Inbound)

define temp-table ttContext no-undo
    field propertyQualifier as character
    field propertyName as character
    field propertyValue as character
    index entityContext is primary unique
        propertyQualifier
        propertyName
    index propertyQualifier
        propertyQualifier.

define dataset dsContext for ttContext.

define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.

/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
       ttContext.propertyValue = "BBusinessRelation".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiStdMaintainTT".
create ttContext.
assign ttContext.propertyName = "applicationId"
       ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
       ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
       ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
       ttContext.propertyValue = "".

/* Create input dataset */
create dataset vhInputDS.
vhInputDS:read-xmlschema("file", "xml/bbusinessrelation.apistdmaintaintt.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icAction = <parameter value>.

vhParameter = vhInputDS:get-buffer-handle("tApiBusinessRelation").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiAddress").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiContact").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiVatNumber").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiBusRelationSafDefault").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").

if not vhServer:connected()
then do:
    message "Could not connect AppServer" view-as alert-box error title "Error".
    return.
end.

/* Run */
assign vhContextDS = dataset dsContext:handle.

run program/rpcrequestservice.p on vhServer
    (input-output dataset-handle vhContextDS by-reference,
           output dataset-handle vhExceptionDS,
     input        dataset-handle vhInputDS by-reference,
     input-output dataset-handle vhInputOutputDS by-reference,
           output dataset-handle vhOutputDS).

/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).

if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).

/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.

if valid-handle(vhInputDS)
then delete object vhInputDS.

if valid-handle(vhOutputDS)
then delete object vhOutputDS.

if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.