cancel
Showing results for 
Search instead for 
Did you mean: 

Sales org/dist channel parameter values

jimminy1
Participant
0 Kudos

I have a material workflow based on BO BUS1001006. I have a request to add visibility of the Sales Org if the user enters one when they create a material. MVKE-VKORG is not part of this business object. I tried adding it as a database field but I'm not sure how to access the parameter the user would have entered. Is it possible?

If it is not possible, how could I add display of the sales org. I tried also adding as a virtual attribute but I am faced with the same issue - coming up with logic that would pick the sales org the user entered for each instance of the workflow.

Your help is greatly appreciated.

D. Scott

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

What are you really trying to achieve?

You could add MVKE-VKORG as a virtual attribute to the object. Just do a select to MVKE table - the key of your business object (material number) is the same as the key in MVKE (well, not exactly since MVKE has three key fields).

I don't really understand what you are trying to achieve, but I hope that you understand that your business object BUS1001006 is basically meant for the material basic data. Now it sounds a bit that you want to take the sales org/distribution channel "dimension" to your object/workflow. You need to understand that it is possible to maintain many sales org/distribution channel combinations to the material. In other words, you will have just one entry in MARA table (="basic data"), but there might be several rows for the same material in MVKE table (="sales org / distribution channel").


Kind regards,

Karri

jimminy1
Participant
0 Kudos

Karri,

That is exactly what I'm trying to achieve. I am trying to add sales org as a virtual object but I will have to supply the logic to derive the value. The select statement will use the key from the BO but I do not know how to access the parameters that were entered for sales org or distribution channel and they are necessary in order to get the correct record from MVKE. It would only need to process the logic if the user created the sales view. VKORG and VTWEG are not available with this BO so I am struggling for how to refer to them in the select statement.

During the process of creating a material when you choose the Sales Org/Sales General Plant tab, a screen pops up which requires you to enter Plant/Sales Org/Dist Channel. In order to return the correct record from MVKE, I need to create a condition in my where clause that refers to the VKORG/VTWEG I entered on this popup screen. Here is a snapshot of the screen:

In the logic for the virtual attribute how do I refer to this parameter in my condition? Is it possible?

Thanks,

D.

Former Member
0 Kudos

You cannot add sales org or distribution channel as virtual attribute for this business object. 


The "parameters" that you enter (in your above screenshot) get stored in MVKE. When you create the material (and are required to enter the sales org and distribution channel), you enter the needed data for all the fields, and when you save, the data gets stored in MARA and MVKE (and few other tables as well). Now you can open MM01 again, and create data for other sales org and distribution channel for the SAME material. => Now you have two rows in MVKE. Now if you go to instantiate your BUS1001006 with the material number (=object key), you have no way of knowing e.g. which sales organisation data you should get from MVKE, because there are two rows for the same material.


Whatever your actual business requirement is, most likely you cannot solve it by using virtual attributes.


Regards,

Karri

jimminy1
Participant
0 Kudos

Thank you for the explanation, Karri, but I am already aware that multiple entries can be created in MVKE for the same material. When the MM01 is saved, workflow is started which is one instance. If it is possible to access the values that were entered in the parameters I referred to in my screenshot in my earlier post, then the logic would pick one record in the table. What I am asking is if there is a way to access the values that were entered in the parameter screen so I can use them in this statement in the virtual attribute for the BO?

Select single vkorg into lv_vkorg

from MVKE

where matnr = (material number for this work item stored in the workflow container)

and    vkorg = (value entered on parameter screen in MM01)

and    vtweg = (value entered on parameter screen in MM01).

If it is not possible to access those values and that is what you are saying, then I agree with you.

Former Member
0 Kudos

BO BUS1001006 will not work in your case. The key is only the material number. The object is instantiated with the key and nothing else.

You can think it like this: Go to transaction SWO1 and test your business object. Click the instantiate button. You need to enter the key, which is the material number. When you instantiate the object, the attributes get populated. Where is for example your vkorg? It's nowhere because you are not able to give it as an input (=it is not part of the key).

If you want to have the sales organisation and distribution channel in your workflow, you need to deliver them to the workflow during the workflow starting phase for example with event parameters or whatever. Then they will be individual container elements and not part of the BUS1001006. Other option is that you change BUS1001006 to something else that has a key <material number> + <sales org> + <distribution channel>.

Regards,

Karri

jimminy1
Participant
0 Kudos

I was able to create parameters on the custom event and write logic in the enhancement spot to pass the values in the input_container. After I created all the bindings, it seems to be working fine.

Now that I have the sales org (MVKE-VKORG) the user entered, the requirement also is to supply the description of the sales org which would be TVKOT-VTEXT. Question - Although I can also write that logic in the enhancement spot and pass that value through the container I'm wondering if that is the best way to do it or if it is possible somehow to do that from within the workflow. Just looking for some direction to see what is the best way to handle for best performance, etc.

Thanks again,

D.

Richa_Gupta
Contributor
0 Kudos

Hi Scott,

You can do these things inside workflow as well.

Just create a subtype of your business object BUS1001006 (lets say ZBUS1001006). Now create a custom method in your business object for which importing parameter will be material number and exporting parameters will be sales org(VKORG) and its description(VTEXT).

Now simply select record from table MVKE based on material number. Now, based on VKORG obtained from MVKE, put a select on table TVKOT to get its description.

Now create a standard task using PFTC and call this custom method inside it. Do the required bindings between task ans method. You will get a task number here.

Now go to your workflow and create an ACTIVITY step type. Assign the task number obtained above inside the activity and do the required bindings between workflow and method.

