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

is there any BAPI or Function Module for Material Substitution create

Former Member
0 Likes
5,833

Hi,

Is ther any a BAPI or Function module to create or change material substitution (transaction VB11/VB12).

Appreciate your help.

Thanks

1 ACCEPTED SOLUTION
Read only

former_member181966
Active Contributor
0 Likes
3,291

Here you go!!

<b>

RV_MAT_SUB_SAVE</b> ( Update for Material Substitution)

for code

see Include :<b>MV13DF00</b>

CALL FUNCTION 'RV_MAT_SUB_SAVE' IN UPDATE TASK

EXPORTING

USE_OUTBOUND_CALL = BOOLE_T

TABLES

X_KONDDVB = XKONDD

Y_KONDDVB = YKONDD

X_KONDDPVB = XKONDDP

Y_KONDDPVB = YKONDDP

DB_TIME = TIME_VAKE_DB

DB_XVAKE = XVAKE.

Hope this’ll give you idea!!

<b>Pl... award the points.</b>

Good luck

Thanks

Saquib Khan

"Some are wise and some are otherwise"

11 REPLIES 11
Read only

former_member181966
Active Contributor
0 Likes
3,292

Here you go!!

<b>

RV_MAT_SUB_SAVE</b> ( Update for Material Substitution)

for code

see Include :<b>MV13DF00</b>

CALL FUNCTION 'RV_MAT_SUB_SAVE' IN UPDATE TASK

EXPORTING

USE_OUTBOUND_CALL = BOOLE_T

TABLES

X_KONDDVB = XKONDD

Y_KONDDVB = YKONDD

X_KONDDPVB = XKONDDP

Y_KONDDPVB = YKONDDP

DB_TIME = TIME_VAKE_DB

DB_XVAKE = XVAKE.

Hope this’ll give you idea!!

<b>Pl... award the points.</b>

Good luck

Thanks

Saquib Khan

"Some are wise and some are otherwise"

Read only

0 Likes
3,291

Hi,

VB11/VB12 is using this Fm , I told you in my last post .

see Include :MV13DF00

CALL FUNCTION <b>'RV_MAT_SUB_SAVE' IN UPDATE TASK</b>

EXPORTING

USE_OUTBOUND_CALL = BOOLE_T

TABLES

X_KONDDVB = XKONDD

Y_KONDDVB = YKONDD

X_KONDDPVB = XKONDDP

Y_KONDDPVB = YKONDDP

DB_TIME = TIME_VAKE_DB

DB_XVAKE = XVAKE.

