Alternative for nested loops

Hi Gurus,
I have the following problem :
There are 2 internal tables namely 1 &2.
Now there is a field in table 1 'AUGBL' which should be equal to  field in Table2-BELNR.
Now if there is a match between TABLE1-AUGBL and TABLE2-BELNR,
so we move to table 2 to look for 'augbl' associated with 'belnr' in the same table.
Then I have to give the following logic -
If table2-belnr = table2-augbr,
   Then do nothing.
Else.
Check, for the Augbl which will equal Belnr in a different position in table 2.
For ex:
Table1-AUGBL = 2.
So now we have to search a field when Table1-augbl = Table2-belnr = 2.
Now for this record in table2, there are 2 conditions:
When Table2-augbl = 2, (in which case we do nothing)
or,
Table2-augbl NE 2, or Table2-augbl = 3.
In the latter case,  there will be another field in Table2-BELNR = 3. So we go to this record now and check for the associated AUGBL and do the same checks above.
We keep on continuing for this till the time we do not get the Table2-belnr = Table2-augbl in the end for the same record.
Now I want to achieve this without using nested loop.
Kindly help as I already have wated a lot of time.
Please let me know if there are any clarifications.

Hey..
Before u get the data into two internal tables through SELECT stmts.
U can use JOIN instead of two SELECT stmts ..that wud fetch the data into single internal table..
and that may ease ur validations and further process..
try this out..
Thanks and Regards,
KC

