SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Read data from CJ30 or budget of a project



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> CO
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Wed Jul 22, 2009 4:22 pm    Post subject: Read data from CJ30 or budget of a project Reply with quote

Code:
*&---------------------------------------------------------------------*
*$*$ Exit            : EXIT_SAPLCNAU_002                            *$*$
*$*$ Project         : ZPS0000                                       *$*$
*$*$ Enhancement     : CNEX0002                                 *$*$
*$*$ -------------------------------------------------------------- *$*$

*&---------------------------------------------------------------------*
*&  Include           ZXCN1U06                                         *
*&---------------------------------------------------------------------*

*declaracao de dados para tratamento das transacoes CJ30,CJ32,CJ37,cj38
DATA: tvarvc     TYPE tvarvc.
DATA: v_text(40) TYPE c.
DATA: i_tget_exp LIKE bpge_id.
DATA: li_qtdreg  TYPE i.

FIELD-SYMBOLS: <fs_tge>      TYPE STANDARD TABLE.
FIELD-SYMBOLS: <fs_tget>     TYPE bpge_id.
FIELD-SYMBOLS: <fs_tget_aux> TYPE bpge_id.

IF sy-tcode EQ 'CJ30' OR
   sy-tcode EQ 'CJ32' OR
   sy-tcode EQ 'CJ37' OR
   sy-tcode EQ 'CJ38'.

  v_text = '(SAPLKBPP)T_GE[]'.
  ASSIGN (v_text) TO <fs_tge>.

  IF <fs_tge> IS ASSIGNED.

    li_qtdreg = lines( <fs_tge> ).

    LOOP AT <fs_tge> ASSIGNING <fs_tget>.

      CASE sy-tcode.

        WHEN 'CJ30' OR 'CJ32'.

          IF <fs_tget>-vorga = 'KBUD'.
            MOVE <fs_tget> TO i_tget_exp.
*        Export to class ZCL_IM__IM_BEHAVIOUR
            EXPORT i_tget_exp TO MEMORY ID 'i_tget_exp'.
            EXIT.
          ENDIF.

        WHEN 'CJ37'.

          IF <fs_tget>-vorga = 'KBN0'.
            MOVE <fs_tget> TO i_tget_exp.
*        Export to class ZCL_IM__IM_BEHAVIOUR
            EXPORT i_tget_exp TO MEMORY ID 'i_tget_exp'.
            EXIT.
          ELSEIF sy-tabix = li_qtdreg.
            READ TABLE <fs_tge> INDEX 1 ASSIGNING <fs_tget_aux>.
            MOVE <fs_tget_aux> TO i_tget_exp.
            CLEAR: i_tget_exp-wtges.
*        Export to class ZCL_IM__IM_BEHAVIOUR
            EXPORT i_tget_exp TO MEMORY ID 'i_tget_exp'.
          ENDIF.

        WHEN 'CJ38'.

          IF <fs_tget>-vorga = 'KBR0'.
            MOVE <fs_tget> TO i_tget_exp.
*        Export to class ZCL_IM__IM_BEHAVIOUR
            EXPORT i_tget_exp TO MEMORY ID 'i_tget_exp'.
            EXIT.
          ELSEIF sy-tabix = li_qtdreg.
            READ TABLE <fs_tge> INDEX 1 ASSIGNING <fs_tget_aux>.
            MOVE <fs_tget_aux> TO i_tget_exp.
            CLEAR: i_tget_exp-wtges.
*        Export to class ZCL_IM__IM_BEHAVIOUR
            EXPORT i_tget_exp TO MEMORY ID 'i_tget_exp'.
          ENDIF.

      ENDCASE.

    ENDLOOP.

  ENDIF.

*&---------------------------------------------------------------------*
*$*$ Class           : ZCL_IM__IM_BEHAVIOUR                         *$*$
*$*$ BAdI            : IM_BEHAVIOUR                              *$*$
*$*$ Implementation  : Z_IM_BEHAVIOUR                         *$*$
*&---------------------------------------------------------------------*
  METHOD if_ex_im_behaviour~get_behaviour .

