Application Development and Automation 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: 
Read only

Logic For avoiding loop inside loop.

Former Member
0 Likes
1,409

how to avoid the double entry of a material in a internal table of a valuated class stock in a loop.because we are used loop inside loop.i am getting the same material value twice.pls give suggestion to avoid twice value.

6 REPLIES 6
Read only

ruben_rollano
Participant
0 Likes
1,290

Hello Sandhya,

Could you show the code or provide a littel more of context?

Best regards.

Read only

1,290

Please use the COMMENT button for comments, questions, adding details, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area: "Before answering You should only submit an answer when you are proposing a solution to the poster's problem"

Read only

rameez_khan
Active Participant
1,290

can you provide the code ?

Anyways, did you try to filter records with where clause/parallel cursor ? or a simply read statement instead of inner loop, if you want to access only 1 record. ?

Without code and giving exact details it will be difficult for everyone to help you.

Thanks
Rameez

Read only

Former Member
0 Likes
1,290

loop at it_mbew into wa_mbew.

LOOP at it_mard INTO wa_mard WHERE matnr = wa_mbew_new-matnr AND werks = wa_mbew_new-bwkey ."AND labst = wa_mbew_NEW-lbkum."AND charg = wa_mbew-bwtar.
wa_mbew1-bwkey = wa_mbew_new-bwkey.
wa_mbew1-matnr = wa_mbew_new-matnr.
wa_mbew1-bwtar = wa_mbew_new-charg.
wa_mbew1-lbkum = wa_mard-labst + wa_mard-insme.
wa_mbew1-verpr = wa_mbew_new-verpr.
wa_mbew1-bklas = wa_mbew_new-bklas.
** wa_mbew1-STPRS = wa_mbew_new-STPRS.
** wa_mbew1-lgort = wa_mchb-lgort.
IF wa_mbew1-bklas = '8100'.
wa_mbew1-salk3 = wa_mbew1-lbkum * wa_mbew_new-STPRS.
ELSE.
wa_mbew1-salk3 = wa_mbew_new-salk3."wa_mbew1-lbkum * wa_mbew_new-verpr.
ENDIF.

* if wa_mbew_new-matnr = wa_mard-matnr.
* APPEND wa_mbew1 to it_mbew1.
* ELSE.
* exit.
* endif.

if wa_mbew1-lbkum IS NOT INITIAL.
APPEND wa_mbew1 to it_mbew1.
ENDIF.
CLEAR wa_mbew1.
ENDLOOP.

SORT it_mbew1 by bwkey matnr bwtar DESCENDING.


ENDLOOP.

Read only

Former Member
0 Likes
1,290

In this code I am getting two values for a mterial .pls give me some suggestion.

Read only

UweFetzer_se38
Active Contributor
0 Likes
1,290

Do you have more than one storage locations?