Loops in AGAL shaders?

Hello!
I am currently working on a SSAO implementation for Molehill but I'm constantly hitting my head against the 256 instruction limit of AGAL shaders. This is a consequence of a fairly complex inner sampling loop which I need to unroll because AGAL doesn't support loops. I can see in the assembler that there are opcodes for "REP" and "BRK", which I'm guessing is repeat and break. Are there any plans to support these operations in the future?
In fact, what's the plans for Molehill? Will we see a new incubator release, or will you go straight to release?
Thanks,
Jakob

Hi Jakob,
We just released a new incubator build.  Unfortunatly we won't be supporting loops in the shader language in the first release.  The instructions placeholders for loop conditionals are there so you can bet that we are planning on supporting loops in a future version of AGAL.
-Charbs

Similar Messages

  • Tools to debug AGAL code for shaders

    Hello,
    Those last few days I was working on some AGAL code, to create some shaders.
    But I sometimes encounter some problems when it comes to debug my code...
    Especially to know what is the current value of ft0 or ft0.x, etc.
    So, my question is :
    Do you know some tools; or tips, to debug your shaders ?
    It would be so cool to share about it
    I've heard about PIX in this blog post : http://jpauclair.net/2011/03/01/zombietycoon-molehill-session-at-flashgamingsummit/
    But It doesn't seem to work with our browser... So bad ! I may be wrong somewhere
    Thanks a lot per advance !

    You can use PIX fairly easily with Molehill - i'm not sure how to get it working in the web browser, but if you use a standalone player it's easy. Of course, you'll need to be running on a PC and have molehill using the directX9 driver for this to work.
    Grab the Unofficial Standalone Player here: http://blog.ascensionsystems.ca/?p=147
    Then grab the latest DirectX SDK and fire up PIX for windows. You just need to point it at the standalone player, and configure the command-line argument path to your swf, and you're in business.
    Tips on how to use PIX: http://msdn.microsoft.com/en-us/library/ee417184(v=vs.85).aspx
    You can debug shader code, individual pixels, draw timings, buffer contents, and so much more - very helpful stuff. It's also nice to be able to see what the molehill implementation is doing behind the scenes.

  • Converting shaders from other programs?

    I'm just getting started with Pixel bender, but I've played around with fairly simplified GLSL Shaders in Max/MSP and Quartz Composer before. I'm trying to convert this one shader for use in after effects, but I'm a bit stuck on converting some of the variable types and things like that. I'm also not sure if the effect is even possible to recreate in after effects because it requires a sort of feedback loop when I use it in Max/MSP. The effect basically creates video trails off of bright elements in the scene. Here is the code as it appears for the max/msp fragment shader. If anyone has some hints of whether it looks possible, let me know
    uniform float slide_up;
    uniform float slide_down;
    varying vec2 texcoord0;
    varying vec2 texcoord1;
    uniform sampler2DRect tex0;
    uniform sampler2DRect tex1;
    void main(void)
        vec4 su, sd, up, down, amount;
        // sample inputs at texcoords
        vec4 input0 = texture2DRect(tex0, texcoord0);
        vec4 input1 = texture2DRect(tex1, texcoord1);
        // get contribution
        amount.x = input0.x > input1.x ? 1.0 : 0.0;
        amount.y = input0.y > input1.y ? 1.0 : 0.0;
        amount.z = input0.z > input1.z ? 1.0 : 0.0;
        amount.w = input0.w > input1.w ? 1.0 : 0.0;
        // calculate slide down
        float d = max(1.0, abs(slide_down));
        sd = vec4(1.0 / d);
        down = input1 + ((input0 - input1) * sd);
        // calculate slide up
        float u = max(1.0, abs(slide_up));
        su = vec4(1.0 / u);
        up = input1 + ((input0 - input1) * su);
        // mix between down and up
        gl_FragColor = mix(down, up, amount);

    Actually I managed to convert the right areas, but now I gues my question is more about setting up a feedback loop in after effects so that the effect can accumulate. Is this a possibility or should I be doing it another way? This is the code that I ended up with:
        input image4 src;
        input image4 feedback;
        output pixel4 dst;
        parameter float slide_up;
        parameter float slide_down;
        void
        evaluatePixel()
            float4 su, sd, amount, up, down;
        // sample inputs at texcoords
        float4 input0 = sampleNearest(src, outCoord());
        float4 input1 = sampleNearest(feedback, outCoord());
        // get contribution
        amount.x = input0.x > input1.x ? 1.0 : 0.0;
        amount.y = input0.y > input1.y ? 1.0 : 0.0;
        amount.z = input0.z > input1.z ? 1.0 : 0.0;
        amount.w = input0.w > input1.w ? 1.0 : 0.0;
        // calculate slide down
        float d = max(1.0, abs(slide_down));
        sd = float4(1.0 / d);
        down = input1 + ((input0 - input1) * sd);
        // calculate slide up
        float u = max(1.0, abs(slide_up));
        su = float4(1.0 / u);
        up = input1 + ((input0 - input1) * su);
        // mix between down and up
            dst = mix(down, up, amount);

  • Tons of ieq/add/or instructions for array indexing in pixel shader loop (D3D 11.0, PS model 5.0)

    First of all, I have to apologize for the long code samples, but their content is not so important, I just wanted to give as much info as I can. Besides they are really simple and I tried to comment as much as possible.
    I'm working on a pixel shader doing deferred lighting of the frame (Direct3D feature level 11.0, PS
    model 5.0, IDE - Visual Studio 2013, OS - Windows 8.1 x64). I noticed some huge FPS drops when I add light sources to the scene, and the more sources I add, the bigger performance impact is. After many hours
    of trying to find the problem, experimenting and checking compiled pixel shader ASM's, I found out that at some moment after I comment / uncomment some lines (or event line) my output ASM changes dramatically. I won't put here all the code, of course, but
    here's simplified part of the point lighting in HLSL, so you could imagine the structure of the lighting algorithm:
    // Total amount of color that pixel receives from all the point light sources.
    float3 totalPointLightColor = { 0.0f, 0.0f, 0.0f };
    // Loop through the active light sources.
    [loop] for (uint i = 0; i < g_scene.pointLightCount; i++)
    // xyz - vector from light source to pixel.
    // w - the length of that vector.
    float4 fromLightToPixel;
    fromLightToPixel.xyz = worldPos - g_pointLights[i].position.xyz;
    fromLightToPixel.w = length(fromLightToPixel.xyz);
    // Check max light distance here (skip pixel if it is too far).
    if (fromLightToPixel.w > g_pointLights[i].farZ)
    continue;
    // Normalize direction vector.
    fromLightToPixel.xyz = normalize(fromLightToPixel.xyz);
    // Angle between the pixel normal and light direction.
    float lightIntensity = saturate(dot(normal, -fromLightToPixel.xyz));
    // Check that light comes not from behind of the pixel surface.
    if (lightIntensity <= 0.0f)
    continue;
    // If light casts shadows, process shadow map and get amount of light the pixel receives.
    // THIS LINE IS MENTIONED IN MY QUESTION BELOW.
    if (g_pointLights[i].shadowMapIndex >= 0)
    // Here was shadow map check, but I removed it and nothing really changed - the problem remained even with no code here.
    // Calculate the amount of light at the pixel from distance and angle and modify intensity.
    lightIntensity *= g_pointLights[i].brightness / (fromLightToPixel.w * fromLightToPixel.w);
    // Add this light's color to the total amount of light the pixel receives from point lights.
    totalPointLightColor += lightIntensity * g_pointLights[i].color.rgb;
    I compile shaders with D3DCompileFromFile() method, using the following flags:
    shaderFlags = D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_DEBUG
    | D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_PREFER_FLOW_CONTROL;
    I tried to compile in release config with the following flags:
    shaderFlags = D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_OPTIMIZATION_LEVEL3;
    But nothing seriously changes - only a couple less ASM instructions here and there, the main problem still remained. I should add that I have zero to none knowledge of ASM, and understand what's happening mostly thanks to comments Visual Studio / FXC generates
    in debug compilation mode.
    So, when I compile my whole deferred shader (including the part above), I get
    414 instructions in ASM, and performance is fine. If I uncomment only 1 line with CAPSED comment in the section above (which actually does nothing, as you can see), I get
    476 instructions, and I get huge FPS hiccups. When I check output ASM code, I can clearly see, that the line I uncommented produces no code in ASM at all, but somehow it makes many parts of compiled shader to change.
    For example, the loop above with commented line looks like the following in ASM:
    # Loop starts.
    loop
    # Loop index check and increment, as I can understand.
    uge r6.w, r5.w, cb0[1].x
    breakc_nz r6.w
    imul null, r6.w, r5.w, l(3)
    # Calculate <fromLightToPixel>.
    # cb6 - constant buffer that stores point lights.
    # Array access is done simply via [] operator.
    add r10.xyz, r3.xyzx, -cb6[r6.w + 1].xyzx
    dp3 r7.w, r10.xyzx, r10.xyzx
    sqrt r8.w, r7.w
    # Distance check.
    lt r8.w, cb6[r6.w + 1].w, r8.w
    if_nz r8.w
    iadd r8.w, r5.w, l(1)
    mov r5.w, r8.w
    continue
    endif
    # Normalization.
    rsq r8.w, r7.w
    mul r10.xyz, r8.wwww, r10.xyzx
    # Calculate <lightIntensity>.
    dp3_sat r8.w, r1.xywx, -r10.xyzx
    # Check <lightIntensity>.
    ge r9.w, l(0.000000), r8.w
    if_nz r9.w
    iadd r9.w, r5.w, l(1) // r9.w <- i
    mov r5.w, r9.w // r5.w <- i
    continue
    endif
    # Update <lightIntensity>. Note [] operator.
    div r7.w, cb6[r6.w + 0].w, r7.w
    mul r7.w, r7.w, r8.w
    # etc.
    endloop
    When I
    uncomment that 1 line, the ASM is growing heavily (by 62 instructions!), and this is how it starts to look like:
    # Loop starts.
    loop
    # Loop index check, but no <imul> instruction, why?
    uge r6.w, r5.w, cb0[1].x
    breakc_nz r6.w
    # Here comes some new code...
    # Indices are obviously related to the size of the point lights' constant buffer (16 elements).
    ieq r10.xyzw, r5.wwww, l(0, 1, 2, 3)
    ieq r11.xyzw, r5.wwww, l(4, 5, 6, 7)
    ieq r12.xyzw, r5.wwww, l(8, 9, 10, 11)
    ieq r13.xyzw, r5.wwww, l(12, 13, 14, 15)
    # And this part is also new...
    and r14.xyzw, r10.xxxx, cb6[1].xyzw
    and r15.xyzw, r10.yyyy, cb6[4].xyzw
    or r14.xyzw, r14.xyzw, r15.xyzw
    and r15.xyzw, r10.zzzz, cb6[7].xyzw
    or r14.xyzw, r14.xyzw, r15.xyzw
    # 26 more lines of such and/or pairs.
    # Calculate <fromLightToPixel> - finally! Why so much code instead of simple [] operator?
    add r14.xyz, r3.xyzx, -r14.xyzx
    dp3 r6.w, r14.xyzx, r14.xyzx
    sqrt r7.w, r6.w
    # Distance check.
    lt r7.w, r14.w, r7.w
    if_nz r7.w
    iadd r7.w, r5.w, l(1)
    mov r5.w, r7.w
    continue
    endif
    # Normalization.
    rsq r7.w, r6.w
    mul r14.xyz, r7.wwww, r14.xyzx
    # Calculate <lightIntensity>.
    dp3_sat r7.w, r1.xywx, -r14.xyzx
    # Check <lightIntensity>.
    ge r8.w, l(0.000000), r7.w
    if_nz r8.w
    iadd r8.w, r5.w, l(1)
    mov r5.w, r8.w
    continue
    endif
    # Here we go again - more code!
    and r15.xyzw, r10.xxxx, cb6[0].wxyz
    and r16.xyzw, r10.yyyy, cb6[3].wxyz
    or r15.xyzw, r15.xyzw, r16.xyzw
    and r16.xyzw, r10.zzzz, cb6[6].wxyz
    or r15.xyzw, r15.xyzw, r16.xyzw
    # 26 more lines of such and/or pairs.
    # Update <lightIntensity> - finally! Why no [] operator here, but tons of those instructions?
    div r6.w, r10.x, r6.w
    mul r6.w, r6.w, r7.w
    # etc.
    endloop
    I tried to save current array element to temp variable at the beginning of the loop, but it makes no difference - only several more instructions are added to copy the data.
    I just can't understand, why in the first case loop is translated into such small and logic code where array access is done via single
    [] operator, but in the second one it expands to such enormous bunch of instructions? And I change only 1 line of code, nothing more (and that line does nothing actually - it even has no ASM representation)! But every array access seems to
    be affected with this change.
    Can someone please explain that to me? Is there some sort of tricks with array indexing or loops in HLSL? I tried to find something about it on the Internet to no avail. Seems like I miss something very simple and obvious, but I don't get it. Sadly I
    work mostly alone by now and know nobody familiar with ASM / HLSL / Direct3D. Answering this question on another popular developer resource brought no result.
    Big thanks in advance for any tips or explanations!

    The latest version may help with this. 11.9.900.170 is now a step back.
    12.0.0.38  is here: http://get.adobe.com/flashplayer/
    or download the FULL installer here: Flash Player 12 (Mac OS X)

  • Moving only one component value into a register AGAL

    Hi
    Do any of you know if there is any way in AGAL of moving a component value from one register to the other without touching the other components in the register? I notice that the following line...
    mov ft1.a, ft0.a
    ...will also overwrite the rgb components in ft1 with the rgb components from ft0. At least it does on my machine. In other words, specifying components may reorder (swizzle) the components, but doesn't mask them to preserve the value of other components in the destination register. Probably because each register is 128 bits wide, so it's easier for the GPU to just do the operation on all four components anyway. I'm trying to implement the technique described here:
    http://http.developer.nvidia.com/GPUGems/gpugems_ch22.html
    Under "22.2.2 Curves". It requires me to process each color component independently.

    "You can't have an HTML form element map to an Oracle PL/SQL procedure parameter that is defined as a TYPE definition"
    Sorry, but this is just plain wrong. Passing values to associative arrays (TYPE xxx IS TABLE OF xxx INDEXED BY BINARY_INTEGER) has been possible at least since OAS 4.0.8.
    The following simple procedure prints the values passed to it from a form with multiple occurrences of in_val
    CREATE OR REPLACE PROCEDURE test_prc (in_val IN owa_util.ident_arr ) IS
    BEGIN
    for i in in_val.first..in_val.last loop
    htp.p(in_val(i));
    end loop;
    END test_prc;
    (owa_util is a SYS package)
    As to the original question, it is very hard to say what the problem is without more details about the error that occurs after the migration.

  • Suggestion: Macros or a way to unroll loops? Integer array input? Shader Model 3 and 4?

    I think it would be nice if pixel bender supported a way to unroll loops. In it's current state certain shaders are really awkward to write or just get ugly when they're converted for flash player. I know it wouldn't be that hard for the developers to just unroll constant sized loops. Things such as:
    for (int i = 0; i < 10; ++i)
      if (foo) { ... }
    can be unrolled easily. Either that or add in some code generation feature that allows this with a preprocessor system. Or better yet add in support for loops since it only requires shader model 3 or equivelant from GLSL.
    This brings me onto another point. Is there going to be support for Shader Model 4? I'm talking about bitwise operations and integer types. Even if you don't allow native support for byte array adding texture sampling for bytes, shorts, and integers would be nice. Also allowing this to work in flash would be nice with the ability to tell the user they don't have shader model 4 or be able to detect compatability and use a different shader.
    Integer arrays would be nice to allow to as input then to the shader. I noticed the reference manual already mentioned:
    "NOTE: Pixel Bender 1.0 supports only arrays of floats, and the array size is a compile-time constant. Future versions of Pixel Bender will allow arrays to be declared with a size based on kernel parameters, which will enable parameter-dependent look-up table sizes."
    Again support for these features in flash player would be really nice.
    Targetting the lowest GPUs is really limiting the true power of pixel bender. I wrote this for fun: http://assaultwars.com/pictures/raycasting6.png which is just a simple real-time voxel raycaster. However, it could be so much more powerful if pixel bender supported more of the GPUs features. Even simple things like custom functions would be really handy in flash player. I'm thinking of this more oriented toward flash games too where more powerful features are unlocked based on the user's GPU.
    If this is already planned for a future pixel bender release then nevermind. I didn't see a developers blog or any news about future versions.
    Interesting:
    http://forums.adobe.com/thread/36659?tstart=60
    Apparently Kevin said "Look for them in a future version of the language as cards that support  these features become common." in regards to bitwise operators aka Shader Model 4.

    Here's an example, not using NetBeans:
    import javax.swing.*;
    public class TextDemo extends JPanel
        public TextDemo()
            int[] newbinarray = {0, 1, 1};
            StringBuffer sb = new StringBuffer();
            for (int value : newbinarray)
                sb.append(value);
            String st = new String(sb);
            this.add(new JTextField(st));
        private static void createAndShowGUI()
            JFrame frame = new JFrame("TextDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(new TextDemo());
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args)
            javax.swing.SwingUtilities.invokeLater(new Runnable()
                public void run()
                    createAndShowGUI();
    }

  • How to override the event loop

    As a windows game developer, I have always overridden the application message loop to make sure that graphics were rendered when the CPU was idle, and still being able to process windows messages like keyboard/mouse events. CPU is then maxed out (except when a forced sleep or v-sync is enabled) to give highest performance on graphics, making a simple clear opengl window render at 3500 frames per second (I know this is idiotic but I'm trying to make a point).
    Now that I'm porting my game engine (c++ code) to cocoa, I  am struggling with how to implement the main loop. I could use a timer but this will fix the framerate and might be slow. It will prevent me to use the CPU to its full extent.
    So: is there some kind of OnIdle event I can override? Or do I have to do the Event loop processing myself? And can anyone tell me how to do something like this? Is there a tutorial or a book or anything I can study to learn about this? I presume this is lower level API.
    Any help is appreciated!
    Dirk.

    etresoft wrote:
    Michael may profess ignorance about MacOS X applications, but he is still 100% correct. You need to study the architecture and find the best way to work with it. The first thing to know is that the CPU is irrelevant. Let the GPU handle your graphics - that is what it does best. You do want your CPU to be as idle as possible. Approach it from a device-driver or event-driven perspective.
    Just to clarify that I'm not a total noob trying to write his first program: of course I will not overly use the CPU if not necessary. I completely agree with what you guys say about maximizing CPU usage. My game engine on windows will put the CPU to sleep when it's not necessary making my engine perform very good with almost no CPU usage.
    But... when I want to test if changes to my engine/shaders/... improve or degrade performance of the renderings, I want to be sure that everything is maxed out so that I can be sure that the difference is correct. On maxed out CPU/GPU, I will notice the difference when framerate goes for example from 2000 to 1900 while this will not be visible when just at 60 fps and a lot of free time. I will see 60 fps even when my code is worse. That's why I need to be able to test this.
    Anyway, as I said, I completely agree and I will certainly do my very best to make sure that CPU is not overly used. So my question remains: how can I make sure that I have everything I need at the time I need it while I will do my best to make sure nothing more is used?
    Timer-events at 1/60th of a second is not the answer...
    Using threads for these things is not the answer... I use them for other things (loading from disk/processing data/generating data)
    But are there other options?
    Can you point me to where I can learn more about the architecture and its possibilities?

  • A problem with Threads and loops.

    Hi, I have some code that needs to be constantly running, like while(true)
          //code here
    }However, the code just checks to see if the user has input anything (and then if the user has, it goes to do some other stuff) so I don't need it constantly running and hogging up 98% of the CPU. So I made my class (which has the method that needs to be looped, call it ClassA) implement Runnable. Then I just added the method which needed to be looped into the public void run()
    I have another class which creates an instance of the above class (call it ClassB), and the main(String[] args) is in there.
    public static void main(String[] args)
              ClassA test = new ClassA();
              Thread thread = new Thread(test.getInstanceOfClassA());
              thread.start();
              while(true)
                           //I do not know what to put here
                   try
                        thread.sleep(100);
                   catch(InterruptedException iex)
         }However, the thread only calls run() once,(duh...) but I can't think of away to get it to run - sleep - run -sleep forever. Can someone help me?

    Hi, I have some code that needs to be constantly
    running, like while(true)
    //code here
    }However, the code just checks to see if the user has
    input anything (and then if the user has, it goes to
    do some other stuff) so I don't need it constantly
    running and hogging up 98% of the CPU. Where does the user input come from. Are you reading from an InputStream? If so, then your loop will be blocked anyway when reading from the InputStream until data is available. During that time, the loop will not consume processor cycles.
    public static void main(String[] args)
              ClassA test = new ClassA();
    Thread thread = new Thread(test.getInstanceOfClassA());I have never seen this idiom. If ClassA instanceof Runnable, you simply write new Thread(test).
              thread.start();
              while(true)
    //I do not know what to put
    do not know what to put here
                   try
                        thread.sleep(100);
                   catch(InterruptedException iex)
         }However, the thread only calls run() once,(duh...)Yeah, why would you want to call it more than once given that you have an infinite loop in ClassA.run()?
    Harald.
    Java Text Crunching: http://www.ebi.ac.uk/Rebholz-srv/whatizit/software

  • Previewing loops

    Have had no luck with PCs trying to do music recoding so I swithced over to Mac because I heard it so easy, seamless, and problem free. Now, on opening Garageband for the first time and trying to preview loops I get an error mesage that says: "the software instrument or apple loop selected is currently being installed. You have already initiated the installation of additional content for Garageband via Software update. For additional information please open the software update application." I have opened this application and nothing. I have now spent about two hours trying to fix this problem. Should I "convert back to PC, take this load of crap back to the store or is there something simple I am missing?

    I have found if you wait long enough, you will hear the file begin to play. Sometimes the delay can several seconds. Not acceptable IMO.

  • Adobe Cloud membership - I am stuck in the loop of Licensing VERY Frustrating!!!

    I have an Adobe Cloud membership - I am stuck in the loop of Licensing as well VERY Frustrating - I have a project due and have been troubleshooting for days -
    Un Installing - Re installing - NIGHTMARE  - Please someone help me!!! Thanks in advance -

    What happens when you enter your Adobe ID tied to your subscription?

  • Lock ups and sound looping!

    I remember reading something here about people having trouble with their systems locking up and then getting a loud static noise then a sound loop when playing games.
       I am getting this about 2-3 times a night now and it is driving me nuts, I do not have temp problems of any sort and I have all of the latest drivers for everything on my system.
      Any ideas?
    Specs in sig

    Set your PCI/AGP Freq to 66.66/33.33MHz.
    Increase your DDR Voltage to 2.7~2.8v.
    Check if you have any background programs causing all high CPU load times while gaming.

  • Help with if statement in cursor and for loop to get output

    I have the following cursor and and want to use if else statement to get the output. The cursor is working fine. What i need help with is how to use and if else statement to only get the folderrsn that have not been updated in the last 30 days. If you look at the talbe below my select statement is showing folderrs 291631 was updated only 4 days ago and folderrsn 322160 was also updated 4 days ago.
    I do not want these two to appear in my result set. So i need to use if else so that my result only shows all folderrsn that havenot been updated in the last 30 days.
    Here is my cursor:
    /*Cursor for Email procedure. It is working Shows userid and the string
    You need to update these folders*/
    DECLARE
    a_user varchar2(200) := null;
    v_assigneduser varchar2(20);
    v_folderrsn varchar2(200);
    v_emailaddress varchar2(60);
    v_subject varchar2(200);
    Cursor c IS
    SELECT assigneduser, vu.emailaddress, f.folderrsn, trunc(f.indate) AS "IN DATE",
    MAX (trunc(fpa.attemptdate)) AS "LAST UPDATE",
    trunc(sysdate) - MAX (trunc(fpa.attemptdate)) AS "DAYS PAST"
    --MAX (TRUNC (fpa.attemptdate)) - TRUNC (f.indate) AS "NUMBER OF DAYS"
    FROM folder f, folderprocess fp, validuser vu, folderprocessattempt fpa
    WHERE f.foldertype = 'HJ'
    AND f.statuscode NOT IN (20, 40)
    AND f.folderrsn = fp.folderrsn
    AND fp.processrsn = fpa.processrsn
    AND vu.userid = fp.assigneduser
    AND vu.statuscode = 1
    GROUP BY assigneduser, vu.emailaddress, f.folderrsn, f.indate
    ORDER BY fp.assigneduser;
    BEGIN
    FOR c1 IN c LOOP
    IF (c1.assigneduser = v_assigneduser) THEN
    dbms_output.put_line(' ' || c1.folderrsn);
    else
    dbms_output.put(c1.assigneduser ||': ' || 'Overdue Folders:You need to update these folders: Folderrsn: '||c1.folderrsn);
    END IF;
    a_user := c1.assigneduser;
    v_assigneduser := c1.assigneduser;
    v_folderrsn := c1.folderrsn;
    v_emailaddress := c1.emailaddress;
    v_subject := 'Subject: Project for';
    END LOOP;
    END;
    The reason I have included the folowing table is that I want you to see the output from the select statement. that way you can help me do the if statement in the above cursor so that the result will look like this:
    emailaddress
    Subject: 'Project for ' || V_email || 'not updated in the last 30 days'
    v_folderrsn
    v_folderrsn
    etc
    [email protected]......
    Subject: 'Project for: ' Jim...'not updated in the last 30 days'
    284087
    292709
    [email protected].....
    Subject: 'Project for: ' Kim...'not updated in the last 30 days'
    185083
    190121
    190132
    190133
    190159
    190237
    284109
    286647
    294631
    322922
    [email protected]....
    Subject: 'Project for: Joe...'not updated in the last 30 days'
    183332
    183336
    [email protected]......
    Subject: 'Project for: Sam...'not updated in the last 30 days'
    183876
    183877
    183879
    183880
    183881
    183882
    183883
    183884
    183886
    183887
    183888
    This table is to shwo you the select statement output. I want to eliminnate the two days that that are less than 30 days since the last update in the last column.
    Assigneduser....Email.........Folderrsn...........indate.............maxattemptdate...days past since last update
    JIM.........      jim@ aol.com.... 284087.............     9/28/2006.......10/5/2006...........690
    JIM.........      jim@ aol.com.... 292709.............     3/20/2007.......3/28/2007............516
    KIM.........      kim@ aol.com.... 185083.............     8/31/2004.......2/9/2006.............     928
    KIM...........kim@ aol.com.... 190121.............     2/9/2006.........2/9/2006.............928
    KIM...........kim@ aol.com.... 190132.............     2/9/2006.........2/9/2006.............928
    KIM...........kim@ aol.com.... 190133.............     2/9/2006.........2/9/2006.............928
    KIM...........kim@ aol.com.... 190159.............     2/13/2006.......2/14/2006............923
    KIM...........kim@ aol.com.... 190237.............     2/23/2006.......2/23/2006............914
    KIM...........kim@ aol.com.... 284109.............     9/28/2006.......9/28/2006............697
    KIM...........kim@ aol.com.... 286647.............     11/7/2006.......12/5/2006............629
    KIM...........kim@ aol.com.... 294631.............     4/2/2007.........3/4/2008.............174
    KIM...........kim@ aol.com.... 322922.............     7/29/2008.......7/29/2008............27
    JOE...........joe@ aol.com.... 183332.............     1/28/2004.......4/23/2004............1585
    JOE...........joe@ aol.com.... 183336.............     1/28/2004.......3/9/2004.............1630
    SAM...........sam@ aol.com....183876.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183877.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183879.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183880.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183881.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183882.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183883.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183884.............3/5/2004.........3/8/2004............     1631
    SAM...........sam@ aol.com....183886.............3/5/2004.........3/8/2004............     1631
    SAM...........sam@ aol.com....183887.............3/5/2004.........3/8/2004............     1631
    SAM...........sam@ aol.com....183888.............3/5/2004.........3/8/2004............     1631
    PAT...........pat@ aol.com.....291630.............2/23/2007.......7/8/2008............     48
    PAT...........pat@ aol.com.....313990.............2/27/2008.......7/28/2008............28
    NED...........ned@ aol.com.....190681.............4/4/2006........8/10/2006............746
    NED...........ned@ aol.com......95467.............6/14/2006.......11/6/2006............658
    NED...........ned@ aol.com......286688.............11/8/2006.......10/3/2007............327
    NED...........ned@ aol.com.....291631.............2/23/2007.......8/21/2008............4
    NED...........ned@ aol.com.....292111.............3/7/2007.........2/26/2008............181
    NED...........ned@ aol.com.....292410.............3/15/2007.......7/22/2008............34
    NED...........ned@ aol.com.....299410.............6/27/2007.......2/27/2008............180
    NED...........ned@ aol.com.....303790.............9/19/2007.......9/19/2007............341
    NED...........ned@ aol.com.....304268.............9/24/2007.......3/3/2008............     175
    NED...........ned@ aol.com.....308228.............12/6/2007.......12/6/2007............263
    NED...........ned@ aol.com.....316689.............3/19/2008.......3/19/2008............159
    NED...........ned@ aol.com.....316789.............3/20/2008.......3/20/2008............158
    NED...........ned@ aol.com.....317528.............3/25/2008.......3/25/2008............153
    NED...........ned@ aol.com.....321476.............6/4/2008.........6/17/2008............69
    NED...........ned@ aol.com.....322160.............7/3/2008.........8/21/2008............4
    MOE...........moe@ aol.com.....184169.............4/5/2004.......12/5/2006............629
    [email protected]/27/2004.......3/8/2004............1631
    How do I incorporate a if else statement in the above cursor so the two days less than 30 days since last update are not returned. I do not want to send email if the project have been updated within the last 30 days.
    Edited by: user4653174 on Aug 25, 2008 2:40 PM

    analytical functions: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions2a.htm#81409
    CASE
    http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/02_funds.htm#36899
    http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/04_struc.htm#5997
    Incorporating either of these into your query should assist you in returning the desired results.

  • Sy-tabix in loop : Doubt

    LOOP AT i_lfa1 INTO wa_lfa1 WHERE werks = space.       
       wf_tabix = sy-tabix.                                 
       APPEND wa_lfa1 TO i_lfa1_werks.                      
       DELETE i_lfa1 index wf_tabix.                        
    ENDLOOP.                                               
    in the above code the sy-tabix is always 2.
    what i want to know is if there is a where clause , should we not use the sy-tabix for deletion.

    >
    Keshav.T wrote:
    > May be ill  get something from sap help.
    Hello Keshav,
    As a matter of fact , I always do
    SAP says:
    If you delete the current line or lines in front of the current line, the internal loop counter is decreased by one with each deleted line. In the case of loops on index tables or if using a sorted key, this affects sy-tabix in the subsequent loop pass, and sy-tabix is decreased accordingly
    @Dzed: Hail SAP Help !!! Anyways this was common sense & i dont think SAP processor is dumb
    Cheers,
    Suhas
    Edited by: Suhas Saha on Jan 28, 2010 6:46 PM

  • Sy-tabix in relation to LOOP AT and READ TABLE

    Hi All,
    As per SAP documentation,
    1) While looping through an internal table (LOOP AT), sy-tabix contains the index number of current row(for standard and sorted tables)
    2)When successfully reading from an internal table(READ TABLE), sy-tabix is set to the index of the result row.
    But what happens when READ TABLE is used while looping through another internal table?
    i.e. Loop at TAB1...
    write sy-tabix.
    READ TABLE TAB2...
    write sy-tabix.
    endloop.
    If we are looping through 1st row of TAB1 and the result of read statement is found in 3rd row of TAB2, I expected that sy-tabix before READ would be 1 and after the READ be 3.
    But, I found that sy-tabix remains unchanged at 1. Can someone expalin why?
    Thanks,
    Jagan

    Hi
    If after reading the table TAB2 the system variable SY-TABIX has still the previous value, that menas the READ TABLE fails or it was read the first record of TAB2.
    After READ TABLE TAB2 try to check the SY-SUBRC:
    LOOP AT TAB1.
       WRITE: / 'TAB1 index:', SY-TABIX.
       READ TABLE TAB2 .........
       IF SY-SUBRC = 0.
         WRITE: 'TAB2 index:', SY-TABIX.
    Try this:
    DATA: BEGIN OF ITAB OCCURS 0,
            FIELD1,
          END   OF ITAB.
    DATA: BEGIN OF ITAB2 OCCURS 0,
            FIELD1,
          END   OF ITAB2.
    DATA: INDEX TYPE I.
    DO 10 TIMES.
      APPEND ITAB.
    ENDDO.
    DO 10 TIMES.
      APPEND ITAB2.
    ENDDO.
    LOOP AT ITAB.
      WRITE: / 'ITAB:', SY-TABIX.
      INDEX = SY-TABIX + 2.
      READ TABLE ITAB2 INDEX INDEX.
      IF SY-SUBRC = 0.
        WRITE:  'ITAB2:', SY-TABIX.
      ENDIF.
    ENDLOOP.
    Max

  • SY-TABIX value of a loop in other loop in other loop.

    Hello Gurus,
    I have a problem i want to modify some columns in final internal table and it is possible by using Transporting and Index but when i see SY-TABIX value it is not really giving particular loop iteration value. Because my present loop is in another loop and it is in another loop. Please gurus help me out
    or
    How to Insert particular filed columns  and how to use where clause in insert..
    Thanks.

    Hi !
    Here are things you could do:
    1. You can use nested loops with the WHERE statement on the inner loop. But this can be slow.
         This will look like this
                   loop at i_tab1 into wa1
                   loop at i_tab2 into wa2 where cond1 = wa1-cond1....
                     (   move wa2-field3 to wa1-field3.....)
                        modify i_tab1.
                   endloop.
                   endloop.
    2. You can use the parallel cursor technique as suggested above.
         This technique speeds up processing of data significantly. Here it is:
         data lv_tabix type i.
              sort i_tab1 by field1 ascending.
              sort i_tab2 by field1 ascending.
              loop at i_tab1 into wa1
              read table i_tab2 transporting no fields with key cond1 = wa1-cond1 binary search.
              lv_tabix = sy-tabix.
                   loop at i_tab2 into wa2 from lv_tabix.
                        if wa2-cond1 <> wa1-cond1.
                                   exit.       
                         endif.
                   ( move wa2-field3 to wa1-field3.....)
                        modify i_tab1.
                    endloop.
              endloop.
    Please let me know if you want more explanation

