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

Bapi extension

Former Member
0 Likes
9,818

hi friends,

could anyone please help me on how to pass the BAPI extension values,,,

I dint understand how would it bee processed, when i read from help.sap.com.

So could anyone of give me an exampla nd code so that it would be more easier for me to understand.

Thanks in advance

Tina

1 ACCEPTED SOLUTION
Read only

Former Member
1,540

Hi

You should know us which BAPI you're using.

Anyway this is the example for BAPI_SALESORDER_CREATEFROMDAT2

The extension structure of header, item and scheduling are BAPE_VBAK, BAPE_VBAP and BAPE_VBEP for the values and BAPE_VBAKX, BAPE_VBAPX and BAPE_VBEPX for flag of updating.

You should know which strcutures to be used reading the BAPI documentation.

In this case I needs to enhance the structure VBAKKOZ, VBAPKOZ and VBEPKOZ.

For example for new item fields you should add your Z-field for item in VBAP, VBAPKOZ and BAPE_VBAP; if you have added Z-FIELD in VBAPKOZ you have to insert ZZ-FIELD but as flag.

So while you're passing the data to BAPI:

BAPE_VBAP-VBELN =

BAPE_VBAP-POSNR =

BAPE_VBAP-ZFIELD1 =

BAPE_VBAP-ZFIELD2 =

...................

BAPE_VBAP-ZFIELDN =

BAPIPAREX-STRUCTURE = 'BAPE_VBAP'.

BAPIPAREX+30 = BAPE_VBAP.

APPEND BAPIPAREX TO EXTENSIONIN.

BAPE_VBAPX-VBELN =

BAPE_VBAPX-POSNR =

BAPE_VBAPX-ZFIELD1 = 'X'

BAPE_VBAPX-ZFIELD2 = 'X'

...................

BAPE_VBAPX-ZFIELDN = 'X'

BAPIPAREX-STRUCTURE = 'BAPE_VBAPX'.

BAPIPAREX+30 = BAPE_VBAPX.

APPEND BAPIPAREX TO EXTENSIONIN.

Max

5 REPLIES 5
Read only

Former Member
1,541

Hi

You should know us which BAPI you're using.

Anyway this is the example for BAPI_SALESORDER_CREATEFROMDAT2

The extension structure of header, item and scheduling are BAPE_VBAK, BAPE_VBAP and BAPE_VBEP for the values and BAPE_VBAKX, BAPE_VBAPX and BAPE_VBEPX for flag of updating.

You should know which strcutures to be used reading the BAPI documentation.

In this case I needs to enhance the structure VBAKKOZ, VBAPKOZ and VBEPKOZ.

For example for new item fields you should add your Z-field for item in VBAP, VBAPKOZ and BAPE_VBAP; if you have added Z-FIELD in VBAPKOZ you have to insert ZZ-FIELD but as flag.

So while you're passing the data to BAPI:

BAPE_VBAP-VBELN =

BAPE_VBAP-POSNR =

BAPE_VBAP-ZFIELD1 =

BAPE_VBAP-ZFIELD2 =

...................

BAPE_VBAP-ZFIELDN =

BAPIPAREX-STRUCTURE = 'BAPE_VBAP'.

BAPIPAREX+30 = BAPE_VBAP.

APPEND BAPIPAREX TO EXTENSIONIN.

BAPE_VBAPX-VBELN =

BAPE_VBAPX-POSNR =

BAPE_VBAPX-ZFIELD1 = 'X'

BAPE_VBAPX-ZFIELD2 = 'X'

...................

BAPE_VBAPX-ZFIELDN = 'X'

BAPIPAREX-STRUCTURE = 'BAPE_VBAPX'.

BAPIPAREX+30 = BAPE_VBAPX.

APPEND BAPIPAREX TO EXTENSIONIN.

Max

Read only

0 Likes
1,540

Hey MAX

Sorry for that, I am using BAPI_MATERIAL_SAVEDATA.

Thanks for the timely help.

Thanks

Regards

Tina

Read only

0 Likes
1,540

Hi

It's the same but the structure are differents of course.

Here you can find the structures BAPI_TE_<TABLE NAME> and BAPI_TE_<TABLE NAME>X.

