2006 Jun 08 9:17 AM
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_tab2EXGEN
i_tab1-GENNR = i_tab2GENNR
i_tab1- GAUFW_DELT = i_tab2-NETWR
if they all match go to 4, if they dont 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.
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_tab2EXGEN
i_tab1-GENNR = i_tab2GENNR
i_tab1- GAUFW_DELT = i_tab2-NETWR
if they all match go to 4, if they dont 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.
2006 Jun 08 9: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
2006 Jun 08 9: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
2006 Jun 08 9: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_TAB2EXGEN
AND I_TAB1-GENNR = I_TAB2GENNR
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
2006 Jun 08 9: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_TAB2EXGEN
AND I_TAB1-GENNR = I_TAB2GENNR
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
2006 Jun 08 10: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.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |