cancel
Showing results for 
Search instead for 
Did you mean: 

data getting deleted when doing the validation

Former Member
0 Kudos

Hi all,

I have a web dynpro application to park an accounting document and I want the following functionality to it.

When a user enters fund starting with 'P' then the cost center field should be greyed out and if WBS element field is not entered then I should see the error on the screen that it's a mandatory field.. For this I have written the following code:

LOOP AT lt_el_tbseg INTO lo_el_tbseg.
    lo_el_tbseg->get_static_attributes(
                           IMPORTING static_attributes = lv_bseg ).
    CLEAR lv_bseg-lifnr.
    CHECK NOT lv_bseg IS INITIAL.
    TRANSLATE lv_bseg-geber TO UPPER CASE.
    IF lv_bseg-geber(1) = 'P'
                       *       navigate from <CONTEXT> to <EDIT_PROPERTY> via lead selection
      lo_nd_edit_property = wd_context->path_get_node( path = `Z_POSTING.CHANGING.T_BSEG.EDIT_PROPERTY` ).


*       get element via lead selection
      lo_el_edit_property = lo_nd_edit_property->get_element( ).

      lo_el_edit_property->set_attribute(
        name =  `EDIT_WBS`
        value = 'ABAP_TRUE' ).

      DATA lv_projk TYPE wd_this->element_t_bseg-projk.

      IF lv_bseg-projk IS INITIAL.
        lv_error = 'E'.
        CALL METHOD lo_api_controller->get_message_manager
          RECEIVING
            message_manager = lo_message_manager.
        lv_message_string = 'WBS Element is a mandatory field'.
        .
*     report message
        CALL METHOD lo_message_manager->report_error_message
          EXPORTING
            message_text = lv_message_string.
        EXIT.
      ENDIF.
    ENDIF.

    wa_bseg = lv_bseg.
    w_amt_line = wa_bseg-dmbtr + w_amt_line.
    wa_bseg-lifnr = lv_lifnr.
    APPEND wa_bseg TO lt_bseg.
    CLEAR wa_bseg,lv_bseg.
endloop.

but right now two things are happening in correctly:

1. It's doing the correct validation and throwing the correct error message but it's clearing out the content of the item table that user entered on the screen.

2. it's not making cost center as an non editable field.

can you please suggest me what I am doing wrong here.

Thanks,

Rajat

Edited by: rajatg on Jul 7, 2011 4:04 PM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos
lo_el_edit_property->set_attribute(
        name =  `EDIT_WBS`
        value = 'ABAP_TRUE' ).  " - >  If this attribute to control Editing of Field it should be ABAP_FALSE.
shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos
  • report message

CALL METHOD lo_message_manager->report_error_message

EXPORTING

message_text = lv_message_string.

EXIT.

your EXIT statement will get you out of the loop. rest of the records in internal table will nto be read

Former Member
0 Kudos

Hi SSM,

thanks for the catch... I thought I removed that exit statment but apparently I didn't.

Can you please also help me with why I am not getting the cost center field to be greyed out.