2006 Apr 03 2:11 PM
Hi!
I need to check/change some values of components of a BOM while saving the bom. I could not find a suitable user exit for this but I found the BADI BOM_UPDATE with the method "change_at_save". As a parameter I found delta_stpob which contains 2 rows for each component. One with the original values and one with the new values. But I'm not able the change the values inside this table to full fill my needs. I have tried the following code:
METHOD if_ex_bom_update~change_at_save.
...
DATA wa TYPE stpob.
LOOP AT delta_stpob INTO wa.
wa-menge = 2.
MODIFY delta_stpob FROM wa.
ENDLOOP.
ENDMETHOD.
But I get the message "THE FIELD DELTA_STPOB CANNOT BE CHANGED"!
So, how can I change the values inside this table?
Thanks,
Konrad
2006 Apr 05 10:56 AM
Hello Konard,
Try the folowing..
data: fld(50) value '(SAPLCSBT)o1-stpob[]'.
field-symbols: <fs1> type table.
data: wa_stpo type stpo.
assign (fld) to <fs1>.
loop at <fs1> into wa_stpo.
wa_stpo-cadpo = 'X'.
modify <fs1> from wa_stpo index sy-tabix.
endloop.
I have put in loop if u need anything different u can change the loop condition...
Hi!
I need to check/change some values of components of a BOM while saving the bom. I could not find a suitable user exit for this but I found the BADI BOM_UPDATE with the method "change_at_save". As a parameter I found delta_stpob which contains 2 rows for each component. One with the original values and one with the new values. But I'm not able the change the values inside this table to full fill my needs. I have tried the following code:
METHOD if_ex_bom_update~change_at_save.
...
DATA wa TYPE stpob.
LOOP AT delta_stpob INTO wa.
wa-menge = 2.
MODIFY delta_stpob FROM wa.
ENDLOOP.
ENDMETHOD.
But I get the message "THE FIELD DELTA_STPOB CANNOT BE CHANGED"!
So, how can I change the values inside this table?
Thanks,
Konrad
2006 Apr 03 2:20 PM
Hi,
check this Sample implementation of the BADI.
<b>CL_EX_BOM_UPDATE</b>
Regards
vijay
2006 Apr 03 2:31 PM
Hi!
Thanks for your answer, but where can I check what sample code? What are the steps to get there?
Greetings,
Konrad
2006 Apr 03 2:25 PM
Hi
That parameter is defined as import parameter in the interface of method.
Max
2006 Apr 03 2:32 PM
Hi!
Does this mean that I cannot change these values? If not, is there an additional way to change the component values while saving a bom?
Thanks,
Konrad
2006 Apr 03 2:38 PM
Hi,
you can do check in SE24 <b>CL_EX_BOM_UPDATE</b>
Regards
Vijay
2006 Apr 03 2:56 PM
2006 Apr 03 3:07 PM
Hi Konrad,
>> As a parameter I found delta_stpob which contains 2 rows for each component. One with the original values and one with the new values..
When you loop at delta_stpob, how are you identifying the new value?
Regards,
Suresh Datti
2006 Apr 03 3:22 PM
Hi!
I have tried it with one component and the first line in the table was the original one and the second line was the line with the new values. I haven't done any more test because I need to change some values every time doesn't matter what the user has entered interactivly. So in my case I can set all table lines with my new values without check which one is the new one. But I guess it is always like "old value first line, new value second line" for each component...
In my case I need to change the CADPO flag and set it to X for each component.
Greetings,
Konrad
2006 Apr 03 3:33 PM
Hi
That BADI is not good to do that and the class CL_EX_BOM_UPDATE is the class used to define the interface the BADI (so I suppose it isn't good too).
You try to find another BADI (check whith BOM), but I don't think you can find something to modify that value.
You should try to force the updating by the famous trick:
(PROGRAN NAME)<VARIABLE> = ......
Max
2006 Apr 03 3:40 PM
Hi!
Can you please tell me more about the "famous trick"!
I need this very urgent, so what does "(PROGRAN NAME)<VARIABLE> = ......" mean?
How can I change the CADPO flag to 'X' for each component of a BOM while saving it within CS02?
Thanks again,
Konrad
2006 Apr 03 5:44 PM
Konrad,
Once you identify the variable ....
FIELD-SYMBOLS : <FS_ANY> TYPE ANY.
ASSIGN (PROGRAM)VARIABLE TO <FS_ANY>
<FS_ANY> = 'New Value'.
This will change the variable value in the standard program.
Regards,
Ravi
Note : Please mark the helpful answers
2006 Apr 04 7:59 AM
Hi!
This sounds very interesting but I need more help from you. How do I use it in my case. I need to change the CAD Indicator for each position while savind a BOM in CS01/CS02. This flag is disabled in the GUI so you cannot change it there!
These are the values I can find:
Program: SAPLCSDI
Structure: RC29P
Field: CADPO
Dynpro-Field: RC29P-CADPO
how do I have to use them and where do I have to put this code (in the above mentioned BADI??)
Thanks again,
Konrad
2006 Apr 04 8:45 AM
Hi,
Try doing this.
Assign (SAPLCSDI)RC29P-CADPO to <fs_any>.
<fs_any> = 'Value'.
Regards,
Ravi
2006 Apr 04 8:56 AM
I have tried:
FIELD-SYMBOLS : <FS_ANY> TYPE ANY.
Assign (SAPLCSDI)RC29P-CADPO to <FS_ANY>.
<FS_ANY> = 'X'.
in the BADI BOM_UPDATE (method: CHANGE_AT_SAVE)
but I get the following error:
After "(SAPLCSDI)", there must be a space or equivalent character (":",",",".").
How can I solve this?
Thanks,
Konrad
2006 Apr 04 9:00 AM
Hi
FIELD-SYMBOLS : <FS_ANY> TYPE ANY.
DATA: FIELDNAME(30) VALUE (SAPLCSDI)RC29P-CADPO.
Assign (FIELDNAME) to <FS_ANY>.
<FS_ANY> = 'X'.
Max
2006 Apr 04 9:12 AM
With this code in the BADI BOM_UPDATE-CHANGE_AT_SAVE I get the same error:
After "(SAPLCSDI)", there must be a space or equivalent character (":",",",".").
What do I have to change?
Thanks,
Konrad
2006 Apr 04 9:20 AM
Hi
excuse me
FIELD-SYMBOLS : <FS_ANY> TYPE ANY.
DATA: FIELDNAME(30) VALUE '(SAPLCSDI)RC29P-CADPO'.
Assign (FIELDNAME) to <FS_ANY>.
<FS_ANY> = 'X'.
Max
2006 Apr 04 9:19 AM
Hello Konard,
Change as follows
FIELD-SYMBOLS : <FS_ANY> TYPE ANY.
DATA: FIELDNAME(30) VALUE '(SAPLCSDI)RC29P-CADPO'.<-changed
Assign (FIELDNAME) to <FS_ANY>.
<FS_ANY> = 'X'.
2006 Apr 04 9:33 AM
Nice try, but the result is a short dump because of trying to change a read-only value ;-). This field is not changeable in the gui so it is not changeable with this code as well. I guess I need to change it after the save process directly in the db. The only problem is how trigger this action!
Any suggestions for this issue?
Greetings,
Konrad
2006 Apr 04 9:33 AM
Nice try, but the result is a short dump because of trying to change a read-only value ;-). This field is not changeable in the gui so it is not changeable with this code as well. I guess I need to change it after the save process directly in the db. The only problem is how trigger this action!
Any suggestions for this issue?
Greetings,
Konrad
2006 Apr 04 9:41 AM
Hi
I think you try to use the method CHANGE_IN_UPDATE or CHANGE_BEFORE_UPDATE, but you have to find the name of global data of the variable you want to change.
Max
Message was edited by: max bianchi
2006 Apr 04 11:57 AM
All parameters in these two methods are IMPORT as well so how can I change values with them? What do you mean with
"but you have to find the name of global data of the variable you want to change."
Please be more specific!
Thanks,
Konrad
2006 Apr 04 5:29 PM
Hi Konrad!
> Nice try, but the result is a short dump because of
> trying to change a read-only value ;-).
...
> Any suggestions for this issue?
Yes, don't do it. I had a very short look - because it's clear: in general the amount can be freely changed, it's quite usual to have different quantity of components assigned to a header article.
If now in your case the amount can't be changed, then this restriction is done by purpose -> you might run into follow on problems, when you succeed to change the value (e.g. by direct DB-update later).
Please describe the business process - otherwise any tip might bring you a lot of problems in other places, if the circumstances aren't known.
Regards,
Christian
2006 Apr 05 8:47 AM
Hi!
The value I need to change is the CAD Indicator flag for each component of a BOM! If this flag is deactivated, you cannot change the component via RFC from outside SAP with an interface.
The process is like the following:
With our software, we create and change BOMs in SAP. Now, if the SAP users need a BOM very urgent in SAP to order some stuff or whatever, they create it inside SAP with the SAPGui. Now, when the process in our software is ready, we transfer this BOM again to SAP and suddenly we have each component twice there because the original components don't have the CAD Indicator flag and so you cannot change it from outside. Because the RFC function is not able to change the components, it creates new one.
Therefore it is necessary to make sure that this flag is activated for a small amount of SAP users even if they create the BOM inside SAP.
So, if there is any chance to do this, please let me know.
Greetings,
Konrad
2006 Apr 05 9:02 AM
Hi Konrad
If there isn't an exit allows to change the data (you need) you can try to use the trick explained in the previous posts.
In this situation you need to found the exit you're sure the std program'll run it (here it should be better to use an exit before saving).
After you have to find the variable(s) global data where the information(s) is stored and the program use to transfer the data to data base:
It often uses structure(s) to define input/output field of a dynpro, then the data are transfered from the structure to internal variable(s) (global data) and at the end from variable(s) to data base.
Max
2006 Apr 05 9:35 AM
Unfortunately Im not an ABAP expert which is able to do such things. When I use the debugger, I can see that before the commit work is performed, the data is hold in a structure rc29k for the header data and rc29p for the positions. But how can I access this data within my user exit / BADI. Can I use these structures or is there some other place like global variables where the data is stored before writing it into the DB. If so, where can I find these global variables and how can I change them?
Thanks a lot,
Konrad
2006 Apr 05 10:09 AM
Hi
The program is SAPLCSDI, so all global data are defined in include lcsditop.
Max
2006 Apr 05 10:38 AM
In the include you mentioned there is again the codeline
talbes:
rc29p
...
This table holds the CADPO flag. Is this some kind of global data definition and if so, how can I access this table in the userexit?
Thanks a lot,
Konrad
2006 Apr 05 11:10 AM
Hi
RC29P is the structure for dynpro, but perhaps the structure where std prog stores the data for updating is STPOB.
So try to change the data of that structure.
Max
2006 Apr 05 10:56 AM
Hello Konard,
Try the folowing..
data: fld(50) value '(SAPLCSBT)o1-stpob[]'.
field-symbols: <fs1> type table.
data: wa_stpo type stpo.
assign (fld) to <fs1>.
loop at <fs1> into wa_stpo.
wa_stpo-cadpo = 'X'.
modify <fs1> from wa_stpo index sy-tabix.
endloop.
I have put in loop if u need anything different u can change the loop condition...
2006 Apr 05 11:08 AM
It works!!!!!
Thank you very much!
One last question if I may:
Please explain me what the code does and where you have find the necessary information! How did you know to use '(SAPLCSBT)o1-stpob[]' (whatever this code means) ...
Thanks again,
Konrad
2006 Apr 05 11:25 AM
Hi
Try this code:
DATA: T_stpob TYPE STANDARD TABLE OF stpob.
DATA: stpob TYPE stpob.
DATA: FIELD_NAME(30) VALUE '(SAPLCSBT)O1-STPOB[]'.
FIELD-SYMBOLS: <TABLE> TYPE TABLE.
ASSIGN (FIELD_NAME) TO <TABLE>.
LOOP AT <TABLE> INTO STPOB.
........................
stpob-cadpo = 'X'.
modify TABLE> FROM STPOB.
ENDLOOP.
Max
2006 Apr 05 11:46 AM
Hi Konrad!
Don't forget field STKO-CADKZ, sounds like it has to be changed, too.
Regards,
Christian
2006 Apr 05 11:46 AM
Hello Konard,
I am happy that it works...
If u analysis the badi, it is getting the values from the table lt_stpob. however this is decalred just before the call so it is local and will not be available during the update. Now this lt_stpob was getting value from t_stpob which is the interface for the FM called before CSBD_CHANGE_AT_SAVE in which this badi is called. So I went to the previus FM which actullay calls this FM and there it was doing an export using the o1-stpob and that is how I found it out. Simple way is I check the FM in the program LCSBTU14 line 101 where it calls BOM_POST and it was passing table as o1-stpob.
2006 Apr 05 12:12 PM
Thanks for the explanation! Very helpfull...
But I have some every strange behaviour now:
The code
> data: fld(50) value '(SAPLCSBT)o1-stpob[]'.
> field-symbols: <fs1> type table.
> data: wa_stpo type stpo.
>
> assign (fld) to <fs1>.
> loop at <fs1> into wa_stpo.
> wa_stpo-cadpo = 'X'.
> modify <fs1> from wa_stpo index sy-tabix.
> endloop.
works for the first component in a BOM. But then you cannot add any other component to the it! Doesn't matter what you add in CS02, only the first row is stored.
The code:
> DATA: T_stpob TYPE STANDARD TABLE OF stpob.
> DATA: stpob TYPE stpob.
> DATA: FIELD_NAME(30) VALUE '(SAPLCSBT)O1-STPOB[]'.
> FIELD-SYMBOLS: <TABLE> TYPE TABLE.
>
> ASSIGN (FIELD_NAME) TO <TABLE>.
> LOOP AT <TABLE> INTO STPOB.
>........................
> stpob-cadpo = 'X'.
> modify TABLE> FROM STPOB.
> ENDLOOP.
works better!
So, what is the difference between both of them?
Next I tried to change the CADKZ if the BOM Header as well using the following code:
> data: fld2(50) value '(SAPLCSBT)o1-stkob[]'.
> field-symbols: <fs2> type table.
> data: wa_stko type stko.
>
> assign (fld2) to <fs2>.
> loop at <fs2> into wa_stko.
> wa_stko-CADKZ = 'X'.
> modify <fs2> from wa_stko index sy-tabix.
> endloop.
The code was performed but now the BOM is damaged and tells me data inconsistency when I try to open it!!!
What's going on?
2006 Apr 05 12:29 PM
Hi
It's better to write the name of variable in upper case:
data: fld(50) value '(SAPLCSBT)o1-stpob[]'. <----
DATA: FIELD_NAME(30) VALUE '(SAPLCSBT)O1-STPOB[]'.
The code you're using change the values of field CADPO of all items of the BOM: do want this?
Anyawy you make sure how the data have to be changed, perhaps there are other data related to CADPO should be changed if CADPO is updated.
Max
2006 Apr 05 12:41 PM
I guess that the line
data: wa_stpo type stpo. <-----
is the problem in the first code example!
I think it shoulb be stpob, shouldn't it?
Yes, I want to set the flag for all lines and I'm not quite sure if there is some other data related. I need to play more with this stuff...
Thanks again,
Konrad
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |