4GL Looping and export to CSV file

Posted on 2011-10-06
Last Modified: 2013-12-25
Hi EE,

i've never done programming, but i'm trying to get a loop to work in progress

all i'm after doing is getting the code below to export the same again and again on different lines a 100 times.

i know only one line is been update in the table so it only exports the one line on the csv

can anyone help me


output to value ("c:\test.csv").
		     for each ttud01 where ttud01.rowmod = 'U':
			     export delimiter ',' ttud01.Key1 ttud01.Key2 ttud01.Key3 ttud01.Key4  skip.

     output close.

Open in new window

Question by:Ross Turner
    LVL 2

    Accepted Solution

    /* Use the REPEAT statement */


    OUTPUT TO VALUE ("c:\test.csv").

    FOR EACH ttud01 where ttud01.rowmod = 'U':
      REPEAT FOR vCount = 1 TO 100:
         EXPORT DELIMITER ',' ttud01.Key1 ttud01.Key2 ttud01.Key3 ttud01.Key4  SKIP.
      END.  /* REPEAT**/
    END. /* FOR EACH ttud01 */

    LVL 7

    Author Comment

    by:Ross Turner
    When I used your code... Which by the way i was very excited about it came up with the error can't understand after vCount I double checked the code and it's spot on... Any ideas ??? But thank you so much for your help so far.

    LVL 2

    Expert Comment

    REPEAT vCount = 1 TO 100:
    LVL 7

    Author Closing Comment

    by:Ross Turner
    HI  ahensch, thank you so much for your help with this little bit of code. i've never been so happy to see a csv file in a folder as i was today.

    i might need your help again in the not to distant future.

    Thank you


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
    Read about achieving the basic levels of HRIS security in the workplace.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now