Skip to Content
author's profile photo Former Member
Former Member

Regarding 2 internal tables manipulation

Hi All,

I have 2 internal tables from which i have to filter data and get into next step.

I have <b>2</b> internal tables <b>i_tab1, i_tab2</b>

Now as per spec

<b>I need to Compare values in i_tab1 & i_tab2 where

i_tab1-EXGEN = i_tab2–EXGEN

i_tab1-GENNR = i_tab2–GENNR

i_tab1- GAUFW_DELT = i_tab2-NETWR

if they all match go to 4, if they don’t match go to 2</b>

What logic can i write over here.

DO i need to loop through the entries.

In this case after finishing all above process i have to goto step 3 right!

Thanks in advance.

Thanks & Regards,

Prasad.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 08, 2006 at 08:20 AM

    hi Prasad,

    One way is to loop i.e,

    <b>loop at itab1

    Read table ...

    loop at itab2

    Read table ....

    Logic

    endloop

    endloop</b>

    the other way is use <b>case endcase</b> statemnet

    Regards,

    Santosh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 08, 2006 at 08:19 AM

    Hi,

    I would proceed with a :

    LOOP AT ...
      READ TABLE ... TRANSPORTING NO FIELDS WITH KEY ... BINARY SEARCH.
      IF sy-subrc = 0. 
    *   do stuff here
      ELSE.
    *   do something else
      ENDIF.
    ENDLOOP.

    Best regards,

    Guillaume

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 08, 2006 at 08:33 AM

    Hi Prasad,

    You can use the below logic.

      LOOP AT I_TAB1.
    
        READ I_TAB2 WITH KEY EXGEN = I_TAB1-EXGEN
                             GENNR = I_TAB1-GENNR.
        IF SY-SUBRC = 0.
        
          IF I_TAB1-EXGEN = I_TAB2–EXGEN
          AND I_TAB1-GENNR = I_TAB2–GENNR
          AND I_TAB1-GAUFW_DELT = I_TAB2-NETWR.
            " YOUR LOGIC.. GOTO 4
          ELSE.
            " GOTO 2
          
          ENDIF.
       
        ENDIF.
    
      ENDLOOP. "I_TAB1
    
    

    Hope the above code will help you.

    Thanks,

    Ramya

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 08, 2006 at 08:56 AM

    Hii Prasad ,

    check this optimized code .

    <b>SORT I_TAB1 BY EXGEN GENNR .</b>
    
    LOOP AT I_TAB1.
     
        READ I_TAB2 WITH KEY EXGEN = I_TAB1-EXGEN
                             GENNR = I_TAB1-GENNR
          <b>BINARY SEARCH TRANSPORTING NO FIELDS</b>.
        
          IF SY-SUBRC = 0.
        
          IF I_TAB1-EXGEN = I_TAB2–EXGEN
          AND I_TAB1-GENNR = I_TAB2–GENNR
          AND I_TAB1-GAUFW_DELT = I_TAB2-NETWR.
    
           <b>FLAG_1 = X .</b>         
          ELSE.
            <b>CLEAR FLAG_1 .
     
            FLAG_1 = Y .</b> 
         
          ENDIF.
       
        ENDIF.
     
      ENDLOOP. "I_TAB1

    Case FLAG_1.
    		
    When ‘X’.
            " GO TO CONDITION 4 .
    	-------------
    	-------------
    When ‘Y’.
    	" GO TO CONDITION 2.
            -------------
    	-------------
    When ‘Z’.
    
    Endcase.

    </b>

    This way you can give as many conditions as you want

    Regards

    Naresh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 08, 2006 at 09:01 AM

    Hi the below loop talks about two internal tables, which go accroding to the condition checking condition and then check SY-SUBRC value....

    LOOP AT T_VBRK_VBRP.
    
      T_FINAL = T_VBRK_VBRP.
    
            IF T_VBRK_VBRP-CHARG IS INITIAL.
    
              READ TABLE T_LIPS WITH KEY VBELN = T_VBRK_VBRP-VGBEL
                                         MATNR = T_VBRK_VBRP-MATNR.
    
                  IF SY-SUBRC  = 0.
    
                    T_FINAL-FKIMG = T_LIPS-LFIMG.
                    T_FINAL-CHARG = T_LIPS-CHARG.
                    T_FINAL-NETWR = T_LIPS-NETWR.
    
                  ELSEIF SY-SUBRC <> 0.  " NO DELIVERY DETAILS FOUND
    
                    CLEAR T_FINAL-VGBEL.
    
                  ENDIF.
    
            ENDIF.
    
        APPEND T_FINAL.
    
      ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.