VinceCoder
6/3/2019 - 7:36 PM

BAPI: SCARICO COSTI SU PROGETTO

Con il codice seguente è possibile reperire tutte le informazioni di un progetto (Def. di un progetto) con la BAPI, dopodichè con il batch input è possibile impostare la regola di scarico costi su un elemento WBS padre (scarico costi del livello superiore su quello inferiore).

      SELECT SINGLE pspid
        FROM proj
        INTO lv_projdef
        WHERE pspnr EQ ls_pspnr-low.

GET DATA A PARTIRE DA UN PROGETTO 

        CALL FUNCTION 'BAPI_PROJECT_GETINFO'
          EXPORTING
            project_definition     = lv_projdef
            with_milestones        = 'X'
          IMPORTING
            e_project_definition   = ls_projdef
            return                 = ls_return
          TABLES
            i_wbs_element_table    = lt_iwbs_element
            e_wbs_element_table    = lt_ewbs_element
            e_wbs_milestone_table  = lt_ewbs_milestone
            e_wbs_hierarchie_table = lt_ewbs_hierarchie
            e_activity_table       = lt_activity
            e_message_table        = lt_message.
            
  ****************************************************************************
  
  BATCH INPUT CJ12 - PER IMPOSTARE SCARICO COSTI SU WBS 
  
      PERFORM bdc_dynpro      USING 'SAPLCJWB' '0100'.

    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  '*PRPS-POSID'.

    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '=METB'.

    PERFORM bdc_field       USING '*PRPS-POSID'
                                  is_prps-posid. "'rg18-001.lab'.

    PERFORM bdc_dynpro      USING 'SAPLCJWB' '1999'.

    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'PRPS-POSID'.

    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '=ABRV'.

    PERFORM bdc_field       USING 'PRPS-POSID'
                                  is_prps-posid. "'RG18-001.LAB'.

    PERFORM bdc_field       USING 'PRPS-POST1'
                                  is_prps-post1. "'Ferrigno: Progettazione'.

    PERFORM bdc_field       USING 'PRTE-PEINH'
                                  'G.'.

    PERFORM bdc_field       USING 'PRTE-EEINH'
                                  'G.'.

    PERFORM bdc_field       USING 'PRTE-IEINH'
                                  'G.'.

    PERFORM bdc_field       USING 'PRPS-SLWID'
                                  '0000001'.

    PERFORM bdc_field       USING 'PRPS-USR10'
                                  'X'.

    PERFORM bdc_field       USING 'PRPS-PRART'
                                  'ZB'.

    PERFORM bdc_field       USING 'PRPS-POSKI'
                                  is_prps-poski.  "'RG18-001.LAB'.

    PERFORM bdc_field       USING 'PRPS-VERNR'
                                  is_prps-vernr. "'23100001'.

    PERFORM bdc_field       USING 'PRPS-PLAKZ'
                                  'X'.

    PERFORM bdc_field       USING 'PRPS-BELKZ'
                                  'X'.

    PERFORM bdc_dynpro      USING 'SAPLKOBS' '0130'.

    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'COBRB-KONTY(01)'.

    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '/00'.

    PERFORM bdc_field       USING 'COBRB-KONTY(01)'
                                  'WBS'.

    PERFORM bdc_field       USING 'DKOBR-EMPGE(01)'
                                  is_ewbs_hierarchie-up. "'RG18-001'.

    PERFORM bdc_dynpro      USING 'SAPLKOBS' '0130'.

    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'COBRB-KONTY(01)'.

    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '=BACK'.

    PERFORM bdc_dynpro      USING 'SAPLCJWB' '1999'.

    PERFORM bdc_field       USING 'BDC_CURSOR'

                                  'PRPS-POSID'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '=BU'.

    PERFORM bdc_field       USING 'PRPS-POSID'
                                  is_prps-posid. "'RG18-001.LAB'.

    PERFORM bdc_field       USING 'PRPS-POST1'
                                  is_prps-post1. "'Ferrigno: Progettazione'.

    PERFORM bdc_field       USING 'PRTE-PEINH'
                                  'G.'.

    PERFORM bdc_field       USING 'PRTE-EEINH'
                                  'G.'.

    PERFORM bdc_field       USING 'PRTE-IEINH'
                                  'G.'.

    PERFORM bdc_field       USING 'PRPS-SLWID'
                                  '0000001'.

    PERFORM bdc_field       USING 'PRPS-USR10'
                                  'X'.

    PERFORM bdc_field       USING 'PRPS-PRART'
                                  'ZB'.

    PERFORM bdc_field       USING 'PRPS-POSKI'
                                  is_prps-poski. "'RG18-001.LAB'.

    PERFORM bdc_field       USING 'PRPS-VERNR'
                                  is_prps-vernr. "'23100001'.

    PERFORM bdc_field       USING 'PRPS-PLAKZ'
                                  'X'.

    PERFORM bdc_field       USING 'PRPS-BELKZ'
                                  'X'.

    CALL TRANSACTION 'CJ12' USING gt_bdcdata
*                         MODE 'N'.
                     MODE 'A'.
**************************************************************************