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

Update PROJ Table custom fields

karuna_gangireddy
Contributor
0 Likes
5,444

Hi All,

I am working on a requirement where i need to update a custom field that we added to PROJ table. I follwed the note "509898 - BAPI enhancement concept and Unicode" and created a strcuture 'ZCI_PROJ_CHAR_COPY' similar to 'CI_PROJ' with all CHAR fields. Also updated the structure 'BAPI_TE_PROJECT_DEFINITION' with my new structure instead of the 'CI_PROJ'. I am not getting any errors but PROJ table is not updating.

After the function 'BAPI_BUS2001_CHANGE', LT_RETURN is having 'Individual check for change of object project def#<XXX> successful'.

After the function ''BAPI_PS_PRECOMMIT', LT_RETURN is having :

1. 'Data from object project def# <XXX> is not changed'

2. Final check of the project def and the WBS elements: NO Error'

Here is my code so far:

_____________________________________________________________________________________________

data:ls_project_definition           type bapi_bus2001_chg,
         ls_project_definition_upd  type bapi_bus2001_upd,
         lt_return                               type standard table of bapiret2,
         lt_return1                             type bapiret2,
         it_extensionin                     type standard table of bapiparex,
         fs_extensionin                    like line of it_extensionin.

*   get project details
    select single * into ls_proj
      from proj
      where pspid = fs_zeban-proj_nbr.

    ls_project_definition-project_definition = ls_proj-pspid.

    move-corresponding ls_proj to ls_ci_proj.
    ls_ci_proj-zz_sanum         = fs_zeban-banfn.

    move-corresponding ls_ci_proj to ls_ci_proj_char_cp.

    fs_extensionin-structure    = 'ZCI_PROJ_CHAR_COPY'.
    fs_extensionin-valuepart1   = ls_ci_proj_char_cp(240).
    fs_extensionin-valuepart2   = ls_ci_proj_char_cp+241(166).
    append fs_extensionin      to it_extensionin.

    ls_project_definition_upd-zz_sanum = 'X'.

    call function 'BAPI_PS_INITIALIZATION'.

    call function 'BAPI_BUS2001_CHANGE'
       exporting
         i_project_definition       = ls_project_definition
         i_project_definition_upd   = ls_project_definition_upd
       tables
         et_return              = lt_return
         extensionin            = it_extensionin .

    call function 'BAPI_PS_PRECOMMIT'
       tables
          et_return = lt_return.

      refresh lt_return.

      call function 'BAPI_TRANSACTION_COMMIT'
        exporting
          wait = 'X'
       importing
         return = lt_return1.
__________________________________________________________________________________________

Any help is much appreciated.

Thanks in advance,

Karuna

1 ACCEPTED SOLUTION
Read only

Former Member
3,230

Hi ,

Here as per your requirement you are going to extend PROJ tables. You need to do like below

1) you have to enhance the standard structure CI_PROJ with your custom fields. So as soon as you add your fields there; this will be appended into BAPI_TE_PROJECT_DEFINITION structure.

2) Then code like below

data : wa_custstr type BAPI_TE_PROJECT_DEFINITION,

         lt_extnin like standard table of bapiparex

          initial size 0 with header line.

wa_custstr-PROJECT_DEFINITION = < project number> - mandatory

wa_custstr- custom field 1 = <field value >.

wa_custstr - cstom field 2 = <field value > .

     lt_extnin-structure = 'BAPI_TE_PROJECT_DEFINITION'.

      lt_extnin-valuepart1 = wa_custstr.

      append lt_extnin.

pass this lt_extnin into  extensionin  of BAPI. Rest coding part keep is as it is. And if error occurs in  any of these BAPI's use BAPI_TRANSACTION_ROLLBACK as a good practice.

7 REPLIES 7
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
3,230

Hi Karuna

Do as follow. Put a break point on PS_BAPI_CALL_BADI called inside PS_BAPI_PREPARE which in turn is called inside BAPI_BUS2001_CHANGE.  Please check if yu need to implement the BADI also to move data from extension to custom fields.

Nabheet


Read only

karuna_gangireddy
Contributor
0 Likes
3,230

Hi Nabheet,

Thank you very much for your quick response. I will do as you suggested. Do you by any chance know the BADI's name that i might have to implement? Because in the note '509898 - BAPI enhancement concept and Unicode' it is mentioned that:

" If you wish to process non-character-like data using the above workaround, you should not use any SAP-designed BAPI Table Extensions. Instead, define your own data structures as described above and execute the conversion between the extension parameters and internal data structures in the Customer Exits / BadIs yourself ".


I will look around as well for the BADI.

Thanks again,

Karuna

Read only

0 Likes
3,230

Hi Nabheet,

