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: 

Comparison of TWO Fieldsymbol records.

Former Member
0 Kudos

Hi Experts,

I have two different field symbol records.both of them having multiple rows of records.But two fields are similar to both. Now i want to compare this two field symbol records and append the same to normal internal table.

Anyone guide me.

In normal internal table we are simply making read table and moving the workarea values to new internal table. But in Field symbol howtodo this.

Regards
Anandhan

7 REPLIES 7

ipravir
Active Contributor
0 Kudos

Hi Anandhan,

Find the below code to read the Information from two different FS.

Field-symbol : <val1> type any,

     <val2> type any.

Suppose you have two diff. work area for your two FS internal tables, like <wa1> & <wa2>.

to read the column from internal table.

loop at <fs_tab1> assign <wa1>.

     assign component 'FIELD_NAME' of structure <wa1> to <val1>.

     "here <val1> will contains the value of the given FIELD_NAME.

     loop at <fs_tab1> assing <wa2>.

           assign component 'FIELD_NAME'   of structure <wa2> to <val2>.

            "here <val2> will contains the value of the same FIELD of diff internal table.

            if <val1> eq <val2>.    

                    here you can write your logic

             endif.

     endloop.

endloop.

Regards.

Praveer.

Former Member
0 Kudos

The structure are different, but few fields are common. Guide me

0 Kudos

Is this what you are looking for..

Data: i_spfli type STANDARD TABLE OF spfli,

       i_sflight type STANDARD TABLE OF sflight.

FIELD-SYMBOLS:

       <fs1> TYPE spfli,

       <fs2> TYPE sflight.

SELECT * from spfli into TABLE i_spfli where carrid = 'AA'.

SELECT * from sflight into TABLE i_sflight where carrid = 'AA'.

LOOP AT i_sflight ASSIGNING <fs2>.

  

   READ TABLE i_spfli ASSIGNING <fs1> with KEY carrid = <fs2>-carrid.

   IF sy-subrc = 0.

    

*    Build target work area and append it.

   ENDIF.

  

ENDLOOP.



Let me know if the structure are not known like this..

0 Kudos

Hi Anandhan,

The logic I have shared you is for all type of structure.

You have to Declare the FS work-area and the rest of the logic will be same to read the information for same field, which is exist in both structure.

data: <it1> type standard table of structure1,

          <it2> type standard table of strucutre2.

          <wa1> type structure1,

          <wa2> type strucure2,

          <val1>    type any,

           <val2> type any.

Loop at <it1> assign <wa1>.

     assign component 'FIELD_NAME' of structure <wa1> to <val1>.

     if <val1> is assigned.

          loop at <it2> assign <wa2>.

               assign component 'SAME_FIELD_NAME' of structure <wa2> to <val2>.

               if <val2> is assigned.

                    if <val1> eq <val2>.

                         write your rest of logic.

                    endif.

               endif.

          endloop.

     endif.

endloop.

Regards.

Praveer.

rajeshkothamasu
Active Participant
0 Kudos

Hi,

Share u r code here.

Regards,
Rajesh K

Former Member
0 Kudos

Hello,

I made the code, but while looping the field symbol and assinging into structure, its looping only one roww of record. But in the fieldsymbol having 47 entries. what mistake i did?

LOOP AT <fs_address> ASSIGNING <ls_address>.

endloop.

Anyone please guide.

Regards

Anandhan

0 Kudos

Hi Anandahan,

LOOP AT <fs_address> ASSIGNING <ls_address>.

     

     Loop at (Your Fields Table ) into WS (Work are for Fields table ).

         

           assign component 'FIELD_NAME' of structure <wa1> to <val1>.

           if <val1> is assigned.

          loop at <it2> assign <wa2>.

               assign component 'SAME_FIELD_NAME' of structure <wa2> to <val2>.

               if <val2> is assigned.

                    if <val1> eq <val2>.

                         write your rest of logic.

                    endif.

               endif.

          endloop.

        endif.

     endloop.

endloop.


Regards.

Praveer.