For example for Z-field in MARA:

BAPI_TE_MARA and BAPI_TE_MARAX.

So if you add new field in MARA and you want to transfer its value by this BAPI, you have to add it in the BAPI structures too.

So you should have:

- MARA-ZFIELD

- BAPI_TE_MARA-ZFIELD

- BAPI_TE_MARAX-ZFIELD.

But while BAPI_TE_MARA-ZFIELD is like MARA-ZFIELD, BAPI_TE_MARAX-ZFIELD has to be a flag (so long only one char).

So if you've to transfer the new fields by BAPI you've to fill the extensions structure in this way:

TABLES: BAPI_TE_MARA, BAPI_TE_MVKE, ......

DATA: EXTENSIONIN LIKE TABLE OF BAPIPAREX.

DATA: EXTENSIONINX LIKE TABLE OF BAPIPAREXX

  • New fields of MARA

BAPI_TE_MARA-ZFIELD1 = .....

BAPI_TE_MARA-ZFIELD2 = .....

BAPI_TE_MARA-ZFIELD3 = .....

............................

BAPIPAREX-STRUCTURE = 'BAPI_TE_MARA'.

BAPIPAREX+30 = BAPI_TE_MARA.

APPEND BAPIPAREX TO EXTENSIONIN.

BAPI_TE_MARAX-ZFIELD1 = 'X'.

BAPI_TE_MARAX-ZFIELD2 = 'X'.

BAPI_TE_MARAX-ZFIELD3 = 'X'.

............................

BAPIPAREXX-STRUCTURE = 'BAPI_TE_MARAX'.

BAPIPAREXX+30 = BAPI_TE_MARAX.

APPEND BAPIPAREXX TO EXTENSIONINX.

  • New fields of MVKE

BAPI_TE_MVKE-ZFIELD1 = .....

BAPI_TE_MVKE-ZFIELD2 = .....

BAPI_TE_MVKE-ZFIELD3 = .....

............................

BAPIPAREX-STRUCTURE = 'BAPI_TE_MVKE'.

BAPIPAREX+30 = BAPI_TE_MVKE.

APPEND BAPIPAREX TO EXTENSIONIN.

BAPI_TE_MVKEX-ZFIELD1 = 'X'.

BAPI_TE_MVKEX-ZFIELD2 = 'X'.

BAPI_TE_MVKEX-ZFIELD3 = 'X'.

............................

BAPIPAREXX-STRUCTURE = 'BAPI_TE_MVKEX'.

BAPIPAREXX+30 = BAPI_TE_MVKEX.

APPEND BAPIPAREXX TO EXTENSIONINX.

and so... (for all material tables you've enhnced)

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

..............

TABLES

..............

EXTENSIONIN = EXTENSIONIN

EXTENSIONINX = EXTENSIONINX.

When this BAPI works, it runs a piece of code like this to transfer the data from extension structure to database table:

LOOP AT EXTENSIONIN.

CASE EXTENSIONIN-STRUCTURE.

WHEN 'BAPI_TE_MARA'.

MOVE EXTENSIONIN+30 TO BAPI_TE_MARA.

WHEN 'BAPI_TE_MVKE'.

MOVE EXTENSIONIN+30 TO BAPI_TE_MVKE.

WHEN ........

....................................

ENDCASE.

ENDLOOP.

LOOP AT EXTENSIONINX.

CASE EXTENSIONIN-STRUCTURE.

WHEN 'BAPI_TE_MARAX'.

MOVE EXTENSIONIN+30 TO BAPI_TE_MARAX.

WHEN 'BAPI_TE_MVKEX'.

MOVE EXTENSIONIN+30 TO BAPI_TE_MVKEX.

WHEN ........

....................................

ENDCASE.

ENDLOOP.

After check the field where the flag is setted and move the value to database (i.e. MARA, MVKE ,.....)

Max

Read only

0 Likes
1,540

Hi Max,

Can u please tell me how to enhance the Extension1 and extension2 structures in BAPI_OUTB_DELIVERY_CHANGE these structures are different.

Thanks,

NN

Read only

0 Likes
1,540

Nethaji,

Did you solve this? If so, what is the solution?

Thank you,

Surya