I just debugged 'PS_BAPI_CALL_BADI', but i am very confussed. How will you know if you need to implement a BADI?

Thanks,

Karuna

Read only

Former Member
0 Likes
3,230

Karuna,

what is the purpose of adding new zfields to the PROJ table.

Here are some ways to add zfields to PROJ Table.

Easy way for updating for the fields which were added through CI_PROJ is through enhancment.

Below is the process:

1) First create a project in CMOD and attach the enhancement CNEX0006 to the project.

2) Go to se11 and in the PROJ table u will find ci_proj include , in this add the required custom fields.

3) Go to se51 give SAPLXCN1 in the program name with screen number 0600 , create the subscreen and in the layout choose

     Dictionary./Program fields and drag and drop in the screen .

4)  If u want to write any logic before the screen is displayed do it in PBO.

5) Now in the function exit EXIT_SAPLCJWB_002 , go in the INCLUDE ZXCN1U11 and write this logic

    move-corresponding sap_proj_imp to proj.

6) Now in the function exit EXIT_SAPLCJWB_003 , go in the INCLUDE ZXCN1U12. and write this logic

    move-corresponding proj to cnci_proj_exp.

Activate the project .

I couldn't suggest you exact solution as your requirement is not 100% clear.

Thanks,

Kishor.

Read only

karuna_gangireddy
Contributor
0 Likes
3,230

Hi Kishor,

Thank you for explaining all the steps in details.  Kishor, we have those steps in place and working. Let me tell you the requirement. It is little different.

As i mentioned the CMOD is woking fine from tcode: CJ20N. We created a custom tab with the fields and the PROJ table is updating from there. no issues with that. But we have a WF for the PREQ approvals in which one of the approvals have to update the PREQ with the project name. Upon which ZEBAN is getting  updating with Project# to that PREQ. At the same time we also want to tie the PREQ with the project# in PROJ. This is where i am trying to update the PROJ table.

Also we have around 15-20 custom fields and the one I want to update is the last one. WHich is why i am using VALUEPART2 as VALUEPART1 is all take with the other custom fields.

Thanks,

Karuna

Read only

Former Member
3,231

Hi ,

Here as per your requirement you are going to extend PROJ tables. You need to do like below

1) you have to enhance the standard structure CI_PROJ with your custom fields. So as soon as you add your fields there; this will be appended into BAPI_TE_PROJECT_DEFINITION structure.

2) Then code like below

data : wa_custstr type BAPI_TE_PROJECT_DEFINITION,

         lt_extnin like standard table of bapiparex

          initial size 0 with header line.

wa_custstr-PROJECT_DEFINITION = < project number> - mandatory

wa_custstr- custom field 1 = <field value >.

wa_custstr - cstom field 2 = <field value > .

     lt_extnin-structure = 'BAPI_TE_PROJECT_DEFINITION'.

      lt_extnin-valuepart1 = wa_custstr.

      append lt_extnin.

pass this lt_extnin into  extensionin  of BAPI. Rest coding part keep is as it is. And if error occurs in  any of these BAPI's use BAPI_TRANSACTION_ROLLBACK as a good practice.

Read only

3,230

Hi Kaushik,

Thank you very much. With your reply I was able to resolve the issue. Here is what i did:
___________________________________________________________________

data: ls_proj                                 type proj,
         wa_custstr                           type BAPI_TE_PROJECT_DEFINITION,
         ls_project_definition           type bapi_bus2001_chg,
         ls_project_definition_upd  type bapi_bus2001_upd,
         lt_return                                type standard table of bapiret2,
         lt_return1                              type bapiret2,
         lt_extensionin                      type standard table of bapiparex initial size 0 with header line.

*   get project details
    select single * into ls_proj from proj where pspid = fs_zeban-proj_nbr.

    lt_extensionin-structure = 'BAPI_TE_PROJECT_DEFINITION'.
    lt_extensionin-valuepart1+0(24)   = ls_proj-pspid.
    lt_extensionin-valuepart2+181(10) = fs_zeban-banfn.
    append lt_extensionin.

    call function 'BAPI_PS_INITIALIZATION'.

    ls_project_definition-project_definition = ls_proj-pspid.
    ls_project_definition_upd-zz_sanum = 'X'.

    call function 'BAPI_BUS2001_CHANGE'
         exporting
                i_project_definition           = ls_project_definition
                i_project_definition_upd   = ls_project_definition_upd
         tables
                et_return                             = lt_return
                extensionin                         = lt_extensionin .

  

    call function 'BAPI_PS_PRECOMMIT'
       tables
          et_return = lt_return.

    refresh lt_return.

    call function 'BAPI_TRANSACTION_COMMIT'
         exporting
                wait = 'X'
         importing
                return = lt_return1.

__________________________________________________________________________

Thank again for helping out,

Karuna