Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Creating PS Network header with one activity

Former Member
0 Likes
1,759

I need to create to a projekt the network header with one activity. so I want top proceed the following coding:


     CALL FUNCTION 'BAPI_PS_INITIALIZATION'.

      CALL FUNCTION 'BAPI_BUS2002_CREATE'
        EXPORTING
          i_network = gs_network
        TABLES
          et_return = et_return.

      CALL FUNCTION 'BAPI_PS_PRECOMMIT'

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        IMPORTING
          return = es_return.


        CALL FUNCTION 'BAPI_PS_INITIALIZATION'.



        CALL FUNCTION 'BAPI_BUS2002_ACT_CREATE_MULTI'
          EXPORTING
            i_number    = ls_number
          TABLES
            it_activity = gt_activity.


        CALL FUNCTION 'BAPI_PS_PRECOMMIT'


        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          IMPORTING
            return = es_return.

But I get an Runtime Error with "MESSAGE_TYPE_X" because the PRECOMMIT was not successful.

Has anyone an idea how to handle that ??

thx a lot

Edited by: Rob Burbank on Nov 18, 2009 9:42 AM

I need to create to a projekt the network header with one activity. so I want top proceed the following coding:


     CALL FUNCTION 'BAPI_PS_INITIALIZATION'.

      CALL FUNCTION 'BAPI_BUS2002_CREATE'
        EXPORTING
          i_network = gs_network
        TABLES
          et_return = et_return.

      CALL FUNCTION 'BAPI_PS_PRECOMMIT'

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        IMPORTING
          return = es_return.


        CALL FUNCTION 'BAPI_PS_INITIALIZATION'.



        CALL FUNCTION 'BAPI_BUS2002_ACT_CREATE_MULTI'
          EXPORTING
            i_number    = ls_number
          TABLES
            it_activity = gt_activity.


        CALL FUNCTION 'BAPI_PS_PRECOMMIT'


        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          IMPORTING
            return = es_return.

But I get an Runtime Error with "MESSAGE_TYPE_X" because the PRECOMMIT was not successful.

Has anyone an idea how to handle that ??

thx a lot

Edited by: Rob Burbank on Nov 18, 2009 9:42 AM

8 REPLIES 8
Read only

Former Member
0 Likes
1,350

use the bapi as given bellow with return parameter

CALL FUNCTION 'BAPI_PS_PRECOMMIT'.

TABLES

ET_RETURN = IT_RETURN.

Read only

0 Likes
1,350

tried doesn´t help....still Runtime Error....

Read only

0 Likes
1,350

Moderator message - Welcome to SCN.

Where do you get the error - the precommit, the commit or elsewhere. What is the message with the error?

Rob

Read only

0 Likes
1,350
*Error analysis*                              
     Short text of error message:            
     Precommit did not run successfully      
                                             
     Long text of error message:             
                                             
     Technical information about the message:
     Message class....... "CNIF_PI"          
     Number.............. 033                
     Variable 1.......... " "                
     Variable 2.......... " "                
     Variable 3.......... " "                
     Variable 4.......... " "

*How to correct the error*                                                 
    Probably the only way to eliminate the error is to correct the progra
    -                                                                                
If the error occures in a non-modified SAP program, you may be able t
    find an interim solution in an SAP Note.                             
    If you have access to SAP Notes, carry out a search with the followin
    keywords:                                                                                
"MESSAGE_TYPE_X" " "                                                 
    "SAPLPS_BAPI" or "LPS_BAPIF01"                                       
    "CHK_PRECOMMIT"                                                                                

Edited by: Rob Burbank on Nov 18, 2009 10:30 AM

Read only

0 Likes
1,350

The error comes after a call to FM PS_FLAG_GET_GLOBAL_FLAGS. Put a breakpoint there anbd see why it is failing.

Rob

Read only

Former Member
0 Likes
1,350

Hello Markus,

Is your issue resolved?...Can you able to create network with one activity?...

If yes,can you please send me sample code for creating network with one activity using BAPI : BAPI_BUS2002_CREATE

Because i'm unable to create networks for WBS in project definition

Katrice

Read only

Former Member
0 Likes
1,350

Hi!

Try this code, without using 'BAPI_PS_PRECOMMIT':

   CALL FUNCTION 'BAPI_PS_INITIALIZATION'.

   CALL FUNCTION 'BAPI_BUS2054_CREATE_MULTI'

     EXPORTING

       i_project_definition = lv_prj_def

     TABLES

       it_wbs_element       = lt_wbs_elm

       et_return            = lt_ret.


   READ TABLE lt_ret WITH KEY type = 'E' TRANSPORTING NO FIELDS.

   IF sy-subrc <> 0.

     CALL FUNCTION 'PS_FLAG_SET_GLOBAL_FLAGS'

       EXPORTING

         I_PRECOMMIT_OK = 'Y'.


     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

       EXPORTING

         wait = 'X'.

   ENDIF.

Read only

Former Member
0 Likes
1,350

DATA: lt_return   TYPE TABLE OF bapiret2,

        l_wa_return TYPE bapiret2.



  CALL FUNCTION 'BAPI_PS_INITIALIZATION'

    .

  CALL FUNCTION 'BAPI_BUS2002_CREATE'

    EXPORTING

      i_network = pi_wa_aufnr

    TABLES

      et_return = lt_return.



  READ TABLE lt_return WITH KEY type = 'S'

                       TRANSPORTING NO FIELDS.

  IF sy-subrc = 0.

    REFRESH lt_return.

    CALL FUNCTION 'BAPI_PS_PRECOMMIT'

      TABLES

        et_return = lt_return.

    READ TABLE lt_return WITH KEY type = 'S'

                       TRANSPORTING NO FIELDS.

    IF sy-subrc = 0.

      READ TABLE lt_return INTO l_wa_return INDEX 3.

      pc_aufnr_new = l_wa_return-message_v2.

    ENDIF.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

      IMPORTING

        return = l_wa_return.

  ENDIF.

this is the sample code to create network & to get the network number created