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: 

Repair Order using BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

Hi,

I am creating a Repairs order using the above BAPI, but it does not provide the functionality to add Servicable Material and Repair Information.

there was a similar forum where it was mentioned to use 'SD_SALES_DOCU_MAINTAIN', I am not sure where to pass this info and if this FM is safe to be directly used..

Regards,

Kaustubh.

14 REPLIES 14

Former Member
0 Kudos

Hi,

Any std function is safe to use as long as the data you supply is correct.

Before you go to BAPI, where do you add servicable material and repair information in the order create screen? The answer depends on that.

This BAPI has structures for material as well as texts. I am not sure where you experience the problem.

Please check and revert.

Raj

Reward points if helpful

0 Kudos

Hi,

The BAPI does not have fields to add the Repair Order related info, like Servicable Material, Qty.. filled in the Structure: V46R_ITEM in VA01/02.

I am not sure where they need to be filled in the FM: 'SD_SALES_DOCU_MAINTAIN'.

0 Kudos

I do not understand why you do not want to populate ORDER_ITEMS_IN table with your material and qty. Is there a problem? I guess the repair orders are identified by corresponding order type. You can use this BAPI for any kinds of order type.

Please do not look for the same field name in BAPI as you would see in the screen. It just does not work that way.

Raj

0 Kudos

the Repair Order, created one more line item automatically, which is the servicable material. If we have a line item as 10000 it created one more with item 10010, this is not handled by the BAPI.

0 Kudos

It is not a function of BAPI. It is your custom process. Please talk to your SD consultant if it is a config issue or have a look at any user exit that may be adding the line item in the background when you do this in VA01 and skipping it when you trigger it via BAPI.

Raj

Reward points if helpful

0 Kudos

K,

BAPI_SALESORDER_CREATEFROMDAT2 calls the _MAINTAIN func module deep down in it's processing.

How is line item 10010 created when run on-line by a user? Through a userexit or config or ???

0 Kudos

its not a userexit, I am sure it must be config. When I go through VA01, and select the option Item -> More Function -> Repair, it asks for a Qty, servicable material, and flag to decide if its Repair , returns.. Once I enter this the line item gets created on its own, this is a SAP functionality for repairs orders I guess, the problem I am facing is where do I put the repairs info in the BAPI..

0 Kudos

On Futher investigation I found that if I put a breakpoint on the FM: SD_SALES_DOCU_MAINTAIN, and the put values in MATNR_G & MENGE_G in the structure : VBAPKOM, it created a proper repairs order with the 2nd line item created automatically. These fields are missing in the BAPI.

Now the question which I have is, Is it safe to use the FM: SD_SALES_DOCU_MAINTAIN, directly, or do I need to do some validations before using it.

Regards,

K

0 Kudos

K,

This REPAIRs functionality is tied to config. It is not turned-off in the std delivered product by SAP. Your org has turned it on for their needs.

In reviewing the BAPIs around VA01 (including the one you cited), I do not see any of them referencing data element VKGRU, which is the REPAIR-related field on VBAP.

It appears that SAP has not enabled this repair functionality in their core-delivered BAPIs. This can be the case in the more obscure areas of SAP functionality.

Unfortunately, it appears that you will need use a BDC to meet your reqs...

0 Kudos

John,

Yes you are correct the BAPI does not handle this functionality, but if I pass the proper values to the FM: SD_SALES_DOCU_MAINTAIN, the fields related to Repair are in the structure: VBAPKOM, the Repair Order gets properly created. So I think I can definately use this FM to create the Order.

But my question is, as you know this FM is called deep inside the BAPI, how safe is it to use it directly.

Regards,

K

0 Kudos

K,

Calling the FM directly is OK... the BAPI provides many levels of validation "in front" of the actual FM that performs the update.

Just make sure that your inputs are clear and accurate.

0 Kudos

I guess I will also check the original BAPI, and see it I can incorporate some of the validations in the new BAPI which i would be creating. As my BAPI would be used to create new Repairs Order and would be called by an external system, I would not be 100% sure of the data..

Else I can even try creating a Repairs Order by using the Std BAPI and then call this FM to update the Repairs Order related info like the Servicable Material and Qty.. Let me check this..

0 Kudos

Sounds like a good idea...

Don't forget the points for helpful answers as well.

Former Member
0 Kudos

Hi Kaustubh,

We are using 'SD_SALES_DOCU_MAINTAIN' to create the Repair Order and its working fine for us. We came at this conclusion only after extensive testing and debugging the standard BAPI.

The material vbapkom-matnr is 'REPAIR' in our case. You should check with your functional person about the same.

You need to populate the vbapkom-zmeng (quantity).

The servicable material field is vbapkom-matnr_g which is the actual material that needs repair.

You also need to populate the vbapkom-menge_g which is the servicable material quantity

Apart from this you have to populate the schedule line table vbepkom, partner table vbapkom and header structure.

My call looks like this CALL FUNCTION 'SD_SALES_DOCU_MAINTAIN'

EXPORTING

i_vbakkom = wa_vbakkom

i_call_bapi = 'X'

suppress_availibility_dia = 'X'

status_buffer_refresh = 'X'

IMPORTING

e_vbak = wa_vbak

TABLES

ix_vbapkom = lt_vbapkom

ix_vbpakom = lt_vbpakom

ix_vbepkom = lt_vbepkom

return = lt_bapireturn

ix_text_header = lt_text_head.

Do let me know if you need any other information.

Regards,

Shubham

P.S.- You can also use the standard BAPI for doing this. But in that case you have to append fields matnr_g and menge_g to the item table vbap and then populate the extension table 'EXTENSIONIN' of the standard BAPI BAPI_SALESORDER_CREATEFROMDAT2.