Application Development 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: 

Problem with Custom fields updation during creation of Project Definition and WBS Elements using BAPI_BUS2001_CREATE

Former Member
0 Kudos

Dear Experts,

For the purpose of the data migration of Open projects and WBS, I am using the following BAPI's:

Project Definition: BAPI_BUS2001_CREATE

WBS Elements :   BAPI_BUS2054_CREATE_MULTI

I have chosen these two BAPI's, as the projects have custom enhancements and the same has to updated during the creation. As both the BAPI's have the EXTENIN structure and the documentation also suggests you can update the custom enhancements through these structures.

The Flow of the BAPI's is as given below:

For Project Definition creation:


CALL FUNCTION 'BAPI_PS_INITIALIZATION'.


CALL FUNCTION 'BAPI_BUS2001_CREATE'

       EXPORTING

         i_project_definition       = wa_projdef

      TABLES

        ET_RETURN                  = it_return

        EXTENSIONIN               = it_extin

        EXTENSIONOUT           = it_extout.

CALL FUNCTION 'BAPI_PS_PRECOMMIT'

              TABLES

                 et_return = it_return1.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

               EXPORTING

                 wait = 'X'

              IMPORTING

                return = wa_return.

.

I am passing the values to the Extensionin structures as given in the documentation but without any success as the Project definition and WBS Elements are created without the custom enhancement values.

There is also a BADI 'BAPIEXT_BUS2001', but I dont think any action is required as I am not doing any further processing.

Also I checked the OSS note 637345, it says replace the CI_PROJ structure into ZCI_PROJ in the  BAPI_TE_PROJECT_DEFINITION if you have alpha-numeric fields in the custom enhancement. As I have only character fields, I am of opinion that this might not help.


Kindly advise a solution to this problem . Prompt replies highly appreciated.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos
  • Are all your customer fields defined in CI_PROJ and CI_PRPS so structures BAPI_TE_PROJECT_DEFINITION and BAPI_TE_WBS_ELEMENT contain those.
  • Did you correctly filled the internal table parameter EXTENSIONIN (passing structure bapi_te_proj thru method CL_ABAP_CONTAINER_UTILITIES=>FILL_CONTAINER_C to extensionin+30) structure names in uppercase, external format for object id (PS_PSPID, PS_POSID)

> Can you post your code for filling extensionin.

Regards,

Raymond

16 REPLIES 16

former_member188724
Contributor
0 Kudos

Hi,

Please check whether the Structure, Valuepart1-4 are filled with correct Parameters. As you say Project & wbs element getting created, only issue can be the fields not getting correctly to the structure......

Maybe you can paste the code.

Regards,

K.S

0 Kudos

Hi KS,

Thanks for your reply,

The Code is as follow:

data : wa_custproj type BAPI_TE_PROJECT_DEFINITION,

          wa_extin      type bapiparex,

          it_extin         type table bapiparex.

wa_custproj-PROJECT_DEFINITION = wa_main-pspid.  "Passing the Project Defn Key

wa_custproj-customfield1     = wa_main-customfield1.   "Passing the custom values.

wa_custproj-customfield2     = wa_main-customfield2.

wa_extin-structure = 'BAPI_TE_PROJECT_DEFINITION'.

wa_extin-valuepart1 = wa_custproj.

append wa_extin to it_extin.

CLEAR: wa_extin, wa_custproj.

raymond_giuseppi
Active Contributor
0 Kudos
  • Are all your customer fields defined in CI_PROJ and CI_PRPS so structures BAPI_TE_PROJECT_DEFINITION and BAPI_TE_WBS_ELEMENT contain those.
  • Did you correctly filled the internal table parameter EXTENSIONIN (passing structure bapi_te_proj thru method CL_ABAP_CONTAINER_UTILITIES=>FILL_CONTAINER_C to extensionin+30) structure names in uppercase, external format for object id (PS_PSPID, PS_POSID)

> Can you post your code for filling extensionin.

Regards,

Raymond

0 Kudos

Hi Raymond,

Thanks for your reply.

I had filled in the values as shown in the previous reply to KS. I changed the code to fill the extension structure with the method CL_ABAP_CONTAINER_UTILITIES=>FILL_CONTAINER_C but without any success.

