cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Supplier list: Deactivate item

RicardoRomero_1
Active Contributor
0 Likes
480

Hi all,

This is the scenario:

In an empty row, if I uncheck the field "Supplier is active", write the Supplier ID and push Enter then the standard code somewhere set the field "Supplier is active"  again to 'X'. This is the standard behavior.

I have a requirement in which when a new item is added the field "Supplier is active" must be disabled and unchecked. ( We have a custom report to activate or deactivate the items, this report can be executed only by some users depending on the user roles ) 

I've changed the visualization of the field by customizing, but I can't uncheck the field.

I've debugged the standard code but I couldn't find the place where the field is being changed.

The badi BBP_DOC_CHANGE_BADI is not used for object BUS2206.

I'm trying to modify the field adding an enhancement spot at the beginning of the method /SAPSRM/IF_CLL_MAPPER~UPDATE of class /SAPSRM/CL_CH_WD_DOTM_ASL_SOS. But all the attempts I've tried don't work.

Do you know how to do it? Or a workaround to do that?

Thanks in advance.

P.S. This is part of the code I've tried in method

DATA:

         ls_zz_item   TYPE /sapsrm/s_cll_asl_sos_list,

         lt_zz_item   TYPE /sapsrm/if_ch_wd_set_facade=>gt_guid_element,

         lt_items     TYPE bbpt_guid,

         lo_zz_item   TYPE REF TO /sapsrm/if_ch_wd_set_element..

   DATA: lt_messages     TYPE bbpt_pd_messages,

         lv_activity TYPE j_vorgang.

   FIELD-SYMBOLS <ls_zz_item> TYPE /sapsrm/if_ch_wd_set_facade=>gs_guid_element.

* Select current lines

   SELECT guid

    INTO TABLE lt_items

    FROM crmd_orderadm_i

    WHERE header EQ MV_BO_GUID

    ORDER BY guid.

   lt_zz_item = mon_cll_set_facade->get_data_elements( ).

   LOOP AT lt_zz_item ASSIGNING <ls_zz_item>.

     lo_zz_item = <ls_zz_item>-set_element.

     lo_zz_item->get_static_attributes( IMPORTING rv_attributes = ls_zz_item ).

     CHECK ls_zz_item-SH_PARTNER_ID IS NOT INITIAL.

* Check if is a new line or already exists:

     READ TABLE lt_items

      TRANSPORTING NO FIELDS

      WITH KEY guid = ls_zz_item-guid

      BINARY SEARCH.

     IF sy-subrc NE 0.

*    1st Attempt

*      ls_zz_item-itm_released = space.

*      CALL METHOD lo_zz_item->set_static_attributes

*        EXPORTING

*          iv_static_attributes = ls_zz_item.

*      CALL METHOD lo_zz_item->set_changed_by_client

*        EXPORTING

*          flag   = ABAP_TRUE.

*    2nd Attempt  "DUMP !!!

*        TRY.

*          mo_pdo->delete_item( EXPORTING item_guid = ls_zz_item-guid

*                               CHANGING  co_message_handler = mo_pdo_message_consumer ).

*        CATCH /sapsrm/cx_pdo_abort.

*

*        ENDTRY.

*    3rd Attempt

       lv_activity  =  /sapsrm/if_pdo_activities_c=>gc_pdo_item_deactivate.

*     Update the status of the item as inactive

       CALL FUNCTION 'BBP_PROCDOC_STATUS_CHANGE'

         EXPORTING

           iv_item_guid  = ls_zz_item-guid

           i_activity    = lv_activity

           i_object_type = /sapsrm/if_pdo_obj_types_c=>gc_pdo_asl

           i_save_db     = abap_false

           i_test_run    = abap_false

         TABLES

           e_messages    = lt_messages[].

*    4th Attempt- 1st part

*      ls_del_item-guid = ls_zz_item-guid.

*      APPEND ls_del_item TO lt_del_items.

     ENDIF.

   ENDLOOP.

*    4. Attempt 2nd part  "DUMP !!!

*  IF lt_del_items[] IS NOT INITIAL.

*    mo_parent_bo_mapper->delete_item( it_item_guid = lt_del_items ).

*  ENDIF.

Accepted Solutions (1)

Accepted Solutions (1)

laurent_burtaire
Active Contributor
0 Likes

Hello Ricardo,

blank lines are defaulted with ITM_RELEASED = abap_true in FILL_BLANK_LINES method from /SAPSRM/CL_CH_WD_DOTM_ASL_SOS class.

Regads.

Laurent.

RicardoRomero_1
Active Contributor
0 Likes

Hi Laurent, Thanks for answer.

I've put an enhacement point at the end of the method you said to clear the field ITM_RELEASED for all the blank lines.

Now, when I open a Supplier List all the blank lines are with this field in blank.

But... If I write the supplier ID and push enter, the field is automatically set again to X.