Similar Messages

  • Logic for nested loops

    Hi guy's,
    I required tipical logic pls any body help me,
    I have to fethch EBELN ,BEDAT from EKKO and  MATNR from EKPO
    based on that i have to go KEKO table based on MATNR
    I have to fetch KALNR and KADKY ,  BEDAT should be between range of BIDAT and KADAT.
    Based on KALNR   i have to go for CKIS table now i fetch  COMPONENT MATERIALS and ELEMT
    If i get the ELEMT 000 again i have to take COM.MATNR  again we have to go KEKO I have to get take KALNR KADKY and
    again i have to go for CKIS .
    I have to continue this logic up to in ELEMT = 010 .Here iam geting the problem.
    MATNR   ELEMT        I have to continue this loop up to elemt become 010 . how many tables i have to declared how to read
    A             000                the tabel.Pls any body help me.
    B              010
    C              010
    D              000
    Thanks
    santhosh
    Edited by: santhosh kumar on Sep 2, 2009 10:13 PM

    Hi,
    You have all the tables and field names and the link between each of the tables. Why dont you start with the select query as per the requirement? You can always revert back if you are stuck up anywhere. Generic questions are not allowed here.
    Regards,
    Vikranth

  • Wrong code analysis on "unreachable statement" for nested loops

    Try this with JavaFX 1.2 (NetBeans 6.5.1)
    function foo():Void {
        for (i in [0..<10]) {
            for (j in [0..<10]) { // be marked as unreachable statement
                if (match()) {
                    break;
                return; // I just want to get out
            // break goes here
    }It shows "unreachable statement" at the second 'for'.
    Right now I just change "return;" to "if (true) return;" to get it pass.

    I agree it is a bug at the compiler level. If I do your change and add println of i and j, I get a trace on j, obviously.
    You should file a bug report at [Jira / Kenai|http://javafx-jira.kenai.com/] (or I can do if you don't want to create an account).
    [EDIT] Uh, no, it is a known problem: [Bogus 'Unreachable statement' error|http://javafx-jira.kenai.com/browse/JFXC-3323], I will add this thread as a comment.
    A more complete use case:
    function foo(): Void {
         for (i in [ 0 ..< 5 ]) {
              println("I {i}");
              for (j in [ 0 ..< 5 ]) {
                   println("J {j}");
                   if (match()) {
                        break;
                   println("Some operation in the inner loop");
                   if (true) return;
              // break goes here
    function match(): Boolean { return Math.random() > 0.5; }
    foo();Now, the inner loop isn't really necessary, we never go beyond 0 for j... But technically, there is no unreachable statement, unless it means we never go up to 5 in the inner loop. In this case, Robert Field is right, the error message should be clearer.
    Edited by: PhiLho on 29 juil. 2009 10:17

  • Hash join vs nested loop

    DECLARE @tableA table (Productid varchar(20),Product varchar(20),RateID int)
    insert into @tableA values('1','Mobile',2);
    insert into @tableA values('2','Chargers',4);
    insert into @tableA values('3','Stand',6);
    insert into @tableA values('4','Adapter',8);
    insert into @tableA values('5','Cover',10);
    insert into @tableA values('6','Protector',12);
    --SELECT * FROM @tableA
    DECLARE @tableB table (id varchar(20),RateID int,Rate int)
    insert into @tableB values('1',2,200);
    insert into @tableB values('2',4,40);
    insert into @tableB values('3',6,60);
    insert into @tableB values('4',8,80);
    insert into @tableB values('5',10,10);
    insert into @tableB values('6',12,15);
    --SELECT * FROM @tableB
    SELECT Product,Rate
    FROM @tableA a
    JOIN @tableB b ON a.RateID = b.RateID
    Above is the sample query, where in execution plan it shows the Hash Match (inner Join). Now how do I change it to Nested Loop with out changing the query? help plz

    Is Hash Match(inner join) or Nested loop is better to have in the query?
    That depends on the size of the tables, available indexes etc. The optimizer will (hopefully) make the best choice.
    Above is the sample query, where in execution plan it shows the Hash Match (inner Join). Now how do I change it to Nested Loop with out changing the query?
    The answer that you should leave that to the optimizer in most cases.
    I see that the logical read for nested loop is higher than Hash Match.
    But Hash Match tends to need more CPU. The best way to two compare two queries or plans is wallclock time.
    On a big tables, how do we reduce the logical read? 
    Make sure that there are usable indexes.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • NESTED LOOP or SORT MERGE

    Hi All,
    How can we judge which one is best to use for the query- NESTED LOOP
    - SORT MERGE
    - HASH JOINThanx.. Ratan

    Hi...
    For Nested Loop Joins:
    Nested loop joins are useful when small subsets of data are being joined and if the join condition is an efficient way of accessing the second table.
    It is very important to ensure that the inner table is driven from (dependent on) the outer table. If the inner table's access path is independent of the outer table, then the same rows are retrieved for every iteration of the outer loop, degrading performance considerably. In such cases, hash joins joining the two independent row sources perform better.
    For Hash Join:
    Hash joins are used for joining large data sets. The optimizer uses the smaller of two tables or data sources to build a hash table on the join key in memory. It then scans the larger table, probing the hash table to find the joined rows.
    For Sort Merge Joins:
    Sort merge joins can be used to join rows from two independent sources. Hash joins generally perform better than sort merge joins. On the other hand, sort merge joins can perform better than hash joins if both of the following conditions exist:
    The row sources are sorted already.
    A sort operation does not have to be done.
    However, if a sort merge join involves choosing a slower access method (an index scan as opposed to a full table scan), then the benefit of using a sort merge might be lost.
    Sort merge joins are useful when the join condition between two tables is an inequality condition (but not a nonequality) like <, <=, >, or >=. Sort merge joins perform better than nested loop joins for large data sets. You cannot use hash joins unless there is an equality condition.
    In a merge join, there is no concept of a driving table. The join consists of two steps:
    Sort join operation: Both the inputs are sorted on the join key.
    Merge join operation: The sorted lists are merged together.
    If the input is already sorted by the join column, then a sort join operation is not performed for that row source.

  • Is merge join cartesian more cpu intensibe than nested loop ?

    Hi,
    just wonderning which access method is more cpu intensive , lets supposed we got 2 the same row sources and doing joing via merge join cartesian and next case is nested loop .
    I know NL can be cpu intensive because of tight loop access , but what abour MJC ?
    I can see bufferd sort but not sure is that cpu friendly ?
    Regards
    GregG

    Hi,
    I think in your case it's more accurate to compare a NESTED LOOP (NL) to a MERGE JOIN (MJ), because CARTESIAN MERGE JOIN is a rather special case of MJ.
    Merge join sorts its inputs before combining them, and it could be efficient when one or both of inputs are already sorted.
    Regarding your question (which is more CPU intensive):
    1) if MERGE JOIN involves disk spills, then CPU is probably irrelevant, because disk operations are much more expensive
    2) the amount of work to combine rowsources via a MJ depends on how well they are aligned with respect to each other, so I don't think it can be expressed via a simple formula.
    For nested loops, the situation is much more simple: you don't need to do any special work do combine the rowsource, so the cost is just the sum of the cost acquiring the outer rowsource plus the number of iterations times the cost of one iteration. If the data is read from disk, then CPU probably won't matter much, if most of reads are logical ones than CPU becomes of a factor (it's hard to tell how much work CPU will have to do per one logical read because there are two many factors here -- how many columns are accessed, how they are located within the block, are there any expensive math functions applied to any of them etc.)
    Best regards,
    Nikolay

  • Nested FOR cursor LOOPs, BASIC QUESTION

    Hello,
    I am trying to nest a For-loop using a cursor (see below), but the program is not entering the second (nested) for-loop. This program compiles fine, but during run-time, the nested loop does not execute. I'd rather not use FETCH statements and keep everything in place. I think the solution is rather trivial, but I'm new to PL/SQL. PLEASE HELP!!!!!
    cursor c1 is
    select coi_con_uid,coi_not_code,coi_closed_yn,coi_timestamp
    from s_coi_con_issue
    where coi_not_code = 'NOT107'
    and coi_timestamp <= v_aweekago
    and coi_closed_yn = 'N';
    cursor c2 is
         select tsk_uid
         from s_tsk_task
         where tsk_status in ('C')
         and tsk_tty_code = 'CONTAC'
         and tsk_date_end = '' FOR UPDATE;     
    BEGIN
    select to_date(sysdate - 7) into v_aweekago from dual;
    DBMS_OUTPUT.PUT_LINE('System date used is ' || v_aweekago);
    FOR coi_row in c1 LOOP
    v_tsk_cnt := 0;
    v_coi_row_cnt := v_coi_row_cnt + 1;
    v_con_uid := rtrim(to_char(coi_row.coi_con_uid));
    v_tsk_act_str := ('"CON_UID","' || v_con_uid || '"') ;
    DBMS_OUTPUT.PUT_LINE('COI_CON_UID: ' || v_con_uid);
    DBMS_OUTPUT.PUT_LINE('v_tsk_act_str: ' || v_tsk_act_str);
    -----The Program is not entering into this Loop
              FOR tsk_row in c2 LOOP
              v_update_cnt := v_update_cnt + 1;
                   update s_tsk_task
                   set tsk_status = 'A'
                   where tsk_uid = tsk_row.tsk_uid and
                   tsk_action_string = v_tsk_act_str;     
                   DBMS_OUTPUT.PUT_LINE('----Task updated');                         
              END LOOP;
    END LOOP;
    COMMIT;

    using your query on your cursor c2 when you execute it on sql*plus did it return any rows?
      select tsk_uid
        from s_tsk_task
       where tsk_status in ('C')
         and tsk_tty_code = 'CONTAC'
         and tsk_date_end = ''; if not it might have something to do with the predicates in your where clause
         and tsk_date_end = '';consider revising your c2 cursor select statement to something like:
    cursor c2 is
      select tsk_uid
        from s_tsk_task
       where tsk_status   = 'C'
         and tsk_tty_code = 'CONTAC'
         and tsk_date_end IS NULL
      FOR UPDATE;

  • Need to access parent elements in nested for-each loop

    Hi All,
    I have a xslt mapping requirement in which I am completely stuck. The details are as listed below. Please help!
    Schema structure is as follows:
    Root
    Payload
    Transaction-123
    Loop-LINE
    Loop-SDPP
    Segment-FSTT
    Element-111
    Required xslt file structure is:
    <xsl:for-each Loop-LINE>
    <tns:Item>
    <Line-1000>
    <Line-2000>
    <Line-3000>
    <Line-8000>
    <xsl:for-each Loop-SDPP>
    <xsl:for-each Segment-FSTT[ns0:Element-111 != "A"]>
    <SDetails>
    </SDetails>
    <xsl:for-each Loop-LINE> --------- How to access Loop-LINE element from this for loop????
    <tns:Item>
    <2000>
    <2020>
    <2070>
    <2150>
    </tns:Item>
    </xsl:for-each>
    </for-each>
    </for-each>
    </tns:item>
    </for-each>
    Need help in understanding how can I run a for-each loop for Loop-LINE which is two levels up in the schema tree structure.
    Thanks..

    Thanks for this answer but I can't obtain the right output with my test case; the multi column must be in the loop as that :
    ALPHABETICAL INDEX C1
    Alternator .......................................... Feed Pump
    Belt Details / Engine Gaskets Sets ..... Flywheel Housing
    < NEW PAGE>
    INDEX ALPHABETIQUE C2
    Alternateur......................................... Culbuteurs
    Bloc-Cylindres.................................... Demarreur
    Denis

  • Nested table updation in FOR Cursor loop

    Hello,
    I have nested table as follows:
    SQL> desc fp
    Name Null? Type
    ORDER_NUM NOT NULL VARCHAR2(10)
    ORDER_TIE_NUM NOT NULL VARCHAR2(10)
    FACILITY NOT NULL VARCHAR2(10)
    ON_SHORTS NUMBER(2)
    ACTIVE_SHORTS NUMBER(2)
    PARTS DPM_TRANSFORM_CODE.FP_SLC_SHORT
    FIRST_SHORT DATE
    LAST_SHORT DATE
    SQL> desc DPM_TRANSFORM_CODE.FP_SLC_SHort
    DPM_TRANSFORM_CODE.FP_SLC_SHort TABLE OF DPM_TRANSFORM_CODE.FP_SHORT_INFO
    Name Null? Type
    PART_NUM VARCHAR2(7)
    AREA VARCHAR2(7)
    PART_QTY NUMBER(3)
    ON_SHORT_CNT NUMBER(4)
    OFF_SHORT_CNT NUMBER(4)
    FIRST_DATE DATE
    LAST_DATE DATE
    UPDATE TABLE(SELECT PARTS FROM DPM_REPORTING.FP WHERE ORDER_NUM = P.ORDER_NUM AND ORDER_TIE_NUM = P.ORDER_TIE_NUM) PARTS
    SET PARTS.OFF_SHORT_CNT = PARTS.OFF_SHORT_CNT + 1
    WHERE PARTS.last_date < SYSDATE - 2/24;
    This Update Statement is in FOR Cursor Loop
    where select statement for the cursor is
    "SELECT ORDER_NUM,ORDER_TIE_NUM,PARTS FROM DPM_REPORTING.FP WHERE FACILITY = 'PN1'"
    This select statement generates 20000 records & due to which the Update statement gets executed that many times inside FOR loop.The Procedure has become quite slow due to this.
    Please help.
    Thanks,
    Rekha

    You could do it all in one sql update statement, without any pl/sql or cursor or looping:
    UPDATE fp t1
    SET    t1.parts =
           CAST (MULTISET (SELECT part_num, area, part_qty, on_short_cnt,  
                                  CASE WHEN last_date < SYSDATE - 2/24
                                       THEN off_short_cnt + 1
                                       ELSE off_short_cnt
                                  END,  
                                  first_date, last_date
                           FROM   TABLE (SELECT parts
                                         FROM   fp
                                         WHERE  facility = 'PN1'
                                         AND    order_num = t1.order_num
                                         AND    order_tie_num = t1.order_tie_num))    
                 AS fp_slc_short)
    WHERE  t1.facility = 'PN1'
    /

  • 106 nested for next loops!

    Well, this is not a problem, but I just had to mention that I could not believe that Java would actually process 106 nested for next loops. I had an hour of free time yesterday and we needed to run an exhaustive branch test of an application that we have, to do so we needed to have 104 data elements generated with all possible cases. I thought, what the heck, and tried it in Java--our old language wouldn't do that on it's best day and in our dreams! Java did it, it not only did it, but it left a clean environment after it was done!

    well, here is more the thing that comes to mind with i think about loop limits: in VB when you get a dozen or so pending closing parentesis, things start to go funny in memory and in some cases, the formula/routine becomes too complicated to interpret. Just how many pending closing parentesis will be accepted before things go bonkers.

  • Explain Plan shows Nested Loops, Is it good or bad?

    Hi All,
    I have a doubt in the explain plan, I would like to know if the Nested Loops , will it degrade the query performance?
    Note: I have pasted only few output that I had taken from the expalin plan.
    Do let me know if there is any article I could read to get clear understanding about the same.
    17 NESTED LOOPS ANTI Cost: 125 Bytes: 186 Cardinality: 1                                                                  
    15 NESTED LOOPS ANTI Cost: 124 Bytes: 166 Cardinality: 1                                                             
    12 NESTED LOOPS Cost: 122 Bytes: 140 Cardinality: 1                                                        
         9 NESTED LOOPS Cost: 121 Bytes: 117 Cardinality: 1           
    Thanks

    Hi,
    there is absolutely nothing wrong about nested loops (NL). It's a very efficient way of combining data from two rowsources. It works pretty much like a regular loop: it takes all rows from one rowsource (the "outer" one) and for each of them it looks up a row matching the join condition in the other rowsource (the "inner" one).
    Note that there are not so many alternatives in Oracle: there are only 3 ways to join data in Oracle, and one of them is used in rather special circumstances (merge join). So normally the choice is between a NL and a hash join. Hash join (HJ) takes the smaller dataset and builds an in-memory lookup table using a hash function on join column(s). Then it goes through the other dataset and as it goes, it applies the hashing function to join column(s) and picks the matching rows from the smaller dataset.
    Actually, hash joins and nested loops are not all that different. The basic mechanism is same: you go through one datasource and as you go, you pick matching rows from the other and do the join. The main difference is that a HJ requires some preparation work (it costs resources to build the in-memory table) and thus HJ are typically associated with less-selective queries and full table scans.
    In your particular case it's nor possible to tell whether or not NL is in order based on just a few rows from the explain plan. We need to know the structure of your tables (the DDL), what kind of data they hold (optimizer stats) and what query you are running to be able to tell.
    Best regards,
    Nikolay

  • How to use for each loop in XSLT when my source is a multilayout file and db

    How do I use a for each loop in XSLT when my source is multilayout file and db .
    My multilayout file is basically contain 2 kind of data one for employee and another for dependent.
    Now my requirement is I want to read each line of data whether it is it is employee or dependent do a join with db and write it in my target file.
    eg :  File content
    1 RichaKumari 311289 TCS INDIA
    2 KiarnKumar 456782 BRO RichaKumari 311289 INDIA
    2 Ravi            456882 BRO RichaKumari 311289 INDIA
    eg : db Content
    311289 RichaKumari TCS INDIA Bangalore [email protected]
    Now in Final File I need something like this :
    1 RichaKumari 311289 TCS INDIA
    2 KiarnKumar RichaKumari 311289 TCS INDIA
    2 Ravi            RichaKumari 311289 TCS INDIA
    here 1 and 2 are the identifier which will decide which layout to follow .

    Hi,
    I think you'll need two nested for-each's... Something like...
    <xsl:for-each select="$root/row[layout = 1]">
    <xsl:variable name="employee" select="."/>
    ... write employee ...
    <xsl:for-each select="$root/row[layout = 2 and dependentid = $employee/id]">
    ... write dependent ...
    </xsl:for-each>
    </xsl:for-each>
    Cheers,
    Vlad

  • Alternative for AT NEW --- ENDAT

    Hello experts,
    I am using field-symbol as internal table. I cant use AT NEW statement inside this loop.
    Can u pls provide alternative for above control break statement.
    Thanks in advance.
    Zak.

    Hi,
    to use control break statement, first you should sort the internal table and then you use it.
    Take one example:
    data: begin of it9 occurs 4,
               f1,
               f2,
             end of it9.
      it9 = '1A'. append it9. "Fill it9 with data
      it9 = '3A'. append it9.
      it9 = '1B'. append it9.
      it9 = '2B'. append it9.
    sort it9 by f1.
    loop at it9.
         at new f1.
             write: / 'start of:', it9-f1.
             endat.
         at end of f1.
             write: / 'end   of:', it9-f1.
             endat.
         endloop.
    free it9.
    Hope it is helpful.
    Regards,
    Chris Gu

  • Building Tree hierarchy Using nested loops and class cl_gui_column_tree

    Hello gurus,
    I want to create a tree report using custom container and class cl_gui_column_tree. I have read and understood the standard demo report which SAP has provided i.e. SAPCOLUMN_TREE_CONTROL_DEMO. But in this report all the levels nodes are created as constants and hardcoded. I want to create hierarchy using nested loops. For this i took one example of a hierarchy of VBAK-VBELN->VBAP-POSNR Like One sales order has many line items and each line item can have number of line items in billing plan.
    I have done some coding for it.
    FORM build_tree USING node_table TYPE treev_ntab
                                           item_table TYPE zitem_table.              " i created the zitem_table table type of mtreeitm in SE11.
      DATA: node TYPE treev_node,
                 item TYPE mtreeitm.
      node-node_key = root.
      CLEAR node-relatkey.
      CLEAR node-relatship.
      node-hidden = ' '.
      node-disabled = ' '.
      CLEAR node-n_image.
      CLEAR node-exp_image.
      node-isfolder = 'X'.
      node-expander = 'X'.
      APPEND node TO node_table.
      item-node_key = root.
      item-item_name = colm1.
      item-class = cl_gui_column_tree=>item_class_text.
      item-text = 'Root'.
      APPEND item TO item_table.
      item-node_key = root.
      item-item_name = colm2.
      item-class = cl_gui_column_tree=>item_class_text.
      item-text = 'Amount'.
      APPEND item TO item_table.
      LOOP AT it_vbeln INTO wa_vbeln.
        node-node_key = wa_vbeln-vbeln.
        node-relatkey = root.
        node-relatship = cl_gui_column_tree=>relat_last_child.
        node-hidden = ' '.
        node-disabled = ' '.
        CLEAR node-n_image.
        CLEAR node-exp_image.
        node-isfolder = 'X'.
        node-expander = 'X'.
        APPEND node TO node_table.
        item-node_key = wa_vbeln-vbeln.
        item-item_name = colm1.
        item-class = cl_gui_column_tree=>item_class_text.
        item-text = wa_vbeln-vbeln.
        APPEND item TO item_table.
        item-node_key = wa_vbeln-vbeln.
        item-item_name = colm2.
        item-class = cl_gui_column_tree=>item_class_text.
        item-text = wa_vbeln-netwr.
        APPEND item TO item_table.
        LOOP AT it_posnr INTO wa_posnr.
        node-node_key = wa_posnr-posnr.
        node-relatkey = wa_vbeln-vbeln.
        node-relatship = cl_gui_column_tree=>relat_last_child.
        node-hidden = ' '.
        node-disabled = ' '.
        CLEAR node-n_image.
        CLEAR node-exp_image.
        node-isfolder = ' '.
        node-expander = ' '.
        APPEND node TO node_table.
        item-node_key = wa_posnr-posnr.
        item-item_name = colm1.
        item-class = cl_gui_column_tree=>item_class_text.
        item-text = wa_posnr-posnr.
        APPEND item TO item_table.
        item-node_key = wa_posnr-posnr.
        item-item_name = colm2.
        item-class = cl_gui_column_tree=>item_class_text.
        item-text = wa_posnr-netpr.
        APPEND item TO item_table.
        ENDLOOP.
      ENDLOOP.
    ENDFORM.
    Now this program compiles fine and runs till there is only one level. That is root->vbeln. But when i add one more loop of it_posnr it gives me runtime error of message type 'X'. The problem i found was uniqueness of item-item_name as all the sales order have posnr = 0010. What could be done? I tried giving item_name unique hierarchy level using counters just like stufe field in prps eg. 10.10.10, 10.10.20,10.20.10,10.20.20,20.10.10 etc.. etc.. but still i am getting runtime error when i add one more hierarchy using nested loop. Plz guide.
    Edited by: Yayati6260 on Jul 14, 2011 7:25 AM

    Hello all,
    Thanks the issue is solved. The node key was not getting a unique identification as nodekey. I resolved the issue by generating unique identification for each level. Thanks all,
    Regards
    Yayati Ekbote

  • Problem with Nested loop in Fox-Formula

    Dear Experts,
    Let s share the scenario :
    MaterialGroups with following Keys for Example AAAA, BBBB, CCCC..., Materialgroups are selected in the 1st input ready query, which is assigned to DataProvider DP_1 in a  webtemplate.
    every Materialgroup has several Materials, for instance:
    Materialgroup AAAA has following Materials: AAAA10, AAAA11, AAAA12, AAAA13...
    Materials are  selected in a second  input ready Query, which is assigned to a second DataProvider DP_2 in the Same Webtemplate as the query 1.
    Both Materialgroup and Material are based on the same Aggreagtion level and same real time cube.
    I want to copy the input values for every  MaterialGroup ( 1st query, DP_1) only to it s own Materials (2cond Query, DP_2).
    To resolve this Issue i wrote the following Fox Formula code with a nested loop, however it does not work properly. when I m debugging the code, i could release that the second Loop was ignored.but wehn i replace the second loop (nested loop) with a fixed value it s seems to work properly
    DATA MG1 TYPE MATG.<------ MaterialGroup
    DATA MT1 TYPE MAT.<----
    Material
    DATA S1 TYPE STRING.
    DATA S2 TYPE STRING.
    DATA S3 TYPE STRING
    DATA K TYPE F.
    DATA Z TYPE F.
    FOREACH MG1.
    To check Materialgroup in debugger
    S1= MG1.
    BREAK-POINT.
    K = {KEYfIG, #, MG1}.
    BREAK-POINT.
    FOREACH  MT1.   <----- if i set MT1 to a fixed value like AAAA11 then S3 get the wished value namely AAAA
    S2 = MT1.
    BREAK-POINT.
    S3 =  SUBSTR (MT1, 0, 4).  
    BREAK-POINT.
    IF S1 = S3.
    {KEYFIG, MT1, #} = K.
    following Statement is only used To check in debugger if Material has become the same Materialgroup value
    Z = {KEYFIG, MT1, #}.
    BREAK-POINT.
    ENDIF.
    ENDFOR.
    ENDFOR.
    Thakns for any help
    Frank
    Edited by: FRYYYBM on Mar 17, 2011 10:54 PM
    Edited by: FRYYYBM on Mar 17, 2011 11:06 PM

    Hi,
    Please try this way.
    DATA MG1 TYPE MATG.<------ MaterialGroup
    DATA MT1 TYPE MAT.<----
    Material
    DATA S1 TYPE STRING.
    DATA S2 TYPE STRING.
    DATA S3 TYPE STRING
    DATA K TYPE F.
    DATA Z TYPE F.
    FOREACH MT1.
    FOREACH MG1.
    To check Materialgroup in debugger
    S1= MG1.
    BREAK-POINT.
    K = {KEYfIG, #, MG1}.
    BREAK-POINT.
    FOREACH MT1. <----- if i set MT1 to a fixed value like AAAA11 then S3 get the wished value namely AAAA
    S2 = MT1.
    BREAK-POINT.
    S3 = SUBSTR (MT1, 0, 4).
    BREAK-POINT.
    IF S1 = S3.
    {KEYFIG, MT1, #} = K.
    following Statement is only used To check in debugger if Material has become the same Materialgroup value
    Z = {KEYFIG, MT1, #}.
    BREAK-POINT.
    ENDIF.
    ENDFOR.
    ENDFOR.
    ENDFOR.
    Thanks.
    With regards,
    Anand Kumar

Maybe you are looking for