data : wa_custproj type BAPI_TE_PROJECT_DEFINITION,

          wa_extin      type bapiparex,

          it_extin         type table bapiparex.

wa_custproj-PROJECT_DEFINITION = wa_main-pspid.  "Passing the Project Defn Key in external format

wa_custproj-customfield1     = wa_main-customfield1.   "Passing the custom values.

wa_custproj-customfield2     = wa_main-customfield2.

CALL METHOD cl_abap_container_utilities=>fill_container_c

   EXPORTING

     im_value                     = wa_custproj

   IMPORTING

     ex_container               = wa_extin+30

   EXCEPTIONS

    illegal_parameter_type = 1

    others                            = 2

         .

IF sy-subrc <> 0.

* Implement suitable error handling here

ENDIF.


append wa_extin to it_extin.

CLEAR: wa_extin, wa_custproj.


Please let me know if I have missed anything.

0 Kudos

Can you add a BREAK-POINT at

move-corresponding wa_bapi_te_proj to proj_new. 

in FM CJ2001_CREATE, and execute you report, if break-point not reached, then add another break-point at

loop at extensionin where structure = 'BAPI_TE_PROJECT_DEFINITION'
           and valuepart1(24) = i_project_definition-project_definition.

Regards,

Raymond

0 Kudos

Hey Raymond,

I kept the break point at the Loop statement. The where clause is failing in the loop statement because of which the move-corresponding statement is not getting processed.


loop at extensionin where structure = 'BAPI_TE_PROJECT_DEFINITION'

and valuepart1(24) = i_project_definition-project_definition.

Although the extensionin-structure contains 'BAPI_TE_PROJECT_DEFINITION' and the extensionin-valuepart1(24) contains E00001 and i_project_definition-project_definition also contains the same., it's not going inside the loop. I don't understand why.

0 Kudos

In Debug mode look for actual value of both fields (trailing space with different actual hex values)

Regards,

Raymond

0 Kudos

Hey Raymond,

You are right,the Hex Values are different. I copied the Valuepart1(24) along with the spaces and copied in the project definition field during debugging and it worked like a charm.

But when i tried adding the spaces in my program to the project definition and pass it to the BAPI, it reverts back without spaces and the where clause fails again.

Any ideas on how to workaround this?

0 Kudos

Clear the 24 leading character before moving your field (which type, length, how filled ?)

0 Kudos

Solved.

The issue was the project definition was getting converted using' CONVERSION_EXIT_ABPSN_INPUT' internally and the ':' was deleted from the project definition. That is why both the values were not matching. I missed that during my comparison, my bad.

Thanks Raymond.

0 Kudos

Hi ganesh,

I am first time interacting with BAPi so please help me out urgent.

I am using BAPI_BUS2001_CREATE for creating project, I have created structure and now I have pass the data from internal table to this BAPI for project creation

My structure is:

types:begin of t_header,

PSPID TYPE PROJ-PSPID, "Project Definition

POST1 TYPE PROJ-POST1, " Description .

PROFL TYPE PROJ-PROFL, " Project Profile.

VKOKR type PROJ-VKOKR, "Controlling Area

VBUKR TYPE PROJ-VBUKR, " Company Code.

VERNR TYPE PROJ-VERNR, " Responsible Person.

PLFAZ TYPE PROJ-PLFAZ, " Start Date.

PLSEZ TYPE PROJ-PLSEZ, " Finish date.

TXJCD TYPE PROJ-TXJCD, " Tax Jurisdiction.

END OF t_header.


Please elaborate it well and how to check:

Before the project definition is created, the following is checked:

Is another project already being processed in the LUW (Logical Unit of Work)?

Does another project with the same project definition already exist?

Is the transferred data consistent (do the company code and the controlling area match)?

If all checks are successful, then the project definition is created in the document tables.

Please help me out. Thanks in advance.


Regards,

Vikash

0 Kudos

Hi Vikash,


vikash pathak wrote:

Please elaborate it well and how to check:

Before the project definition is created, the following is checked:

Is another project already being processed in the LUW (Logical Unit of Work)?

Does another project with the same project definition already exist?

Is the transferred data consistent (do the company code and the controlling area match)?

If all checks are successful, then the project definition is created in the document tables.

For the BAPI to work, the structure needs to be filled with the mandatory fields.

