Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

highlight one of the fields which are changed in a table control

Former Member
0 Kudos

I want to highlight one of the fields of a table control which are changed by the user, but when i am trying to do so all the fields get highlighted in that table control.

For example if I am changing only one email all the other email fields get highlighted along with the changed one.

8 REPLIES 8

Former Member
0 Kudos

Can you share the code pls?

0 Kudos

PROCESS BEFORE OUTPUT.

 

*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'ZPSMM_EMAIL_T'

  MODULE zpsmm_email_t_change_tc_attr.

*&SPWIZARD: MODULE ZPSMM_EMAIL_T_CHANGE_COL_ATTR.

  LOOP AT   gt_zpslo_vendor_e_t

       INTO wa_zpslo_vendor_e_t

       WITH CONTROL zpsmm_email_t

       CURSOR zpsmm_email_t-current_line.

 

    MODULE zpsmm_email_t_get_lines.

     MODULE pbo_0301_loop1. "apr 30 2013

*&SPWIZARD:   MODULE ZPSMM_EMAIL_T_CHANGE_FIELD_ATTR

  ENDLOOP.

*******The above underlined and bold module lands here************

FORM highlight_email_changes .

  DATA : i TYPE i VALUE 0,

  l_addr1_complete TYPE  szadr_addr1_complete,

   gt_zpslo_vendor_e_t_p TYPE zpslo_vendor_e_t OCCURS 0 WITH HEADER LINE,

   lw_zpslo_vendor_e_t TYPE zpslo_vendor_e_t,

   l_gt_zpslo_vendor_e_t TYPE zpslo_vendor_e_t OCCURS 0 WITH HEADER LINE,

   l_adsmtp_tab TYPE szadr_adsmtp_line,

   lw_gt_zpslo_vendor_e_t TYPE zpslo_vendor_e_t.

  CLEAR : l_addr1_complete, gt_zpslo_vendor_e_t_p, lw_zpslo_vendor_e_t, l_adsmtp_tab.

  READ TABLE gt_zpslo_vendor_e_t INTO wa_zpslo_vendor_e_t INDEX zpsmm_email_t-current_line.

  if sy-subrc = 0.

  IF lfa1-adrnr IS NOT INITIAL.

    CALL FUNCTION 'ADDR_GET_COMPLETE'

      EXPORTING

        addrnumber              = lfa1-adrnr

      IMPORTING

        addr1_complete          = l_addr1_complete

      EXCEPTIONS

        parameter_error         = 1

        address_not_exist       = 2

        internal_error          = 3

        wrong_access_to_archive = 4

        OTHERS                  = 5.

    IF sy-subrc <> 0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

  ENDIF.

    LOOP AT l_addr1_complete-adsmtp_tab INTO l_adsmtp_tab.

      i = i + 1.

      lw_zpslo_vendor_e_t-smtp_addr = l_adsmtp_tab-adsmtp-smtp_addr.

      lw_zpslo_vendor_e_t-flgdefault = l_adsmtp_tab-adsmtp-flgdefault.

      lw_zpslo_vendor_e_t-remark     = l_adsmtp_tab-adsmtp-remark.

      APPEND lw_zpslo_vendor_e_t TO gt_zpslo_vendor_e_t_p.

    ENDLOOP.

    SORT gt_zpslo_vendor_e_t_p BY remark.

    READ TABLE gt_zpslo_vendor_e_t_p INDEX zpsmm_email_t-current_line.

    LOOP AT SCREEN.

      CASE screen-name.

        WHEN 'WA_ZPSLO_VENDOR_E_T-SMTP_ADDR'.

          IF gt_zpslo_vendor_e_t_p-smtp_addr <> wa_zpslo_vendor_e_t-smtp_addr.

            screen-intensified = '1'.

            g_changes_made = 'X'.

MODIFY gt_zpslo_vendor_e_t FROM wa_zpslo_vendor_e_t INDEX zpsmm_email_t-current_line.

          MODIFY SCREEN.

          ELSE.

          ENDIF.

       ENDCASE.

      ENDLOOP.

ENDIF.

ENDFORM.                    " HIGHLIGHT_EMAIL_CHANGES

0 Kudos

Swati,

The problem is with the code where use the index.

I see 2 tables:

1. Vendor_e_t

2. vendor_e_t_p.

Lets say you have 5 records in v_e_t. You loop at these records 1 by 1. For the first record the value for zpsmm_email_t-current_line is going to be 1. then you get the address details and append the details to e_t_p. Then you are reading e_t_p with the same index. This will work for the first record assuming you fetch address details. if there are no address details even the first record will fail.