* Declaracao de dados para implementacao das transacoes CJ30, CJ32,CJ38

    DATA: tvarvc     TYPE tvarvc.
    DATA: v_text(40) TYPE c.
    DATA: i_tget_exp TYPE bpge_id.

    FIELD-SYMBOLS: <fs_tge> TYPE ANY TABLE,
                   <fs_tget> TYPE bpge_id.

    IF sy-tcode EQ 'CJ30' OR
       sy-tcode EQ 'CJ32' OR

       sy-tcode EQ 'CJ37' OR
       sy-tcode EQ 'CJ38'.

*    Import da EXIT_SAPLCNAU_002
      IMPORT i_tget_exp TO i_tget_exp FROM MEMORY ID 'i_tget_exp'.

      v_text = '(SAPLKBPP)T_GE[]'.
      ASSIGN (v_text) TO <fs_tge>.

      LOOP AT <fs_tge> ASSIGNING <fs_tget>.

        IF <fs_tget>-epos = 'X'.

* Conditions CJ30
          IF ( sy-tcode = 'CJ30' AND <fs_tget>-vorga = 'KBUD' ) AND
             ( ( <fs_tget>-objnr EQ i_tget_exp-objnr AND
                <fs_tget>-wtges NE i_tget_exp-wtges ) OR
               ( <fs_tget>-wtges NE i_tget_exp-wtges AND
                 i_tget_exp-objnr IS INITIAL ) )
* Conditions CJ32
          OR ( sy-tcode = 'CJ32' AND <fs_tget>-vorga = '*ADD' )
* Conditions CJ37
          OR ( sy-tcode = 'CJ37' AND  <fs_tget>-vorga = 'KBN0' ) AND
             ( <fs_tget>-objnr EQ i_tget_exp-objnr AND
               <fs_tget>-wtges NE i_tget_exp-wtges )
* Conditions CJ38
          OR ( sy-tcode = 'CJ38' AND  <fs_tget>-vorga = 'KBR0' ) AND
             ( <fs_tget>-objnr EQ i_tget_exp-objnr AND
               <fs_tget>-wtges NE i_tget_exp-wtges ).

            SELECT SINGLE *
            FROM tvarvc
            INTO tvarvc
            WHERE name = 'PS_CONT_ORC_N1'
            AND low  = sy-uname.

            IF sy-subrc NE 0.
              MESSAGE ID 'ZPS' TYPE 'E' NUMBER '117' WITH sy-uname.
            ENDIF.

          ENDIF.

        ENDIF.

      ENDLOOP.

    ENDIF. " Fim CJ30, CJ32, CJ37 e CJ38
  ENDIF.

ENDMETHOD. "if_ex_im_behaviour~get_behaviour
Back to top
View user's profile Send private message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Wed Jul 22, 2009 4:26 pm    Post subject: Using FM KBPP_EXTERN_UPDATE_CO for budget Update in CJ30 Reply with quote

Code:
****Updating the Budget update ( WRTTP = 41 and VORGA = KBUD)

IF wa_final-budg_upd NE 0.
  wa_bpak-s_profil = v_bprof.
  wa_bpak-twaer = v_twaer.
  wa_bpak-e_objnr = wa_final-objnr.
  wa_bpak-s_wrttp = c_41.
  wa_bpak-s_vorga = c_kbud.
  wa_bpak-wert = wa_final-budg_upd.
  APPEND wa_bpak TO it_bpak.

  CALL FUNCTION 'KBPP_EXTERN_UPDATE_CO'
       EXPORTING
            i_budget_activity      = wa_bpak-s_vorga
            i_budget_activ_sup_ret = ' '
            i_commit_data          = c_x
            i_delta_amounts        = ' '
            i_rollup_data          = c_x
            i_check_plan_data      = c_x
       TABLES
            it_bpak                = it_bpak
            it_return              = it_return.
  IF NOT it_return IS INITIAL.
    LOOP AT it_return INTO wa_return WHERE type = c_e.
      wa_error-budg_upd = wa_return-message.
    ENDLOOP.
  ELSE.
    wa_error-budg_upd = text-003. "'Updated'.
    PERFORM transaction_commit.
  ENDIF.
ELSE.
  wa_error-budg_upd = text-004.
ENDIF.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> CO All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.