What I saw in method /SAPSRM/IF_PDO_BO_ASL~UPDATE_ITEMS of class /SAPSRM/CL_PDO_BO_ASL is trying to change this field ( this method is called the first time you add a new line from the method ADD_FROM_BLANK_LINES). Inside this method is trying to change the status using the FM BBP_PROCDOC_STATUS_CHANGE. But, the FM returns the following errors:

ABBP_PD002Interface data contains errors
EBS001No status object is available for (unknown object)

Once the line is added (and the field "Supplier is active" is flagged) if you unckeck this field (I've removed the code to set as enabled the field again)  if you push enter again the method UPDATE_ITEMS is triggered again (this time from method /SAPSRM/IF_CLL_MAPPER~UPDATE) and the FM PRODOC_STATUS_CHANGE this time doesn't return any errors...

So this time you can set as inactive the item and save the document, but I need to inactive the item the first time automatically, because the user the user won't can do it manually (we need to put this field as not editable).

I dont know if I'll can change the status the first time for new lines...


Answers (2)

Answers (2)

RicardoRomero_1
Active Contributor
0 Likes

In the end I've found a solution. I don't like it too much, but is working, by the moment.


What I did is create a custom FM to update the status of the items using the FMs BBP_PD_AVL_STATUS_CHANGE, BBP_PD_AVL_UPDATE, BBP_PD_AVL_SAVE....

I'm calling this FM in class /SAPSRM/CL_CH_WD_BOM_ASL, at the end of the following methods:

/SAPSRM/IF_CLL_BO_MAPPER~SAVE

/SAPSRM/IF_CLL_BOM_ASL~RELEASE

Regards,

laurent_burtaire
Active Contributor
0 Likes

Hello Ricardo,

using metadata, you cannot put default value for any field.

For seach requirement, implement WD_BADI_DOMODIFYVIEW BAdI (Enhancement Spot WD_BADI element definition) for the Web Dynpro Component (/SAPSRM/WDC_DOTC_ASL_SU_D) and its concerned view (V_ASL_DOTC_SOS) used as BAdI filter.

You code should be like this:

DATA: lr_checkbox TYPE REF TO cl_wd_checkbox.

lr_checkbox ?= view->get_element( 'SOURCES_OF_SUPPLY_ITM_RELEASED_EDITOR' ).

IF lr_checkbox IS BOUND.
  
CALL METHOD lr_checkbox->SET_CHECKED
    
EXPORTING
      
value = abap_false.

ENDIF.

Regards.

Laurent.

RicardoRomero_1
Active Contributor
0 Likes

Hi Laurent,
Thanks for answer.


Yes, I know using metadata I cannot change any data, I've only used metadata to change de visualization.

I've tried to modify the webdynpro adding a post-exit in method WDDOMODIFYVIEW and I can change the data, but only works if I push enter (or check or do something) before push save or release. If I add the data and then push save without push enter, then doesn't work because the method WDDOMODIVYVIEW is triggered after the method to save the data...

I think with the BADI you said the same will occur.

laurent_burtaire
Active Contributor
0 Likes

Hi,

so, i guess same behavior with enhancement spot i gave you... ?

Regards.

Laurent.

RicardoRomero_1
Active Contributor
0 Likes

Yes, I think so.


For that reason I've created the enhancement point in class /SAPSRM/CL_CH_WD_DOTM_ASL_SOS because for the method UPDATE always pass. But my code doesn't work fine...

If I don't get the solution... may be I'll need to add some validations in BBP_DOC_CHECK_BADI to don't allow the user to Release the document if the field "active" is checked...

laurent_burtaire
Active Contributor
0 Likes

Hello,

strange behavior...

In our system, using POWL for Vendor Lists, if i click onto "Display" or "Edit" from action buttons (or if i click onto the hyper-link from Vendor List number), method WDDOMODIFYVIEW from V_ASL_DOTC_SOS view (WDC /SAPSRM/WDC_DOTC_ASL_SU_D) is triggered...

But whatever...

I do not understand you logic.

Just do an overwrite Exit and manage on your own value ITM_RELEASED: during the LOOP to transfer CLL data to PDO data, line 155, after the move corresponding:

         

MOVE-CORRESPONDING ls_cll_item TO ls_pdo_item. " map ui-structure to pdo-structure

unset ls_pdo_item-itm_released.

Before row is modified, field will be set, but after row creation/modification, PDO layer will updated.

Regards.

Laurent.

RicardoRomero_1
Active Contributor
0 Likes

Hi Laurent

The standard code inside the method WDDOMODIFYVIEW is executed only when the parameter first_time is set to X. For that reason I had created a post-exit, instead a overwrite-exit, to do what you said.

This solution works fine in all the case but one.

after write the supplier ID If you push enter (or check or do something) before push save or release then works fine. But if you push directly save, without doing anything, then doesn't work.

I'm trying to make it work in all cases.