For the second record, the contents in e_t_p would get refreshed as that table is a local table. So when you read this table for the second time you are using index 2. So instead of using index read based on smtp_addr or use a separate index.

PROCESS BEFORE OUTPUT.

*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'ZPSMM_EMAIL_T'

  MODULE zpsmm_email_t_change_tc_attr.

*&SPWIZARD: MODULE ZPSMM_EMAIL_T_CHANGE_COL_ATTR.

  LOOP AT   gt_zpslo_vendor_e_t

       INTO wa_zpslo_vendor_e_t

       WITH CONTROL zpsmm_email_t

       CURSOR zpsmm_email_t-current_line.

    MODULE zpsmm_email_t_get_lines.

     MODULE pbo_0301_loop1. "apr 30 2013

*&SPWIZARD:   MODULE ZPSMM_EMAIL_T_CHANGE_FIELD_ATTR

  ENDLOOP.

*******The above underlined and bold module lands here************

FORM highlight_email_changes .

  DATA : i TYPE i VALUE 0,

  l_addr1_complete TYPE  szadr_addr1_complete,

   gt_zpslo_vendor_e_t_p TYPE zpslo_vendor_e_t OCCURS 0 WITH HEADER LINE,

   lw_zpslo_vendor_e_t TYPE zpslo_vendor_e_t,

   l_gt_zpslo_vendor_e_t TYPE zpslo_vendor_e_t OCCURS 0 WITH HEADER LINE,

   l_adsmtp_tab TYPE szadr_adsmtp_line,

   lw_gt_zpslo_vendor_e_t TYPE zpslo_vendor_e_t.

  CLEAR : l_addr1_complete, gt_zpslo_vendor_e_t_p, lw_zpslo_vendor_e_t, l_adsmtp_tab.

  READ TABLE gt_zpslo_vendor_e_t INTO wa_zpslo_vendor_e_t INDEX zpsmm_email_t-current_line.

  if sy-subrc = 0.

  IF lfa1-adrnr IS NOT INITIAL.

    CALL FUNCTION 'ADDR_GET_COMPLETE'

      EXPORTING

        addrnumber              = lfa1-adrnr

      IMPORTING

        addr1_complete          = l_addr1_complete

      EXCEPTIONS

        parameter_error         = 1

        address_not_exist       = 2

        internal_error          = 3

        wrong_access_to_archive = 4

        OTHERS                  = 5.

    IF sy-subrc <> 0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

  ENDIF.

    LOOP AT l_addr1_complete-adsmtp_tab INTO l_adsmtp_tab.

      i = i + 1.

      lw_zpslo_vendor_e_t-smtp_addr = l_adsmtp_tab-adsmtp-smtp_addr.

      lw_zpslo_vendor_e_t-flgdefault = l_adsmtp_tab-adsmtp-flgdefault.

      lw_zpslo_vendor_e_t-remark     = l_adsmtp_tab-adsmtp-remark.

      APPEND lw_zpslo_vendor_e_t TO gt_zpslo_vendor_e_t_p.

    ENDLOOP.

    SORT gt_zpslo_vendor_e_t_p BY smtp_addr

    CLEAR gt_zpslo_vendor_e_t_p

    READ TABLE gt_zpslo_vendor_e_t_p where smtp_add EQ wa_zpslo_vendor_e_t-smtp_addr binary     search.

   if not sy-subrc is initial.

    LOOP AT SCREEN.

      CASE screen-name.

        WHEN 'WA_ZPSLO_VENDOR_E_T-SMTP_ADDR'.

            screen-intensified = '1'.

            g_changes_made = 'X'.

          MODIFY gt_zpslo_vendor_e_t FROM wa_zpslo_vendor_e_t INDEX zpsmm_email_t-current_line.

          MODIFY SCREEN.

          ELSE.

          ENDIF.

       ENDCASE.

      ENDLOOP.

endif.

ENDIF.

clear gt_zpslo_vendor_e_t_p.

refresh gt_zpslo_vendor_e_t_p.

ENDFORM.                    " HIGHLIGHT_EMAIL_CHANGES

Hope this works. Let me know.

Thanks,

Vikram.M

0 Kudos

We cannot use 'where' with a read statement.

Secondly in table vendor_e_t_p data is getting appended thru a function module 'ADDR_GET_COMPLETE'

I have debugged the code the value of screen-intensified is updated to '1' and the screen is also modified but still no reflection.

