Adding to a temp-table after the define statement

Posted by Peter Mayson on 28-Mar-2017 07:06

Dear All

I am using CHUI on Release 11.3.3 on AIX unix

I am dumping loads (about 40) tables and have written a generic include to create a temp-table LIKE the DBtable which allows me to manipulate the temp-table and then dump it to an ascii file.

The problem is that now suddenly I need to dump dates as "CCYY-MM-DD HH:MM:SS.000" and also to add fields from one table to the temp-table of another table.

I would like to carry o using the include, but add fields to the temp-tables after the generic DEF TEMP-TABLE below.

So this is in the include, what brilliant options do I have?

&IF DEFINED (TableN1) &THEN

DEF TEMP-TABLE tt1 LIKE {&TableN1}.

lg_TempFileName1 = lg_GenFileName + "{&TableN1}.xls".

PROCEDURE ip_DumpFile1:

RUN cottprt1.p (INPUT TABLE tt1, "",lg_TempFileName0,"|").

END. /* PROCEDURE ip_DumpFile1: */

lg_Unix = "tr -d '~"' " + lg_TempFileName1.

UNIX SILENT VALUE(lg_Unix).

&ENDIF /* &IF DEFINED (TableN) &THEN */

********************

Nedbank disclaimer and confidentiality notice:

This email may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this email or all or some of the information contained therein, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this email is neither an offer or a solicitation to buy or sell any securities, investment products or other financial product or service, nor is it an official confirmation of any transaction or an official statement of Nedbank. Any views or opinions presented are solely those of the author and do not necessarily represent those of Nedbank. Nedbank Ltd Reg No 1951/000009/06.

The following link displays the names of the Nedbank Board of Directors and Company Secretary. [http://www.nedbank.co.za/terms/DirectorsNedbank.htm]

If you do not want to click on a link, please type the relevant address in your browser

********************

All Replies

Posted by James Palmer on 28-Mar-2017 08:32

You can't manipulate a temp table (static or dynamic) after it's instantiated. I suppose what you could do is to generate a dynamic temp table from the static one, and then add the extra detail you want, but it's going to be clunky.

Posted by Peter Mayson on 28-Mar-2017 08:47

Thanks for this.
Actually it suddenly came to me that in the DEF TEMP-TABLE statement I could add a bunch of SCOPED-DEFINES that can hold my added FIELD statements (or not for most programs)
 
 

Posted by James Palmer on 28-Mar-2017 11:32

You could certainly do something along these lines, but scoped defines are to be avoided really. They aren't considered good practise anymore. In particular they lead to code that is very difficult to maintain.

This thread is closed