This way you will be able to have sales organization and its description inside your workflow and you can use it whatever way you want.

Regards,

Richa Gupta

Former Member
0 Kudos

You can pass the value through the event parameter. That's fine. Or you can do something like Richa Gupta presented (anyhow this requires one additional step in the workflow which I many times try to avoid).

One thing that you should consider is the possible language requirements. Where you do actually want to show this description? Let's say you get the description in English, but the user is using SAP in Spanish. Probably this is not a problem, but worth to check before implementing something.

Regards,

Karri

jimminy1
Participant
0 Kudos

I am trying to make sales org/description available to the user in the task descriptions of each work item. Language must be what the user logs on in so that is an issue.

jimminy1
Participant
0 Kudos

In a method how would I refer to the sales org/distribution channel the user entered when creating the material in my select statement condition?

Richa_Gupta
Contributor
0 Kudos

Hi Scott,

In this case, once you get the description of task in your original language, then you can change it to the other required languages via PFTC. You just need to make sure that other languages have been set up in SPRO.

In PFTC transaction go to EDIT->Description->Other Existing Language.


Hope this helps.


Regards,

Richa

jimminy1
Participant
0 Kudos

I have already created the other translations so I can just add these values to them. Could you take a look at my other question related to creating a method to get the sales org/description and let me know how I could form a condition on a select statement from the MVKE table and return the right record? How do I access the parameters the user entered?

Richa_Gupta
Contributor
0 Kudos

Hi Scott,

The material number will be received inside the workflow in container for business object BUS1001006. Now just bind this material number to the task and task to method. This way you will get material number in your method. Now, based on it put your queries. Finally, do th bindings of your exporting parameters from method to task and task to workflow.

You will get a single material number in a single workflow instance.

Regards,

Richa

jimminy1
Participant
0 Kudos

This is where I am confused. A query from the MVKE table could give me more than 1 entry for a material unless I restrict it by sales org/distribution channel - which I do not have in the workflow.

Richa_Gupta
Contributor
0 Kudos

Hi Scott,

It's my mistake. I thought you wanted to display all the sales orgs.

Anyways, for this case, I think you can go with the following solution :

1. In user exit EXIT_SAPLMGMU_001, you will get the values of material number and sales organization which user has entered on screen.

2. Create a custom event(ZSALES) with a parameter (IM_VKORG) in the subtype business object(ZBUS1006).

3. Now call function module to trigger this custom event inside the exit and pass the value of sales org in INPUT_CONTAINER table.

This way you should be able to receive value of sales org inside workflow.

Don't forget to change the basic settings of workflow. There you need to specify your custom business object and custom event(ZBUS1006-ZSALES) as the start event instead of BUS1001006-CREATE.

Regards,

Richa

Answers (1)

Answers (1)

former_member185167
Active Contributor
0 Kudos

Hello,

If you know how to do it in ABAP then you can do it in workflow (or, rather, the BOR object).

If you don't know how to do it in ABAP then it's more of a functional question. What table is BUS1001006 based on? If you had to look it up manually, how would you do it?

regards

Rick Bakker

jimminy1
Participant
0 Kudos

That's really the problem, Rick. I'm not sure how to do it in ABAP and return the sales org the user entered. I could do a select on the MVKE table but the question is what is the syntax for referring to the parameter from the screen in MM01 for sales org. Does that make sense?

Thanks for responding. I hope my request makes sense.

D.

jimminy1
Participant
0 Kudos

Forgot to answer, 'what table is BUS1001006 based on' - MARA and MARC are the two tables used for all of the standard attributes.

former_member185167
Active Contributor
0 Kudos

Hello,

You know it's MVKE-VKORG. What is the problem, you don't know how to link MVKE to MARA and MARC?

(I don't know either, yet)


Maybe you could give an example.

regards

Rick Bakker

jimminy1
Participant
0 Kudos

Correct, I know it's MVKE-VKORG but since the key for the MVKE table is MATNR, VKORG and VTWEG I need those values to look up the correct entry. FYI - I am using the same workflow for material creation and material extension so potentially there could already be an entry in the MVKE table for that material and a different sales org. since we also use MM01 to extend a material.

I thought I might be able to use WERKS and lookup which sales org/dist channel would be tied to it but unfortunately some plants are assigned more than one sales org/dist channel.

I believe the only way to find the correct VKORG is to use what was entered in the parameter screen in MM01. I'm really hoping that is possible.

former_member185167
Active Contributor
0 Kudos

I don't know much about these tables and screens but surely if you log out of SAP and then go back in and look at the same screen then SAP will display the same Sales Org (VKORG) in the same field for the same material? Surely that is being done with ABAP.

I searched SCN for MARA MARC MVKE and saw a few joins that may help you.

You may want to post this question in the ABAP forum.

jimminy1
Participant
0 Kudos

Would that forum be helpful in macro programming logic? If you think so, then I will post it there.

former_member185167
Active Contributor
0 Kudos

It's not macros, it's pure ABAP.

former_member185167
Active Contributor
0 Kudos

Don't mention workflow, just say you're writing ABAP to fetch the Sales Org.

jimminy1
Participant
0 Kudos

You are correct - it is not macro programming although the BO uses some macros to access parameters, etc. What I meant to say is since I am using a BO to create the logic, the syntax would be different than I would use if the logic was being written in an enhancement. I would be able to use the structure those parameters are stored in if I were to write the logic in an enhancement spot during material creation/extension. For this one in particular, that would be RMMG1-VKORG. It is not possible to access that structure in a virtual attribute of the BO. Thanks for your suggestions.