matt
Active Contributor
0 Kudos

It was probably a typo: use

    READ TABLE gt_zpslo_vendor_e_t_p WITH KEY smtp_add = wa_zpslo_vendor_e_t-smtp_addr binary     search.

Not too hard to work out, I think! Of course, using a SORTED table in the first place would be more efficient.

0 Kudos

As Mattew mentioned it was a typo. if you use index, you might not be reading the correct record. That is why the code was modified to read based on smtp address.

0 Kudos

Hi

I have changed the code accordingly but still the changed fields are not highlighted.

FORM highlight_email_changes .

  DATA : i TYPE i VALUE 0,

          l_addr1_complete TYPE  szadr_addr1_complete,

   gt_zpslo_vendor_e_t_p TYPE zpslo_vendor_e_t OCCURS 0 WITH HEADER LINE,

                lw_zpslo_vendor_e_t TYPE zpslo_vendor_e_t,

   l_gt_zpslo_vendor_e_t TYPE zpslo_vendor_e_t OCCURS 0 WITH HEADER LINE,

                l_adsmtp_tab TYPE szadr_adsmtp_line,

                lw_gt_zpslo_vendor_e_t TYPE zpslo_vendor_e_t.

  CLEAR : l_addr1_complete, gt_zpslo_vendor_e_t_p, lw_zpslo_vendor_e_t, l_adsmtp_tab.

  READ TABLE gt_zpslo_vendor_e_t INTO wa_zpslo_vendor_e_t INDEX zpsmm_email_t-current_line.

  if sy-subrc = 0.

  IF lfa1-adrnr IS NOT INITIAL.

    CALL FUNCTION 'ADDR_GET_COMPLETE'

      EXPORTING

        addrnumber              = lfa1-adrnr

      IMPORTING

        addr1_complete          = l_addr1_complete

      EXCEPTIONS

        parameter_error         = 1

        address_not_exist       = 2

        internal_error          = 3

        wrong_access_to_archive = 4

        OTHERS                  = 5.

    IF sy-subrc <> 0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

  ENDIF.

    LOOP AT l_addr1_complete-adsmtp_tab INTO l_adsmtp_tab.

      i = i + 1.

      lw_zpslo_vendor_e_t-smtp_addr = l_adsmtp_tab-adsmtp-smtp_addr.

      lw_zpslo_vendor_e_t-flgdefault = l_adsmtp_tab-adsmtp-flgdefault.

      lw_zpslo_vendor_e_t-remark     = l_adsmtp_tab-adsmtp-remark.

      APPEND lw_zpslo_vendor_e_t TO gt_zpslo_vendor_e_t_p.

    ENDLOOP.

    SORT gt_zpslo_vendor_e_t_p BY remark.

    READ TABLE gt_zpslo_vendor_e_t_p WITH KEY remark = wa_zpslo_vendor_e_t-remark BINARY SEARCH. "added on may 6

    LOOP AT SCREEN.

      CASE screen-name.

        WHEN 'WA_ZPSLO_VENDOR_E_T-SMTP_ADDR'.

          IF gt_zpslo_vendor_e_t_p-smtp_addr <> wa_zpslo_vendor_e_t-smtp_addr.

            screen-intensified = '1'.

            g_changes_made = 'X'.

*            screen-intensified = '0'.

          ENDIF.



            WHEN 'WA_ZPSLO_VENDOR_E_T-REMARK'.

           IF gt_zpslo_vendor_e_t_p-remark <> wa_zpslo_vendor_e_t-remark.

              screen-intensified = '1'.

              g_changes_made = 'X'.


              ELSE.

              screen-intensified = '0'.

            ENDIF.


MODIFY gt_zpslo_vendor_e_t FROM wa_zpslo_vendor_e_t INDEX zpsmm_email_t-current_line.

      ENDCASE.

MODIFY SCREEN.

    ENDLOOP.

ENDIF.

ENDFORM.

0 Kudos

when you loop at screen, did you check what were the screen-names? are you getting a screen name called WA_ZPSLO_VENDOR_E_T-REMARK or WA_ZPSLO_VENDOR_E_T-SMTP_ADDR. Or is it just REMARK/SMTP_ADDR?

Also why not remove screen-intensified and try something else like screen-color to make sure its working for the rest.

Also add a clear statement before the read:

  CLEAR gt_zpslo_vendor_e_t_p.

   READ TABLE gt_zpslo_vendor_e_t_p WITH KEY remark =wa_zpslo_vendor_e_t-remark BINARY SEARCH. "added on may 6