5 Replies Latest reply: Nov 23, 2016 1:56 AM by Manuel Rühl RSS

    Nested Loop

    Manuel Rühl

      Hello,

       

      I want to load a SAP-SD-BAPI in a loop, but I have problems to generate the loop.

       

      Output musst be a variable, which I can insert into the Bapi with the syntax:   [ "$(variable)" ]

       

      start: 1 (=0000000001) end 999999 (=0000999999)

       

      The syntax without variable is [ "0000000123","0000000345","0000000678" ]

       

      So the the variable musst contain 0000000001","0000000002","0000000003"

       

      I want to load the Bapi in 10, 100, 1000 packages, I have to check the performance, which works.

       

      I tried a double for loop, but it didnt work.

       

      thx for help !

        • Re: Nested Loop
          Marcus Sommer

          Hi Manuel,

           

          is this a particular SAP topic or more a script logic/syntax issue (and it would be helpful if you post it)?

           

          - Marcus

          • Re: Nested Loop
            Peter Cammaert

            What didn't work in your attempts? The content of the variable wasn't correct? The double loop couldn't generate all values between 1 and 999999? You weren't able to create the package configuration so that the number of values in the variable at a time could be controlled?

              • Re: Nested Loop
                Peter Cammaert

                Lack of feedback made me guess for a solution like this:

                 

                LET vMaxValue = 999999; // Set this to whatever you want except 0
                LET vPackageWidth = 1000; // Set this to whatever you want
                
                
                LET vLastValue = 0;
                
                
                FOR i = 1 TO div(vMaxValue, vPackageWidth) + 1
                  LET vStart = vLastValue + 1;
                  LET vLastValue = RangeMin(vStart + vPackageWidth - 1, 999999);
                
                
                  LET vVariable = '"' & Num(vStart, '0000000000') & '"';
                  FOR j = vStart+1 TO vLastValue
                    LET vVariable = vVariable & ', "' & Num(j, '0000000000') & '"';
                  NEXT
                  TRACE Run $(i), vStart = $(vStart), vEnd = $(vLastValue);
                  TRACE Run $(i) = $(vVariable);
                  
                  // Put your BAPI Statement(s)/Call(s) here
                  
                NEXT
                
                

                 

                Is it any good?

              • Re: Nested Loop
                Manuel Rühl

                Hello Peter,

                 

                Sometimes people here are faster than the feedback.

                 

                That's exactly what I described and it works! Thanks a lot !

                Perfect for testing!

                 

                But it is not exactly what I needed... The orders do not only start with 0000000001, there are orders with 40000000001 and 600000001. I have built an application (see attachment) reading the VBAK to get the headers of the really existing headers.

                 

                The performance with packages of 250 orders was the fastest in my tests.

                 

                BAPI Name is BAPISDORDER_GETDETAILEDLIST

                 

                Maybe it helps others as well !