Aller au contenu

Archi - transfo pour annuler tous les kpis sans les lister

Goal of this transformation is to cancel "bad" records in this adso. To do this we need to multiply by -1 all KPI's for the records that will be selected in the DTP linked to this Transformation. Because there is a lot of KPI we will not do this KPI by KPI. It will be too long to do kpi by kpi. We will use another method :

  • Get list of ALL key figures stored in this adso
  • Loop on source_package and use dynamic variable and field symbols to multiply each kpi by -1
  • List of kpi for this adso.
  • RSOOBJXREF : table for the fields in the adso
  • RSDIOBJ : table to find the Key Figures
* déclaration des variables :  
    types : begin of kpi_list,
            fieldnm type rsdiobjfieldnm,
    end of kpi_list.

    data it_kpi_list      type table of kpi_list.    
    data s_kpi_list       like line  of it_kpi_list.
    data v_fieldname(50)  type c.
    field-symbols : <fs_global_variable> type any.

*   Début du code
    SELECT b~fieldnm
      FROM ( rsoobjxref AS a
             INNER JOIN 
             rsdiobj AS b 
             ON a~objnm_dep = b~iobjnm
            )
     WHERE a~tlogo     = 'ADSO'
       AND a~objvers   = 'A'
       AND a~objnm     = 'ZPRD_A004'
       AND a~tlogo_dep = 'IOBJ'
       AND b~iobjtp    = 'KYF'
       AND b~objvers   = 'A'
      INTO CORRESPONDING FIELDS OF TABLE @it_kpi_list.

* 2) Modify each kpi in the source_package table.
LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>.

*   For each KPI in the adso
    LOOP AT it_kpi_list INTO s_kpi_list.

*       Create the dynamic name of the kpi to modify.
        CLEAR v_fieldname.
        CONCATENATE '<source_fields>-' s_kpi_list-fieldnm INTO v_fieldname.

*       Create the dynamic variable.
        ASSIGN (v_fieldname) TO <fs_global_variable>.

*       Modify the value.
        <fs_global_variable> = <fs_global_variable> * -1.

    ENDLOOP.

ENDLOOP.