Tip: if you go to se93 : give transaction ..double click on the prog name and search key word "Call fucntion" in program . you`ll get this FM "RV_MAT_SUB_SAVE".

Thanks

Saquib

Read only

0 Likes
3,291

Hi Saquib,

I knew this function is used by transaction VB11&Vb12. But just calling this function and passing data can't create condition record for material determination.

Iam using SAP standard condition type A001&pocedure A0001. I am looking for a function to create material substitution in an interface mode. i.e looking function or sequence of functions for creating Material determination.

Appreciate your ideas/help.

Thanks

Read only

ferry_lianto
Active Contributor
0 Likes
3,291

Hi Hariprasad,

Please check this FM.

<b>PRODUCT_SUBSTITUTION

COND_CROSS_SELLING</b>.

Hope this will help.

Regards,

Ferry Lianto

Read only

0 Likes
3,291

Hi Guys,

I tried both the function modules with out much sucess. Basicaaly I want to save data for transaction VB11/VB12 in background. I don't want to use BDC to save data.Is there any BAPI which save data for Material Substitution?.

Thanks

Read only

Former Member
0 Likes
3,291

Hello,

Try with Fm RV_MAT_SUB_SAVE

CALL FUNCTION 'RV_MAT_SUB_SAVE' IN UPDATE TASK

EXPORTING

USE_OUTBOUND_CALL = BOOLE_T

TABLES

X_KONDDVB = XKONDD

Y_KONDDVB = YKONDD

X_KONDDPVB = XKONDDP

Y_KONDDPVB = YKONDDP

DB_TIME = TIME_VAKE_DB

DB_XVAKE = XVAKE.

This FM is used in the include MV13DF00

If useful reward points.

Regards,

Vasanth

Read only

0 Likes
3,291

I used this function, But I can't view the data from VB13 once I save data using this function. basically once I save the data using function, I should able to see the data again in vb13 which is material determination display.

I am using SAP standard material determination procedure A0001 and condition type A001. looking for help.

Thanks in advance

Read only

Former Member
0 Likes
3,291

I have tried using the Function module RV_MAT_SUB_SAVE' IN UPDATE TASK, but the records are not getting updated. Do we need to use any other function module before calling this?

Read only

Former Member
0 Likes
3,291

Hi all,

I think you'll need to execute function module RV_KONDITION_SICHERN before calling RV_MAT_SUB_SAVE.

Hope this helps.

Cheers,

Chris.

p.s. you will also need to use the NUMBER_GET_NEXT function before calling RV_KONDITION_SICHERN. Parameters are as follows:

NR_RANGE_NR = '01'

OBJECT = 'KOND'

Read only

Former Member
0 Likes
3,291

Hi Hari,

As Shilpa has already used the FM 'RV_MAT_SUB_SAVE' and is not able to save the records. Why cant we try to commit the DB work by using 'BAPI_TRANSACTION_COMMIT' and see if table has been updated.

Regards,

Vijay.

Read only

0 Likes
3,291

Ok, I'll make it easy for you guys. Here's a function module I knocked together to do the job. I know it works as I'm using it in one of my programs.

FUNCTION z_create_mat_substitution.

*"----


""Local Interface:

*" IMPORTING

*" REFERENCE(IT_MAT_SUB) TYPE ZMATERIAL_SUBSTITUTION_T

*" EXPORTING

*" REFERENCE(ET_BAPIRET2) TYPE BAPIRET2_T

*" EXCEPTIONS

*" FAILED

*"----


*" This function uses the following standard function modules to

*" create material substitutions:

*" RV_KONDITION_SICHERN

*" RV_MAT_SUB_SAVE

*"----


DATA: ls_mat_sub LIKE zmaterial_substitution,

ls_vakedb LIKE vakedb,

ls_xkonddvb LIKE konddvb,

ls_bapiret2 LIKE bapiret2,

lt_vakedb LIKE STANDARD TABLE OF vakedb,

lt_xkonddvb LIKE STANDARD TABLE OF konddvb,

lt_ykonddvb LIKE STANDARD TABLE OF konddvb,

lt_xkonddpvb LIKE STANDARD TABLE OF konddpvb,

lt_ykonddpvb LIKE STANDARD TABLE OF konddpvb,

lv_knumh TYPE knumh.

LOOP AT it_mat_sub INTO ls_mat_sub.

CLEAR: ls_vakedb,

ls_xkonddvb,

lt_vakedb[],

lt_xkonddvb[].

  • Populate structure for RV_KONDITION_SICHERN.

MOVE: 'D' TO ls_vakedb-kvewe,

'001' TO ls_vakedb-kotabnr,

'V' TO ls_vakedb-kappl,

'A001' TO ls_vakedb-kschl,

ls_mat_sub-matwa TO ls_vakedb-vakey,

ls_mat_sub-datbi TO ls_vakedb-datbi,

ls_mat_sub-datab TO ls_vakedb-datab,

'I' TO ls_vakedb-xxdbaction.

  • Populate structure for RV_MAT_SUB_SAVE.

MOVE: sy-mandt TO ls_xkonddvb-mandt,

ls_mat_sub-smatn TO ls_xkonddvb-smatn,

ls_mat_sub-meins TO ls_xkonddvb-meins,

ls_mat_sub-sugrd TO ls_xkonddvb-sugrd,

'I' TO ls_xkonddvb-updkz.

  • Determine next available condition record number.

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING

nr_range_nr = '01'

object = 'KOND'

IMPORTING

number = lv_knumh.

ls_vakedb-knumh = ls_xkonddvb-knumh = lv_knumh.

  • Append to internal tables.

APPEND: ls_vakedb TO lt_vakedb,

ls_xkonddvb TO lt_xkonddvb.

ENDLOOP.

  • Call RV_KONDITION_SICHERN.

CALL FUNCTION 'RV_KONDITION_SICHERN' IN UPDATE TASK

TABLES

vakedb_tab = lt_vakedb.

  • Call RV_MAT_SUB_SAVE to complete creation of Material Substitution.

CALL FUNCTION 'RV_MAT_SUB_SAVE' IN UPDATE TASK

TABLES

x_konddvb = lt_xkonddvb

y_konddvb = lt_ykonddvb

x_konddpvb = lt_xkonddpvb

y_konddpvb = lt_ykonddpvb.

  • Commit to DB and wait as we need to check if the updates have been

  • successful or not.

COMMIT WORK AND WAIT.

  • Check that substitutions have been created successfully.

LOOP AT it_mat_sub INTO ls_mat_sub.

SELECT SINGLE matwa INTO ls_mat_sub-matwa

FROM kotd001

WHERE kappl EQ 'V'

AND kschl EQ 'A001'

AND matwa EQ ls_mat_sub-matwa

AND datbi GE sy-datum

AND datab LE sy-datum.

CLEAR: ls_bapiret2.

IF sy-subrc EQ 0.

  • Return success message.

ls_bapiret2-type = 'S'.

ls_bapiret2-id = 'ZMD_TOOL'.

ls_bapiret2-number = '010'.

ls_bapiret2-message_v1 = ls_mat_sub-matwa.

ls_bapiret2-message_v2 = ls_mat_sub-smatn.

ELSE.

  • Return error message.

ls_bapiret2-type = 'E'.

ls_bapiret2-id = 'ZMD_TOOL'.

ls_bapiret2-number = '011'.

ls_bapiret2-message_v1 = ls_mat_sub-matwa.

ls_bapiret2-message_v2 = ls_mat_sub-smatn.

ENDIF.

SHIFT: ls_bapiret2-message_v1 LEFT DELETING LEADING '0',

ls_bapiret2-message_v2 LEFT DELETING LEADING '0'.

  • Obtain message text.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = ls_bapiret2-type

cl = ls_bapiret2-id

number = ls_bapiret2-number

par1 = ls_bapiret2-message_v1

par2 = ls_bapiret2-message_v2

IMPORTING

return = ls_bapiret2.

APPEND ls_bapiret2 TO et_bapiret2.

ENDLOOP.

ENDFUNCTION.

The only extra bit you need to do is create a structure called ZMATERIAL_SUBSTITUTION with the following fields:

MATWA

SMATN

MEINS

SUGRD

DATBI

DATAB

.... and then a Table Type based on this structure.

Cheers,

Chris.