1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

How to export text file in for each loop?

Discussão em 'StackOverflow' iniciado por fdantas, Junho 5, 2019.

  1. fdantas

    fdantas Administrator Moderador

    I have written a program for export file to a specific directory and I feel I have written some unwanted logic. so I would like to know short and best way to do export the files. Let me share what I tried

    DEFINE VARIABLE cData AS CHARACTER NO-UNDO.
    DEFINE VARIABLE i AS INTEGER NO-UNDO.
    DEFINE VARIABLE icount AS INTEGER NO-UNDO.
    DEFINE VARIABLE cName AS CHARACTER NO-UNDO.
    DEFINE VARIABLE cPath AS CHARACTER NO-UNDO.

    DEFINE TEMP-TABLE ttdata
    FIELD GetName AS CHARACTER
    FIELD iValue AS INTEGER.

    ASSIGN
    icount = 2
    cPath = "*******".

    DO I = 1 TO icount:
    IF I = 1 THEN cName = "David".
    IF I = 2 THEN cName = "Macavo".


    CREATE ttdata.
    ASSIGN
    ttdata.GetName = cName
    ttdata.iValue = 100.
    END.

    /** ttdata has two records now*/
    FOR EACH ttdata.
    RUN CallProc.p (INPUT ttdata.GetName,
    INPUT ttdata.iValue).
    END.

    PROCEDURE CallProc:

    DEFINE INPUT PARAMETER getName AS CHARACTER NO-UNDO.
    DEFINE INPUT PARAMETER iValue AS INTEGER NO-UNDO.

    OUTPUT TO cPath.
    PUT UNFORMATTED ttdata.GetName ttdata.GetName.
    OUTPUT CLOSE.
    END PROCEDURE.


    From my logic its working well and exporting 2 files as I expected but its poor idea to call another procedure.Please help this case.

    Continue reading...

Compartilhe esta Página