A program that outputs a report, as a CSV












0















Ho do I write code for a program that can accept three input parameters: x , y, and the filename to write to?



I should be able to call the program like this:
run prog.p (input “1”, input 5, input “filename1.csv”).



so far my I have written the code below and not sure how to go around it.



OUTPUT TO xxxxxxfilename1.csv". 

DEFINE VARIABLE Profit AS DECIMAL FORMAT "->>,>>9.99":U INITIAL 0 NO-UNDO.

EXPORT DELIMITER "," "Amount" "Customer Number" "Invoice Date" "Invoice Number" "Total_Paid" "Profit".

FOR EACH Invoice WHERE Invoice.Ship-charge > 5.00
AND Invoice.Total-Paid > 0.01
AND Invoice.Invoice-Date GE 01/31/93 /* this is between also can use < >*/
AND Invoice.Invoice-Date LE TODAY NO-LOCK:

Profit = (Invoice.Invoice-Num / Invoice.Total-Paid) * 100.

EXPORT DELIMITER "," Amount Cust-Num Invoice-Date Invoice-Num Total-Paid Profit.
END.

OUTPUT CLOSE.


Thank you.










share|improve this question



























    0















    Ho do I write code for a program that can accept three input parameters: x , y, and the filename to write to?



    I should be able to call the program like this:
    run prog.p (input “1”, input 5, input “filename1.csv”).



    so far my I have written the code below and not sure how to go around it.



    OUTPUT TO xxxxxxfilename1.csv". 

    DEFINE VARIABLE Profit AS DECIMAL FORMAT "->>,>>9.99":U INITIAL 0 NO-UNDO.

    EXPORT DELIMITER "," "Amount" "Customer Number" "Invoice Date" "Invoice Number" "Total_Paid" "Profit".

    FOR EACH Invoice WHERE Invoice.Ship-charge > 5.00
    AND Invoice.Total-Paid > 0.01
    AND Invoice.Invoice-Date GE 01/31/93 /* this is between also can use < >*/
    AND Invoice.Invoice-Date LE TODAY NO-LOCK:

    Profit = (Invoice.Invoice-Num / Invoice.Total-Paid) * 100.

    EXPORT DELIMITER "," Amount Cust-Num Invoice-Date Invoice-Num Total-Paid Profit.
    END.

    OUTPUT CLOSE.


    Thank you.










    share|improve this question

























      0












      0








      0








      Ho do I write code for a program that can accept three input parameters: x , y, and the filename to write to?



      I should be able to call the program like this:
      run prog.p (input “1”, input 5, input “filename1.csv”).



      so far my I have written the code below and not sure how to go around it.



      OUTPUT TO xxxxxxfilename1.csv". 

      DEFINE VARIABLE Profit AS DECIMAL FORMAT "->>,>>9.99":U INITIAL 0 NO-UNDO.

      EXPORT DELIMITER "," "Amount" "Customer Number" "Invoice Date" "Invoice Number" "Total_Paid" "Profit".

      FOR EACH Invoice WHERE Invoice.Ship-charge > 5.00
      AND Invoice.Total-Paid > 0.01
      AND Invoice.Invoice-Date GE 01/31/93 /* this is between also can use < >*/
      AND Invoice.Invoice-Date LE TODAY NO-LOCK:

      Profit = (Invoice.Invoice-Num / Invoice.Total-Paid) * 100.

      EXPORT DELIMITER "," Amount Cust-Num Invoice-Date Invoice-Num Total-Paid Profit.
      END.

      OUTPUT CLOSE.


      Thank you.










      share|improve this question














      Ho do I write code for a program that can accept three input parameters: x , y, and the filename to write to?



      I should be able to call the program like this:
      run prog.p (input “1”, input 5, input “filename1.csv”).



      so far my I have written the code below and not sure how to go around it.



      OUTPUT TO xxxxxxfilename1.csv". 

      DEFINE VARIABLE Profit AS DECIMAL FORMAT "->>,>>9.99":U INITIAL 0 NO-UNDO.

      EXPORT DELIMITER "," "Amount" "Customer Number" "Invoice Date" "Invoice Number" "Total_Paid" "Profit".

      FOR EACH Invoice WHERE Invoice.Ship-charge > 5.00
      AND Invoice.Total-Paid > 0.01
      AND Invoice.Invoice-Date GE 01/31/93 /* this is between also can use < >*/
      AND Invoice.Invoice-Date LE TODAY NO-LOCK:

      Profit = (Invoice.Invoice-Num / Invoice.Total-Paid) * 100.

      EXPORT DELIMITER "," Amount Cust-Num Invoice-Date Invoice-Num Total-Paid Profit.
      END.

      OUTPUT CLOSE.


      Thank you.







      openedge progress-4gl progress-db






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 9:17









      Duke578Duke578

      286




      286
























          1 Answer
          1






          active

          oldest

          votes


















          5














          You're on the right track! OUTPUT TO VALUE(variable) is what might help you. Also you should possibly use a named stream.



          It's not clear to me what parameters x and y should do so I just inserted them as dummies below.



          Note:
          You're commenting about using <> instead of GE. That might work logically but could (will) effect your performance by forcing the database to scan entires tables instead of using an index.



          Something like this:



          DEFINE INPUT  PARAMETER pcX    AS CHARACTER NO-UNDO.
          DEFINE INPUT PARAMETER piY AS INTEGER NO-UNDO.
          DEFINE INPUT PARAMETER pcFile AS CHARACTER NO-UNDO.

          /* Bogus temp-table to make the program run... */
          /* Remove this unless just testing without database ...*/
          DEFINE TEMP-TABLE Invoice NO-UNDO
          FIELD Ship-Charge AS DECIMAL
          FIELD Total-Paid AS DECIMAL
          FIELD Invoice-Date AS DATE
          FIELD Invoice-Num AS INTEGER
          FIELD Amount AS INTEGER
          FIELD Cust-Num AS INTEGER.

          DEFINE STREAM str.

          DEFINE VARIABLE Profit AS DECIMAL FORMAT "->>,>>9.99":U INITIAL 0 NO-UNDO.

          OUTPUT STREAM str TO VALUE(pcFile).

          EXPORT STREAM str DELIMITER "," "Amount" "Customer Number" "Invoice Date" "Invoice Number" "Total_Paid" "Profit".
          FOR EACH Invoice WHERE Invoice.Ship-charge > 5.00
          AND Invoice.Total-Paid > 0.01
          AND Invoice.Invoice-Date GE 01/31/93 /* this is between also can use < >*/
          AND Invoice.Invoice-Date LE TODAY NO-LOCK:

          Profit = (Invoice.Invoice-Num / Invoice.Total-Paid) * 100.
          EXPORT STREAM str DELIMITER "," Amount Cust-Num Invoice-Date Invoice-Num Total-Paid Profit.
          END.

          OUTPUT STREAM str CLOSE.


          Now you can run this program, assuming it's named "program.p":



          RUN program.p("1", 5, "c:tempfile.txt").


          or



          RUN program.p(INPUT "1", INPUT 5, INPUT "c:tempfile.txt").


          (INPUT is the default direction for parameters).



          EDIT:
          Run example + changed first input to CHARACTER instead of integer






          share|improve this answer


























          • Thank you, when I implement this into my code I get an error saying "Mismatched number of parameters passed to ruotine Cxxxxxx (3234) . Im not sure what this means.

            – Duke578
            Nov 21 '18 at 12:09













          • This example assumes you run with something like RUN example.p(INPUT 1, INPUT 5, INPUT "C:file.csv"). I notice now that your first input is a string and not an int. So you should change the first input to "CHARACTER" instead.

            – Jensd
            Nov 21 '18 at 12:11











          • Edit to reflect the first input as character and a run example.

            – Jensd
            Nov 21 '18 at 12:14






          • 1





            I have managed to figure it out with your help. Thank you.

            – Duke578
            Nov 21 '18 at 12:38











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408700%2fa-program-that-outputs-a-report-as-a-csv%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          5














          You're on the right track! OUTPUT TO VALUE(variable) is what might help you. Also you should possibly use a named stream.



          It's not clear to me what parameters x and y should do so I just inserted them as dummies below.



          Note:
          You're commenting about using <> instead of GE. That might work logically but could (will) effect your performance by forcing the database to scan entires tables instead of using an index.



          Something like this:



          DEFINE INPUT  PARAMETER pcX    AS CHARACTER NO-UNDO.
          DEFINE INPUT PARAMETER piY AS INTEGER NO-UNDO.
          DEFINE INPUT PARAMETER pcFile AS CHARACTER NO-UNDO.

          /* Bogus temp-table to make the program run... */
          /* Remove this unless just testing without database ...*/
          DEFINE TEMP-TABLE Invoice NO-UNDO
          FIELD Ship-Charge AS DECIMAL
          FIELD Total-Paid AS DECIMAL
          FIELD Invoice-Date AS DATE
          FIELD Invoice-Num AS INTEGER
          FIELD Amount AS INTEGER
          FIELD Cust-Num AS INTEGER.

          DEFINE STREAM str.

          DEFINE VARIABLE Profit AS DECIMAL FORMAT "->>,>>9.99":U INITIAL 0 NO-UNDO.

          OUTPUT STREAM str TO VALUE(pcFile).

          EXPORT STREAM str DELIMITER "," "Amount" "Customer Number" "Invoice Date" "Invoice Number" "Total_Paid" "Profit".
          FOR EACH Invoice WHERE Invoice.Ship-charge > 5.00
          AND Invoice.Total-Paid > 0.01
          AND Invoice.Invoice-Date GE 01/31/93 /* this is between also can use < >*/
          AND Invoice.Invoice-Date LE TODAY NO-LOCK:

          Profit = (Invoice.Invoice-Num / Invoice.Total-Paid) * 100.
          EXPORT STREAM str DELIMITER "," Amount Cust-Num Invoice-Date Invoice-Num Total-Paid Profit.
          END.

          OUTPUT STREAM str CLOSE.


          Now you can run this program, assuming it's named "program.p":



          RUN program.p("1", 5, "c:tempfile.txt").


          or



          RUN program.p(INPUT "1", INPUT 5, INPUT "c:tempfile.txt").


          (INPUT is the default direction for parameters).



          EDIT:
          Run example + changed first input to CHARACTER instead of integer






          share|improve this answer


























          • Thank you, when I implement this into my code I get an error saying "Mismatched number of parameters passed to ruotine Cxxxxxx (3234) . Im not sure what this means.

            – Duke578
            Nov 21 '18 at 12:09













          • This example assumes you run with something like RUN example.p(INPUT 1, INPUT 5, INPUT "C:file.csv"). I notice now that your first input is a string and not an int. So you should change the first input to "CHARACTER" instead.

            – Jensd
            Nov 21 '18 at 12:11











          • Edit to reflect the first input as character and a run example.

            – Jensd
            Nov 21 '18 at 12:14






          • 1





            I have managed to figure it out with your help. Thank you.

            – Duke578
            Nov 21 '18 at 12:38
















          5














          You're on the right track! OUTPUT TO VALUE(variable) is what might help you. Also you should possibly use a named stream.



          It's not clear to me what parameters x and y should do so I just inserted them as dummies below.



          Note:
          You're commenting about using <> instead of GE. That might work logically but could (will) effect your performance by forcing the database to scan entires tables instead of using an index.



          Something like this:



          DEFINE INPUT  PARAMETER pcX    AS CHARACTER NO-UNDO.
          DEFINE INPUT PARAMETER piY AS INTEGER NO-UNDO.
          DEFINE INPUT PARAMETER pcFile AS CHARACTER NO-UNDO.

          /* Bogus temp-table to make the program run... */
          /* Remove this unless just testing without database ...*/
          DEFINE TEMP-TABLE Invoice NO-UNDO
          FIELD Ship-Charge AS DECIMAL
          FIELD Total-Paid AS DECIMAL
          FIELD Invoice-Date AS DATE
          FIELD Invoice-Num AS INTEGER
          FIELD Amount AS INTEGER
          FIELD Cust-Num AS INTEGER.

          DEFINE STREAM str.

          DEFINE VARIABLE Profit AS DECIMAL FORMAT "->>,>>9.99":U INITIAL 0 NO-UNDO.

          OUTPUT STREAM str TO VALUE(pcFile).

          EXPORT STREAM str DELIMITER "," "Amount" "Customer Number" "Invoice Date" "Invoice Number" "Total_Paid" "Profit".
          FOR EACH Invoice WHERE Invoice.Ship-charge > 5.00
          AND Invoice.Total-Paid > 0.01
          AND Invoice.Invoice-Date GE 01/31/93 /* this is between also can use < >*/
          AND Invoice.Invoice-Date LE TODAY NO-LOCK:

          Profit = (Invoice.Invoice-Num / Invoice.Total-Paid) * 100.
          EXPORT STREAM str DELIMITER "," Amount Cust-Num Invoice-Date Invoice-Num Total-Paid Profit.
          END.

          OUTPUT STREAM str CLOSE.


          Now you can run this program, assuming it's named "program.p":



          RUN program.p("1", 5, "c:tempfile.txt").


          or



          RUN program.p(INPUT "1", INPUT 5, INPUT "c:tempfile.txt").


          (INPUT is the default direction for parameters).



          EDIT:
          Run example + changed first input to CHARACTER instead of integer






          share|improve this answer


























          • Thank you, when I implement this into my code I get an error saying "Mismatched number of parameters passed to ruotine Cxxxxxx (3234) . Im not sure what this means.

            – Duke578
            Nov 21 '18 at 12:09













          • This example assumes you run with something like RUN example.p(INPUT 1, INPUT 5, INPUT "C:file.csv"). I notice now that your first input is a string and not an int. So you should change the first input to "CHARACTER" instead.

            – Jensd
            Nov 21 '18 at 12:11











          • Edit to reflect the first input as character and a run example.

            – Jensd
            Nov 21 '18 at 12:14






          • 1





            I have managed to figure it out with your help. Thank you.

            – Duke578
            Nov 21 '18 at 12:38














          5












          5








          5







          You're on the right track! OUTPUT TO VALUE(variable) is what might help you. Also you should possibly use a named stream.



          It's not clear to me what parameters x and y should do so I just inserted them as dummies below.



          Note:
          You're commenting about using <> instead of GE. That might work logically but could (will) effect your performance by forcing the database to scan entires tables instead of using an index.



          Something like this:



          DEFINE INPUT  PARAMETER pcX    AS CHARACTER NO-UNDO.
          DEFINE INPUT PARAMETER piY AS INTEGER NO-UNDO.
          DEFINE INPUT PARAMETER pcFile AS CHARACTER NO-UNDO.

          /* Bogus temp-table to make the program run... */
          /* Remove this unless just testing without database ...*/
          DEFINE TEMP-TABLE Invoice NO-UNDO
          FIELD Ship-Charge AS DECIMAL
          FIELD Total-Paid AS DECIMAL
          FIELD Invoice-Date AS DATE
          FIELD Invoice-Num AS INTEGER
          FIELD Amount AS INTEGER
          FIELD Cust-Num AS INTEGER.

          DEFINE STREAM str.

          DEFINE VARIABLE Profit AS DECIMAL FORMAT "->>,>>9.99":U INITIAL 0 NO-UNDO.

          OUTPUT STREAM str TO VALUE(pcFile).

          EXPORT STREAM str DELIMITER "," "Amount" "Customer Number" "Invoice Date" "Invoice Number" "Total_Paid" "Profit".
          FOR EACH Invoice WHERE Invoice.Ship-charge > 5.00
          AND Invoice.Total-Paid > 0.01
          AND Invoice.Invoice-Date GE 01/31/93 /* this is between also can use < >*/
          AND Invoice.Invoice-Date LE TODAY NO-LOCK:

          Profit = (Invoice.Invoice-Num / Invoice.Total-Paid) * 100.
          EXPORT STREAM str DELIMITER "," Amount Cust-Num Invoice-Date Invoice-Num Total-Paid Profit.
          END.

          OUTPUT STREAM str CLOSE.


          Now you can run this program, assuming it's named "program.p":



          RUN program.p("1", 5, "c:tempfile.txt").


          or



          RUN program.p(INPUT "1", INPUT 5, INPUT "c:tempfile.txt").


          (INPUT is the default direction for parameters).



          EDIT:
          Run example + changed first input to CHARACTER instead of integer






          share|improve this answer















          You're on the right track! OUTPUT TO VALUE(variable) is what might help you. Also you should possibly use a named stream.



          It's not clear to me what parameters x and y should do so I just inserted them as dummies below.



          Note:
          You're commenting about using <> instead of GE. That might work logically but could (will) effect your performance by forcing the database to scan entires tables instead of using an index.



          Something like this:



          DEFINE INPUT  PARAMETER pcX    AS CHARACTER NO-UNDO.
          DEFINE INPUT PARAMETER piY AS INTEGER NO-UNDO.
          DEFINE INPUT PARAMETER pcFile AS CHARACTER NO-UNDO.

          /* Bogus temp-table to make the program run... */
          /* Remove this unless just testing without database ...*/
          DEFINE TEMP-TABLE Invoice NO-UNDO
          FIELD Ship-Charge AS DECIMAL
          FIELD Total-Paid AS DECIMAL
          FIELD Invoice-Date AS DATE
          FIELD Invoice-Num AS INTEGER
          FIELD Amount AS INTEGER
          FIELD Cust-Num AS INTEGER.

          DEFINE STREAM str.

          DEFINE VARIABLE Profit AS DECIMAL FORMAT "->>,>>9.99":U INITIAL 0 NO-UNDO.

          OUTPUT STREAM str TO VALUE(pcFile).

          EXPORT STREAM str DELIMITER "," "Amount" "Customer Number" "Invoice Date" "Invoice Number" "Total_Paid" "Profit".
          FOR EACH Invoice WHERE Invoice.Ship-charge > 5.00
          AND Invoice.Total-Paid > 0.01
          AND Invoice.Invoice-Date GE 01/31/93 /* this is between also can use < >*/
          AND Invoice.Invoice-Date LE TODAY NO-LOCK:

          Profit = (Invoice.Invoice-Num / Invoice.Total-Paid) * 100.
          EXPORT STREAM str DELIMITER "," Amount Cust-Num Invoice-Date Invoice-Num Total-Paid Profit.
          END.

          OUTPUT STREAM str CLOSE.


          Now you can run this program, assuming it's named "program.p":



          RUN program.p("1", 5, "c:tempfile.txt").


          or



          RUN program.p(INPUT "1", INPUT 5, INPUT "c:tempfile.txt").


          (INPUT is the default direction for parameters).



          EDIT:
          Run example + changed first input to CHARACTER instead of integer







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 21 '18 at 12:13

























          answered Nov 21 '18 at 9:28









          JensdJensd

          5,91522034




          5,91522034













          • Thank you, when I implement this into my code I get an error saying "Mismatched number of parameters passed to ruotine Cxxxxxx (3234) . Im not sure what this means.

            – Duke578
            Nov 21 '18 at 12:09













          • This example assumes you run with something like RUN example.p(INPUT 1, INPUT 5, INPUT "C:file.csv"). I notice now that your first input is a string and not an int. So you should change the first input to "CHARACTER" instead.

            – Jensd
            Nov 21 '18 at 12:11











          • Edit to reflect the first input as character and a run example.

            – Jensd
            Nov 21 '18 at 12:14






          • 1





            I have managed to figure it out with your help. Thank you.

            – Duke578
            Nov 21 '18 at 12:38



















          • Thank you, when I implement this into my code I get an error saying "Mismatched number of parameters passed to ruotine Cxxxxxx (3234) . Im not sure what this means.

            – Duke578
            Nov 21 '18 at 12:09













          • This example assumes you run with something like RUN example.p(INPUT 1, INPUT 5, INPUT "C:file.csv"). I notice now that your first input is a string and not an int. So you should change the first input to "CHARACTER" instead.

            – Jensd
            Nov 21 '18 at 12:11











          • Edit to reflect the first input as character and a run example.

            – Jensd
            Nov 21 '18 at 12:14






          • 1





            I have managed to figure it out with your help. Thank you.

            – Duke578
            Nov 21 '18 at 12:38

















          Thank you, when I implement this into my code I get an error saying "Mismatched number of parameters passed to ruotine Cxxxxxx (3234) . Im not sure what this means.

          – Duke578
          Nov 21 '18 at 12:09







          Thank you, when I implement this into my code I get an error saying "Mismatched number of parameters passed to ruotine Cxxxxxx (3234) . Im not sure what this means.

          – Duke578
          Nov 21 '18 at 12:09















          This example assumes you run with something like RUN example.p(INPUT 1, INPUT 5, INPUT "C:file.csv"). I notice now that your first input is a string and not an int. So you should change the first input to "CHARACTER" instead.

          – Jensd
          Nov 21 '18 at 12:11





          This example assumes you run with something like RUN example.p(INPUT 1, INPUT 5, INPUT "C:file.csv"). I notice now that your first input is a string and not an int. So you should change the first input to "CHARACTER" instead.

          – Jensd
          Nov 21 '18 at 12:11













          Edit to reflect the first input as character and a run example.

          – Jensd
          Nov 21 '18 at 12:14





          Edit to reflect the first input as character and a run example.

          – Jensd
          Nov 21 '18 at 12:14




          1




          1





          I have managed to figure it out with your help. Thank you.

          – Duke578
          Nov 21 '18 at 12:38





          I have managed to figure it out with your help. Thank you.

          – Duke578
          Nov 21 '18 at 12:38




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408700%2fa-program-that-outputs-a-report-as-a-csv%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()