Maybe you are looking for

  • If I restore my iPod Touch 4g, would I be able to get my data from my applications back?

    I recently bought a new iPod Touch 4G about 2 weeks ago and today when I tried to sync it with iTunes, it said that iTunes cannot read the contents of my iPod and that I have to factory restore my iPod. It has not been Jailbroken by the way. I'm a ne

  • When are Redolog files reset to zero size? Manual reset possible?

    As far as I know redolog files contain all stuff which is changed during operation of an Oracle database. However I wonder if there are events when these files are AUTOMATICALLY reset to zero. I guess it is when I do a full offline backup. Is this co

  • Custom Buttons in ALV Grid

    Hi Experts, I have a ALV grid. I have added some custom buttons to it. I want to change dynamically enable of disable some of the buttons in the ALV. Please help me through. I tried free, clear refresh for the grid object, control object and the even

  • Can I back-up my iPod Touch without syncing?

    I use my iPod mainly for podcasts, which I don't want to keep once I've listened to them. Now that I can download them via wifi and delete them right on the iPod, I see no reason to download the podcasts to iTunes. But I still would like to back-up m

  • Problem installing CC - asking for serial number.

    Hello! I recently purchased CC and download it to a temporary laptop (until mine returns from apple lab). I now got my laptop back, downloaded the programs but I'm unable to open them without it asking for a serial number. It also notes that it's a t