on 12-11-2014 1:08 PM
Hey everyone,
I'm trying to control visibility of field custom on shop cart in SRM. Below follow the process executed for me to control fields.
The process of Shop Cart here is:
a) We have 4 types of Cart: "Claim Cart", "Tooling Cart", "DQF Cart" and "Freight Cart".
b) For the type Freight Cart, some options will appear in the screen for choice.
c) Insert an item normally in the field Prod. ID and click in details. The fields included in customizing SPRO will appear.
d) For each option of freight I have control which fields should appear in details.
My solution.
1º -> I've included the fields in Structure via SPRO customizing and Control Metadata(All fields that I have to control, I've setting like Not Visible).
2º -> I have created a enhancement for to control visibility in component /SAPSRM/WDC_DODC_SC_I_BD, View V_DODC_SC_I_BD.
For the choice freight I search in table Z the fields that should appear in details and hide the others fields.
Code:
" Caminho no Context
v_path = `ITEM_BASIC_DATA`.
" Busca Context WebDynpro
o_context_items = wd_context->path_get_node( path = v_path ).
IMPORT button TO v_button FROM MEMORY ID 'SHOP_CART'.
" Verifica se houve retorno com sucesso
IF o_context_items IS BOUND.
SELECT *
FROM ztbsrm_screen
INTO CORRESPONDING FIELDS OF TABLE t_screen
WHERE zz_screen = 'DOTC_BASIC'.
IF sy-subrc IS INITIAL.
SELECT *
FROM ztbsrm_process
INTO CORRESPONDING FIELDS OF TABLE t_process
FOR ALL ENTRIES IN t_screen
WHERE zz_process = t_screen-zz_process.
IF NOT sy-subrc IS INITIAL.
RETURN.
ENDIF.
SELECT *
FROM ztbsrm_fields
INTO CORRESPONDING FIELDS OF TABLE t_fields
FOR ALL ENTRIES IN t_process
WHERE zz_process = t_process-zz_process
AND zz_option = t_process-zz_option.
IF NOT sy-subrc IS INITIAL.
RETURN.
ENDIF.
" Deleta
DELETE t_fields WHERE NOT zz_radiobutton EQ v_button.
LOOP AT t_fields ASSIGNING <fs_field>.
" Limpa Work Area
CLEAR: wa_properties,
v_campo.
" Move nome do campo
v_campo = <fs_field>-zz_field.
" Busca elemento de tela
o_element = o_context_items->get_element( ).
" Verifica Retorno
IF o_element IS BOUND.
o_context_items->set_attribute_property(
EXPORTING
attribute_name = v_campo
property = o_element->e_property-visible
value = abap_true
).
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
My problem is:
The fields are not hidden. All fields display in screen and the control of visibility is not working correctly.
Thanks any help.
Regards.
Hello Wellington,
according to your fourth screenshot, it seems that you flagged all those fields as visible and editable in customizing.
Therefore, these fields would always be visible unless your code in WDDOMODIFYVIEW states the opposite. Could this be the cause of your problem?
Another approach regarding properties: you can restrict criteria which have been specified in customizing (SPRO). But - at least, in releases I dealt with - you cannot extend them using code.
To provide you an example:
you can specify by customing that a field is visible (first checkbox = 'X') and editable (second checkbox = 'X')..
Then, you can associate that line of customizing to a specific method of a class (that two fields that follow the checkboxes), let's say ZCLASS -> ZMYMETHOD, in which you can code your own logic to modify existing metadata (you can copy the same interface used by standard methods you'll find again in customizing, for what concerns standard fields).
In ZMYMETHOD you could say something like: "if the type of chart is Y and <other conditions>, then set the VISIBLE property to <blank>.
Hope that helps,
Best regards
Matteo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Wellington,
how can a field be editable if it's not visible?
For what concerns the customizing; you need to adopt the same interface used by standard methods.
I'm posting now an example taken from an SRM 7.0 system, most probably the signature should be the same on your system:
method ZMethod
IMPORTING parameters:
IS_ITEM TYPE BBP_PDS_SC_ITEM_D;
IS_HEADER TYPE BBP_PDS_SC_HEADER_D;
IV_OBJECT_TYPE TYPE BBP_BUS_OBJECT_TYPE;
IV_FIELD_NAME TYPE NAME_KOMP;
IS_ADD_DATA TYPE /SAPSRM/S_PDO_META_FLD_ADD_DAT (OPTIONAL);
CHANGING parameter:
CS_METADATA TYPE /SAPSRM/S_PDO_FIELD_METADATA.
Now, I'd try as follows:
- create a ZMETHOD with the above interface and specify it in customizing for a certain field;
- mark the certain field as VISIBLE and ENABLED (first two checkboxes);
- set a external debug in ZMETHOD and see what happens.
What should happen is as follows: the structure CS_METADATA in your ZMETHOD should contain two "X" for the fields VISIBLE and ENABLED.
According to your logic, you can modify such values.
Hope that helps,
Matteo
Hi Wellington, check the dump in ST22 transaction in order to get additional information on the problem.
In particular:
- if the point is the dynamic call of the method (see something like CALL METHOD (dyn_class) -> (dyn_method), then check interfaces and types of the involved parameters.
- From the customizing screen, press F4 on the class field and check that your method/class is available from the standard search help (it should).
Let us know
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.