Skip to Content
author's profile photo Former Member
Former Member

help on user exit to save cuobj value in SAPMV45A

Hello Guys,

I am working on a project for variant configuration where in I am trying to substitute the pfunction by a logic in which I need to capture the field CUOBJ; i know its in the structure but I need to know the name of the user exit wherein I can capture it and then save it in the table for characteristics value so that i can pass it on as a characteristics.

I will be using the User exit in program SAPMV45A which has t.code VA01.

Any one with experience on this; please help.

BR,

Prasenjit Singh Bist

Edited by: Prassenjit S. Bist on May 24, 2011 5:54 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on May 26, 2011 at 10:51 AM

    Hello, I have found the solution inside the user exit USEREXIT_SAVE_DOCUMENT we can track VBAP-CUOBJ.

    once done use the following function module to rea the characteristics 'CUCB_GET_CONFIGURATION'

    once, done change the values of the characteristics you want to do using the function module CUCB_CHANGE_CONFIGURATION.

    Below is the code I have written, feel free if any one out there is with similiar requirement and needs help. Although I am not very experienced but I will be happy to help.

    • local variables to pass import parameters.

    DATA: lv_instance type cuib_cuobj, " instance created on saving the sales order

    lv_new_instance_update type cuib_cuobj, " new updated instance after DB commit.

    lv_werks type marc-werks, " plant

    lv_konfmat type MARA-MATNR, " material number

    lv_wo_commit_update type Boolean, " * data type C length 1

    lv_force_new_instance type Boolean, " * data type C length 1

    lv_sep(1) type C.

    • internal tables to receive tables parameters.

    DATA: lt_e1cucfg type table of E1CUCFG,

    lt_E1CUINS type table of E1CUINS,

    lt_E1CUVAL type table of E1CUVAL, " internal table with characteristics and values entered by user in config. editor

    lt_E1CUCOM type table of E1CUCOM,

    lt_ET_RETURN type BAPIRET2_T.

    • work area for lt_e1cuval.

    DATA: lw_lt_e1cuval like line of lt_e1cuval.

    • To be selectively executed in test runs.

    DATA:

    BEGIN OF LS_VBPS_KEY,

    VBELN LIKE VBAP-VBELN, " Sales Order Number

    POSNR LIKE VBAP-POSNR, " Line Item

    END OF LS_VBPS_KEY.

    DATA: ls_ROOT_OBJECT type CUIB_BUSINESS_OBJECT. " To pass CUIB: Business Objekt to FM CUCB_CONFIGURATION_TO_DB

    *&----


    • Added by PRBIST on 26.05.2011

    • Test Function group GET/SET/ DB from FGrp CUCB.

    *&----


    TYPE-POOLS: IBXX.

    TYPE-POOLS: IBCO2 .

    • export parameters for CUCB_GET_CONFIGURATION.

    DATA: lv_ibase type IBCO2_IBASE_REC,

    lt_CONFIGURATION type IBCO2_INSTANCE_TAB2,

    lref_EO_CBASE_REF type ref to IF_CBASE_E,

    lt_values type standard table of IBVALUE0, " Read values from field VALUE of lt_configuration

    lw_lt_values like line of lt_values,

    lw_lt_configuration like line of lt_configuration.

    • move data from temporary vbap structure to local variables.

    MOVE: VBAP-cuobj to lv_instance,

    VBAP-werks to lv_werks,

    VBAP-matnr to lv_konfmat,

    VBAK-VBELN to LS_VBPS_KEY-VBELN,

    VBAP-POSNR to LS_VBPS_KEY-POSNR.

    CALL FUNCTION 'CUCB_GET_CONFIGURATION'

    EXPORTING

    instance = lv_instance

    • IS_BUSINESS_OBJECT =

    • IV_MOMENT =

    • IV_WITH_DB_INSTANCE =

    IMPORTING

    IBASE = lv_ibase

    CONFIGURATION = lt_configuration

    EO_CBASE_REF = lref_eo_cbase_ref

    EXCEPTIONS

    INVALID_INPUT = 1

    INVALID_INSTANCE = 2

    INSTANCE_IS_A_CLASSIFICATION = 3

    OTHERS = 4.

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    IF sy-subrc EQ 0.

    • in side the loop copy the content of the values field.

    • we have VBAP-CUOBJ, lw_lt_configuration-ibase and characteristics values.

    LOOP AT lt_configuration INTO lw_lt_configuration.

    lt_values[ ] = lw_lt_configuration-values[ ].

    ENDLOOP.

    ENDIF.

    • make changes to the values of the characteristics.

    LOOP AT lt_values INTO lw_lt_values WHERE atinn EQ '0000000128'.

    lw_lt_values-atwrt = 'J'.

    • modify the table lt_values.

    MODIFY lt_values FROM lw_lt_values.

    ENDLOOP.

    • make the changes in the table lt_configuration, too.

    LOOP AT lt_configuration INTO lw_lt_configuration.

    lw_lt_configuration-values[] = lt_values[].

    MODIFY lt_configuration FROM lw_lt_configuration.

    ENDLOOP.

    • Once the values have been changed in the temp. variable make thechanges in database.

    CALL FUNCTION 'CUCB_CHANGE_CONFIGURATION'

    EXPORTING

    root_instance = lv_instance

    • IS_CBASE_HEADER =

    CHANGING

    INSERTED_OR_CHANGED_INSTANCES = lt_configuration[]

    • DELETED_INSTANCES =

    EXCEPTIONS

    INVALID_INPUT = 1

    INVALID_INSTANCE = 2

    INSTANCE_IS_A_CLASSIFICATION = 3

    OTHERS = 4.

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.