Going to the next part about the checks, the BAPI will take care of all the checks that you have mentioned here. So go ahead and fill in the structure and run with the BAPI as I have shown in the first post here with the sequence.

For Eg for you it would look something like this.

CALL FUNCTION 'BAPI_PS_INITIALIZATION'.


CALL FUNCTION 'BAPI_BUS2001_CREATE'

       EXPORTING

         i_project_definition       = t_header

      TABLES

        ET_RETURN                  = it_return.

CALL FUNCTION 'BAPI_PS_PRECOMMIT'

              TABLES

                 et_return = it_return1.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

               EXPORTING

                 wait = 'X'

              IMPORTING

                return = wa_return.

0 Kudos

Hi Ganesh,

Thanks For your Reply,

it was great help for me,

Regards

Vikash

0 Kudos

Hi Ganesh,

can you let me know where i am going wrong,

my code is mention below.

TYPE-POOLS: truxs.

*& Structure Declaration

TYPES:

    BEGIN OF fs_field_m,

    PSPID TYPE PROJ-PSPID,                       "Project Definition

    POST1  TYPE PROJ-POST1,                      " Description .

    PROFL TYPE PROJ-PROFL,                        " Project Profile.

    VKOKR type PROJ-VKOKR,                        "Controlling Area

    VBUKR TYPE PROJ-VBUKR,                        " Company Code.

    VERNR TYPE PROJ-VERNR,                  " Responsible Person.

    PLFAZ TYPE PROJ-PLFAZ,                  " Start Date.

    PLSEZ TYPE PROJ-PLSEZ,                  " Finish date.

    TXJCD TYPE PROJ-TXJCD,                  " Tax Jurisdiction.

END OF fs_field_m.

DATA : it_field TYPE TABLE OF fs_field_m,

             wa_field TYPE fs_field_m,

             it_header TYPE TABLE OF BAPI_BUS2001_NEW,

             wa_header TYPE BAPI_BUS2001_NEW.

Data: it_ret type STANDARD TABLE OF BAPIRET2 ,

      wa_ret TYPE BAPIRET2.

Data: it_ret1 type TABLE OF BAPIRET2.

LOOP AT it_field INTO wa_field.

   MOVE :    wa_field-PSPID   TO    wa_header-PROJECT_DEFINITION,

             wa_field-POST1   TO    wa_header-DESCRIPTION,

             wa_field-PROFL   TO    wa_header-PROJECT_PROFILE,

             wa_field-VKOKR   TO    wa_header-CONTROLLING_AREA ,

             wa_field-VBUKR   TO    wa_header-COMPANY_CODE,

             wa_field-VERNR   tO    wa_header-RESPONSIBLE_NO,

             wa_field-PLFAZ   TO    wa_header-START,

             wa_field-PLSEZ   TO    wa_header-FINISH,

             wa_field-TXJCD   to    wa_header-TAXJURCODE ,

      APPEND wa_header to it_header.

       CLEAR wa_header.

  ENDLOOP.

*BAPI Initialization.

CALL FUNCTION 'BAPI_PS_INITIALIZATION'

          .

*loop at it_header into wa_header.

* Bapi For Project Creation

CALL FUNCTION 'BAPI_BUS2001_CREATE'

  EXPORTING

    I_PROJECT_DEFINITION       = it_header

TABLES

   ET_RETURN                  = it_ret .

CALL FUNCTION 'BAPI_PS_PRECOMMIT'

   TABLES

     ET_RETURN       = it_ret1

            .

READ TABLE it_ret1 INTO wa_ret WITH KEY type = 'E'.

  IF sy-subrc EQ 0.

    EXIT.

  ENDIF.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

   EXPORTING

     WAIT          = 'X'

   IMPORTING

     RETURN        = wa_ret

            .

Thanks

Vikash

0 Kudos

Hi Vikash,

If you have any query, please start your own thread. If you don't mind, most of your queries deals with the basic programming stuff and will get rejected. So please do not waste your time here. Also I have noticed that you have been pestering others with your silly questions for many months. If you take my opinion programming doesn't seem to be your cup of tea.

BR.

0 Kudos

Hi Sam,

Dont mind but i am just satrted working on BAPI and new for BAPI,

and i am stuck here thatswhy i am asking this kind of questions,

so kindly if you could help me so please must help me.

Thanks

Vikash