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: 

BAPI Extensions

Former Member
0 Kudos

Hi All,

Requirement is for the Table : VBAK , there is one custom field appended by structure.Using Bapi

I should update this Custom field.

Using Bapi : BAPI_SALESORDER_CHANGE , but unable to update the field.

Please kindly let me know how to pass the parameter , so that I can Update the field.

Thanks

Ravi

5 REPLIES 5

former_member181962
Active Contributor
0 Kudos

Check the documentation for the bapi extensions parameters if you haven't already done that.

It has an example also.

<i><b>Customer Enhancement for VBAK, VBAP, VBEP

Description

You can use this parameter to transfer user-specific enhancments to a BAPI. The customer has to complete the EXTENSION structure and the system automatically continues processing it. If you have not defined any user-specific fields, then you can transfer a blank EXTENSIONIN structure.

Technical information about Customer Enhancements

The following description uses an example to explain how to proceed with customer enhancements to the SD tables VBAK, VBKD, VBAP and VBEP.

The customer has added their own fields to table VBAP using the INCLUDE structure CUTEST. This structure contains 2 fields:

CFIELD1, CHAR 10

CFIELD2, CHAR 3.

The customer also requires that these two fields can be maintained with the BAPI.

1. Maintain structure CUTEST in table VBAP

2. Because the BAPIs work with checkboxes, you must also define a CUTESTX checkbox for the customer structure. It should be structured like this:

Field name Data element

CFIELD1 CHAR1

CFIELD2 CHAR1

3. Define these customer structures in the structures VBAPKOZ und VBAPKOZX using INCLUDE or APPEND.

4. Add the customer structures to the BAPE_VBAP and BAPE_VBAPX BAPI structures using the APPEND technique.

5. Adjust the following structures for customer enhancements to table VBAK:

a) VBAKKOZ

b) VBAKKOZX

c) BAPE_VBAK

d) BAPE_VBAKX

6. Adjust the following structures for customer enhancements to table VBEK:

a) VBEPKOZ

b) VBEPKOZX

c) BAPE_VBEP

d) BAPE_VBEPX

7. Generally, the data should be added to the BAPI interface in the internal communication structures (VBAKKOM, and so on). There, you can process the data in the SD tables (VBAK, and so on).

8. If the EXTENSIONIN parameter contains customer data, you must complete at least the key fields in the relevant standard parameters.

For example:

You want to change customer field VBAP-CFIELD2 for item 20 to "XYZ" in order 4711.

The following entries are expected:

Import: BAPIVBELN-VBELN = '0000004711' Document number

BAPISDHD1X-UPDATEFLAG = 'U' UPDKZ for doc header

Tables: BAPISDITM-ITM_NUMBER = '000020' Item number

BAPISDITMX-ITM_NUMBER = '000020' Item number

+ BAPISDITMX-UPDATEFLAG = 'U' UPDKZ for item

You must complete the EXTENSION table as follows:

STRUCTURE VALUEPART1 1234561234567890123

BAPE_VBAP 0000004711000020 XYZ

BAPE_VBAPX 0000004711000020 X

Further Information

You can find more information in the BAPI programming guide in the chapter for enhancements to BAPIs.

Notes

You must complete the STRUCTURE field with the name of the relevant enhancement structure (BAPE_VBAK, BAPE_VBAP, BAPE_VBEP). You can complete the remaining fields with the append structures from the enhancement structures.

At the moment, you can use the BAPI to store enhancements in the following structures:

VBAK : An enhancement to header data requires an append structure to BAPE_VBAK and an enhancement to structure VBAKKOZ.

VBAP : An enhancement to item data requires an append structure to BAPE_VBAP and an enhancment to structure VBAPKOZ.

VBEP : An enhancement to schedule line data requires an append structure to BAPE_VBEP and an enhancement to structure VBEPKOZ.

VBKD : If you are using an enhancement for header data, you must add an append structure to BAPE_VBAK. You also need to enhance structure VBAKKOZ. If it is for item data, you need to add an append structure to BAPE_VBAP. You must also enhance structure VBAPKOZ.

If you also want to work with checkboxes, each X-structure must also contain an append structure.

For example:

A customer has created an order and wants to include the material long text (50 digits long).

The EXTENSIONIN structure must be completed with BAPE_VBAP. Two fields have fixed definitions in this structure. These are in the VBAP host key (VBELN, POSNR). The customer sets up an append structure that contains field ZMAT50.

Because the VBELN is normally blank when you create an order, the data can look like this:

STRUCTURE |BAPE_VBAP

VALUEPART1 | 000010Customermateriallongtext50

VBELN POSNR ZMAT50</b></i>

0 Kudos

Thanx a lot for your inputs

