Skip to Content
avatar image
Former Member

Finding fields having different values

Hi

There are two internal tables with same structures, each holding single record. However, the values of those records are different.

I need to find out the fields in which the values are different.

How can I perform this.

Could any one help?

Thanks

Divya

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Sep 05, 2008 at 03:45 AM

    Hello Divya

    You could do a field-by-field comparison, e.g.:

    " Read single record of each itab into work area
    
    FIELD-SYMBOLS:
      <ld_fld1>   TYPE ANY,
      <ld_fld2>   TYPE ANY.
    
    DO.
      ASSIGN COMPONENT syst-index OF STRUCTURE ls_record1 TO <ld_fld1>.
      ASSIGN COMPONENT syst-index OF STRUCTURE ls_record2 TO <ld_fld2>.
      CHECK ( syst-subrc = 0 ).  " assign worked
    
      IF ( <ld_fld1> NE <ld_fld2 ).
    ...
      ENDIF.
    ENDDO.
    

    Or you may use a more generic approach which will work for all records of itabs having the same structure. This approach gives you new, modified and deleted records: [Comparing Two Internal Tables - A Generic Approach|https://wiki.sdn.sap.com/wiki/display/Snippets/ComparingTwoInternalTables-AGeneric+Approach]

    Regards

    Uwe

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 05, 2008 at 04:19 AM

    Hi,

    You can directly try comparison using the string comparision statements like

    EQ - Equals,

    NE - Not Equals

    GT - Greater than

    LT - Less than

    GE - Greater than or Equals

    LE - Less than or Equals

    IF Structure1-field NE structure2-field.
    
    ENDIF.

    Regards,

    Kunjal

    Add comment
    10|10000 characters needed characters exceeded