Skip to main content

How accumulate payload in this subflow?

<sub-flow name="declaration-gen-bdxSub_Flow" doc:id="4a053275-e3a0-4d7f-9a2e-a1d4a2df55dd" >

<foreach doc:name="For Each" doc:id="ec657e3d-2621-4c5b-a19e-108b96ad765d" >

<db:select doc:name="Select" doc:id="86b58687-f81b-461c-99cc-1980b43e8f52" config-ref="Database_Config" target="record_emo_id">

<db:sql><![CDATA[SELECT COUNT(*) as Occurrences

FROM SOCLESI_DEV.FLUX_RECEPT.EMO_DECLARATION

WHERE SUBSTRING(EMO_ID, 1, 11) = :EMO_ID]]></db:sql>

<db:input-parameters><![CDATA[#[{

EMO_ID: payload.Reference

}]]]></db:input-parameters>

</db:select>

<logger level="INFO" doc:name="Logger" doc:id="5cfe5250-e08d-44cb-9fe0-cbb9080606f0" message="#vars.record_emo_id[0.Occurrences]" />

<ee:transform doc:name="Transform Message" doc:id="f7492f10-1dc7-44ff-8e57-b7550dfef4f3">

<ee:message>

<ee:set-payload><![CDATA[%dw 2.0

output application/json

var occurenceVal=vars.record_emo_id[0].Occurrences

fun incrementId(id, occurenceVal) =

id ++ "0" ++ occurenceVal +1 as String

fun formatDate(inputDate: String): String =

inputDate[0 to 9] replace "-" with ""

---

{

Intitule: "declaration",

Reference: incrementId(payload.Reference,occurenceVal),

Numero_etude: payload.Numero_etude,

Date_debut: payload.Date_debut,

Date_fin: payload.Date_fin,

Date_exigibilite: payload.Date_exigibilite,

Date_mise_en_demeure: payload.Date_mise_en_demeure,

Date_saisie: null,

Date_generation: null,

Code_saisie: "A",

Siret: null,

Nb_creance: "01",

Nb_reduction: null,

Moyen_payement: null,

Montant_cotisation: null,

Montant_reduction: null,

Intitule: "creancegeneral",

Code_saisie: "A",

Type_creance: "EM01",

Periode: payload.Periode,

Code_regime: payload.Code_regime,

Taux: null,

Taux_emolument: "004.00",

Montant_base: "0.00",

Montant_cotisation1: null,

vide_1: null,

vide_2: null,

Montant_cotisation2: null,

Sens_du_montant: null

}]]></ee:set-payload>

</ee:message>

<ee:variables>

</ee:variables>

</ee:transform>

<ee:transform doc:name="Transform Message" doc:id="6896184b-b2e4-4053-848d-33b49ceaacc5">

<ee:message>

<ee:set-payload><![CDATA[%dw 2.0

output application/csv header = false, separator = ";"

---

[payload] flatMap ((item, index) -> [{

Intitule: "declaration",

Reference: payload.Reference,

Numero_etude: payload.Numero_etude,

Date_debut: payload.Date_debut,

Date_fin: payload.Date_fin,

Date_exigibilite: payload.Date_exigibilite,

Date_mise_en_demeure: payload.Date_mise_en_demeure,

Date_saisie: null,

Date_generation: null,

Code_saisie: "A",

Siret: null,

Nb_creance: "01",

Nb_reduction: null,

Moyen_payement: null,

Montant_cotisation: null,

Montant_reduction: null

},{

Intitule: "creancegeneral",

Code_saisie: "A",

Type_creance: "EM01",

Periode: payload.Periode,

Code_regime: payload.Code_regime,

Taux: null,

Taux_emolument: "004.00",

Montant_base: "0.00",

Montant_cotisation1: null,

vide_1: null,

vide_2: null,

Montant_cotisation2: null,

Sens_du_montant: null

}] )]]></ee:set-payload>

</ee:message>

</ee:transform>

</foreach>

<logger level="INFO" doc:name="Logger" doc:id="83d5a592-2018-49ef-82ab-c832a2aafe0d" message="#payload"/>

</sub-flow>

 

accumulate payload

2 个回答
  1. 2024年2月22日 02:26

    Hi @Hichem Rtibi​ ,

     

    Based on what I can understand from your code, you are walking through an array in the payload, using some information of each element to query the DB and to a transformation.

    If you want as a result, an array with each transformed element, you need to create an auxiliary variable in the flow, and before finishing the for each append the result you are looking for.

    Check this flow:

    Hi @Hichem Rtibi​ , Based on what I can understand from your code, you are walking through an array in the payload, using some information of each element to query the DB and to a transformation.In the first processor you need to initialize the auxiliar variable as an empty array with []. Be aware, after doing the processing logic, you have to set the auxiliar variable again. I this sample I used the transform processor and append the result of my transformation to the array.

     

    Hope it helps.

     

    Good luck!

    Juan Cruz Basso

0/9000