manuel_bassani
Contributor
0 Kudos

Hi Ravi,

did you append your custom field in structures

BAPE_VBAK and VBAKKOM ?

This is neccesary in order to make the field to be updated

Then fill extension table in this way


EXTENSIONIN-STRUCTURE = 'BAPE_VBAK'.
BAPE_VBAK-VBELN = doc_number.
BAPE_VBAK-ZZFIELD = '123'.
EXTENSIONIN+30 = BAPE_VBAK.
APPEND EXTENSIONIN.

Let me know

Regards, Manuel

Please remembre to reward points if it is useful

Clemenss
Active Contributor
0 Kudos

Hi Ravi,

as you want to handle additional header data fiels in VBAK, the enhancement requires an append structure to BAPE_VBAK and an enhancement to structure VBAKKOZ.

Look at the function module documentation of tables parameter EXTENSIONIN.

I think this is pretty clear.

Try to gio that way and if you have more questions, feel free to ask.

Kind regards,

Clemens

Former Member
0 Kudos

Hi Ravi,

I have worked on BAPI_SALESORDER_CHANGE ...

Try as below and let me know if it does not work .. It will work for sure

*--------------------------------------------------------------------*

TYPES : BEGIN OF lty_valuepartx,

           valuepart1 TYPE valuepart,

           valuepart2 TYPE valuepart,

           valuepart3 TYPE valuepart,

           valuepart4 TYPE valuepart,

         END OF lty_valuepartx.

DATA : lt_extensionin TYPE TABLE OF bapiparex,

        lt_extensioninx TYPE TABLE OF bapiparex.

DATA : lwa_valuepart   TYPE lty_valuepartx,

        lwa_bape_vbap   TYPE bape_vbap,

        lwa_bape_vbapx  TYPE bape_vbapx,

        lwa_extensionin TYPE bapiparex.

*--------------------------------------------------------------------*

* Populate all the required information for BAPI

* Populate extension information VBAP for BAPE_VBAP

lwa_bape_vbap-vbeln        = lv_vbeln.      " Sales Document Number

lwa_bape_vbap-posnr        = lv_item.       " Item Number

lwa_bape_vbap-zzfield      = 'AB83259'.     " Z field value

lwa_valuepart              = lwa_bape_vbap.

lwa_extensionin-structure  = 'BAPE_VBAP'.

lwa_extensionin-valuepart1 = lwa_valuepart-valuepart1.

lwa_extensionin-valuepart2 = lwa_valuepart-valuepart2.

lwa_extensionin-valuepart3 = lwa_valuepart-valuepart3.

lwa_extensionin-valuepart4 = lwa_valuepart-valuepart4.

APPEND lwa_extensionin TO lt_extensionin.

CLEAR : lwa_extensionin,

         lwa_bape_vbap,

         lwa_valuepart.

* Same way for BAPE_VBAPX also, populate extensionx information

lwa_bape_vbapx-vbeln       = lv_vbeln.      " Sales Document Number

lwa_bape_vbapx-posnr       = lv_item.       " Item Number

lwa_bape_vbapx-zzfield     = abap_true.      " Z field value

lwa_valuepart              = lwa_bape_vbapx.

lwa_extensionin-structure  = 'BAPE_VBAPX'.

lwa_extensionin-valuepart1 = lwa_valuepart-valuepart1.

lwa_extensionin-valuepart2 = lwa_valuepart-valuepart2.

lwa_extensionin-valuepart3 = lwa_valuepart-valuepart3.

lwa_extensionin-valuepart4 = lwa_valuepart-valuepart4.

APPEND lwa_extensionin TO lt_extensioninx.

CLEAR : lwa_extensionin,

         lwa_bape_vbapx,

         lwa_valuepart.

* Set updateflag so that the  sales order will be updated

lwa_order_headx-updateflag = lc_update" U "

* BAPI call for sales order change

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

   EXPORTING

     salesdocument    = lv_vbeln " Sales Document Number

     order_header_in  = lwa_order_head

     order_header_inx = lwa_order_headx

   TABLES

     return           = lt_return

     order_item_in    = lt_order_item_in

     order_item_inx   = lt_order_item_inx

     partners         = lt_partners

     partnerchanges   = lt_partner_chngs

     partneraddresses = lt_partneraddresses

     order_cfgs_ref   = lt_order_cfgs_ref_in

     order_cfgs_inst  = lt_order_cfgs_inst_in

     order_cfgs_value = lt_order_cfgs_value_in

     schedule_lines   = lt_schedule_lines_in

     schedule_linesx  = lt_schedule_lines_inx

     extensionin      = lt_extensionin

     extensionex      = lt_extensionx.


Hope this will help you ..


Thanks & Regards,

Arun.